dat <- byers.apple
library(lattice)
xyplot(diameter ~ time | factor(appleid), data=dat, type=c('p','l'),
main="byers.apple")
# Overall fixed linear trend, plus random intercept/slope deviations
# for each apple. Observations within each apple are correlated.
library(nlme)
m1 <- lme(diameter ~ 1 + time, data=dat,
random = ~ time|appleid, method='ML',
cor = corAR1(0, form=~ time|appleid),
na.action=na.omit)
VarCorr(m1)
## appleid = pdLogChol(time)
## Variance StdDev Corr
## (Intercept) 7.353789e-03 0.08575423 (Intr)
## time 3.632377e-05 0.00602692 0.83
## Residual 4.555256e-04 0.02134305Run the code above in your browser using DataLab