dfCompile.lm: Creates an augmented data frame for lm and glm objects (for...

Description Usage Arguments Details Value Examples

View source: R/lm.R

Description

Similar to a extended version of broom::augment for lm and glm objects but with prepared for the diagnostic plots.

Usage

1
2

Arguments

x

lm or glm object

labels.id

labels for all observations

Details

original data frame

original data frame used to create lm or glm object

.index

row number 1 to nrow(original data)

.labels.id

provides labels or strings with same names as .index

.weights

weights from the model for each observation

.yhat

predicted values in y terms (not probablities, logit probabilities, log transformed, etc), as such, for glm this is different then fitted(x)

.resid

residuals between .yhat and y

.leverage

leverage for each observation, corresponds to the diagonal of the "hat" matrix (diag(X(X^TX)^{-1}X).

.cooksd

Cook's Distance, if lm, then we use the estimated standard deviation to calculate the value. Cook's Distance is the a "leave-one-out" based diagnostic for linear and generalized linear models discussed in Belsley, Kuh and Welsch (1980), Cook and Weisberg (1982), etc

.weighted.resid

residuals weighted by the .weights, (i.e. √{ .weights } \cdot .resid)

.std.resid

the standardized residuals using weighted.residuals and scaled by leverage and the estimated standard deviation, (i.e. \frac{\code{.weighted.resid}}{std.deviation * (1 - \code{.leverage})} )

.sqrt.abs.resid

the square-root of the absolute value of the standardized residuals

.pearson.resid

pearson residuals, residuals divided by the square root the variance

.std.pearson.resid

standardized pearson residuals, (i.e. \frac{\code{.pearson.resid}}{std.deviation * (1- \code{.leverage})})

.logit.leverage

logit of the leverage (i.e. log(\frac{x}{1-x}))

.ordering.resid

Index ordering of residuals (in absolute value)

.ordering.std.resid

Index ordering of standardized residuals (in absolute value)

.ordering.cooks

Index ordering of cook's distance

.non.extreme.leverage

logical vector if leverage != 1 (for extreme cases)

Value

augmented data.frame, see details for more information

Examples

1
2
3
4
5
library(tidyverse)

lm.object <- lm(Sepal.Length ~., data = iris)

dfCompile.lm(lm.object) %>% head

benjaminleroy/ggDiagnose documentation built on May 4, 2019, 3:07 a.m.