Computes exact leave-one-out (LOO) prediction errors by refitting the
model n times, each time dropping one observation. Uses
qr_downdate internally to avoid recomputing the full
factorization from scratch.
Arguments
- X
Numeric matrix or
adgeMatrixof predictors, shape[n, p]. No intercept column is added automatically.- y
Numeric vector or single-column matrix of responses, length
n.- method
Character string passed to
am_qrcontrolling the QR algorithm. Currently only"qr"is supported.- ...
Additional arguments forwarded to
am_qr.
Value
A named list with two elements:
- residuals
Numeric vector of length
n: LOO prediction errors \(y_i - \hat{y}_i^{(-i)}\).- mse
Scalar mean squared LOO error.
Examples
if (FALSE) { # \dontrun{
X <- adgeMatrix(matrix(rnorm(50), nrow = 10))
y <- rnorm(10)
cv <- lm_loo_cv(X, y)
cv$mse
} # }