Re: [R] Nested ANOVA with covariate using Type III sums of squares

2010-06-06 Thread John Fox
, Ontario, Canada web: socserv.mcmaster.ca/jfox -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Anita Narwani Sent: June-03-10 8:49 PM To: Joris Meys Cc: r-help@r-project.org Subject: Re: [R] Nested ANOVA with covariate using Type

[R] Nested ANOVA with covariate using Type III sums of squares

2010-06-03 Thread Anita Narwani
Thanks for your response Joris. I was aware of the potential for aliasing, although I thought that this was only a problem when you have missing cell means. It was interesting to read the vehement argument regarding the Type III sums of squares, and although I knew that there were different

Re: [R] Nested ANOVA with covariate using Type III sums of squares

2010-06-03 Thread Anita Narwani
I would just like to add that when I remove the co-variate of Mean.richness from the model (i.e. eliminating the non-orthogonality), the aliasing warning is replaced by the following error message: Error in t(Z) %*% ip : non-conformable arguments That is when I enter this model:

Re: [R] Nested ANOVA with covariate using Type III sums of squares

2010-06-03 Thread Joris Meys
Could you copy the data? Data - data.frame(C.Mean,Mean.richness,Zoop,Diversity,Phyto) dput(Data) I have the feeling something's wrong there. I believe you have 48 observations (47df + 1 for the intercept), 2 levels of Diversity, 4 of Phyto and 48/(3*4)=4 levels of Zoop. But you don't have 3df

Re: [R] Nested ANOVA with covariate using Type III sums of squares

2010-06-03 Thread Joris Meys
I see where my confusion comes from. I counted 4 levels of Phyto, but you have 8, being 4 in every level of Diversity. There's your aliasing. table(Diversity,Phyto) Phyto Diversity M1 M2 M3 M4 P1 P2 P3 P4     H  0  0  0  0  6  6  6  6     L  6  6  6  6  0  0  0  0 There's no

Re: [R] Nested ANOVA with covariate using Type III sums of squares

2010-06-03 Thread Joris Meys
Hi Anita, I have to correct myself too, I've been rambling a bit. Off course you don't delete the variable out of the interaction term when you test the main effect. What I said earlier didn't really make any sense. That testing a main effect without removing the interaction term is has a tricky

Re: [R] Nested ANOVA with covariate using Type III sums of squares

2010-06-03 Thread Anita Narwani
Hi Joris, That seems to have worked and the contrasts look correct. I have tried comparing the results to what SPSS produces for the same model. The two programs produce very different results, although the model F statistics, R squared and adjusted R squared values are identical. The results are

Re: [R] Nested ANOVA with covariate using Type III sums of squares

2010-06-03 Thread Joris Meys
SPSS uses a different calculation. As far as I understood, they test main effects without the covariate. Regarding the difference between my and your results, did you use sum contrasts? options(contrasts=c(contr.sum,contr.poly)) On Fri, Jun 4, 2010 at 2:19 AM, Anita Narwani

Re: [R] Nested ANOVA with covariate using Type III sums of squares

2010-06-03 Thread Anita Narwani
Yes I understood the strangeness of removing a main effect without interactions that contain it because I did this during my efforts using model simplification. I had checked out the link you sent a couple of days ago. It was useful. So does Type II SS remove both the factor and any interactions

[R] Nested ANOVA with covariate using Type III sums of squares

2010-06-02 Thread Anita Narwani
Hello, I have been trying to get an ANOVA table for a linear model containing a single nested factor, two fixed factors and a covariate: carbonmean-lm(C.Mean~ Mean.richness + Diversity + Zoop + Diversity/Phyto + Zoop*Diversity/Phyto) where, *Mean.richness* is a covariate*, Zoop* is a

Re: [R] Nested ANOVA with covariate using Type III sums of squares

2010-06-02 Thread Joris Meys
That's what one would expect with type III sum of squares. You have Phyto twice in your model, but only as a nested factor. To compare the full model with a model without diversity of zoop, you have either the combination diversity/phyto, zoop/phyto or phyto twice in the formula. That's aliasing.

Re: [R] Nested ANOVA with covariate using Type III sums of squares

2010-06-02 Thread Joris Meys
that's diversity/phyto, zoop or phyto twice in the formula. On Thu, Jun 3, 2010 at 3:00 AM, Joris Meys jorism...@gmail.com wrote: That's what one would expect with type III sum of squares. You have Phyto twice in your model, but only as a nested factor. To compare the full model with a model

[R] Nested ANOVA with covariate using Type III sums of squares in R

2010-06-02 Thread Anita Narwani
Hello, I have been trying to get an ANOVA table for a linear model containing a single nested factor, two fixed factors and a covariate: carbonmean-lm(C.Mean~ Mean.richness + Diversity + Zoop + Diversity/Phyto + Zoop*Diversity/Phyto) where, Mean.richness is a covariate, Zoop is a categorical