R: Get p-value for all coefficients in multiple linear regression (incl. reference level) -


example

i have linear regression, fits numerical dependent variable 3 explanatory factor variables. each of factor variables has 2 levels.

install.packages("robustbase") install.packages("mass") require(robustbase) require(mass)  # example data data(npk) df= npk[,-1] str(df)   # 'data.frame':  24 obs. of  4 variables: # $ n    : factor w/ 2 levels "0","1": 1 2 1 2 2 2 1 1 1 2 ... # $ p    : factor w/ 2 levels "0","1": 2 2 1 1 1 2 1 2 2 2 ... # $ k    : factor w/ 2 levels "0","1": 2 1 1 2 1 2 2 1 1 2 ... # $ yield: num  49.5 62.8 46.8 57 59.8 58.5 55.5 56 62.8 55.8 ...  set.seed(0) model <- lmrob(yield ~ n + p + k - 1, data= df) 

task

i want access p-values each coefficient of model object. avoid unnecessary intercept using - 1 in formula.

summary(model)$coefficients  # estimate std. error    t value     pr(>|t|) # n0 54.644672   2.400075 22.7678995 8.972084e-16 # n1 60.166737   1.966661 30.5933467 2.858276e-18 # p1 -1.059299   2.139443 -0.4951286 6.259053e-01 # k1 -3.905052   2.226012 -1.7542822 9.469295e-02 

seems baseline (reference) levels p , k hidden.

question

how can change code access p-values p0and k0 coefficients model object?

note: not sure if makes difference solution, using in real problem lmrob robust regression function, decided better keep in reproducible example.

the p-values estimated are:

coef(summary(model))[, 4] 

regarding reference levels, model using treatment contrasts values of reference levels 0 not meaningful ask p-values.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -