Your lme statement is OK. To get the usual split-plot anova, your aov statement should be fit2 <- aov(y ~ a*b*c + Error(s), data = d) This gives the same F-values as lme. On Mon, Aug 14, 2006 at 10:27:19AM -0400, William Simpson wrote:> I have used lme() on data from a between-within subjects experiment. The correct > ANOVA table is known because this is a textbook example (Experimental Design by > Roger Kirk Chapter 12: Split-Plot Factorial Design). The lme() F-values differ from > the known results. Please help me understand why. > > d<-read.table("kirkspf2.dat",header=TRUE) > for(j in 1:4) d[,j] <- factor(d[,j]) ### Make vars into type "factor" > > ##lme() results > library(nlme) > fit<-lme(y~a*b*c,random=~1|s, data=d) > anova(fit) > > ##correct anova table > ##subjects are nested within a; a between, b & c within > fit2<-aov(y ~ a*b*c + Error(s/(c*b)), data=d) > summary(fit2) > > I suspect I need a different random=... statement in lme(). > Thanks very much for any help > Bill > > The data file is attached -- kirkspf2.dat > Here it is again: > > s a c b y > 1 1 1 1 3 > 1 1 1 2 7 > 1 1 2 1 4 > 1 1 2 2 7 > 2 1 1 1 6 > 2 1 1 2 8 > 2 1 2 1 5 > 2 1 2 2 8 > 3 1 1 1 3 > 3 1 1 2 7 > 3 1 2 1 4 > 3 1 2 2 9 > 4 1 1 1 3 > 4 1 1 2 6 > 4 1 2 1 3 > 4 1 2 2 8 > 5 2 1 1 1 > 5 2 1 2 5 > 5 2 2 1 2 > 5 2 2 2 10 > 6 2 1 1 2 > 6 2 1 2 6 > 6 2 2 1 3 > 6 2 2 2 10 > 7 2 1 1 2 > 7 2 1 2 5 > 7 2 2 1 4 > 7 2 2 2 9 > 8 2 1 1 2 > 8 2 1 2 6 > 8 2 2 1 3 > 8 2 2 2 11> ______________________________________________ > R-help at stat.math.ethz.ch 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.-- ************************************************ * I.White * * University of Edinburgh * * Ashworth Laboratories, West Mains Road * * Edinburgh EH9 3JT * * Fax: 0131 650 6564 Tel: 0131 650 5490 * * E-mail: i.m.s.white at ed.ac.uk *
I have used lme() on data from a between-within subjects experiment. The correct ANOVA table is known because this is a textbook example (Experimental Design by Roger Kirk Chapter 12: Split-Plot Factorial Design). The lme() F-values differ from the known results. Please help me understand why. d<-read.table("kirkspf2.dat",header=TRUE) for(j in 1:4) d[,j] <- factor(d[,j]) ### Make vars into type "factor" ##lme() results library(nlme) fit<-lme(y~a*b*c,random=~1|s, data=d) anova(fit) ##correct anova table ##subjects are nested within a; a between, b & c within fit2<-aov(y ~ a*b*c + Error(s/(c*b)), data=d) summary(fit2) I suspect I need a different random=... statement in lme(). Thanks very much for any help Bill The data file is attached -- kirkspf2.dat Here it is again: s a c b y 1 1 1 1 3 1 1 1 2 7 1 1 2 1 4 1 1 2 2 7 2 1 1 1 6 2 1 1 2 8 2 1 2 1 5 2 1 2 2 8 3 1 1 1 3 3 1 1 2 7 3 1 2 1 4 3 1 2 2 9 4 1 1 1 3 4 1 1 2 6 4 1 2 1 3 4 1 2 2 8 5 2 1 1 1 5 2 1 2 5 5 2 2 1 2 5 2 2 2 10 6 2 1 1 2 6 2 1 2 6 6 2 2 1 3 6 2 2 2 10 7 2 1 1 2 7 2 1 2 5 7 2 2 1 4 7 2 2 2 9 8 2 1 1 2 8 2 1 2 6 8 2 2 1 3 8 2 2 2 11
> Your lme statement is OK. To get the usual split-plot anova, your aov > statement should be > > fit2 <- aov(y ~ a*b*c + Error(s), data = d)No, this gives wrong F-values. By "wrong" I mean it does not agree with the published table. Table 12.10-2, page 559: Number of obs = 32 R-squared = 0.9920 Root MSE = .559017 Adj R-squared = 0.9589 Source | Partial SS df MS F Prob > F -----------+---------------------------------------------------- Model | 233.625 25 9.345 29.90 0.0002 | a | 3.125 1 3.125 2.00 0.2070 s|a | 9.375 6 1.5625 -----------+---------------------------------------------------- b | 162.00 1 162.00 199.38 0.0000 a*b | 6.125 1 6.125 7.54 0.0335 b*s|a | 4.875 6 .8125 -----------+---------------------------------------------------- c | 24.50 1 24.50 61.89 0.0002 a*c | 10.125 1 10.125 25.58 0.0023 c*s|a | 2.375 6 .395833333 -----------+---------------------------------------------------- b*c | 8.00 1 8.00 25.60 0.0023 a*b*c | 3.125 1 3.125 10.00 0.0195 | Residual | 1.875 6 .3125 -----------+---------------------------------------------------- Total | 235.50 31 7.59677419 Bill