fitres: Create matrix of model fit, residuals, and residuals...

View source: R/fitres.R

fitresR Documentation

Create matrix of model fit, residuals, and residuals proportions.

Description

Create matrix of model fit, residuals, and residuals proportions.

Usage

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

Arguments

model

An lm, glm, or nls(model = TRUE) object.

data

Dataframe. If defined, column-wise binds predictions/residuals to dataframe.

fit_type

String. Prediction type. See ?predict for details.

residual_type

String. See ?resid for details.

Details

fitres() creates a matrix of the fitted values, residuals, and residuals as a proportion (percent) of the actual dependent variable values based on an OLS model or GLM. If the data input is defined, then said matrix is column-wise binded to the specified dataset.

Value

A matrix OR dataframe (if data is not null).

Warning

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

See Also

https://github.com/robertschnitman/diagnoser

Examples

# OLS case
model.lm <- lm(data = mtcars, formula = mpg ~ wt + gear)
fitres(model.lm, fit_type = 'response')
fitres(model.lm, data = mtcars)

# NLS case
model.nls <- nls(Ozone ~ theta0 + Temp^theta1, airquality, model = TRUE)
fitres(model.nls)


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