Hello- I'm trying to do some repeated measures ANOVAs. In the past, using SAS, I have used the framework outlined in Littell et al.'s "SAS System for Mixed Models", using the REPEATED statement in PROC MIXED to model variation across time within an experimental unit. SAS allows you to specify different within-unit covariance structures (e.g., compound symmetric, AR(1), etc.) to determine the best model. I'm having trouble figuring out how to do a similar analysis in R. While 'lme' will let you choose the class of correlation structure to use, it seems to require that you specify this structure rather than using the data to estimate the covariance matrix. For example, it seems that to specify 'corAR1' as the correlation structure, you have to pick a value for rho, the autoregressive parameter. So, my question: is there a way to tell 'lme' what sort of covariance structure you'd like to model, and then let the function estimate the covariances? Or, alternatively, is there a better way to go about this sort of repeated measures analysis in R? I've exhausted my available R resources and done a pretty good search of the help archives without finding a clear answer. Thanks much! Chris ******* Chris Solomon Center for Limnology Univ. of Wisconsin Phone: (608) 263-2465
Yes. Try something akin to> fm1<- lme(y~time, data, random=~time|ID)> fm2<-update(fm1, correlation=corAR1(form~time|ID)You can then use anova(fm1,fm2) to compare. Harold -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Chris Solomon Sent: Tuesday, September 14, 2004 12:07 PM To: R-help at stat.math.ethz.ch Subject: [R] repeated measures and covariance structures Hello- I'm trying to do some repeated measures ANOVAs. In the past, using SAS, I have used the framework outlined in Littell et al.'s "SAS System for Mixed Models", using the REPEATED statement in PROC MIXED to model variation across time within an experimental unit. SAS allows you to specify different within-unit covariance structures (e.g., compound symmetric, AR(1), etc.) to determine the best model. I'm having trouble figuring out how to do a similar analysis in R. While 'lme' will let you choose the class of correlation structure to use, it seems to require that you specify this structure rather than using the data to estimate the covariance matrix. For example, it seems that to specify 'corAR1' as the correlation structure, you have to pick a value for rho, the autoregressive parameter. So, my question: is there a way to tell 'lme' what sort of covariance structure you'd like to model, and then let the function estimate the covariances? Or, alternatively, is there a better way to go about this sort of repeated measures analysis in R? I've exhausted my available R resources and done a pretty good search of the help archives without finding a clear answer. Thanks much! Chris ******* Chris Solomon Center for Limnology Univ. of Wisconsin Phone: (608) 263-2465 ______________________________________________ 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
On Tue, 14 Sep 2004, Chris Solomon wrote:> Hello- > > I'm trying to do some repeated measures ANOVAs. In the past, using SAS, > I have used the framework outlined in Littell et al.'s "SAS System for > Mixed Models", using the REPEATED statement in PROC MIXED to model > variation across time within an experimental unit. SAS allows you to > specify different within-unit covariance structures (e.g., compound > symmetric, AR(1), etc.) to determine the best model. > > I'm having trouble figuring out how to do a similar analysis in R. While > 'lme' will let you choose the class of correlation structure to use, it > seems to require that you specify this structure rather than using the > data to estimate the covariance matrix. For example, it seems that to > specify 'corAR1' as the correlation structure, you have to pick a value > for rho, the autoregressive parameter.Why does `it seems'? Your information is incorrect.> So, my question: is there a way to tell 'lme' what sort of covariance > structure you'd like to model, and then let the function estimate the > covariances?That is the default. Take a look at the examples in Venables & Ripley or Pinheiro & Bates (as recommended in the posting guide and the FAQ).> Or, alternatively, is there a better way to go about this > sort of repeated measures analysis in R? I've exhausted my available R > resources and done a pretty good search of the help archives without > finding a clear answer.Did you look at the references in the FAQ?> Chris Solomon > Center for Limnology > Univ. of WisconsinYou do know where the maintainer of the nlme package works, don't you? I am sure your University library has a copy or two of Pinheiro & Bates! -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Hello Chris, as far as I know from the Pinheiro and Bates book "Mixed-Effects Models in S and S-PLUS", the autoregressive parameter has to be specified only as initial value for the estimation. That is, the parameter will be estimated, but the result may depend on the prespecified value. You do not need to specify it. Then, 0 is used as initial value and this may work well (as in the example in Pinheiro and Bates, p. 241 f.). Christian PS: Have you been at a workshop on model selection near Munich in Nov. 2002? I suspect that I know who you are but I am not sure. On Tue, 14 Sep 2004, Chris Solomon wrote:> Hello- > > I'm trying to do some repeated measures ANOVAs. In the past, using SAS, > I have used the framework outlined in Littell et al.'s "SAS System for > Mixed Models", using the REPEATED statement in PROC MIXED to model > variation across time within an experimental unit. SAS allows you to > specify different within-unit covariance structures (e.g., compound > symmetric, AR(1), etc.) to determine the best model. > > I'm having trouble figuring out how to do a similar analysis in R. While > 'lme' will let you choose the class of correlation structure to use, it > seems to require that you specify this structure rather than using the > data to estimate the covariance matrix. For example, it seems that to > specify 'corAR1' as the correlation structure, you have to pick a value > for rho, the autoregressive parameter. > > So, my question: is there a way to tell 'lme' what sort of covariance > structure you'd like to model, and then let the function estimate the > covariances? Or, alternatively, is there a better way to go about this > sort of repeated measures analysis in R? I've exhausted my available R > resources and done a pretty good search of the help archives without > finding a clear answer. > > Thanks much! > Chris > > > > ******* > Chris Solomon > Center for Limnology > Univ. of Wisconsin > Phone: (608) 263-2465 > > ______________________________________________ > 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 >*********************************************************************** Christian Hennig Fachbereich Mathematik-SPST/ZMS, Universitaet Hamburg hennig at math.uni-hamburg.de, http://www.math.uni-hamburg.de/home/hennig/ ####################################################################### ich empfehle www.boag-online.de