Extract the Linear-Smoother Matrix of a Fixed-Configuration LPS Fit
Source:R/lps_uncertainty.R
smoother.matrix.lps.RdFor a fixed configuration (singleton support.grid, degree.grid, and
kernel.grid, with an explicit numeric chart dimension) the LPS fitted
vector is linear in the response: fitted = S %*% y with S depending on
X, the kernel weights, and the configuration, but not on y. This
function reconstructs S analytically, one evaluation row at a time, by
rebuilding each local fit's support, kernel weights, local chart, and
design through the same internal routines fit.lps() used, and reading off
the influence row of the local weighted least-squares solve.
Usage
# S3 method for class 'lps'
smoother.matrix(object, check.tol = 1e-10, ...)Arguments
- object
A fitted
"lps"object fromfit.lps()at a fixed configuration (see Details).- check.tol
Positive scalar: maximum allowed absolute discrepancy of the self-guard identity
S %*% y == fitted.values.raw. Default1e-10, the program's algebraic tolerance.- ...
Additional arguments are not currently supported.
Value
A numeric matrix S with nrow(object$X.eval) rows and
nrow(object$X) columns: row i holds the weights through which the
training responses enter the prediction at evaluation point i.
Details
The extraction refuses configurations where the linearity premise fails or
is unsupported: it requires outcome.family = "gaussian", the R backend,
design.basis = "orthogonal.polynomial.drop", singleton grids (no
data-driven selection: the CV-selected pipeline is not a linear
smoother), and coordinate.method = "coordinates" or "local.pca" with an
explicit numeric chart.dim (never "auto" or "local.auto").
Self-guard: before returning, the function verifies
max(abs(S %*% y - fitted.values.raw)) <= check.tol against the fit it was
given (and that the NA patterns agree), so any divergence between the
reconstruction and the estimator is a hard error, never a silent drift.
Local fits that fell back are represented honestly: a weighted-mean
fallback (unstable.action = "mean") contributes its exact linear row
w / sum(w); an unstable.action = "na" non-fit contributes an all-NA
row.
See also
lps.pointwise.band() for pointwise variances and confidence
bands derived from S.
smoother.matrix for supported fitted objects and migration.
Examples
set.seed(1)
n <- 30
X <- matrix(runif(2 * n, -1, 1), ncol = 2)
y <- sin(pi * X[, 1]) + 0.1 * rnorm(n)
fit <- fit.lps(X, y, foldid = rep(1:2, length.out = n),
support.grid = 12L, degree.grid = 1L,
kernel.grid = "tricube", backend = "R",
design.basis = "orthogonal.polynomial.drop",
ridge.multiplier.grid = 0, ridge.condition.max = Inf,
unstable.action = "na")
S <- smoother.matrix(fit)
max(abs(S %*% y - fit$fitted.values)) # ~1e-15: the linear identity
#> [1] 4.440892e-16
sum(diag(S)) # effective degrees of freedom
#> [1] 10.75683