Skip to contents

Computes effective degrees of freedom, generalized cross-validation (GCV), and analytic leave-one-out residual diagnostics from a MALPS smoother matrix. These diagnostics are exact for fixed-support, fixed-weight linear MALPS fits. For cross-validated fits they are conditional on the selected support profile. Robust fits are rejected by default for the same reason described in smoother.matrix.

Usage

malps.gcv(
  object,
  y = NULL,
  smoother.matrix = NULL,
  include.loocv = TRUE,
  max.n = 1000L,
  allow.robust = FALSE,
  ...
)

Arguments

object

A "malps" object from fit.malps or refit.

y

Optional response vector. Defaults to object$y.

smoother.matrix

Optional precomputed matrix from smoother.matrix.

include.loocv

Logical; include analytic leave-one-out residuals and mean squared error.

max.n

Maximum dense smoother size passed to smoother.matrix when smoother.matrix = NULL.

allow.robust

Logical; passed to smoother.matrix.

...

Reserved for future extensions.

Value

A list with residual, fitted-value, EDF, GCV, and optional LOOCV diagnostics.

Details

The GCV score is computed as $$ \mathrm{GCV} = \frac{n^{-1}\|y - S y\|_2^2} {(1 - \operatorname{tr}(S)/n)^2}. $$ The analytic leave-one-out residuals are computed as $$ e_i^{\mathrm{loo}} = \frac{y_i - \hat y_i}{1 - S_{ii}}. $$

Examples

X <- matrix(seq(0, 1, length.out = 20), ncol = 1)
fit <- fit.malps(X, X[, 1]^2, degree = 1L,
                 support.type = "knn", support.size = 8L)
malps.gcv(fit)$gcv
#> [1] 3.90985e-05