fitresdf: Merge fitted values and residuals to the original data frame.

View source: R/fitresdf.R

fitresdfR Documentation

Merge fitted values and residuals to the original data frame.

Description

Merge fitted values and residuals to the original data frame.

Usage

fitresdf(model, data = NULL, fit_type = 'response', residual_type = 'response')

Arguments

model

An lm, glm, or nls object.

data

A data frame. If unspecified, then the original data is used (i.e. model.frame(model)).

fit_type

String. Default is "response". Type of fitted values to use based on options in predict().

residual_type

String. Default is "response". Type of residuals values to use based on options in resid().

Value

A data frame. "residual_margin" is the residuals as a proportion of the actual dependent variable values.

Warning

NLS objects will only work if "model = TRUE" is specified in the original NLS function.

See Also

https://github.com/robertschnitman/diagnoser

Examples

model.lm <- lm(data = mtcars, formula = mpg ~ wt + gear)
fitresdf(data = mtcars, model = model.lm)

# A warning message displays when there are missing values in the dataset.
df       <- mtcars
df[1,1]  <- NA
model.lm <- lm(data = mtcars, formula = mpg ~ wt + gear)
fitresdf(model.lm, data = df)


robertschnitman/schnitr documentation built on Aug. 18, 2022, 8:39 p.m.