Debian Codegraph @

man/tidy.summary_emm.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/emmeans.R
3 \name{tidy.summary_emm}
4 \alias{tidy.summary_emm}
5 \title{Tidy a(n) summary_emm object}
6 \usage{
7 \method{tidy}{summary_emm}(x, null.value = NULL, ...)
8 }
9 \arguments{
10 \item{x}{A \code{summary_emm} object.}
11
12 \item{null.value}{Value to which estimate is compared.}
13
14 \item{...}{Additional arguments passed to \code{\link[emmeans:summary.emmGrid]{emmeans::summary.emmGrid()}} or
15 \code{\link[lsmeans:ref.grid]{lsmeans::summary.ref.grid()}}. \strong{Cautionary note}: misspecified arguments
16 may be silently ignored!}
17 }
18 \description{
19 Tidy summarizes information about the components of a model.
20 A model component might be a single term in a regression, a single
21 hypothesis, a cluster, or a class. Exactly what tidy considers to be a
22 model component varies across models but is usually self-evident.
23 If a model has several distinct types of components, you will need to
24 specify which components to return.
25 }
26 \details{
27 Returns a data frame with one observation for each estimated marginal
28 mean, and one column for each combination of factors. When the input is a
29 contrast, each row will contain one estimated contrast.
30
31 There are a large number of arguments that can be
32 passed on to \code{\link[emmeans:summary.emmGrid]{emmeans::summary.emmGrid()}} or \code{\link[lsmeans:ref.grid]{lsmeans::summary.ref.grid()}}.
33 }
34 \examples{
35 \dontshow{if (rlang::is_installed(c("emmeans", "ggplot2"))) withAutoprint(\{ # examplesIf}
36
37 # load libraries for models and data
38 library(emmeans)
39
40 # linear model for sales of oranges per day
41 oranges_lm1 <- lm(sales1 ~ price1 + price2 + day + store, data = oranges)
42
43 # reference grid; see vignette("basics", package = "emmeans")
44 oranges_rg1 <- ref_grid(oranges_lm1)
45 td <- tidy(oranges_rg1)
46 td
47
48 # marginal averages
49 marginal <- emmeans(oranges_rg1, "day")
50 tidy(marginal)
51
52 # contrasts
53 tidy(contrast(marginal))
54 tidy(contrast(marginal, method = "pairwise"))
55
56 # plot confidence intervals
57 library(ggplot2)
58
59 ggplot(tidy(marginal, conf.int = TRUE), aes(day, estimate)) +
60 geom_point() +
61 geom_errorbar(aes(ymin = conf.low, ymax = conf.high))
62
63 # by multiple prices
64 by_price <- emmeans(oranges_lm1, "day",
65 by = "price2",
66 at = list(
67 price1 = 50, price2 = c(40, 60, 80),
68 day = c("2", "3", "4")
69 )
70 )
71
72 by_price
73
74 tidy(by_price)
75
76 ggplot(tidy(by_price, conf.int = TRUE), aes(price2, estimate, color = day)) +
77 geom_line() +
78 geom_errorbar(aes(ymin = conf.low, ymax = conf.high))
79
80 # joint_tests
81 tidy(joint_tests(oranges_lm1))
82 \dontshow{\}) # examplesIf}
83 }
84 \seealso{
85 \code{\link[=tidy]{tidy()}}, \code{\link[emmeans:ref_grid]{emmeans::ref_grid()}}, \code{\link[emmeans:emmeans]{emmeans::emmeans()}},
86 \code{\link[emmeans:contrast]{emmeans::contrast()}}
87
88 Other emmeans tidiers:
89 \code{\link{tidy.emmGrid}()},
90 \code{\link{tidy.lsmobj}()},
91 \code{\link{tidy.ref.grid}()}
92 }
93 \concept{emmeans tidiers}
94 \value{
95 A \code{\link[tibble:tibble]{tibble::tibble()}} with columns:
96 \item{conf.high}{Upper bound on the confidence interval for the estimate.}
97 \item{conf.low}{Lower bound on the confidence interval for the estimate.}
98 \item{contrast}{Levels being compared.}
99 \item{den.df}{Degrees of freedom of the denominator.}
100 \item{df}{Degrees of freedom used by this term in the model.}
101 \item{null.value}{Value to which the estimate is compared.}
102 \item{num.df}{Degrees of freedom.}
103 \item{p.value}{The two-sided p-value associated with the observed statistic.}
104 \item{std.error}{The standard error of the regression term.}
105 \item{level1}{One level of the factor being contrasted}
106 \item{level2}{The other level of the factor being contrasted}
107 \item{term}{Model term in joint tests}
108 \item{estimate}{Expected marginal mean}
109 \item{statistic}{T-ratio statistic or F-ratio statistic}
110
111 }