View source: R/blasso_default.R
bpCausal | R Documentation |
Bayesian Causal inference with TSCS data
bpCausal(data, index, Yname, Dname, Xname, Zname, Aname,
re = "unit", ar1 = TRUE, r,
niter = 10000, burn = 5000,
xlasso, zlasso, alasso, flasso,
a1 = 0.001, a2 = 0.001, b1 = 0.001, b2 = 0.001,
c1 = 0.001, c2 = 0.001, p1 = 0.001, p2 = 0.001)
data |
a data frame (must be with a dichotomous treatment but balanced is not reqiored). |
index |
a two-element string vector specifying the unit (group) and time indicators. Must be of length 2. |
Yname |
outcome. |
Dname |
treatment. |
Xname |
covariates that have constant effects. |
Zname |
covariates that have unit-level random effects. |
Aname |
covariates that have time-level random effects. |
re |
a string indicating whether additive unit or time fixed effects will be imposed. Must be one of the following, "none", "unit", "time", or "two-way". The default is "unit". |
ar1 |
a logical flag indicating whether time-varying parameters and factors are AR(1) process or independent across periods. |
r |
an integer specifying the (upper bound of) number of factors. |
niter |
an integer specifying the iterations of MCMC run. Default value is 10000. |
burn |
an integer specifying the length of burn in iterations of MCMC run. Default value is 5000. |
xlasso |
a logical flag indicating whether to assign constant coefficients hierachical shrinkage priors. |
zlasso |
a logical flag indicating whether to assign unit-level random coefficients hierachical shrinkage priors. |
alasso |
a logical flag indicating whether to assign time-level random coefficients hierachical shrinkage priors. |
flasso |
a logical flag indicating whether to assign factor loadings hierachical shrinkage priors for factor selection. |
a1 |
shape parameter for the Gamma prior for constant coefficients shrinkage. |
a2 |
rate parameter for the Gamma prior for constant coefficients shrinkage. |
b1 |
shape parameter for the Gamma prior for unit-level random coefficients shrinkage. |
b2 |
rate parameter for the Gamma prior for unit-level random coefficients shrinkage. |
c1 |
shape parameter for the Gamma prior for time-level random coefficients shrinkage. |
c2 |
rate parameter for the Gamma prior for unit-level random coefficients shrinkage. |
p1 |
shape parameter for the Gamma prior for factor loadings shrinkage. |
p2 |
rate parameter for the Gamma prior for factor loadings shrinkage. |
bpCausal
implements counterfactual estimators in TSCS data analysis. It
simulates counterfactual outcomes under control for observations under treatment
based on posterior predictive distributions.
yct |
trace of simulated counterfactual outcomes under control for each observation under treated. |
sigma2 |
trace of simulated variance for the error term. |
beta |
trace of constant coefficients. |
alpha |
trace of unit-level random coefficients. |
xi |
trace of time-level random coefficients. |
gamma |
trace of factor loadings. |
f |
trace of factors. |
pxi |
trace of ar1 parameter for time-level random coefficients. |
pf |
trace of ar1 parameter for factors. |
wa |
trace of square roots for prior variance of unit-level random coefficients. |
wxi |
trace of square roots for prior variance of time-level random coefficients. |
wg |
trace of square roots for prior variance of factor loadings. |
sb2 |
trace of prior variance of constant coefficients. |
swa2 |
trace of prior variance of square roots for prior variance of unit-level random coefficients. |
swxi2 |
trace of prior variance of square roots for prior variance of time-level random coefficients. |
swg2 |
trace of prior variance of square roots for prior variance of factor loadings. |
raw.id.tr |
a vector of names of treated units. |
id.tr |
a vector of integer indicating which units are under treated. |
time.tr |
a vector of periods (see |
tr.unit.pos |
a vector of integer indicating which observations in the dataset correspond to a treated unit. |
rela.time.tr |
a vector of period relative to the occurrence of treatment for each observation that corresponds to a treated unit. |
A Bayesian Alternative to Synthetic Control for Comparative Case Studies. Pang et. al (2021).
library(bpCausal)
data(bpCausal)
out <- bpCausal(data = simdata, index = c("id", "time"),
Yname = "Y", Dname = "D",
Xname = c("X1", "X2"), Zname = NULL, Aname = c("X1", "X2"),
re = "time", r = 10, niter = 20000)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.