Unconditional Density Hat Operator
npudenshat.RdConstructs the unconditional density hat operator associated with
npudens bandwidth objects. The returned operator maps a
right-hand side y to \(H y\); with y = 1 this reproduces the
fitted unconditional density.
Arguments
Data, Bandwidth Inputs And Formula Interface
These arguments identify the fitted bandwidth object, training data, and evaluation data.
Details
For output = "matrix", the return value is a matrix with class
c("npudenshat", "matrix") and attributes storing the bandwidth object,
training data, evaluation data, and call metadata.
For output = "apply", the function returns H y directly. Matrix
right-hand sides are applied column-wise.
This helper is intended for object-fed repeated evaluation once a bandwidth object has already been constructed. It does not perform bandwidth selection.
Examples
if (FALSE) { # \dontrun{
data(cps71)
tx <- data.frame(age = cps71$age)
bw <- npudensbw(dat = tx, bwtype = "fixed",
bandwidth.compute = FALSE, bws = 1.0)
H <- npudenshat(bws = bw, tdat = tx)
dens.hat <- npudenshat(bws = bw, tdat = tx,
y = rep(1, nrow(tx)),
output = "apply")
dens.core <- fitted(npudens(bws = bw, tdat = tx))
head(cbind(dens.core, dens.hat), n = 2L)
} # }