inst/doc/confidence-intervals.R

## ---- echo = FALSE, results = "hide", message = FALSE-------------------------
require("emmeans")
knitr::opts_chunk$set(fig.width = 4.5, class.output = "ro")

## -----------------------------------------------------------------------------
pigs.lm1 <- lm(log(conc) ~ source + factor(percent), data = pigs)
pigs.rg <- ref_grid(pigs.lm1)
pigs.emm.s <- emmeans(pigs.rg, "source")

## -----------------------------------------------------------------------------
test(pigs.emm.s)

## -----------------------------------------------------------------------------
test(pigs.emm.s, null = log(40), side = ">")

## -----------------------------------------------------------------------------
confint(pigs.emm.s, calc = c(n = ~.wgt.))

## -----------------------------------------------------------------------------
test(pigs.emm.s, null = log(40), side = ">", type = "response")

## -----------------------------------------------------------------------------
confint(pigs.emm.s, side = ">", level = .90, type = "response")

## -----------------------------------------------------------------------------
confint(pigs.emm.s, adjust = "tukey")

## -----------------------------------------------------------------------------
test(pigs.emm.s, null = log(40), side = ">", adjust = "bonferroni")

## -----------------------------------------------------------------------------
confint(pigs.rg, by = "source")

## ----eval = FALSE-------------------------------------------------------------
#  emmeans(pigs.lm, ~ percent | source)     ### same results as above
#  summary(.Last.value, by = percent)       ### grouped the other way

## -----------------------------------------------------------------------------
warp.lm <- lm(breaks ~ wool * tension, data = warpbreaks)
warp.pw <- pairs(emmeans(warp.lm, ~ tension | wool))
warp.pw

## -----------------------------------------------------------------------------
test(warp.pw, by = NULL, adjust = "bonferroni")

## -----------------------------------------------------------------------------
test(warp.pw, adjust = "tukey", cross.adjust = "bonferroni")

## -----------------------------------------------------------------------------
pigsint.lm <- lm(log(conc) ~ source * factor(percent), data = pigs)
pigsint.rg <- ref_grid(pigsint.lm)
contrast(pigsint.rg, "consec", simple = "percent")

## -----------------------------------------------------------------------------
pigs.prs.s <- pairs(pigs.emm.s)
pigs.prs.s

## -----------------------------------------------------------------------------
test(pigs.prs.s, joint = TRUE)

## -----------------------------------------------------------------------------
joint_tests(pigsint.rg)

## -----------------------------------------------------------------------------
joint_tests(pigsint.rg, by = "source")

## -----------------------------------------------------------------------------
test(pigs.prs.s, delta = log(1.25), adjust = "none")

Try the emmeans package in your browser

Any scripts or data that you put into this service are public.

emmeans documentation built on Sept. 9, 2022, 1:06 a.m.