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