# NOT RUN {
head(Loblolly) # groupedData w/ 'Seed' is grouping variable :
## Grouped Data: height ~ age | Seed
## height age Seed
## 1 4.51 3 301
## 15 10.89 5 301
## .. ..... . ...
fm1 <- nlme(height ~ SSasymp(age, Asym, R0, lrc), data = Loblolly,
fixed = Asym + R0 + lrc ~ 1,
random = Asym ~ 1, ## <---grouping---> Asym ~ 1 | Seed
start = c(Asym = 103, R0 = -8.5, lrc = -3.3))
fm1
age. <- seq(from = 2, to = 30, by = 2)
newLL.301 <- data.frame(age = age., Seed = 301)
newLL.329 <- data.frame(age = age., Seed = 329)
(p301 <- predict(fm1, newLL.301, level = 0:1))
(p329 <- predict(fm1, newLL.329, level = 0:1))
## Prediction are the same at level 0 :
all.equal(p301[,"predict.fixed"],
p329[,"predict.fixed"])
## and differ by the 'Seed' effect at level 1 :
p301[,"predict.Seed"] -
p329[,"predict.Seed"]
# }
Run the code above in your browser using DataLab