true, why it has to omit "treat 7-group 2"....

Thanks again


________________________________
From: David Winsemius <dwinsem...@comcast.net>

Cc: "r-help@r-project.org" <r-help@r-project.org>
Sent: Monday, November 7, 2011 10:19 PM
Subject: Re: [R] why NA coefficients


On Nov 7, 2011, at 10:07 PM, array chip wrote:

> Thanks David. The only category that has no cases is "treat 1-group 2":
> 
> > with(test,table(treat,group))
>      group
> treat 1 2
>     1 8 0
>     2 1 5
>     3 5 5
>     4 7 3
>     5 7 4
>     6 3 3
>     7 8 2
> 
> But why the coefficient for "treat 7-group 2" is not estimable?

Well, it had to omit one of them didn't it?

(But I don't know why that level was chosen.)

--David.
> 
> Thanks
> 
> John
> 
> 
> From: David Winsemius <dwinsem...@comcast.net>

> Cc: "r-help@r-project.org" <r-help@r-project.org>
> Sent: Monday, November 7, 2011 5:13 PM
> Subject: Re: [R] why NA coefficients
> 
> 
> On Nov 7, 2011, at 7:33 PM, array chip wrote:
> 
> > 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?
> 
> Because you have no cases in one of the crossed categories.
> 
> --David Winsemius, MD
> West Hartford, CT
> 
> 
> 

David Winsemius, MD
West Hartford, CT
        [[alternative HTML version deleted]]

______________________________________________
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