Description Format Source Examples
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))
}
|
'data.frame': 32 obs. of 6 variables:
$ Id : num 1 2 3 4 5 6 7 8 9 10 ...
$ Block : Factor w/ 8 levels "1","2","3","4",..: 1 1 1 1 2 2 2 2 3 3 ...
$ Treatment: Factor w/ 4 levels "0","10","20",..: 1 2 3 4 1 2 3 4 1 2 ...
$ adg : num 1.03 1.54 1.82 1.86 1.31 2.16 2.13 2.23 1.59 2.53 ...
$ InitWt : num 338 477 444 370 403 451 450 393 394 499 ...
$ Trt : num 0 10 20 30 0 10 20 30 0 10 ...
- attr(*, "ginfo")=List of 7
..$ formula :Class 'formula' language adg ~ Trt | Block
.. .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv>
..$ order.groups: logi TRUE
..$ FUN :function (x)
..$ outer : NULL
..$ inner : NULL
..$ labels :List of 2
.. ..$ Trt: chr "Level of medicated feed additive in diet"
.. ..$ adg: chr "Average Daily Gain of steers fed for 160 days"
..$ units : list()
Linear mixed model fit by REML ['lmerMod']
Formula: adg ~ InitWt * Treatment - 1 + (1 | Block)
Data: AvgDailyGain
REML criterion at convergence: 65.3268
Random effects:
Groups Name Std.Dev.
Block (Intercept) 0.5092
Residual 0.2223
Number of obs: 32, groups: Block, 8
Fixed Effects:
InitWt Treatment0 Treatment10 Treatment20
0.004448 0.439137 1.426119 0.479629
Treatment30 InitWt:Treatment0 InitWt:Treatment10 InitWt:Treatment20
0.200107 -0.002154 -0.003365 -0.001082
Analysis of Variance Table
Df Sum Sq Mean Sq F value
InitWt 1 4.5318 4.5318 91.6823
Treatment 4 1.7425 0.4356 8.8131
InitWt:Treatment 3 0.1381 0.0460 0.9312
Linear mixed model fit by REML ['lmerMod']
Formula: adg ~ InitWt + Treatment + (1 | Block)
Data: AvgDailyGain
REML criterion at convergence: 36.3373
Random effects:
Groups Name Std.Dev.
Block (Intercept) 0.4908
Residual 0.2238
Number of obs: 32, groups: Block, 8
Fixed Effects:
(Intercept) InitWt Treatment0 Treatment10 Treatment20
0.80111 0.00278 -0.55207 -0.06857 -0.08813
Analysis of Variance Table
Df Sum Sq Mean Sq F value
InitWt 1 0.51455 0.51455 10.275
Treatment 3 1.52670 0.50890 10.162
Linear mixed model fit by REML ['lmerMod']
Formula: adg ~ InitWt + Treatment - 1 + (1 | Block)
Data: AvgDailyGain
REML criterion at convergence: 36.3373
Random effects:
Groups Name Std.Dev.
Block (Intercept) 0.4908
Residual 0.2238
Number of obs: 32, groups: Block, 8
Fixed Effects:
InitWt Treatment0 Treatment10 Treatment20 Treatment30
0.00278 0.24903 0.73254 0.71298 0.80111
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.