Code Monkey home page Code Monkey logo

bayesian-multivariate-time-series-causal-inference's Introduction

Bayesian multivariate time series causal inference

R code for Ning, B., Ghosal, S. and Thomas, J. (2017)

We provide the code for the new Bayesian causal inference method proposed in our paper: Ning, B., Ghosal, S. and Thomas, J. (2017).

The multivariate basic structural time series model is:

Two-stage algorithm

Stage 1: EMVS step

Use EMVS algorithm to estimate beta and obtain EMVS

Stage 2: MCMC step

(a) Generate alpha using the Kalman-filter and simulation smoother method

(b) Generate phi using the Metropolis-Hastings algorithm

(c) Generate D from its posterior

(d) Generate covariance matrices from their respective G-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 tau

The folder includes:

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 Ytilde

-- 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 tau

-- 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

bayesian-multivariate-time-series-causal-inference's People

Contributors

bo-ning avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.