| feedlot {lsmeans} | R Documentation |
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.
data(feedlot)
A data frame with 67 observations on the following 4 variables.
herda factor with levels 9 16 3 32 24 31 19 36 34 35 33, designating the herd that a feeder calf came from.
dieta factor with levels Low Medium High: the energy level of the diet given the animal.
swta numeric vector: the weight of the animal at slaughter.
ewta numeric vector: the weight of the animal at entry to the feedlot.
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.
Urquhart NS (1982) Adjustment in covariates when one factor affects the covariate. Biometrics 38, 651-660.
require(lsmeans) feedlot.lm <- lm(swt ~ ewt + herd*diet, data = feedlot) # Obtain LS~means with a separate reference value of ewt for each # herd. This reproduces the last part of Table 2 in the reference lsmeans(feedlot.lm, ~ diet | herd, cov.reduce = ewt ~ herd)