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