The AvgDailyGain
data frame has 32 rows and 6 columns.
This data frame contains the following columns:
the animal number
an ordered factor indicating the barn in which the steer was housed.
an ordered factor with levels
0
< 10
< 20
< 30
indicating the amount of medicated feed additive added to
the base ration.
a numeric vector of average daily weight gains over a period of 160 days.
a numeric vector giving the initial weight of the animal
the Treatment
as a numeric variable
Littel, R. C., Milliken, G. A., Stroup, W. W., and Wolfinger, R. D. (1996), SAS System for Mixed Models, SAS Institute (Data Set 5.3).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19  str(AvgDailyGain)
if (require("lattice", quietly = TRUE, character = TRUE)) {
## plot of adg versus Treatment by Block
xyplot(adg ~ Treatment  Block, AvgDailyGain, type = c("g", "p", "r"),
xlab = "Treatment (amount of feed additive)",
ylab = "Average daily weight gain (lb.)", aspect = "xy",
index.cond = function(x, y) coef(lm(y ~ x))[1])
}
if (require("lme4", quietly = TRUE, character = TRUE)) {
options(contrasts = c(unordered = "contr.SAS", ordered = "contr.poly"))
## compare with output 5.1, p. 178
print(fm1Adg < lmer(adg ~ InitWt * Treatment  1 + (1  Block),
AvgDailyGain))
print(anova(fm1Adg)) # checking significance of terms
print(fm2Adg < lmer(adg ~ InitWt + Treatment + (1  Block),
AvgDailyGain))
print(anova(fm2Adg))
print(lmer(adg ~ InitWt + Treatment  1 + (1  Block), AvgDailyGain))
}

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
All documentation is copyright its authors; we didn't write any of that.