I am running a linear regression on a number of attributes including two categorical attributes, B
and F
, and I don't get a coefficient value for every factor level I have.
B
has 9 levels and F
has 6 levels. When I initially ran the model (with intercepts), I got 8 coefficients for B
and 5 for F
which I understood as the first level of each being included in the intercept.
I want ranking the levels within B
and F
based on their coefficient so I added -1
after each factor to lock the intercept at 0 so that I could get coefficients for all levels.
Call:
lm(formula = dependent ~ a + B-1 + c + d + e + F-1 + g + h, data = input)
Coefficients:
Estimate Std. Error t value Pr(>|t|)
a 2.082e+03 1.026e+02 20.302 < 2e-16 ***
B1 -1.660e+04 9.747e+02 -17.027 < 2e-16 ***
B2 -1.681e+04 9.379e+02 -17.920 < 2e-16 ***
B3 -1.653e+04 9.254e+02 -17.858 < 2e-16 ***
B4 -1.765e+04 9.697e+02 -18.202 < 2e-16 ***
B5 -1.535e+04 1.388e+03 -11.059 < 2e-16 ***
B6 -1.677e+04 9.891e+02 -16.954 < 2e-16 ***
B7 -1.644e+04 9.694e+02 -16.961 < 2e-16 ***
B8 -1.931e+04 9.899e+02 -19.512 < 2e-16 ***
B9 -1.722e+04 9.071e+02 -18.980 < 2e-16 ***
c -6.928e-01 6.977e-01 -0.993 0.321272
d -3.288e-01 2.613e+00 -0.126 0.899933
e -8.384e-01 1.171e+00 -0.716 0.474396
F2 4.679e+02 2.176e+02 2.150 0.032146 *
F3 7.753e+02 2.035e+02 3.810 0.000159 ***
F4 1.885e+02 1.689e+02 1.116 0.265046
F5 5.194e+02 2.264e+02 2.295 0.022246 *
F6 1.365e+03 2.334e+02 5.848 9.94e-09 ***
g 4.278e+00 7.350e+00 0.582 0.560847
h 2.717e-02 5.100e-03 5.328 1.62e-07 ***
This worked in part, leading to the display of all levels of B
, however F1
is still not displayed. As there is no longer an intercept I am confused why F1
is not in the linear model.
Switching the order of the call so that + F - 1
precedes + B - 1
results in coefficients of all levels of F
being visible but not B1
.
Does anybody know either how to display all levels of both B
and F
, or how to assess the relative weight of F1
compared to other levels of F
from the outputs I have?
R
keeps only the first appearing – Bread