| npiv_choose_J | R Documentation | 
npiv_choose_J implements the data-driven choice of sieve dimension developed in Chen, Christensen, and Kankanala (2024) for nonparametric instrumental variables estimation using a B-spline sieve. It applies to nonparametric regression as a special case.
npiv_choose_J(Y, 
              X,
              W,
              X.grid = NULL,
              J.x.degree = 3,
              K.w.degree = 4,
              K.w.smooth = 2,
              knots = c("uniform", "quantiles"),
              basis = c("tensor", "additive", "glp"),
              X.min = NULL,
              X.max = NULL,
              W.min = NULL,
              W.max = NULL,
              grid.num = 50,
              boot.num = 99,
              check.is.fullrank = FALSE,
              progress = TRUE)
Y | 
 dependent variable vector.  | 
X | 
 matrix of endogenous regressors.  | 
W | 
 matrix of instrumental variables. Set   | 
X.grid | 
 vector of grid point(s). Default uses 50 equally spaced points over the support of each   | 
J.x.degree | 
 B-spline degree (integer or vector of integers of length   | 
K.w.degree | 
 B-spline degree (integer or vector of integers of lenth   | 
K.w.smooth | 
 non-negative integer. Basis for the nonparametric first-stage uses   | 
knots | 
 knots type, a character string. Options are: 
 
  | 
basis | 
 basis type (if  
 
 
  | 
X.min | 
 lower bound on the support of each   | 
X.max | 
 upper bound on the support of each   | 
W.min | 
 lower bound on the support of each   | 
W.max | 
 upper bound on the support of each   | 
grid.num | 
 number of grid points for each   | 
boot.num | 
 number of bootstrap replications.  | 
check.is.fullrank | 
 check that   | 
progress | 
 whether to display progress bar or not. Default is   | 
J.hat.max | 
 largest element of candidate set of sieve dimensions searched over.  | 
J.hat.n | 
 second largest element of candidate set of sieve dimensions searched over.  | 
J.hat | 
 bootstrap-based Lepski choice of sieve dimension.  | 
J.tilde | 
 data-driven choice of sieve dimension using the method of Chen, Christensen, and Kankanala (2024). Minimum of   | 
J.x.seg | 
 data-driven number of segments for   | 
K.w.seg | 
 data-driven number of segments for   | 
theta.star | 
 Lepski critical value used in determination of   | 
Jeffrey S. Racine <racinej@mcmaster.ca>, Timothy Christensen <timothy.christensen@yale.edu>
Chen, X., T. Christensen and S. Kankanala (2024). “Adaptive Estimation and Uniform Confidence Bands for Nonparametric Structural Functions and Elasticities.” Review of Economic Studies, forthcoming. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1093/restud/rdae025")}
npiv
library(MASS)
## Simulate the data
n <- 10000
cov.ux <- 0.5
var.u <- 0.1
mu <- c(1,1,0)
Sigma <- matrix(c(1.0,0.85,cov.ux,
                  0.85,1.0,0.0,
                  cov.ux,0.0,1.0),
                3,3,
                byrow=TRUE)
foo <- mvrnorm(n = n,
               mu,
               Sigma)
X <- 2*pnorm(foo[,1],mean=mu[1],sd=sqrt(Sigma[1,1])) -1
W <- 2*pnorm(foo[,2],mean=mu[2],sd=sqrt(Sigma[2,2])) -1
U <- foo[,3]
## Cosine structural function
h0 <- sin(pi*X)
Y <- h0 + sqrt(var.u)*U
npiv_choose_J(Y,X,W)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.