Description Format Source Examples
The HR
data frame has 120 rows and 5 columns of the heart
rates of patients under one of three possible drug treatments.
This data frame contains the following columns:
an ordered factor indicating the patient.
the drug treatment  a factor with levels a
,
b
and p
where p
represents the placebo.
the patient's base heart rate
the observed heart rate at different times in the experiment
the time of the observation
Littel, R. C., Milliken, G. A., Stroup, W. W., and Wolfinger, R. D. (1996), SAS System for Mixed Models, SAS Institute (Data Set 3.5).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24  str(HR)
if (require("lattice", quietly = TRUE, character = TRUE)) {
xyplot(HR ~ Time  Patient, HR, type = c("g", "p", "r"), aspect = "xy",
index.cond = function(x, y) coef(lm(y ~ x))[1],
ylab = "Heart rate (beats/min)")
}
if (require("lme4", quietly = TRUE, character = TRUE)) {
options(contrasts = c(unordered = "contr.SAS", ordered = "contr.poly"))
## linear trend in time
print(fm1HR < lmer(HR ~ Time * Drug + baseHR + (TimePatient), HR))
print(anova(fm1HR))
## Not run:
fm2HR < update(fm1HR, weights = varPower(0.5)) # use powerofmean variance
summary(fm2HR)
intervals(fm2HR) # variance function does not seem significant
anova(fm1HR, fm2HR) # confirm with likelihood ratio
## End(Not run)
print(fm3HR < lmer(HR ~ Time + Drug + baseHR + (TimePatient), HR))
print(anova(fm3HR))
## remove Drug term
print(fm4HR < lmer(HR ~ Time + baseHR + (TimePatient), HR))
print(anova(fm4HR))
}

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.