Learn R Programming

SASmixed (version 1.0-4)

AvgDailyGain: Average daily weight gain of steers on different diets

Description

The AvgDailyGain data frame has 32 rows and 6 columns.

Arguments

Format

This data frame contains the following columns:
Id
the animal number
Block
an ordered factor indicating the barn in which the steer was housed.
Treatment
an ordered factor with levels 0 < 10 < 20 < 30 indicating the amount of medicated feed additive added to the base ration.
adg
a numeric vector of average daily weight gains over a period of 160 days.
InitWt
a numeric vector giving the initial weight of the animal
Trt
the Treatment as a numeric variable

Source

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).

Examples

Run this code
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))
}

Run the code above in your browser using DataLab