| npreghat | R Documentation |
Constructs 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.
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,
...)
These arguments identify the fitted bandwidth object, formula/data interface, training data, and evaluation data.
bws |
An object of class |
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. |
These arguments control local-polynomial basis, degree, derivatives, leave-one-out behavior, and ridge stabilization.
basis |
Local polynomial basis: |
bernstein.basis |
Logical; use Bernstein basis for LP terms. |
degree |
Optional local polynomial degree vector override (LP path). |
deriv |
Convenience alias for |
leave.one.out |
Logical; if |
ridge |
Base diagonal regularization used when local systems are ill-conditioned. The ridge sequence starts at |
s |
Derivative multi-index over continuous predictors. |
This argument identifies a fitted hat-operator object supplied to an S3 method.
object |
An object returned by |
These arguments control whether the operator is returned as a matrix or applied directly.
output |
Either |
y |
Optional response vector or matrix for apply mode. |
Further arguments are passed to methods.
... |
Additional arguments passed to methods. |
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.
Either a hat matrix (class "npreghat") or the applied result
H^{(s)} y, depending on output.
## Not run:
data(cps71)
bw <- npregbw(xdat = cps71$age, ydat = cps71$logwage,
regtype = "ll", bandwidth.compute = FALSE, bws = 1.0)
H <- npreghat(bws = bw, txdat = data.frame(age = cps71$age))
H.fitted <- H
ghat <- npreg(bws = bw)
head(cbind(fitted(ghat), H.fitted), n = 2L)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.