Skip to content

Showcase use of splines in interrupted time series #475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
drbenvincent opened this issue May 26, 2025 · 0 comments
Open

Showcase use of splines in interrupted time series #475

drbenvincent opened this issue May 26, 2025 · 0 comments
Labels
documentation Improvements or additions to documentation

Comments

@drbenvincent
Copy link
Collaborator

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.

@drbenvincent drbenvincent added the documentation Improvements or additions to documentation label May 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant