% Generated by roxygen2: do not edit by hand % Please edit documentation in R/fixest.R \name{augment.fixest} \alias{augment.fixest} \title{Augment data with information from a(n) fixest object} \usage{ \method{augment}{fixest}( x, data = NULL, newdata = NULL, type.predict = c("link", "response"), type.residuals = c("response", "deviance", "pearson", "working"), ... ) } \arguments{ \item{x}{A \code{fixest} object returned from any of the \code{fixest} estimators} \item{data}{A \link[base:data.frame]{base::data.frame} or \code{\link[tibble:tibble]{tibble::tibble()}} containing the original data that was used to produce the object \code{x}. Defaults to \code{stats::model.frame(x)} so that \code{augment(my_fit)} returns the augmented original data. \strong{Do not} pass new data to the \code{data} argument. Augment will report information such as influence and cooks distance for data passed to the \code{data} argument. These measures are only defined for the original training data.} \item{newdata}{A \code{\link[base:data.frame]{base::data.frame()}} or \code{\link[tibble:tibble]{tibble::tibble()}} containing all the original predictors used to create \code{x}. Defaults to \code{NULL}, indicating that nothing has been passed to \code{newdata}. If \code{newdata} is specified, the \code{data} argument will be ignored.} \item{type.predict}{Passed to \code{\link[fixest:predict.fixest]{predict.fixest}} \code{type} argument. Defaults to \code{"link"} (like \code{predict.glm}).} \item{type.residuals}{Passed to \code{\link[fixest:resid.fixest]{predict.fixest}} \code{type} argument. Defaults to \code{"response"} (like \code{residuals.lm}, but unlike \code{residuals.glm}).} \item{...}{Additional arguments passed to \code{summary} and \code{confint}. Important arguments are \code{se} and \code{cluster}. Other arguments are \code{dof}, \code{exact_dof}, \code{forceCovariance}, and \code{keepBounded}. See \code{\link[fixest:summary.fixest]{summary.fixest}}.} } \description{ Augment accepts a model object and a dataset and adds information about each observation in the dataset. Most commonly, this includes predicted values in the \code{.fitted} column, residuals in the \code{.resid} column, and standard errors for the fitted values in a \code{.se.fit} column. New columns always begin with a \code{.} prefix to avoid overwriting columns in the original dataset. Users may pass data to augment via either the \code{data} argument or the \code{newdata} argument. If the user passes data to the \code{data} argument, it \strong{must} be exactly the data that was used to fit the model object. Pass datasets to \code{newdata} to augment data that was not used during model fitting. This still requires that at least all predictor variable columns used to fit the model are present. If the original outcome variable used to fit the model is not included in \code{newdata}, then no \code{.resid} column will be included in the output. Augment will often behave differently depending on whether \code{data} or \code{newdata} is given. This is because there is often information associated with training observations (such as influences or related) measures that is not meaningfully defined for new observations. For convenience, many augment methods provide default \code{data} arguments, so that \code{augment(fit)} will return the augmented training data. In these cases, augment tries to reconstruct the original data based on the model object with varying degrees of success. The augmented dataset is always returned as a \link[tibble:tibble]{tibble::tibble} with the \strong{same number of rows} as the passed dataset. This means that the passed data must be coercible to a tibble. If a predictor enters the model as part of a matrix of covariates, such as when the model formula uses \code{\link[splines:ns]{splines::ns()}}, \code{\link[stats:poly]{stats::poly()}}, or \code{\link[survival:Surv]{survival::Surv()}}, it is represented as a matrix column. We are in the process of defining behaviors for models fit with various \code{na.action} arguments, but make no guarantees about behavior when data is missing at this time. } \note{ Important note: \code{fixest} models do not include a copy of the input data, so you must provide it manually. augment.fixest only works for \code{\link[fixest:feols]{fixest::feols()}}, \code{\link[fixest:feglm]{fixest::feglm()}}, and \code{\link[fixest:femlm]{fixest::femlm()}} models. It does not work with results from \code{\link[fixest:femlm]{fixest::fenegbin()}}, \code{\link[fixest:feNmlm]{fixest::feNmlm()}}, or \code{\link[fixest:feglm]{fixest::fepois()}}. } \examples{ \dontshow{if (rlang::is_installed("fixest") & !broom:::is_cran_check()) withAutoprint(\{ # examplesIf} # load libraries for models and data library(fixest) gravity <- feols( log(Euros) ~ log(dist_km) | Origin + Destination + Product + Year, trade ) tidy(gravity) glance(gravity) augment(gravity, trade) # to get robust or clustered SEs, users can either: # 1) specify the arguments directly in the `tidy()` call tidy(gravity, conf.int = TRUE, cluster = c("Product", "Year")) tidy(gravity, conf.int = TRUE, se = "threeway") # 2) or, feed tidy() a summary.fixest object that has already accepted # these arguments gravity_summ <- summary(gravity, cluster = c("Product", "Year")) tidy(gravity_summ, conf.int = TRUE) # approach (1) is preferred. \dontshow{\}) # examplesIf} } \seealso{ \code{\link[=augment]{augment()}}, \code{\link[fixest:feglm]{fixest::feglm()}}, \code{\link[fixest:femlm]{fixest::femlm()}}, \code{\link[fixest:feols]{fixest::feols()}} Other fixest tidiers: \code{\link{tidy.fixest}()} } \concept{fixest tidiers} \value{ A \code{\link[tibble:tibble]{tibble::tibble()}} with columns: \item{.fitted}{Fitted or predicted value.} \item{.resid}{The difference between observed and fitted values.} }