sigmaNN: Nearest Neighborhood Estimation of Conditional Standard...

View source: R/sd_fcns.R

sigmaNNR Documentation

Nearest Neighborhood Estimation of Conditional Standard Deviation

Description

Standard deviation is calculated by the formula (23) of Armstrong and Kolesár (2020)

Usage

sigmaNN(Xt, Xc, Yt, Yc, t.dir = c("left", "right"), N = 3)

Arguments

Xt

n_t by k design matrix for the treated units.

Xc

n_c by k design matrix for the control units.

Yt

outcome value for the treated group observations.

Yc

outcome value for the control group observations.

t.dir

treatment direction; t.dir = "left" if x < 0 is treated. Otherwise, t.dir = "right".

N

the number of nearest neighbors; default is N = 3.

Details

For now, this function works only for one-dimensional cases.

Value

a list containing conditional standard deviation estimates for treated observations (sigma.t) and control observations (sigma.c)

References

Armstrong, Timothy B., and Michal Kolesár. 2020. "Simple and honest confidence intervals in nonparametric regression." Quantitative Economics 11 (1): 1–39.

Examples

n <- 500
d <- 1
X <- matrix(rnorm(n * d), nrow = n, ncol = d)
tind <- X[, 1] < 0
Xt <- X[tind == 1, ,drop = FALSE]
Xc <- X[tind == 0, ,drop = FALSE]
sigma <- rnorm(n)^2 + 1
sigma_t <- sigma[tind == 1]
sigma_c <- sigma[tind == 0]
Yt = 1 + rnorm(length(sigma_t), mean = 0, sd = sigma_t)
Yc = rnorm(length(sigma_c), mean = 0, sd = sigma_c)
sigmaNN(Xt, Xc, Yt, Yc, t.dir = "left")

koohyun-kwon/rdadapt documentation built on May 8, 2022, 8:49 p.m.