How to extract inclusion probabilities of predictors from tfcausalimpact library

43 Views Asked by At

Basically, this Python library is written with tensorflow_probability library and should be an analog of R package CausalImpact, where posterior inclusion probabilities for each predictor are extracted with plot(impact$model$bsts.model, "coefficients")

I was wondering if there is a similar functionality or method available in the tfcausalimpact library for extracting inclusion probabilities in Python.

Code example in R:

set.seed(1)
x1 <- 100 + arima.sim(model = list(ar = 0.88), n = 100)
x2 <- arima.sim(model = list(ar = 0.22), n = 100) + rnorm(100)
x3 <- rnorm(100) + rnorm(100, mean = 80, sd = 10)

y <- 1.2 * (x1+x2+x3)/3 + rnorm(100)

y[71:100] <- y[71:100] + 60
data <- cbind(y, x1, x2, x3)

pre.period <- c(1, 70)
post.period <- c(71, 100)

impact <- CausalImpact(data, pre.period, post.period)
plot(impact$model$bsts.model, "coefficients")

Code example to generate data in Python:

import pandas as pd
from causalimpact import CausalImpact

data = pd.read_csv('https://raw.githubusercontent.com/WillianFuks/tfcausalimpact/master/tests/fixtures/comparison_data.csv', index_col=['DATE'])
pre_period = ['2019-04-16', '2019-07-14']
post_period = ['2019-7-15', '2019-08-01']

ci = CausalImpact(data, pre_period, post_period)
0

There are 0 best solutions below