Test for systematic treatment effect heterogeneity using Fisherian permutation inference methods.
detect_idiosyncratic(formula, data, interaction.formula,
control.formula, plugin, tau.hat, test.stat, te.vec, B, gamma, grid.gamma,
grid.size, return.matrix, na.rm, n.cores, verbose, ...)
If plug-in, the value of the test and the associated p-value. If not, a list with the value of the test statistic on the observed data, the value of the CI-adjusted p-value, the plug-in p-value, and other information on the test.
An object of class formula, as in lm(), such as Y ~ Z with only the treatment variable on the right-hand side.
A data.frame, tbl_df, or data.table with the input data.
A right-sided formula with pre-treatment covariates to model treatment effects for on the right hand side, such as ~ x1 + x2 + x3. Defaultis NULL (no interactions modeled)
A right-sided formula with pre-treatment covariates to adjust for on the right hand side, such as ~ x1 + x2 + x3. Default is NULL (no variables adjusted for)
Whether to calculate the plug-in p-value without sweeping over range of possible treatment effect magnitudes. Default is FALSE.
The value of the plug-in treatment effect. Default is sample average treatment effect.
Test statistic function to use on the data. Default is shifted Kolmogorov-Smirnov statistic, potentially with covariate adjustment depending on passed arguments. test.stat can be a string name for a test statistic function, or the function itself.
Vector of taus to examine if you want to override generating ones automatically. Default is NULL.
Number of permutations to take. Default is 500.
How wide of a CI to make around tau-hat for search. Default is 0.0001.
Parameter to govern where the grid points are sampled. Bigger values means more samples towards the estimated tau-hat. Default is 100*gamma.
Number of points in the grid. Default is 151.
Whether to return the matrix of all the imputed statistics. Default is FALSE.
A logical flag indicating whether to list-wise delete missing data. The function will report an error if missing data exist. Default is FALSE.
Number of cores to use to parallelize permutation step. Default is 1.
Whether to print out progress bar when fitting and other diagnostics. Default is TRUE.
Extra arguments passed to the generate.permutations function and test.stat functions.
Z <- rep(c(0, 1), 100)
tau <- 4
Y <- ifelse(Z, rnorm(100, tau), rnorm(100, 0))
df <- data.frame(Y=Y, Z=Z)
tst <- detect_idiosyncratic(Y ~ Z, df, B = 50, grid.size = 50)
Run the code above in your browser using DataLab