PSAboot | R Documentation |
Bootstrapping has become a popular resampling method for estimating sampling distributions. And propensity score analysis (PSA) has become popular for estimating causal effects in observational studies. This function implements bootstrapping specifically for PSA. Like typical bootstrapping methods, this function estimates treatment effects for M random samples. However, unlike typical bootstrap methods, this function allows for separate sample sizes for treatment and control units. That is, under certain circumstances (e.g. when the ratio of treatment-to-control units is large) bootstrapping only the control units may be desirable. Additionally, this function provides a framework to use multiple PSA methods for each bootstrap sample.
PSAboot(
Tr,
Y,
X,
M = 100,
formu = as.formula(paste0("treat ~ ", paste0(names(X), collapse = " + "))),
control.ratio = 5,
control.sample.size = min(control.ratio * min(table(Tr)), max(table(Tr))),
control.replace = TRUE,
treated.sample.size = min(table(Tr)),
treated.replace = TRUE,
methods = getPSAbootMethods(),
parallel = TRUE,
seed = NULL,
...
)
Tr |
numeric (0 or 1) or logical vector of treatment indicators. |
Y |
vector of outcome variable |
X |
matrix or data frame of covariates used to estimate the propensity scores. |
M |
number of bootstrap samples to generate. |
formu |
formula used for estimating propensity scores. The default is to use
all covariates in |
control.ratio |
the ratio of control units to sample relative to the treatment units. |
control.sample.size |
the size of each bootstrap sample of control units. |
control.replace |
whether to use replacement when sampling from control units. |
treated.sample.size |
the size of each bootstrap sample of treatment units. The default uses all treatment units for each bootstrap sample. |
treated.replace |
whether to use replacement when sampling from treated units. |
methods |
a named vector of functions for each PSA method to use. |
parallel |
whether to run the bootstrap samples in parallel. |
seed |
random seed. Each iteration, i, will use a seed of |
... |
other parameters passed to |
a list with following elements:
Data frame with the results using the complete dataset (i.e. unbootstrapped results).
Objects returned from each method for complete dataset.
Data frame with results of each bootstrap sample.
List of objects returned from each method for each bootstrap sample.
sample size used for control units.
sample size used for treated units.
whether control units were sampled with replacement.
whether treated units were sampled with replacement.
vector of treatment assignment.
vector out outcome.
matrix or data frame of covariates.
number of bootstrap samples.
getPSAbootMethods
library(PSAboot)
data(pisa.psa.cols)
data(pisausa)
bm.usa <- PSAboot(Tr = as.integer(pisausa$PUBPRIV) - 1,
Y = pisausa$Math,
X = pisausa[,pisa.psa.cols],
control.ratio = 5, M = 100, seed = 2112)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.