Nonparametric Regression Hat Operator
npreghat.RdConstructs nonparametric regression hat operators for npreg-compatible
bandwidth objects. The returned operator \(H^{(s)}\) maps responses to fitted
values or derivative estimates via \(H^{(s)} y\).
Usage
npreghat(bws, ...)
# S3 method for class 'formula'
npreghat(bws,
data = NULL,
newdata = NULL,
...)
# S3 method for class 'rbandwidth'
npreghat(bws,
txdat = stop("training data 'txdat' missing"),
exdat, y = NULL,
output = c("matrix", "apply"),
basis = NULL,
bernstein.basis = NULL,
degree = NULL,
deriv = NULL,
leave.one.out = FALSE,
ridge = 0,
s = NULL,
...)
# S3 method for class 'npregression'
npreghat(bws,
txdat,
y,
...)
# S3 method for class 'npreghat'
predict(object,
newdata = NULL, y = NULL,
output = c("matrix", "apply"),
s = attr(object, "s"),
leave.one.out = attr(object, "leave.one.out"),
deriv = NULL,
...)Arguments
Data, Bandwidth Inputs And Formula Interface
These arguments identify the fitted bandwidth object, formula/data interface, training data, and evaluation data.
- bws
An object of class
rbandwidthornpregression.- data
A data frame used with the formula interface.
- exdat
Optional evaluation predictors.
- newdata
Optional evaluation data for formula and predict methods.
- txdat
Training predictors.
Local-Polynomial Controls
These arguments control local-polynomial basis, degree, derivatives, leave-one-out behavior, and ridge stabilization.
- basis
Local polynomial basis:
"glp","additive", or"tensor".- bernstein.basis
Logical; use Bernstein basis for LP terms.
- degree
Optional local polynomial degree vector override (LP path).
- deriv
Convenience alias for
s.- leave.one.out
Logical; if
TRUE, compute in-sample leave-one-out hat weights. This cannot be combined with explicitexdat/newdata.- ridge
Base diagonal regularization used when local systems are ill-conditioned. The ridge sequence starts at
0(no regularization) and then increments by1/n.trainas needed for stable solves.- s
Derivative multi-index over continuous predictors.
Operator Output
These arguments control whether the operator is returned as a matrix or applied directly.
Details
For output = "matrix", the return value is a matrix with class
c("npreghat", "matrix") so it can be used directly in matrix products,
e.g. H %*% y. Attributes on the matrix store metadata used by
predict.npreghat.
For output = "apply", the function returns H^{(s)} y directly and
accepts matrix right-hand sides for one-shot bootstrap-style calculations.