pymc-labs / CausalPy

A Python package for causal inference in quasi-experimental settings
https://causalpy.readthedocs.io
Apache License 2.0
880 stars 63 forks source link

Add penalised synthetic control model #366

Open drbenvincent opened 3 months ago

drbenvincent commented 3 months ago

As of now, we have "vanilla" synthetic control working with cp.pymc_experiments.SyntheticControl cp.SyntheticControl as the experiment class, and that is fed the cp.pymc_models.WeightedSumFitter as the model.

It is the cp.pymc_models.WeightedSumFitter which does the vanilla synthetic control model - as in weightings which sum to 1, and that is done via a Dirichlet distribution.

We want to add the ability to do penalised synthetic control. This will still use the cp.pymc_experiments.SyntheticControl cp.SyntheticControl experiment class, but instead we will feed it a new model, something like cp.pymc_models.PenalizedSyntheticControlModel. (However, see below because we may no need a new model)

Implementation notes

As far as I understand constraining the sum of the weights of control units to sum to 1 is optional in penalised synthetic control.

If we want to keep the sum to 1 constraint, then we could just keep the existing cp.pymc_models.WeightedSumFitter model, but change the hyper parameters of the Dirichlet distribution to bias towards more sparsity in the coefficients.

If we don't want to keep the sum to 1 constraint, then we could create a new model class and implement the L1 or L2 constraint via Laplace or Normal priors on coefficients.

drbenvincent commented 1 month ago

@NathanielF We merged #381 last week, so that has been taken away as a blocker for whenever you wanted to work on this :)