h_cqr: Bandwidth computation

Description Usage Arguments Value References Examples

View source: R/h_cqr.R

Description

This function computes several bandwidths for local composite quantile estimation on the boundary.

Usage

1
2
h_cqr(dat, kernID = 0, left = TRUE, maxit = 20, tol = 1.0e-3, para = 1,
 grainsize = 1, llr.residuals = TRUE, ls.derivative = TRUE)

Arguments

dat

A list with the following components:

y

A vector treatment outcomes. In a fuzzy RD, this variable can also be a vector of treatment assignment variables.

x

A vector of covariates.

q

Number of quantiles to be used in estimation. Defaults to 5. It needs to be an odd number.

h

A scalar bandwidth.

tau

Quantile positions that correspond to the q quantiles. They are obtained by tau = (1:q)/(q+1).

p

The degree of polynomial in LCQR estimation. Set it to 1 when estimating the residuals.

n_all

Total number of observations in the data set.

f0_hat

Estimated density of the covariate at x = 0.

fd1

Estimated first derivative of the density of the covariate at x = 0.

kernID

Kernel id number. Defaults to 0.

  1. kernID = 0: triangular kernel.

  2. kernID = 1: biweight kernel.

  3. kernID = 2: Epanechnikov kernel.

  4. kernID = 3: Gaussian kernel.

  5. kernID = 4: tricube kernel.

  6. kernID = 5: triweight kernel.

  7. kernID = 6: uniform kernel.

left

A logical variable that takes the value TRUE for data to the left of (below) the cutoff. Defaults to TRUE.

maxit

Maximum iteration number in the MM algorithm for quantile estimation. Defaults to 20.

tol

Convergence criterion in the MM algorithm. Defaults to 1.0e-3.

para

A 0/1 variable specifying whether to use parallel computing. Defaults to 1.

grainsize

Minimum chunk size for parallelization. Defaults to 1.

llr.residuals

Whether to use residuals from the local linear regression as the input to compute the LCQR standard errors and the corresponding bandwidths. Defaults to TRUE. If this option is set to TRUE, the treatment effect estimate and the bias-correction is still done in LCQR. We use the same kernel function used in LCQR in the local linear regression to obtain the residuals and use them to compute the unadjusted and adjusted asymptotic standard errors and the bandwidths. This option will improve the speed. One can use this option to get a quick estimate of the standard errors when the sample size is large. To use residuals from the LCQR method, set llr.residuals = FALSE.

ls.derivative

Whether to use a global quartic and quintic polynomial to estimate the second and third derivatives of the conditional mean function. Defaults to TRUE.

Value

h_cqr returns a list with the following components:

h_mse

MSE-optimal bandwidth on the boundary. This bandwidth has order O(n^{-1/5}), where n is the sample size for data either below or above the cutoff.

h_opt

Bandwidth based on the adjusted MSE on the boundary. See Huang and Zhan (2020) for details about the adjusted MSE. This bandwidth has order O(n^{-1/7}), where n is the sample size for data either below or above the cutoff.

h_rot

A transform of the rule-of-thumb bandwidth for the local linear regression. The rule-of-thumb bandwidth is close to the Mean Integrated Squared Error optimal (MISE-optimal) bandwidth in a local linear regression. This bandwidth has order O(n^{-1/5}), where n is the sample size for data either below or above the cutoff.

References

Huang and Zhan (2021) "Local Composite Quantile Regression for Regression Discontinuity," working paper.

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
## Not run: 
# Use the headstart data.
data(headstart)
data_n = subset(headstart, headstart$poverty < 0)
p = 1
q = 5
tau = (1:q) / (q + 1)
x = headstart$poverty
h_d0   = ks::hns(x, deriv.order = 0)
f0_hat = ks::kdde(x, h = h_d0, deriv.order = 0, eval.points = c(0))$estimate
h_d1   = ks::hns(x, deriv.order = 1)
fd1    = ks::kdde(x, h = h_d1, deriv.order = 1, eval.points = c(0))$estimate

# Set up the list to be passed to the h_cqr function.
# Supply a bandwidth that is equal to 3.5.
dat_n = list("x"      = data_n$poverty,
             "y"      = data_n$mortality,
             "q"      = q,
             "h"      = 3.5,
             "tau"    = tau,
             "p"      = p,
             "n_all"  = n_all,
             "f0_hat" = f0_hat,
             "fd1"    = fd1)

# Use the residuals from local linear regression for a quick try.
h_cqr(dat = dat_n, llr.residuals = TRUE)

## End(Not run)

xhuang20/rdcqr documentation built on July 1, 2021, 5:22 a.m.