Debian Codegraph @

man/tidy.mfx.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/mfx.R
3 \name{tidy.mfx}
4 \alias{tidy.mfx}
5 \alias{tidy.logitmfx}
6 \alias{tidy.negbinmfx}
7 \alias{tidy.poissonmfx}
8 \alias{tidy.probitmfx}
9 \title{Tidy a(n) mfx object}
10 \usage{
11 \method{tidy}{mfx}(x, conf.int = FALSE, conf.level = 0.95, ...)
12
13 \method{tidy}{logitmfx}(x, conf.int = FALSE, conf.level = 0.95, ...)
14
15 \method{tidy}{negbinmfx}(x, conf.int = FALSE, conf.level = 0.95, ...)
16
17 \method{tidy}{poissonmfx}(x, conf.int = FALSE, conf.level = 0.95, ...)
18
19 \method{tidy}{probitmfx}(x, conf.int = FALSE, conf.level = 0.95, ...)
20 }
21 \arguments{
22 \item{x}{A \code{logitmfx}, \code{negbinmfx}, \code{poissonmfx}, or \code{probitmfx} object.
23 (Note that \code{betamfx} objects receive their own set of tidiers.)}
24
25 \item{conf.int}{Logical indicating whether or not to include a confidence
26 interval in the tidied output. Defaults to \code{FALSE}.}
27
28 \item{conf.level}{The confidence level to use for the confidence interval
29 if \code{conf.int = TRUE}. Must be strictly greater than 0 and less than 1.
30 Defaults to 0.95, which corresponds to a 95 percent confidence interval.}
31
32 \item{...}{Additional arguments. Not used. Needed to match generic
33 signature only. \strong{Cautionary note:} Misspelled arguments will be
34 absorbed in \code{...}, where they will be ignored. If the misspelled
35 argument has a default value, the default value will be used.
36 For example, if you pass \code{conf.lvel = 0.9}, all computation will
37 proceed using \code{conf.level = 0.95}. Two exceptions here are:
38 \itemize{
39 \item \code{tidy()} methods will warn when supplied an \code{exponentiate} argument if
40 it will be ignored.
41 \item \code{augment()} methods will warn when supplied a \code{newdata} argument if it
42 will be ignored.
43 }}
44 }
45 \description{
46 Tidy summarizes information about the components of a model.
47 A model component might be a single term in a regression, a single
48 hypothesis, a cluster, or a class. Exactly what tidy considers to be a
49 model component varies across models but is usually self-evident.
50 If a model has several distinct types of components, you will need to
51 specify which components to return.
52
53 The particular functions below provide generic tidy methods for
54 objects returned by the \code{mfx} package, preserving the calculated marginal
55 effects instead of the naive model coefficients. The returned tidy tibble
56 will also include an additional "atmean" column indicating how the marginal
57 effects were originally calculated (see Details below).
58 }
59 \details{
60 The \code{mfx} package provides methods for calculating marginal effects
61 for various generalized linear models (GLMs). Unlike standard linear
62 models, estimated model coefficients in a GLM cannot be directly
63 interpreted as marginal effects (i.e., the change in the response variable
64 predicted after a one unit change in one of the regressors). This is
65 because the estimated coefficients are multiplicative, dependent on both
66 the link function that was used for the estimation and any other variables
67 that were included in the model. When calculating marginal effects, users
68 must typically choose whether they want to use i) the average observation
69 in the data, or ii) the average of the sample marginal effects. See
70 \code{vignette("mfxarticle")} from the \code{mfx} package for more details.
71 }
72 \examples{
73 \dontshow{if (rlang::is_installed("mfx")) withAutoprint(\{ # examplesIf}
74
75 # load libraries for models and data
76 library(mfx)
77
78 # get the marginal effects from a logit regression
79 mod_logmfx <- logitmfx(am ~ cyl + hp + wt, atmean = TRUE, data = mtcars)
80
81 tidy(mod_logmfx, conf.int = TRUE)
82
83 # compare with the naive model coefficients of the same logit call
84 tidy(
85 glm(am ~ cyl + hp + wt, family = binomial, data = mtcars),
86 conf.int = TRUE
87 )
88
89 augment(mod_logmfx)
90 glance(mod_logmfx)
91
92 # another example, this time using probit regression
93 mod_probmfx <- probitmfx(am ~ cyl + hp + wt, atmean = TRUE, data = mtcars)
94
95 tidy(mod_probmfx, conf.int = TRUE)
96 augment(mod_probmfx)
97 glance(mod_probmfx)
98 \dontshow{\}) # examplesIf}
99 }
100 \seealso{
101 \code{\link[=tidy]{tidy()}}, \code{\link[mfx:logitmfx]{mfx::logitmfx()}}, \code{\link[mfx:negbinmfx]{mfx::negbinmfx()}}, \code{\link[mfx:poissonmfx]{mfx::poissonmfx()}}, \code{\link[mfx:probitmfx]{mfx::probitmfx()}}
102
103 Other mfx tidiers:
104 \code{\link{augment.betamfx}()},
105 \code{\link{augment.mfx}()},
106 \code{\link{glance.betamfx}()},
107 \code{\link{glance.mfx}()},
108 \code{\link{tidy.betamfx}()}
109 }
110 \concept{mfx tidiers}
111 \value{
112 A \code{\link[tibble:tibble]{tibble::tibble()}} with columns:
113 \item{conf.high}{Upper bound on the confidence interval for the estimate.}
114 \item{conf.low}{Lower bound on the confidence interval for the estimate.}
115 \item{estimate}{The estimated value of the regression term.}
116 \item{p.value}{The two-sided p-value associated with the observed statistic.}
117 \item{statistic}{The value of a T-statistic to use in a hypothesis that the regression term is non-zero.}
118 \item{std.error}{The standard error of the regression term.}
119 \item{term}{The name of the regression term.}
120 \item{atmean}{TRUE if the marginal effects were originally calculated as
121 the partial effects for the average observation. If FALSE, then these
122 were instead calculated as average partial effects.}
123
124 }