Debian Codegraph @

man/augment.robustbase.glmrob.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/robustbase-glmrob.R
3 \name{augment.glmrob}
4 \alias{augment.glmrob}
5 \title{Augment data with information from a(n) glmrob object}
6 \usage{
7 \method{augment}{glmrob}(
8 x,
9 data = model.frame(x),
10 newdata = NULL,
11 type.predict = c("link", "response"),
12 type.residuals = c("deviance", "pearson"),
13 se_fit = FALSE,
14 ...
15 )
16 }
17 \arguments{
18 \item{x}{A \code{glmrob} object returned from \code{\link[robustbase:glmrob]{robustbase::glmrob()}}.}
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
34 to the \code{type} argument of the \code{\link[stats:predict]{stats::predict()}} generic. Allowed arguments
35 vary with model class, so be sure to read the \code{predict.my_class}
36 documentation.}
37
38 \item{type.residuals}{Character indicating type of residuals to use. Passed
39 to the \code{type} argument of \code{\link[stats:residuals]{stats::residuals()}} generic. Allowed arguments
40 vary with model class, so be sure to read the \code{residuals.my_class}
41 documentation.}
42
43 \item{se_fit}{Logical indicating whether or not a \code{.se.fit} column should be
44 added to the augmented output. For some models, this calculation can be
45 somewhat time-consuming. Defaults to \code{FALSE}.}
46
47 \item{...}{Additional arguments. Not used. Needed to match generic
48 signature only. \strong{Cautionary note:} Misspelled arguments will be
49 absorbed in \code{...}, where they will be ignored. If the misspelled
50 argument has a default value, the default value will be used.
51 For example, if you pass \code{conf.lvel = 0.9}, all computation will
52 proceed using \code{conf.level = 0.95}. Two exceptions here are:
53 \itemize{
54 \item \code{tidy()} methods will warn when supplied an \code{exponentiate} argument if
55 it will be ignored.
56 \item \code{augment()} methods will warn when supplied a \code{newdata} argument if it
57 will be ignored.
58 }}
59 }
60 \description{
61 Augment accepts a model object and a dataset and adds
62 information about each observation in the dataset. Most commonly, this
63 includes predicted values in the \code{.fitted} column, residuals in the
64 \code{.resid} column, and standard errors for the fitted values in a \code{.se.fit}
65 column. New columns always begin with a \code{.} prefix to avoid overwriting
66 columns in the original dataset.
67
68 Users may pass data to augment via either the \code{data} argument or the
69 \code{newdata} argument. If the user passes data to the \code{data} argument,
70 it \strong{must} be exactly the data that was used to fit the model
71 object. Pass datasets to \code{newdata} to augment data that was not used
72 during model fitting. This still requires that at least all predictor
73 variable columns used to fit the model are present. If the original outcome
74 variable used to fit the model is not included in \code{newdata}, then no
75 \code{.resid} column will be included in the output.
76
77 Augment will often behave differently depending on whether \code{data} or
78 \code{newdata} is given. This is because there is often information
79 associated with training observations (such as influences or related)
80 measures that is not meaningfully defined for new observations.
81
82 For convenience, many augment methods provide default \code{data} arguments,
83 so that \code{augment(fit)} will return the augmented training data. In these
84 cases, augment tries to reconstruct the original data based on the model
85 object with varying degrees of success.
86
87 The augmented dataset is always returned as a \link[tibble:tibble]{tibble::tibble} with the
88 \strong{same number of rows} as the passed dataset. This means that the passed
89 data must be coercible to a tibble. If a predictor enters the model as part
90 of a matrix of covariates, such as when the model formula uses
91 \code{\link[splines:ns]{splines::ns()}}, \code{\link[stats:poly]{stats::poly()}}, or \code{\link[survival:Surv]{survival::Surv()}}, it is represented
92 as a matrix column.
93
94 We are in the process of defining behaviors for models fit with various
95 \code{na.action} arguments, but make no guarantees about behavior when data is
96 missing at this time.
97 }
98 \details{
99 For tidiers for robust models from the \pkg{MASS} package see
100 \code{\link[=tidy.rlm]{tidy.rlm()}}.
101 }
102 \examples{
103
104 if (requireNamespace("robustbase", quietly = TRUE)) {
105 # load libraries for models and data
106 library(robustbase)
107
108 data(coleman)
109 set.seed(0)
110
111 m <- lmrob(Y ~ ., data = coleman)
112 tidy(m)
113 augment(m)
114 glance(m)
115
116 data(carrots)
117
118 Rfit <- glmrob(cbind(success, total - success) ~ logdose + block,
119 family = binomial, data = carrots, method = "Mqle",
120 control = glmrobMqle.control(tcc = 1.2)
121 )
122
123 tidy(Rfit)
124 augment(Rfit)
125 }
126 }
127 \seealso{
128 \code{\link[robustbase:glmrob]{robustbase::glmrob()}}
129
130 Other robustbase tidiers:
131 \code{\link{augment.lmrob}()},
132 \code{\link{glance.lmrob}()},
133 \code{\link{tidy.glmrob}()},
134 \code{\link{tidy.lmrob}()}
135 }
136 \concept{robustbase tidiers}
137 \value{
138 A \code{\link[tibble:tibble]{tibble::tibble()}} with columns:
139 \item{.fitted}{Fitted or predicted value.}
140 \item{.resid}{The difference between observed and fitted values.}
141
142 }