Description Usage Arguments Value Examples
Main function: Prepares data, calls help functions, stores results. See the LATEtest website on https://github.com/farbmacher/LATEtest for more information, documentation and examples. Please report any bugs to farbmacher@econ.lmu.de
1 2 3 |
data |
provides dataset: outcome must be labelled Y, treatment D and instrument Z |
covars |
provides names of covariables in data (e.g., "Xvar1" "Xvar2" "Xvar3") |
huge |
if set to TRUE, model for orthogonalization learned on random subset of data (size defined in tree_fraction) |
tree_fraction |
fraction of the data used to build each tree of causal forest (and if huge==T, also used for regression forests); default=0.5 |
minsize |
causal forest insists on at least "minsize" treated and "minsize" control observations per leaf, and pruned tree insists on at least 2*"minsize" observations in the additional trees to identify the promising subgroups |
cp |
sets complexity parameter which rpart uses to fit the tree before pruning; default=0 |
slice |
choose "equisized" for equisized subsets (quantile-based) of the outcome or "equidistant" for equidistant subsets (grid-based) of the outcome |
subsets |
number of subsets used to discretize the outcome |
alpha |
nominal significance level of the test |
seed |
set random seed number |
list of the pruned trees, test results
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # Generate data:
library("LATEtest")
library("rpart.plot")
n = 3000; p = 3; rho=0.3
u <- rnorm(n)
v <- rho * u + sqrt(1 - rho^2) * rnorm(n)
X <- matrix(rnorm(n * p), n, p)
colnames(X) <- paste("Xvar", 1:p, sep="")
Z <- rbinom(n, size = 1, prob = 0.5)
D<-as.numeric(0.2 * Z + v > 0)
# local violation of the exclusion restriction:
gamma <- as.numeric(ifelse(X[, 2] < -1, 1.25, 0))
Y <- as.vector(D + gamma * Z + u)
data <- as.data.frame(cbind(Y,D,Z,X))
# Perform test:
covars = paste0(colnames(data)[4:ncol(data)])
test <- LATEtest(data = data, covars = covars, subsets = 4, alpha = 0.05)
test
# Draw plot of pruned tree that led to local violation of LATE assumptions:
maxtree <- eval(parse(text = paste("test$treelist$tree_", test$maxTtree$label, test$maxTtree$J,sep = "")))
rpart.plot(maxtree, extra = 101, box.palette = "GyRd", shadow.col = "gray", nn = TRUE, roundint = FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.