项目作者: ck37

项目描述 :
Horvitz-Thompson estimator for RCTs, with Joel Middleton
高级语言: R
项目地址: git://github.com/ck37/htestimate.git
创建时间: 2015-06-08T20:46:54Z
项目社区:https://github.com/ck37/htestimate

开源协议:

下载


htestimate

Htestimate calculates unbiased estimates of treatment effects from randomized trials when the random assignment is correlated across units, using the Horvitz-Thompson estimator (Särndal et al. 2003, section 2.8). Standard approaches to RCT evaluation (difference in means and regression) are generally biased under clustered randomization (Middleton 2008) or under rerandomization (Morgan & Rubin 2012), for example. In addition to the treatment effect the package produces a standard error and p-value of that effect estimate. Differences in outcome totals rather than means can also be produced. Any number of experimental arms/conditions are allowed.

This package is currently under active development so bug reports and feature requests are encouraged.

Install

Install directly from github using devtools:

  1. install.packages("devtools") # If not already installed.
  2. devtools::install_github("ck37/htestimate")
  3. library(htestimate)

Requirements

R packages: dplyr

Examples

  1. # Example using data from RI package.
  2. y <- c(8,6,2,0,3,1,1,1,2,2,0,1,0,2,2,4,1,1)
  3. Z <- c(1,1,0,0,1,1,0,0,1,1,1,1,0,0,1,1,0,0)
  4. # Generate 10,000 random permutations of the assignment vector.
  5. perms = ri::genperms(Z, maxiter=10000)
  6. # Estimate the probability of assignment for each unit and assignment level.
  7. prob_matrix = createProbMatrix(perms)
  8. # Estimate the treatment effect using Horvitz-Thompson.
  9. htestimate(y, Z, contrasts = c(-1, 1), prob_matrix = prob_matrix)

References

Aronow, P. M., & Middleton, J. A. (2013). A class of unbiased estimators of the average treatment effect in randomized experiments. Journal of Causal Inference, 1(1), 135-154.

Middleton, J. A. (2008). Bias of the regression estimator for experiments using clustered random assignment. Statistics & Probability Letters, 78(16), 2654-2659.

Morgan, K. L., & Rubin, D. B. (2012). Rerandomization to improve covariate balance in experiments. The Annals of Statistics, 40(2), 1263-1282.

Särndal, C. E., Swensson, B., & Wretman, J. (2003). Model assisted survey sampling. Springer Science & Business Media.