Skip to content

Showcase use of splines in interrupted time series #475

Open
@drbenvincent

Description

@drbenvincent

At the moment we only have one example of using splines in CausalPy, and that's in a non-Bayesian example of the regression discontinuity design.

I would be interesting to see splines used more, particular in a Bayesian notebook. The easiest way to do this would be to extend the existing Excess deaths due to COVID-19 notebook example which just has a basic linear trend. For example, we could modify the equation to standardize(deaths) ~ 0 + cr(t, df=6) + C(month) + temp to model the trend with a natural cubic spline.

I did give that a quick go, and was able to get a better pre-treatment fit ($R^2=0.75$) than the linear trend model ($R^2=0.71$), however there were $\hat{R}$ convergence problems. This could be also be related to the mismatch between the scale of the data and the (not cleverly chosen priors), and that is what probably lead me to use the standardize function in the patsy model formula. One solution to that might end up being better / automated priors (related to, but not the same as, #387).

It would also be interesting to optionally add in cyclic splines to model annual seasonality.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions