[R] can I get same results using lme and gls?

toby909 at gmail.com toby909 at gmail.com
Mon May 21 03:56:40 CEST 2007

Hi All

I was wondering how to get the same results with gls and lme. In my lme, the 
design matrix for the random effects is (should be) a identity matrix and 
therefore G should add up with R to produce the R matrix that gls would report 
(V=ZGZ'+R). Added complexity is that I have 3 levels, so I have R, G and say H 
(V=WHW'+ZGZ'+R). The lme is giving me the correct results, I am having trouble 
finding the right corresponding specification for the gls.

Thanks for your help.


dtaa = 
dta1 = reshape(dtaa, list(c("V10","V12")), "score", direction="long", 
colnames(dta1)[1] = "schoolNR"
dta2 = dta1[order(dta1$id),]
timef = factor(dta2$time)

summary(mdl1l <- lme(score~timef-1, dta2, ~timef-1|schoolNR/id,,,,"ML"))
summary(mdl1g <- gls(score~timef-1, dta2, corCompSymm(, ~timef|schoolNR/id), 
varIdent(, ~1|id*timef),,"ML"))

More information about the R-help mailing list