-
Notifications
You must be signed in to change notification settings - Fork 73
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
Power analysis using UC or pyBats dynamic linear models #103
Comments
Hi @MilaimKas , I like this idea. I do consider doing a refactoring to implement the concept of I still couldn't work on it though, I suspect it'd take around an entire month to implement. I'll leave this one open, hopefully I can start working on it soon - if the community wants to contribute ideas and PRs they are upmost valuable as well. As for your approach on power analysis, I couldn't entirely understand your approach but it looks like you have the necessary confirmations that it's working. One idea that came to mind was to fit a |
Hi @WillianFuks |
To run the analysis as I mentioned probably you'd need to use tfp directly to fit a model on the posterior, i.e., current tfci package won't offer you this analysis by default. |
Hello there,
first, many thanks for providing a stable and Bayesian based python version of the original R package.
I was previously using the deprecated pycausalimpact package to perform analysis of intervention. Sure it was not Bayesian but was nevertheless providing some useful insights. In addition, I used to perform "power analysis" (so far as this term can be used in the context of time series) to assess the "power" of my model, i.e. to answer the question "what effect size would I be able to detect at a given level of confidence". In order to do that, I would:
** add the effect to the post-period (optionally including a lag and noises)
** extract the final result (last point of the estimated cumulative effect size and CI)
I would then obtain a plot similar to this:
![image](https://private-user-images.githubusercontent.com/58304272/359482161-222dacbd-cfe0-433b-ae0c-1988752acbbc.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5OTE4ODIsIm5iZiI6MTczODk5MTU4MiwicGF0aCI6Ii81ODMwNDI3Mi8zNTk0ODIxNjEtMjIyZGFjYmQtY2ZlMC00MzNiLWFlMGMtMTk4ODc1MmFjYmJjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA4VDA1MTMwMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTBlYWUxMmY3NzA3YTBiMDY3Y2U1MjBkOTljNGQ3NzYxN2RkMWE2NTAwNDRiYzgyMTdmZDNkZDUxMDViYjdiYmMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.YqYXp6QWDN0qP82AjfI5a57rtU30pHNkaZK_AdrYH9I)
Where the blue filled region correspond to the 95% interval and the gray to the 80%.
I would then interpret the results as follows: at a 95% level of confidence I would be able to "detect" an effect of ~6% or larger, at a 80% level of confidence I would be able to detect a very small effect (~1%).
Of course, this is a typical frequentest approach, but I still found it very useful to assess the "power" of a model.
In addition, since I often encountered the case where it was possible to "tune" the model (varying the pre and post period length, adding or removing certain control variables) to get significant or non-significant result, I also used the same approach described above but, in addition to looping over effect size, I would also loop over pre- and post-period lengths. This would give me an idea on how stable the results are with respect to these parameters.
This approach needs many of causal impact calculations, which is not possible with the current tensor flow based model.
I was therefore wondering how difficult it would be to allow the user to switch from a tensor flow bsts model to, for example, a UC model ? The idea would be to perform these "power analysis" with the simple model, decide on which parameters to use, and asses the final impact using the more accurate tensor flow model.
Alternatively, to stay within the Bayesian framework, one could also rely on Normal approximations and used conjugated priors to get the posteriors. I believe, this is what the python package pyBats does.
The text was updated successfully, but these errors were encountered: