We provide the R code for the new Bayesian causal inference method proposed in our paper: Bayesian method for causal inference in spatially-correlated multivariate time series (https://arxiv.org/abs/1801.06282).
Use EMVS algorithm to estimate and obtain
(a) Generate using the Kalman-filter and simulation smoother method
(b) Generate using the Metropolis-Hastings algorithm
(c) Generate from its posterior
(d) Generate covariance matrices from their respective -Wishart posterior
(e) Go to Step (a) and repeat until the chain converges.
Skip Step (b) and (c) if no stationarity restriction is imposed on
example.R: uses to simulate a dataset. The simulation process the same as the one described in that paper.
BayesianCausalImpact folder: includes the code for runing the causal inference analysis
-- two.stage.estimate.R: the main code for the two-stage algorithm
-- estimate.counterfactual.R: the code for the EMVS step in the two-stage algorithm, the output is
-- EMVS.R: the code for the EMVS algorithm
-- MCMC.multivariate.ssm.R: the code for the MCMC step in the two-stage algorithm, the outputs are the parameter posterior draws
-- koopmanfilter.R: the code for the Kalman filter and simulation smoother algorithm
-- kalmflter.R: the code for the Kalman-filter and Backward smoother algorithm
-- stationaryRestrict.R & varp.R: the codes for making stationarity constraint on
-- MultiCausalImpact.R: the code for conducting our new causal inference method
-- MungeMatrix.R: the code to convert a computationally singular matrix into a non-singular matrix
-- ks.distance-plot.R: the code for generating plots of estimated KS distances and thresholds