Set the number of bootstrap samples. This should be set to at least 100 but kept small to reduce the execution time for CRAN submissions.

boot.M <- 10

NOTE: This vignette uses 10 bootstrap samples. It is generally recommended to use at least 100 bootstrap samples or more for final publication.

Introduction

The latest version of the PSAboot package can be downloaded from Github using the devtools package.

devtools::install_github('jbryer/PSAboot')

The PSAboot function will perform the actual bootstrapping. It has a number of parameters for to specify how the bootstrap samples are drawn.

Other parameters can be passed to methods using the ... parameter.

Methods

The methods parameter on the PSAboot function specifies the different propensity score methods that will be used. Specifically, for each bootstrap sample drawn, each function will be called. This allows for a comparison of methods across all bootstrap samples. Five methods are included, they are:

  • boot.strata - This method estimates propensity scores using logistic regression and stratifies using quintiles on the propensity scores. Effects within each strata are estimated and aggregated.
  • boot.ctree - This method creates strata using conditional inference trees vis-a-vis the ctree function in the party package. Effects within each strata (i.e. leaf node) are estimated and aggregated.
  • boot.rpart - This method creates strata using classification trees vis-a-vis the rpart function. Effects within each strata (i.e. leaf node) are estimated and aggregated.
  • boot.matching - This method finds matched pairs using the Match function in the Matching package. A paired dependent sample t-test is used to estimate effect sizes.
  • boot.matchit - This method finds match pairs using the matchit function in the MatchIt package. A paired dependent sample t-ttest is used to estimate effect sizes.

Defining Custom Methods

It is possible to define a custom method. Each method is a function with, at minimum, the following six parameters:

  • Tr - A logical or integer (0 and 1) vector with treatment indicators.
  • Y - A numeric vector representing the outcome.
  • X - A data frame with the covariates.
  • X.trans - A data frame with factor levels dummy coded.
  • formu - A formula for estimating propensity scores in phase one.
  • ... - Other parameters passed through from the PSAboot function.

Each method must return a list with three elements:

  • summary - This must be a named numeric vector with at minimum estimate, ci.min, and ci.max, however other values allowed.
  • balance - This must be a named numeric vector with one element per covariate listed in X.trans representing a balance statistic. It is recommended, and the implementation for the built-in methods, to use an absolute standardized effect size. As will be shown below, the summary and plotting functions will include an adjusted balance statistic (i.e. effect size) before adjustment for comparison.
  • details - This can be an arbitrary object, typically the result of the underlying method used.

For example, the boot.matching.1to3 function below wraps the built-in boot.matching method but sets the M parameter to 3, thereby performing 1-to-3 matching instead of the default 1-to-1 matching. This framework simplifies the process of using, and comparing, slight variations of different propensity score methods.

boot.matching.1to3 <- function(Tr, Y, X, X.trans, formu, ...) {
    return(boot.matching(Tr=Tr, Y=Y, X=X, X.trans=X.trans, formu=formu, M=3, ...))
}

The PSAboot function returns an object of class PSAboot. The following S3 methods are implemented: print, summary, plot, boxplot, and matrixplot.


Example One: National Work Demonstration and PSID

The lalonde (Lalonde, 1986) has become the de defacto teaching dataset in PSA since Dehejia and Wahba’s (1999) re-examination of the National Supported Work Demonstration (NSW) and the Current Population Survey (CPS).

The lalonde data set is included in the Matching package. The contingency table shows that there are 429 control units and 185 treatment units.

data(lalonde, package='Matching')
table(lalonde$treat)
## 
##   0   1 
## 260 185
lalonde.formu <- treat~age + I(age^2) + educ + I(educ^2) + black +
             hisp + married + nodegr + re74  + I(re74^2) + re75 + I(re75^2) +
             u74 + u75
boot.lalonde <- PSAboot(Tr = lalonde$treat, 
                        Y = lalonde$re78,
                        X = lalonde,
                        formu = lalonde.formu,
                        M = 100, 
                        seed = 2112)

The summary function provides numeric results for each method including the overall estimate and confidence interval using the complete sample as well as the pooled estimates and confidence intervals with percentages of the number of confidence intervals that do not span zero.

summary(boot.lalonde)
## Stratification Results:
##    Complete estimate = 1493
##    Complete CI = [231, 2755]
##    Bootstrap pooled estimate = 1426
##    Bootstrap weighted pooled estimate = 1376
##    Bootstrap pooled CI = [89.1, 2762]
##    59% of bootstrap samples have confidence intervals that do not span zero.
##       59% positive.
##       0% negative.
## ctree Results:
##    Complete estimate = 1598
##    Complete CI = [-6.62, 3203]
##    Bootstrap pooled estimate = 1457
##    Bootstrap weighted pooled estimate = 1463
##    Bootstrap pooled CI = [170, 2743]
##    39% of bootstrap samples have confidence intervals that do not span zero.
##       39% positive.
##       0% negative.
## rpart Results:
##    Complete estimate = 1332
##    Complete CI = [-295, 2959]
##    Bootstrap pooled estimate = 1429
##    Bootstrap weighted pooled estimate = 1442
##    Bootstrap pooled CI = [-136, 2993]
##    32% of bootstrap samples have confidence intervals that do not span zero.
##       32% positive.
##       0% negative.
## Matching Results:
##    Complete estimate = 1069
##    Complete CI = [396, 1742]
##    Bootstrap pooled estimate = 1370
##    Bootstrap weighted pooled estimate = 1364
##    Bootstrap pooled CI = [-322, 3062]
##    83% of bootstrap samples have confidence intervals that do not span zero.
##       83% positive.
##       0% negative.
## MatchIt Results:
##    Complete estimate = 2053
##    Complete CI = [657, 3450]
##    Bootstrap pooled estimate = 1755
##    Bootstrap weighted pooled estimate = 1744
##    Bootstrap pooled CI = [357, 3153]
##    74% of bootstrap samples have confidence intervals that do not span zero.
##       74% positive.
##       0% negative.
## Weighting Results:
##    Complete estimate = 1558
##    Complete CI = [310, 2807]
##    Bootstrap pooled estimate = 1489
##    Bootstrap weighted pooled estimate = 1440
##    Bootstrap pooled CI = [126, 2853]
##    64% of bootstrap samples have confidence intervals that do not span zero.
##       64% positive.
##       0% negative.

The plot function plots the estimate (mean difference) for each bootstrap sample. The default is to sort from largest to smallest estimate for each method separately. That is, rows do not correspond across methods. The sort parameter can be set to none for no sorting or the name of any method to sort only based upon the results of that method. In these cases the rows then correspond to matching bootstrap samples. The blue points correspond to the the estimate for each bootstrap sample and the horizontal line to the confidence interval. Confidence intervals that do not span zero are colored red. The vertical blue line and green lines correspond to the overall pooled estimate and confidence for each method, respectively.

plot(boot.lalonde)