1
% Generated by roxygen2: do not edit by hand
2
% Please edit documentation in R/emtrends.R
5
\title{Estimated marginal means of linear trends}
7
emtrends(model, specs, var, delta.var = 0.01 * rng, data,
8
transform = c("none", "response"), ...)
11
\item{model}{A supported model object (\emph{not} a reference grid)}
13
\item{specs}{Specifications for what marginal trends are desired -- as in
14
\code{\link{emmeans}}}
16
\item{var}{Character value giving the name of a variable with respect to
17
which a difference quotient of the linear predictors is computed. In order
18
for this to be useful, \code{var} should be a numeric predictor that
19
interacts with at least one factor in \code{specs}. Then instead of
20
computing EMMs, we compute and compare the slopes of the \code{var} trend
21
over levels of the specified other predictor(s). As in EMMs, marginal
22
averages are computed for the predictors in \code{specs} and \code{by}.
23
See also the \dQuote{Generalizations} section below.}
25
\item{delta.var}{The value of \emph{h} to use in forming the difference
26
quotient \eqn{(f(x+h) - f(x))/h}. Changing it (especially changing its
27
sign) may be necessary to avoid numerical problems such as logs of negative
28
numbers. The default value is 1/100 of the range of \code{var} over the
31
\item{data}{As in \code{\link{ref_grid}}, you may use this argument to supply
32
the dataset used in fitting the model, for situations where it is not
33
possible to reconstruct the data. Otherwise, leave it missing.}
35
\item{transform}{If \code{object} has a response
36
transformation or link function, then specifying
37
\code{transform = "response"} will cause
38
\code{emtrends} to calculate the trends after back-transforming to the
39
response scale. This is done using the chain rule, and standard errors are
40
estimated via the delta method. With \code{transform = "none"} (the
41
default), the trends are calculated on the scale of the linear predictor,
42
without back-transforming it. This argument works similarly to the
43
\code{transform} argument in \code{\link{ref_grid}}, in that the returned
44
object is re-gridded to the new scale (see also \code{\link{regrid}}).}
46
\item{...}{Additional arguments passed to other methods or to
47
\code{\link{ref_grid}}}
50
An \code{emmGrid} or \code{emm_list} object, according to \code{specs}.
51
See \code{\link{emmeans}} for more details on when a list is returned.
54
The \code{emtrends} function is useful when a fitted model involves a
55
numerical predictor \eqn{x} interacting with another predictor \code{a}
56
(typically a factor). Such models specify that \eqn{x} has a different trend
57
depending on \eqn{a}; thus, it may be of interest to estimate and compare
58
those trends. Analogous to the \code{\link{emmeans}} setting, we construct a
59
reference grid of these predicted trends, and then possibly average them over
60
some of the predictors in the grid.
62
\section{Generalizations}{
64
Instead of a single predictor, the user may specify some monotone function of
65
one variable, e.g., \code{var = "log(dose)"}. If so, the chain rule is
66
applied. Note that, in this example, if \code{model} contains
67
\code{log(dose)} as a predictor, we will be comparing the slopes estimated by
68
that model, whereas specifying \code{var = "dose"} would perform a
69
transformation of those slopes, making the predicted trends vary depending on
74
fiber.lm <- lm(strength ~ diameter*machine, data=fiber)
75
# Obtain slopes for each machine ...
76
( fiber.emt <- emtrends(fiber.lm, "machine", var = "diameter") )
77
# ... and pairwise comparisons thereof
80
# Suppose we want trends relative to sqrt(diameter)...
81
emtrends(fiber.lm, ~ machine | diameter, var = "sqrt(diameter)",
82
at = list(diameter = c(20, 30)))
86
\code{link{emmeans}}, \code{\link{ref_grid}}