[R] lm and levels
Chuck White
chuckwhite8 at charter.net
Wed Nov 11 06:27:43 CET 2009
Consider the following example:
x <- c(2,4,3,6)
y <- c(4,9,5,10)
z <- factor(c(1,1,2,2))
summary(lm("y ~ x + z"))
The above works fine.
Suppose I change z so that
x <- c(2,4,3,6)
y <- c(4,9,5,10)
z <- factor(c(1,1,2,NA))
summary(lm("y ~ x + z"))
the last row/observation is not considered in the regression. I would like this to be treated as z with two levels "1" and "2" which are both in the regression model (rather than dropping one of them which would be the case in the first example). The last row would have 0 for z1 and z2. How can that be achieved? THANKS.
More information about the R-help
mailing list