Skip to contents

Hat-matrix diagonal, Cook's distance (stats::cooks.distance is preferred for fitted lms; this function works straight from X, y, and a fitted y_hat), DFFITS, DFBETAS, and COVRATIO.

Usage

compute_influence(y, X, y_hat = NULL)

Arguments

y

Response vector.

X

Design matrix.

y_hat

Optional fitted values (OLS is used if NULL).

Value

A morie_influence_diagnostics list.

Examples

set.seed(4)
X <- cbind(1, matrix(rnorm(40 * 2), 40, 2))
y <- drop(X %*% c(0.5, 1, -0.5) + rnorm(40, sd = 0.5))
r <- compute_influence(y, X)
head(r$cooks_distance)
#> [1] 4.800810e-02 8.583586e-05 2.476192e-02 6.849958e-02 3.980990e-02
#> [6] 2.484932e-02
r$influential_indices
#> [1] 10 17 24 39