simontbate
2011-Mar-12 22:06 UTC
[R] Repeated measures in nlme vs SAS Proc Mixed with AR1 correlation structure
Hi all, I don't know if anyone has any thoughts on this. I have been trying to move from SAS Proc Mixed to R nlme and have an unusual result. I have several subjects measured at four timepoints. I want to model the within-subject correlation using an autoregressive structure. I've attached the R and SAS code I'm using along with the results from SAS. With R lme I get an estimate of the autoregressive paramater phi = 0.2782601, whereas SAS gives me an estimate of 0.3389 Intriguingly if I include a between subject factor or a covariate or delete one of the observations, then the results appear to agree. I'm suprised the seemingly simpler model if different between the two packages whereas the more complex models agree. Any ideas would be most welcome! Simon R Code: library(nlme) Response<-c(0.55,0.86,0.21,0.36,0.46,0.32,0.11,0.24,0.36,0.29,0.48,0.93,0.56,0.67,0.36,0.55,0.51,0.4,0.34,0.51,1,0.61,0.65,0.41,0.99,0.86,0.64,0.86,0.31,0.19,0.21,0.36,0.41,0.47,0.16,0.81,0.9,0.72,0.87,0.02) Subject<-c(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7,8,8,8,8,9,9,9,9,10,10,10,10) Day<-c(1,2,4,6,1,2,4,6,1,2,4,6,1,2,4,6,1,2,4,6,1,2,4,6,1,2,4,6,1,2,4,6,1,2,4,6,1,2,4,6) sasdata<-data.frame(cbind(Response, Subject, Day)) sasdata$Time<-as.factor(sasdata$Day) AR1<-lme(Response~Time, random=~1|Subject, correlation=corAR1(form=~as.numeric(Time)|Subject, fixed =FALSE), data=sasdata, na.action = (na.omit), method = "REML") AR1 SAS Code: proc mixed; class Subject Day; model Response = Day / outp=pout; repeated Day / subject = Subject type=AR(1); run; SAS Results: Model Information Data Set WORK.ALLDATA Dependent Variable Response Covariance Structure Autoregressive Subject Effect Subject Estimation Method REML Residual Variance Method Profile Fixed Effects SE Method Model-Based Degrees of Freedom Method Between-Within Class Level Information Class Levels Values Subject 10 1 10 2 3 4 5 6 7 8 9 Day 4 1 2 3 4 Dimensions Covariance Parameters 2 Columns in X 5 Columns in Z 0 Subjects 10 Max Obs Per Subject 4 Number of Observations Number of Observations Read 40 Number of Observations Used 40 Number of Observations Not Used 0 Iteration History Iteration Evaluations -2 Res Log Like Criterion 0 1 14.67045653 1 2 11.63168913 0.00000018 2 1 11.63168429 0.00000000 Convergence criteria met. Covariance Parameter Estimates Cov Parm Subject Estimate AR(1) Animal1 0.3389 Residual 0.06862 -- View this message in context: http://r.789695.n4.nabble.com/Repeated-measures-in-nlme-vs-SAS-Proc-Mixed-with-AR1-correlation-structure-tp3350929p3350929.html Sent from the R help mailing list archive at Nabble.com.