Aliases: tidy.summary_emm
Keywords:
### ** Examples # feel free to ignore the following line—it allows {broom} to supply # examples without requiring the model-supplying package to be installed. if (requireNamespace("emmeans", quietly = TRUE)) { # load libraries for models and data library(emmeans) # linear model for sales of oranges per day oranges_lm1 <- lm(sales1 ~ price1 + price2 + day + store, data = oranges) # reference grid; see vignette("basics", package = "emmeans") oranges_rg1 <- ref_grid(oranges_lm1) td <- tidy(oranges_rg1) td # marginal averages marginal <- emmeans(oranges_rg1, "day") tidy(marginal) # contrasts tidy(contrast(marginal)) tidy(contrast(marginal, method = "pairwise")) # plot confidence intervals library(ggplot2) ggplot(tidy(marginal, conf.int = TRUE), aes(day, estimate)) + geom_point() + geom_errorbar(aes(ymin = conf.low, ymax = conf.high)) # by multiple prices by_price <- emmeans(oranges_lm1, "day", by = "price2", at = list( price1 = 50, price2 = c(40, 60, 80), day = c("2", "3", "4") ) ) by_price tidy(by_price) ggplot(tidy(by_price, conf.int = TRUE), aes(price2, estimate, color = day)) + geom_line() + geom_errorbar(aes(ymin = conf.low, ymax = conf.high)) # joint_tests tidy(joint_tests(oranges_lm1)) }
# A tibble: 4 × 5 term num.df den.df statistic p.value <chr> <dbl> <dbl> <dbl> <dbl> 1 price1 1 23 30.3 0.0000134 2 price2 1 23 2.23 0.149 3 day 5 23 4.88 0.00346 4 store 5 23 2.52 0.0583