# Given summary statistics for 4 cells in a 2 x 2 layout, obtain
# marginal means and comparisons thereof. Assume heteroscedasticity
# and use the Satterthwaite method
levels <- list(trt = c("A", "B"), dose = c("high", "low"))
ybar <- c(57.6, 43.2, 88.9, 69.8)
s <- c(12.1, 19.5, 22.8, 43.2)
n <- c(44, 11, 37, 24)
se2 = s^2 / n
Satt.df <- function(x, dfargs)
sum(x * dfargs$v)^2 / sum((x * dfargs$v)^2 / (dfargs$n - 1))
expt.emm <- emmobj(bhat = ybar, V = diag(se2),
levels = levels, linfct = diag(c(1, 1, 1, 1)),
df = Satt.df, dfargs = list(v = se2, n = n), estName = "mean")
( trt.emm <- emmeans(expt.emm, "trt") )
( dose.emm <- emmeans(expt.emm, "dose") )
rbind(pairs(trt.emm), pairs(dose.emm), adjust = "mvt")
### Create an emmobj from means and SEs
### (This illustration reproduces the MOats example for Variety = "Victory")
means = c(71.50000, 89.66667, 110.83333, 118.50000)
semeans = c(5.540591, 6.602048, 8.695358, 7.303221)
sediffs = c(7.310571, 9.894724, 7.463615, 10.248306, 4.935698, 8.694507)
foo = emmobj(bhat = means, se.bhat = semeans, se.diff = sediffs,
levels = list(nitro = seq(0, .6, by = .2)), df = 10)
plot(foo, comparisons = TRUE)
Run the code above in your browser using DataLab