weights_ES2012 {kader}R Documentation

Weights WniW_{ni} of Eichner & Stute (2012)

Description

Function, vectorized in its first argument sigma, to compute the “updated” weights WniW_{ni} in eq. (2.1) of Eichner & Stute (2012) for the kernel adjusted regression estimator.

Usage

weights_ES2012(sigma, xXh, thetaXh, K, h)

Arguments

sigma

Numeric vector (σ1,,σs)(\sigma_1, \ldots, \sigma_s) with s1s \ge 1 with values of the scale parameter σ\sigma.

xXh

Numeric vector expecting the pre-computed h-scaled differences (xX1)/h(x - X_1)/h, ..., (xXn)/h(x - X_n)/h where xx is the single (!) location for which the weights are to be computed, the XiX_i's are the data values, and hh is the numeric bandwidth scalar.

thetaXh

Numeric vector expecting the pre-computed h-scaled differences (θX1)/h(\theta - X_1)/h, ..., (θXn)/h(\theta - X_n)/h where θ\theta is the numeric scalar location parameter, and the XiX_i's and hh are as in xXh.

K

A kernel function (with vectorized in- & output) to be used for the estimator.

h

Numeric scalar for bandwidth hh (as “contained” in thetaXh and xXh).

Details

Note that it is not immediately obvious that WniW_{ni} in eq. (2.1) of Eichner & Stute (2012) is a function of σ\sigma. In fact, Wni=Wni(x;h,θ,σ)W_{ni} = W_{ni}(x; h, \theta, \sigma) as can be seen on p. 2542 ibid. The computational version implemented here, however, is given in (15.19) of Eichner (2017). Pre-computed (xXi)/h(x - X_i)/h and (θXi)/h(\theta - X_i)/h, i=1,,ni = 1, \ldots, n are expected for efficiency reasons (and are currently prepared in function kare).

Value

If length(sigma) > 1 a numeric matrix of the dimension length(sigma) by length(xXh) with elements (Wni(x;h,θ,σr))(W_{ni}(x; h, \theta, \sigma_r)) for r=1,,r = 1, \ldots, length(sigma) and i=1,,i = 1, \ldots, length(xXh); otherwise a numeric vector of the same length as xXh.

References

Eichner & Stute (2012) and Eichner (2017): see kader.

See Also

bias_ES2012 and var_ES2012 which both call this function, and kare which currently does the pre-computing.

Examples

require(stats)

 # Regression function:
m <- function(x, x1 = 0, x2 = 8, a = 0.01, b = 0) {
 a * (x - x1) * (x - x2)^3 + b
}
 # Note: For a few details on m() see examples in ?nadwat.

n <- 100       # Sample size.
set.seed(42)   # To guarantee reproducibility.
X <- runif(n, min = -3, max = 15)      # X_1, ..., X_n   # Design.
Y <- m(X) + rnorm(length(X), sd = 5)   # Y_1, ..., Y_n   # Response.

h <- n^(-1/5)
Sigma <- seq(0.01, 10, length = 51)   # sigma-grid for minimization.
x0 <- 5   # Location at which the estimator of m should be computed.

 # Weights (W_{ni}(x; \sigma_r))_{1<=r<=length(Sigma), 1<=i<=n} for
 # Var_n(sigma) and Bias_n(sigma) each at x0 on the sigma-grid:
weights_ES2012(sigma = Sigma, xXh = (x0 - X) / h,
  thetaXh = (mean(X) - X) / h, K = dnorm, h = h)


[Package kader version 0.0.8 Index]