Returns raw / standardised / externally studentised residuals along with normality, heteroskedasticity (Breusch-Pagan), and autocorrelation (Durbin-Watson) tests. Optionally also returns deviance and Pearson residuals for logistic / Poisson GLMs.
Examples
set.seed(1)
X <- cbind(1, matrix(rnorm(100 * 2), 100, 2))
y <- drop(X %*% c(0.5, 1, -0.5) + rnorm(100, sd = 0.5))
y_hat <- drop(X %*% solve(crossprod(X), crossprod(X, y)))
r <- compute_residuals(y, y_hat, X)
head(r$standardized_residuals)
#> [1] 0.3525897 1.6008833 1.4886868 -0.3727842 -2.2715227 2.5498705
