detect_idiosyncratic {hettx}R Documentation

detect_idiosyncratic

Description

Test for systematic treatment effect heterogeneity using Fisherian permutation inference methods.

Usage

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, ...)

Arguments

formula

An object of class formula, as in lm(), such as Y ~ Z with only the treatment variable on the right-hand side.

data

A data.frame, tbl_df, or data.table with the input data.

interaction.formula

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)

control.formula

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)

plugin

Whether to calculate the plug-in p-value without sweeping over range of possible treatment effect magnitudes. Default is FALSE.

tau.hat

The value of the plug-in treatment effect. Default is sample average treatment effect.

test.stat

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.

te.vec

Vector of taus to examine if you want to override generating ones automatically. Default is NULL.

B

Number of permutations to take. Default is 500.

gamma

How wide of a CI to make around tau-hat for search. Default is 0.0001.

grid.gamma

Parameter to govern where the grid points are sampled. Bigger values means more samples towards the estimated tau-hat. Default is 100*gamma.

grid.size

Number of points in the grid. Default is 151.

return.matrix

Whether to return the matrix of all the imputed statistics. Default is FALSE.

na.rm

A logical flag indicating whether to list-wise delete missing data. The function will report an error if missing data exist. Default is FALSE.

n.cores

Number of cores to use to parallelize permutation step. Default is 1.

verbose

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.

Value

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.

Examples

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)

[Package hettx version 0.1.3 Index]