Debian Codegraph @

man/augment.betamfx.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/mfx.R
3 \name{augment.betamfx}
4 \alias{augment.betamfx}
5 \title{Augment data with information from a(n) betamfx object}
6 \usage{
7 \method{augment}{betamfx}(
8 x,
9 data = model.frame(x$fit),
10 newdata = NULL,
11 type.predict = c("response", "link", "precision", "variance", "quantile"),
12 type.residuals = c("sweighted2", "deviance", "pearson", "response", "weighted",
13 "sweighted"),
14 ...
15 )
16 }
17 \arguments{
18 \item{x}{A \code{betamfx} object.}
19
20 \item{data}{A \link[base:data.frame]{base::data.frame} or \code{\link[tibble:tibble]{tibble::tibble()}} containing the original
21 data that was used to produce the object \code{x}. Defaults to
22 \code{stats::model.frame(x)} so that \code{augment(my_fit)} returns the augmented
23 original data. \strong{Do not} pass new data to the \code{data} argument.
24 Augment will report information such as influence and cooks distance for
25 data passed to the \code{data} argument. These measures are only defined for
26 the original training data.}
27
28 \item{newdata}{A \code{\link[base:data.frame]{base::data.frame()}} or \code{\link[tibble:tibble]{tibble::tibble()}} containing all
29 the original predictors used to create \code{x}. Defaults to \code{NULL}, indicating
30 that nothing has been passed to \code{newdata}. If \code{newdata} is specified,
31 the \code{data} argument will be ignored.}
32
33 \item{type.predict}{Character indicating type of prediction to use. Passed to
34 the \code{type} argument of \code{\link[betareg:predict.betareg]{betareg::predict.betareg()}}. Defaults to
35 \code{"response"}.}
36
37 \item{type.residuals}{Character indicating type of residuals to use. Passed
38 to the \code{type} argument of \code{\link[betareg:residuals.betareg]{betareg::residuals.betareg()}}. Defaults to
39 \verb{"sweighted2}.}
40
41 \item{...}{Additional arguments. Not used. Needed to match generic
42 signature only. \strong{Cautionary note:} Misspelled arguments will be
43 absorbed in \code{...}, where they will be ignored. If the misspelled
44 argument has a default value, the default value will be used.
45 For example, if you pass \code{conf.lvel = 0.9}, all computation will
46 proceed using \code{conf.level = 0.95}. Two exceptions here are:
47 \itemize{
48 \item \code{tidy()} methods will warn when supplied an \code{exponentiate} argument if
49 it will be ignored.
50 \item \code{augment()} methods will warn when supplied a \code{newdata} argument if it
51 will be ignored.
52 }}
53 }
54 \description{
55 Augment accepts a model object and a dataset and adds
56 information about each observation in the dataset. Most commonly, this
57 includes predicted values in the \code{.fitted} column, residuals in the
58 \code{.resid} column, and standard errors for the fitted values in a \code{.se.fit}
59 column. New columns always begin with a \code{.} prefix to avoid overwriting
60 columns in the original dataset.
61
62 Users may pass data to augment via either the \code{data} argument or the
63 \code{newdata} argument. If the user passes data to the \code{data} argument,
64 it \strong{must} be exactly the data that was used to fit the model
65 object. Pass datasets to \code{newdata} to augment data that was not used
66 during model fitting. This still requires that at least all predictor
67 variable columns used to fit the model are present. If the original outcome
68 variable used to fit the model is not included in \code{newdata}, then no
69 \code{.resid} column will be included in the output.
70
71 Augment will often behave differently depending on whether \code{data} or
72 \code{newdata} is given. This is because there is often information
73 associated with training observations (such as influences or related)
74 measures that is not meaningfully defined for new observations.
75
76 For convenience, many augment methods provide default \code{data} arguments,
77 so that \code{augment(fit)} will return the augmented training data. In these
78 cases, augment tries to reconstruct the original data based on the model
79 object with varying degrees of success.
80
81 The augmented dataset is always returned as a \link[tibble:tibble]{tibble::tibble} with the
82 \strong{same number of rows} as the passed dataset. This means that the passed
83 data must be coercible to a tibble. If a predictor enters the model as part
84 of a matrix of covariates, such as when the model formula uses
85 \code{\link[splines:ns]{splines::ns()}}, \code{\link[stats:poly]{stats::poly()}}, or \code{\link[survival:Surv]{survival::Surv()}}, it is represented
86 as a matrix column.
87
88 We are in the process of defining behaviors for models fit with various
89 \code{na.action} arguments, but make no guarantees about behavior when data is
90 missing at this time.
91 }
92 \details{
93 This augment method wraps \code{\link[=augment.betareg]{augment.betareg()}} for
94 \code{\link[mfx:betamfx]{mfx::betamfx()}} objects.
95 }
96 \examples{
97 \dontshow{if (rlang::is_installed("mfx")) withAutoprint(\{ # examplesIf}
98
99 library(mfx)
100
101 # Simulate some data
102 set.seed(12345)
103 n <- 1000
104 x <- rnorm(n)
105
106 # Beta outcome
107 y <- rbeta(n, shape1 = plogis(1 + 0.5 * x), shape2 = (abs(0.2 * x)))
108 # Use Smithson and Verkuilen correction
109 y <- (y * (n - 1) + 0.5) / n
110
111 d <- data.frame(y, x)
112 mod_betamfx <- betamfx(y ~ x | x, data = d)
113
114 tidy(mod_betamfx, conf.int = TRUE)
115
116 # Compare with the naive model coefficients of the equivalent betareg call (not run)
117 # tidy(betamfx(y ~ x | x, data = d), conf.int = TRUE)
118
119 augment(mod_betamfx)
120 glance(mod_betamfx)
121 \dontshow{\}) # examplesIf}
122 }
123 \seealso{
124 \code{\link[=augment.betareg]{augment.betareg()}}, \code{\link[mfx:betamfx]{mfx::betamfx()}}
125
126 Other mfx tidiers:
127 \code{\link{augment.mfx}()},
128 \code{\link{glance.betamfx}()},
129 \code{\link{glance.mfx}()},
130 \code{\link{tidy.betamfx}()},
131 \code{\link{tidy.mfx}()}
132 }
133 \concept{mfx tidiers}
134 \value{
135 A \code{\link[tibble:tibble]{tibble::tibble()}} with columns:
136 \item{.cooksd}{Cooks distance.}
137 \item{.fitted}{Fitted or predicted value.}
138 \item{.resid}{The difference between observed and fitted values.}
139
140 }