Vicki Allison
2006-Nov-14 21:59 UTC
[R] Repeated measures by lme and aov give different results
I am analyzing data from an experiment with two factors: Carbon (+/-) and O3 (+/-), with 4 replicates of each treatment, and 4 harvests over a year. The treatments are assigned in a block design to individual Rings. I have approaches this as a repeated measures design. Fixed factors are Carbon, O3 and Harvest, with Ring assigned as a random variable. I have performed repeated measures analysis on this data set two different ways: one utilizing lme (as described in Crawley, 2002), and the second using aov (based on Baron and Li, 2006). Using lme I get very conservative p-values, while aov gives me significant p-values, consistent with those I obtain performing this analysis in SYSTAT. Can anyone explain how these models differ, and which is more appropriate to the experimental design I have described? The code I use, and the output obtained follow: 1 lme model library(nlme) M5 <-lme(ln_tot_lgth ~ Carbon*O3*Harv., random = ~-1|Ring) anova(M5, type="marginal") # Output numDF denDF F-value p-value (Intercept) 1 44 176.59692 <.0001 Carbon 1 12 0.42187 0.5282 O3 1 12 0.06507 0.8030 Harv. 1 44 17.15861 0.0002 Carbon:O3 1 12 0.23747 0.6348 Carbon:Harv. 1 44 0.85829 0.3593 O3:Harv. 1 44 0.04524 0.8325 Carbon:O3:Harv. 1 44 0.05645 0.8133> plot(M5)2 aov model M6<-aov(ln_tot_lgth ~ O3*Harv.*Carbon + Error (Ring/Carbon+O3)) summary(M6) plot(M6) # Output Error: Ring Df Sum Sq Mean Sq F value Pr(>F) O3 1 1.76999 1.76999 8.2645 0.01396 * Carbon 1 0.64766 0.64766 3.0241 0.10760 O3:Carbon 1 0.15777 0.15777 0.7366 0.40756 Residuals 12 2.57002 0.21417 Error: Within Df Sum Sq Mean Sq F value Pr(>F) Harv. 1 33.541 33.541 84.0109 9.14e-12 *** O3:Harv. 1 0.001 0.001 0.0036 0.9524 Harv.:Carbon 1 0.414 0.414 1.0362 0.3143 O3:Harv.:Carbon 1 0.020 0.020 0.0508 0.8226 Residuals 44 17.567 0.399 *** Note change of location*** Victoria Allison Landcare Research Private Bag 92170 Auckland 1142 New Zealand Phone: +64 9 574 4164 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ WARNING: This email and any attachments may be confidential ...{{dropped}}
Spencer Graves
2006-Nov-16 21:14 UTC
[R] Repeated measures by lme and aov give different results
RSiteSearch("lme and aov") returned 350 hits for me just now. I'm sure that many are not relevant to your question, but I believe some are. Beyond this, there is now and R Wiki, accessible via www.r-project.org -> Documentation: Wiki (or directly as http://wiki.r-project.org/rwiki/doku.php?id=guides:lmer-tests&s=lme%20and%20aov). The first hit in a search there for "lme and aov" "is an edited transcript of a long thread in R-help starting Sept 7, 2006 from a comment by Hank Stevens, with Douglas Bates as leading actor." (http://wiki.r-project.org/rwiki/doku.php?id=guides:lmer-tests&s=lme%20and%20aov). If that fails to answer your questions on this, please submit another post. Please realize however that the expected number and quality of replies is inversely proportional to some large power of the length and complexity of your question. Hope this helps. Spencer Graves Vicki Allison wrote:> I am analyzing data from an experiment with two factors: Carbon (+/-) > and O3 (+/-), with 4 replicates of each treatment, and 4 harvests over a > year. The treatments are assigned in a block design to individual > Rings. > > I have approaches this as a repeated measures design. Fixed factors > are Carbon, O3 and Harvest, with Ring assigned as a random variable. I > have performed repeated measures analysis on this data set two different > ways: one utilizing lme (as described in Crawley, 2002), and the second > using aov (based on Baron and Li, 2006). Using lme I get very > conservative p-values, while aov gives me significant p-values, > consistent with those I obtain performing this analysis in SYSTAT. Can > anyone explain how these models differ, and which is more appropriate to > the experimental design I have described? The code I use, and the > output obtained follow: > > 1 lme model > > library(nlme) > M5 <-lme(ln_tot_lgth ~ Carbon*O3*Harv., random = ~-1|Ring) > anova(M5, type="marginal") > > # Output > numDF denDF F-value p-value > (Intercept) 1 44 176.59692 <.0001 > Carbon 1 12 0.42187 0.5282 > O3 1 12 0.06507 0.8030 > Harv. 1 44 17.15861 0.0002 > Carbon:O3 1 12 0.23747 0.6348 > Carbon:Harv. 1 44 0.85829 0.3593 > O3:Harv. 1 44 0.04524 0.8325 > Carbon:O3:Harv. 1 44 0.05645 0.8133 > >> plot(M5) >> > > > 2 aov model > > M6<-aov(ln_tot_lgth ~ O3*Harv.*Carbon + Error (Ring/Carbon+O3)) > summary(M6) > plot(M6) > > # Output > Error: Ring > Df Sum Sq Mean Sq F value Pr(>F) > O3 1 1.76999 1.76999 8.2645 0.01396 * > Carbon 1 0.64766 0.64766 3.0241 0.10760 > O3:Carbon 1 0.15777 0.15777 0.7366 0.40756 > Residuals 12 2.57002 0.21417 > > Error: Within > Df Sum Sq Mean Sq F value Pr(>F) > Harv. 1 33.541 33.541 84.0109 9.14e-12 *** > O3:Harv. 1 0.001 0.001 0.0036 0.9524 > Harv.:Carbon 1 0.414 0.414 1.0362 0.3143 > O3:Harv.:Carbon 1 0.020 0.020 0.0508 0.8226 > Residuals 44 17.567 0.399 > > > *** Note change of location*** > > Victoria Allison > Landcare Research > Private Bag 92170 > Auckland 1142 > New Zealand > Phone: +64 9 574 4164 > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > WARNING: This email and any attachments may be confidential ...{{dropped}} > > ______________________________________________ > 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. >
Andrew Robinson
2006-Nov-16 21:43 UTC
[R] Repeated measures by lme and aov give different results
Vicki, take a look at P. 47 of the book by Pinheiro and Bates, if you have a copy (if not, get one!) They show the analysis of a split-plot design using lme there. Here, both aov and lme are estimating two levels of variation. The key difference is that with aov the Ring-level variation is not being included in the test of all the terms, whereas with lme it is being included. If you want to eliminate it from the tests, which will replicate the aov analysis, then you need to include it as a fixed effect. To pinpoint the question: in the simplest case of a randomized complete block design, we need to ask whether or not the block-level variation should be included in the error sum of squares. aov() excludes it, lme() includes it unless Block is included as a fixed effect. Whether or not you want to exclude it depends on what you think about the design and where the variation is coming from. The traditional RCB excludes it, but whether or not you should depends on the circumstances. Cheers Andrew On Wed, November 15, 2006 8:59 am, Vicki Allison wrote:> I am analyzing data from an experiment with two factors: Carbon (+/-) > and O3 (+/-), with 4 replicates of each treatment, and 4 harvests over a > year. The treatments are assigned in a block design to individual > Rings. > > I have approaches this as a repeated measures design. Fixed factors > are Carbon, O3 and Harvest, with Ring assigned as a random variable. I > have performed repeated measures analysis on this data set two different > ways: one utilizing lme (as described in Crawley, 2002), and the second > using aov (based on Baron and Li, 2006). Using lme I get very > conservative p-values, while aov gives me significant p-values, > consistent with those I obtain performing this analysis in SYSTAT. Can > anyone explain how these models differ, and which is more appropriate to > the experimental design I have described? The code I use, and the > output obtained follow: > > 1 lme model > > library(nlme) > M5 <-lme(ln_tot_lgth ~ Carbon*O3*Harv., random = ~-1|Ring) > anova(M5, type="marginal") > > # Output > numDF denDF F-value p-value > (Intercept) 1 44 176.59692 <.0001 > Carbon 1 12 0.42187 0.5282 > O3 1 12 0.06507 0.8030 > Harv. 1 44 17.15861 0.0002 > Carbon:O3 1 12 0.23747 0.6348 > Carbon:Harv. 1 44 0.85829 0.3593 > O3:Harv. 1 44 0.04524 0.8325 > Carbon:O3:Harv. 1 44 0.05645 0.8133 >> plot(M5) > > > 2 aov model > > M6<-aov(ln_tot_lgth ~ O3*Harv.*Carbon + Error (Ring/Carbon+O3)) > summary(M6) > plot(M6) > > # Output > Error: Ring > Df Sum Sq Mean Sq F value Pr(>F) > O3 1 1.76999 1.76999 8.2645 0.01396 * > Carbon 1 0.64766 0.64766 3.0241 0.10760 > O3:Carbon 1 0.15777 0.15777 0.7366 0.40756 > Residuals 12 2.57002 0.21417 > > Error: Within > Df Sum Sq Mean Sq F value Pr(>F) > Harv. 1 33.541 33.541 84.0109 9.14e-12 *** > O3:Harv. 1 0.001 0.001 0.0036 0.9524 > Harv.:Carbon 1 0.414 0.414 1.0362 0.3143 > O3:Harv.:Carbon 1 0.020 0.020 0.0508 0.8226 > Residuals 44 17.567 0.399 > > > *** Note change of location*** > > Victoria Allison > Landcare Research > Private Bag 92170 > Auckland 1142 > New Zealand > Phone: +64 9 574 4164 > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > WARNING: This email and any attachments may be confidential ...{{dropped}} > > ______________________________________________ > 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. >Andrew Robinson Senior Lecturer in Statistics Tel: +61-3-8344-9763 Department of Mathematics and Statistics Fax: +61-3-8344 4599 University of Melbourne, VIC 3010 Australia Email: a.robinson at ms.unimelb.edu.au Website: http://www.ms.unimelb.edu.au