est_cqr: Function to compute the fitted values and residuals

Description Usage Arguments Value Examples

View source: R/RcppExports.R

Description

This function computes the fitted values and residuals in a local composite quantile regression.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
est_cqr(
  x_vec,
  y,
  kernID,
  tau,
  h,
  p = 1L,
  maxit = 100L,
  tol = 1e-04,
  parallel = 0L,
  grainsize = 1L
)

Arguments

x_vec

A vector of covariates.

y

a vector of dependent variable, the treatment outcome variable in the case of regression discontinuity.

kernID

The kernel id that includes

  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.

tau

A vector of quantile positions. They are obtained by tau = (1:q)/(q+1).

h

A scalar bandwidth.

p

The polynomial degree. Defaults to 1.

maxit

Maximum number of iterations in the MM algorithm. Defaults to 100.

tol

The convergence criterion. Defaults to 1.0e-4.

parallel

Set it to 1 if using parallel computing. Default is 1.

grainsize

The minimum chunk size for parallelization. Defaults to 1.

Value

est_cqr returns a list with the following components:

y_hat

The fitted value at each point of the input vector x_vec.

u_hat

The residual vector.

sig_hat

The estimated standard deviation at each point of the input vector x_vec.

e_hat

The scaled residual vector. It is the residual vector divided by the sig_hat vector.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Use the Head Start data as an example.
data(headstart)
data_n = subset(headstart, headstart$poverty < 0)
q      = 5
tau    = (1:q) / (q + 1)
est_cqr(x_vec  = data_n$poverty,
        y      = data_n$mortality,
        kernID = 2,
        tau    = tau,
        h      = 4.0,
        p      = 1) 

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