FMenchetti / CausalArima

An R package to estimate the effect of interventions on univariate time series using ARIMA models
14 stars 2 forks source link

Potential Python implementation #22

Open juanitorduz opened 2 years ago

juanitorduz commented 2 years ago

Hi! This is more a suggestion on how a potential python implementation could look like.

  1. The package pycausalimpact is a nice python implementation of the CausalImpact approach based on the UnobservedComponets model of statsmodels. This implementation is not fully bayesian and relies on Maximum Likelihood Estimation.

  2. This package uses the UnobservedComponets model here. The idea would be to replace or extend it to use the SARIMAX model. Note that both UnobservedComponets and SARIMAX part of the statsmodels.tsa.statespace module.

  3. Note that there is no "auto-arima" in statsmodels, but python users often just couple it with the AutoARIMA function from the pmdarima package (which by itself is based on the forecast R package).

I will be happy so help, but at the moment I do not have the capacity to port CausalArima to python. Nevertheless, maybe this suggestion triggers some initial draft implementations :)

palmierieugenio commented 2 years ago

Hi Juan, thank you for your suggestions!

We would like to start working on a first draft of a python implementation, as soon as we have a more stable version of our R package, hopefully at the beginning of next year.

We could use this function statsmodels.tsa.arima.model.ARIMAResults.simulate to run the bootstrap simulations, extracting the needed parameters from a pmdarima or we could implement our version of bootstrap. For the closed formula solution, pmdarima should be enough.

Anyway, if you or other people want to help us, we are more than happy!

juanitorduz commented 2 years ago

Yes, indeed by looking into these lines of the python package they are using simulation to estimate prediction intervals.

I think I won't be able to be an active contributor but I will be happy to review and test the code ;)