if (requireNamespace("nlme", quietly = TRUE)) {
library(nlme)
rat_weight <- lme(weight ~ Time * Diet, data=BodyWeight, ~ Time | Rat)
vcovCR(rat_weight, type = "CR2")
}
pkgs_available <-
requireNamespace("nlme", quietly = TRUE) &
requireNamespace("mlmRev", quietly = TRUE)
if (pkgs_available) {
data(egsingle, package = "mlmRev")
subset_ids <- levels(egsingle$schoolid)[1:10]
egsingle_subset <- subset(egsingle, schoolid %in% subset_ids)
math_model <- lme(math ~ year * size + female + black + hispanic,
random = list(~ year | schoolid, ~ 1 | childid),
data = egsingle_subset)
vcovCR(math_model, type = "CR2")
}
Run the code above in your browser using DataLab