if (FALSE) {
library(agridat)
data(woodman.pig)
dat <- woodman.pig
# add day of year for each weighing
dat <- transform(dat, date1=36, date2=148)
plot(NA, xlim=c(31,153), ylim=c(28,214),
xlab="day of year", ylab="weight")
segments(dat$date1, dat$weight1, dat$date2, dat$weight2,
col=as.numeric(as.factor(dat$treatment)))
title("woodman.pig")
# Average gain per week
dat <- transform(dat, pen=factor(pen), treatment=factor(treatment),
sex=factor(sex))
m1 <- lm(g ~ -1 + pen + treatment +sex + treatment:sex + w0, data=dat)
anova(m1)
# Compare diets. Results similar to Westfall 8.13
libs(emmeans)
pairs(emmeans(m1, "treatment"))
# NOTE: Results may be misleading due to involvement in interactions
# contrast estimate SE df t.ratio p.value
# A - B 0.4283 0.288 19 1.490 0.3179
# A - C 0.5200 0.284 19 1.834 0.1857
# B - C 0.0918 0.288 19 0.319 0.9456
}
Run the code above in your browser using DataLab