Hi, I am trying to run ANOVA with an interaction term on 2 factors (treat has 7
levels, group has 2 levels). I found the coefficient for the last interaction
term is always 0, see attached dataset and the code below:
> test<-read.table("test.txt",sep='\t',header=T,row.names=NULL)
> lm(y~factor(treat)*factor(group),test)
Call:
lm(formula = y ~ factor(treat) * factor(group), data = test)
Coefficients:
(Intercept) factor(treat)2
factor(treat)3
0.429244
0.499982 0.352971
factor(treat)4 factor(treat)5
factor(treat)6
-0.204752
0.142042 0.044155
factor(treat)7 factor(group)2
factor(treat)2:factor(group)2
-0.007775
-0.337907 -0.208734
factor(treat)3:factor(group)2 factor(treat)4:factor(group)2
factor(treat)5:factor(group)2
-0.195138
0.800029 0.227514
factor(treat)6:factor(group)2 factor(treat)7:factor(group)2
0.331548 NA
I guess this is due to model matrix being singular or collinearity among the
matrix columns? But I can't figure out how the matrix is singular in this case?
Can someone show me why this is the case?
Thanks
John
treat group y
3 1 0.659156868932769
2 2 0.531460140598938
5 2 0.111702043330297
3 2 0.531970057170838
3 2 0.190075619611889
6 2 0.0234142139088362
2 1 0.929225602652878
1 1 0.165439655771479
1 1 0.245642073685303
4 2 0.973135874373838
2 2 0.40159740881063
2 2 0.230675351573154
4 1 0.15201729699038
4 2 0.770770706702024
3 2 0.00170516152866185
7 1 0.475904347142205
7 1 0.477398047922179
2 2 0.57676896895282
2 2 0.17242363281548
1 1 0.263812917750329
1 1 0.332802928285673
7 1 0.999866250436753
7 2 0.0795505701098591
5 2 0.723311265930533
4 1 0.301724245771766
4 1 0.174829749623314
4 1 0.161948098335415
4 1 0.0022172573953867
3 1 0.815872102044523
3 1 0.953563597053289
7 1 0.687810138566419
7 1 0.305082862731069
1 1 0.742835792247206
1 1 0.643639815272763
4 1 0.751568211475387
6 1 0.844687921227887
4 2 0.315934179816395
5 1 0.884743785485625
5 1 0.316437228582799
3 2 0.00965709099546075
3 2 0.512446181615815
5 1 0.765263902954757
5 1 0.754491505213082
4 1 0.0271341009065509
7 1 0.242603822145611
7 1 0.12916071084328
6 1 0.531941789202392
6 1 0.0435664399992675
5 1 0.380349192768335
5 1 0.457562071271241
6 2 0.539795646909624
6 2 0.837911191163585
7 1 0.0539217721670866
1 1 0.910242940066382
1 1 0.129532726714388
5 1 0.440152890980244
3 1 0.945850990246981
3 1 0.53663158044219
5 2 0.866308335913345
5 2 0.142251220298931
7 2 0.0875730190891773
______________________________________________
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.