jibleriz...@yahoo.com wrote:
I run lm to fit an OLS model where one of the covariates is a factor with 30 
levels. I use contr.treatment() to set the base level of the factor, so when I 
run lm() no coefficients are estimated for that level. But in addition (and 
regardless of which level I choose to be the base), lm also gives a vector of 
NA coefficients for another level of my factor.

The output says that these coefficients were "not defined because of 
singularities", suggesting maybe that the 28 estimated coefficients are sufficient 
to pin down the 29th... but why is this the case? Why am I going from 30 levels to 28 
coefficients? Am I misunderstanding the way factors/levels are supposed to work?
The usual cause of this is that one of the levels is not present in the data set. Another possibility is collinearity with some other covariate in your model.

Duncan Murdoch

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to