A function includes both Bayesian and non-Bayesian methods to incorporate uncertainties in estimated propensity scores and to provide adjusted standard errors for propensity score matching estimators.
Usage
bpsm(Y, t, X, estimand = "ATE", method = "AI", M = 1, L = 1, K = 10000, S = 1000)
Arguments
Y
A vector containing the outcome variable.
t
A vector containing the treatment indicator.
X
A matrix containing the covariates.
estimand
A character string for the estimand. The default is "ATE", average treatment effects. The other option is "ATT", average treatment effects on the treated.
method
A character string for the method to adjust standard errors. The default is "AI", which uses the methods proposed by Abadie and Imbens (2011). "BPSM" invokes the Bayesian methods developed by An (2010). "Both" use both methods.
M
Number of matches requested.
L
Number of within-group matches requested for the AI method.
K
Numbers of iterations. Only needed for BPSM.
S
Number of posterior samples. Only needed for BPSM.
Details
Estimated propensity scores are used to match treated units with untreated units. The function includes two methods to take into account the uncertainties in the estimated propensity scores and to provide adjusted standard errors. The AI method is computationally more efficient but may produce negative standard errors in some cases. In contrast, the BPSM method always provides positive standard errors but requires longer computational time to converge, especially when the sample size is large.
Value
estimates
The estimated treatment effects and their adjusted standard errors. Phat shows the results with unadjusted standard errors. AI shows the results with adjusted standard errors based on the AI method. BP* shows the results with adjusted standard errors based on the Bayesian method.
estimand
A character string indicting the estimand requested.
time
The time elapsed for the computation.
sims
The number of iterations requested for the Bayesian computation, K
posterior
The posterior sample distribution of the treatment effects. BPSM uses the posterior standard deviation to approximate the standard error.
library(boot)
a = 2; b = c(1, -2, 5); N = 500
x1 <- runif(N, 0, 1)
x2 <- runif(N, 0, 1)
X <- as.matrix(cbind(rep(1, N), x1, x2))
p <- inv.logit( X %*% b )
t <- rbinom(N, 1, p)
e <- rnorm(N, 0, 1)
Y <- 5 * t + a * ( x1 + x2 ) + e
bpsm( Y, t, X, method = "AI", estimand = "ATE" )
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(IUPS)
Loading required package: R2jags
Loading required package: rjags
Loading required package: coda
Linked to JAGS 4.1.0
Loaded modules: basemod,bugs
Attaching package: 'R2jags'
The following object is masked from 'package:coda':
traceplot
Loading required package: Matching
Loading required package: MASS
##
## Matching (Version 4.9-2, Build Date: 2015-12-25)
## See http://sekhon.berkeley.edu/matching for additional documentation.
## Please cite software as:
## Jasjeet S. Sekhon. 2011. ``Multivariate and Propensity Score Matching
## Software with Automated Balance Optimization: The Matching package for R.''
## Journal of Statistical Software, 42(7): 1-52.
##
Loading required package: boot
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/IUPS/bpsm.Rd_%03d_medium.png", width=480, height=480)
> ### Name: bpsm
> ### Title: Bayesian Propensity Score Matching
> ### Aliases: bpsm
>
> ### ** Examples
>
> library(boot)
>
> a = 2; b = c(1, -2, 5); N = 500
> x1 <- runif(N, 0, 1)
> x2 <- runif(N, 0, 1)
> X <- as.matrix(cbind(rep(1, N), x1, x2))
> p <- inv.logit( X %*% b )
> t <- rbinom(N, 1, p)
> e <- rnorm(N, 0, 1)
> Y <- 5 * t + a * ( x1 + x2 ) + e
> bpsm( Y, t, X, method = "AI", estimand = "ATE" )
$estimates
est se
Phat 4.681682 0.3200531
AI 4.681682 0.2978756
$estimand
[1] "ATE"
$time
user system elapsed
0.108 0.020 0.112
>
>
>
>
>
> dev.off()
null device
1
>