Skip to contents

Add residuals from a model to a data frame

Usage

add_residuals(data, model, value = ".residual", ...)

# S3 method for class 'gamm4'
add_residuals(data, model, ...)

# S3 method for class 'scam'
add_residuals(data, model, ...)

Arguments

data

a data frame containing values for the variables used to fit the model, in fitting order. Supply either the retained fitting rows or, for stats::na.exclude(), the original fitting rows after any subset. This does not compute residuals for new or reordered observations.

model

a fitted model for which a stats::residuals() method is available. S3 method dispatch is performed on the model argument.

value

character; the name of the variable in which model residuals will be stored.

...

additional arguments passed to methods.

Value

A data frame (tibble) formed from data and residuals from model.

See also