View source: R/Source-Basis-Approach.R
TSBA | R Documentation |
This functions implements Two Stage Curvature Identification with the Basis Approach. It tests the IV strength and chooses the violation space among a series of candidate spaces, and also constructs the confidence interval for the treatment effect with the selected violation space.
TSBA( Y, D, Z, X, vio.space = NULL, intercept = TRUE, str.thol = 10, alpha = 0.05 )
Y |
outcome with dimension n by 1 |
D |
treatment with dimension n by 1 |
Z |
instrument variable with dimension n by 1 |
X |
baseline covariates with dimension n by p |
vio.space |
a matrix with each column corresponding to a violation form of Z; If NULL, then default by the n by 3 matrix (Z^3, Z^2, Z). Violation space selection will be performed according to provided violation space, for example, null violation space vs Z vs (Z^2, Z) vs (Z^3, Z^2, Z) in the default case |
intercept |
logic, including the intercept or not in the outcome model, default by TRUE |
str.thol |
the minimal value of the threshold of IV strength test, default by 10 |
alpha |
the significance level, default by 0.05 |
|
a series of point estimators of treatment effect corresponding to different violation spaces and the OLS |
|
standard errors of Coef.all |
|
confidence intervals for the treatment effect corresponding to different violation spaces and the OLS |
|
the point estimators corresponding to the violation space selected by the robust comparison |
|
the standard errors of Coef.robust |
|
confidence intervals for the treatment effect with the violation space selected by the robust comparison |
|
IV strength corresponding to different violation spaces |
|
the threshold of IV strength test corresponding to different violation spaces |
|
the index of largest violation space selected by IV strength test. If -1, the IV strength test fails for null violation space and run OLS. If 0, the IV Strength test fails for the first violation space and run TSBA only for null violation space. In other cases, violation space selection is performed |
|
the index of estimated violation space corresponding to Qmax |
|
invalidity of TSLS. If TRUE, the IV is invalid; Otherwise, the IV is valid |
## Not run: # dimension p = 10 # n = 100 # interaction value inter.val = 1 # the IV strength a = 1 # violation strength tau = 1 f = function(x){a*(1*sin(2*pi*x) + 1.5*cos(2*pi*x))} rho1=0.5 # function to generate covariance matrix A1gen=function(rho,p){ A1=matrix(0,p,p) for(i in 1:p){ for(j in 1:p){ A1[i,j]=rho^(abs(i-j)) } } A1 } Cov=(A1gen(rho1,p+1)) mu=rep(0,p+1) # true effect beta=1 alpha=as.matrix(rep(-0.3,p)) gamma=as.matrix(rep(0.2,p)) inter=as.matrix(c(rep(inter.val,5),rep(0,p-5))) # generate the data mu.error=rep(0,2) Cov.error=matrix(c(1,0.5,0.5,1),2,2) Error=mvrnorm(n, mu.error, Cov.error) W.original=mvrnorm(n, mu, Cov) W=pnorm(W.original) Z=W[,1] X=W[,-1] # generate the treatment variable D D=f(Z)+X%*%alpha+Z*X%*%inter+Error[,1] # generate the outcome variable Y Y=D*beta+ tau*Z+ X%*% gamma+Error[,2] # Two Stage Basis Approach output.BA = TSBA(Y,D,Z,X) # point estimates output.BA$Coef.robust # standard errors output.BA$sd.robust # confidence intervals output.BA$CI.robust ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.