var_ES2012: Variance Estimator of Eichner & Stute (2012)

Description Usage Arguments Details Value References See Also Examples

Description

Variance estimator Var_n(σ), vectorized in σ, on p. 2540 of Eichner & Stute (2012).

Usage

1
var_ES2012(sigma, h, xXh, thetaXh, K, YmDiff2)

Arguments

sigma

Numeric vector (σ_1, …, σ_s) with s ≥ 1 with values of the scale parameter σ.

h

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

xXh

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

thetaXh

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

K

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

YmDiff2

Numeric vector of the pre-computed squared differences (Y_1 - m_n(x))^2, ..., (Y_n - m_n(x))^2.

Details

The formula can also be found in eq. (15.22) of Eichner (2017). Pre-computed (x - X_i)/h, (θ - X_i)/h, and (Y_i - m_n(x))^2 are expected for efficiency reasons (and are currently prepared in function kare).

Value

A numeric vector of the length of sigma.

References

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

See Also

kare which currently does the pre-computing.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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.

mnX  <- nadwat(x = X, dataX = X, dataY = Y, K = dnorm, h = h) # m_n(X_i)
                                                     # for i = 1, ..., n.
 # Estimator of Var_x0(sigma) on the sigma-grid:
(Vn <- var_ES2012(sigma = Sigma, h = h, xXh = (x0 - X) / h,
  thetaXh = (mean(X) - X) / h, K = dnorm, YmDiff2 = (Y - mnX)^2))

## Not run: 
 # Visualizing the estimator of Var_n(sigma) at x0 on the sigma-grid:
plot(Sigma, Vn, type = "o", xlab = expression(sigma), ylab = "",
  main = bquote(widehat("Var")[n](sigma)~~"at"~~x==.(x0)))

## End(Not run)

GerritEichner/kader documentation built on May 10, 2019, 1:14 p.m.