This is an unbalanced analysis-of-covariance example, where one covariate is affected by a factor. Feeder calves from various herds enter a feedlot, where they are fed one of three diets. The weight of the animal at entry is the covariate, and the weight at slaughter is the response.
feedlot
A data frame with 67 observations and 4 variables:
herd
a factor with levels 9
16
3
32
24
31
19
36
34
35
33
, designating the herd that a feeder calf came from.
diet
a factor with levels Low
Medium
High
: the energy level of the diet given the animal.
swt
a numeric vector: the weight of the animal at slaughter.
ewt
a numeric vector: the weight of the animal at entry to the feedlot.
Urquhart NS (1982) Adjustment in covariates when one factor affects the covariate. Biometrics 38, 651-660.
The data arise from a Western Regional Research Project conducted at New
Mexico State University. Calves born in 1975 in commercial herds entered a
feedlot as yearlings. Both diets and herds are of interest as factors. The
covariate, ewt
, is thought to be dependent on herd
due to
different genetic backgrounds, breeding history, etc. The levels of
herd
ordered to similarity of genetic background.
Note: There are some empty cells in the cross-classification of
herd
and diet
.
feedlot.lm <- lm(swt ~ ewt + herd*diet, data = feedlot)
# Obtain EMMs with a separate reference value of ewt for each
# herd. This reproduces the last part of Table 2 in the reference
emmeans(feedlot.lm, ~ diet | herd, cov.reduce = ewt ~ herd)
#> herd = 9:
#> diet emmean SE df lower.CL upper.CL
#> Low 839 32.7 36 773 906
#> Medium 877 40.1 36 796 958
#> High nonEst NA NA NA NA
#>
#> herd = 16:
#> diet emmean SE df lower.CL upper.CL
#> Low 940 41.3 36 856 1024
#> Medium 951 60.3 36 829 1073
#> High nonEst NA NA NA NA
#>
#> herd = 3:
#> diet emmean SE df lower.CL upper.CL
#> Low 981 32.8 36 915 1048
#> Medium 1002 41.2 36 918 1085
#> High 1015 105.0 36 803 1227
#>
#> herd = 32:
#> diet emmean SE df lower.CL upper.CL
#> Low 1003 33.2 36 936 1070
#> Medium 890 94.2 36 699 1081
#> High 970 75.7 36 817 1124
#>
#> herd = 24:
#> diet emmean SE df lower.CL upper.CL
#> Low 982 28.3 36 924 1039
#> Medium 982 90.2 36 799 1165
#> High nonEst NA NA NA NA
#>
#> herd = 31:
#> diet emmean SE df lower.CL upper.CL
#> Low 1128 32.9 36 1062 1195
#> Medium 1069 88.7 36 889 1249
#> High 1111 56.6 36 996 1226
#>
#> herd = 19:
#> diet emmean SE df lower.CL upper.CL
#> Low 1087 28.3 36 1030 1145
#> Medium 1036 80.2 36 873 1199
#> High 999 56.7 36 884 1114
#>
#> herd = 36:
#> diet emmean SE df lower.CL upper.CL
#> Low 1155 65.3 36 1023 1288
#> Medium 1062 65.8 36 928 1195
#> High 1191 76.8 36 1035 1346
#>
#> herd = 34:
#> diet emmean SE df lower.CL upper.CL
#> Low 987 53.1 36 879 1094
#> Medium 1015 58.1 36 897 1132
#> High 1048 57.4 36 931 1165
#>
#> herd = 35:
#> diet emmean SE df lower.CL upper.CL
#> Low 1094 61.3 36 970 1218
#> Medium 1092 111.0 36 867 1317
#> High 1103 67.2 36 966 1239
#>
#> herd = 33:
#> diet emmean SE df lower.CL upper.CL
#> Low 1207 80.4 36 1044 1370
#> Medium 1031 140.0 36 748 1314
#> High 1018 80.0 36 856 1180
#>
#> Confidence level used: 0.95