I have a data set
dat = data.frame(y = c(.3,.5,.3,.6,.8,.9,.3,.6),
group1= c(1,1,2,2,1,1,2,2),
group2 =c("a","a","b","b","c","c","e","e")
)
l =lm(data = dat, y~ factor(group1)+factor(group2))
l
model.matrix(l)
The coef for group2 e is NA
Coefficients:
(Intercept) factor(group1)2 factor(group2)b factor(group2)c factor(group2)e
4.000e-01 5.000e-02 3.786e-18 4.500e-01 NA
here is model.matrix(l)
(Intercept) factor(group1)2 factor(group2)b factor(group2)c factor(group2)e
1 1 0 0 0 0
2 1 0 0 0 0
3 1 1 1 0 0
4 1 1 1 0 0
5 1 0 0 1 0
6 1 0 0 1 0
7 1 1 0 0 1
8 1 1 0 0 1
attr(,"assign")
Is that because factor(group1)2 = factor(group2)b + factor(group2)e?
To fix this ---I would remove one either group1 or group2 form the model correct?