causalimpact icon indicating copy to clipboard operation
causalimpact copied to clipboard

Calculation error of p-value

Open CYW0018 opened this issue 1 year ago • 7 comments

I'm not sure whether there is an error in the calculation of p_value of the code. As the following figure shows, the p_value is calculated by the mean value of the synthetic control group's predictor rather than the point effect value. I guess you may be want to use the latter? image Another evidence is that when I use the example from https://colab.research.google.com/drive/1HkJ9zm0LY36Wz-wB_bSHq68w8Cef6qJO?usp=sharing#scrollTo=AqyItZ3Hggoh, even if I don't change the value of y after 3000, the p-value is still significant and inconsistent with the confidence interval given(including zero)

CYW0018 avatar Oct 27 '23 06:10 CYW0018

I also think there is something off with the p-value, as I'm seeing constant 100% confidence level.

mare011rs avatar Mar 23 '24 07:03 mare011rs

I am seeing the same problem as @mare011rs : p_value = 0, Prob of causal effect 100% even when I explicitly synthesize data to have zero effect. This seems to be a rather big bug.

patrick-le-shopify avatar Apr 12 '24 17:04 patrick-le-shopify

This package is outdated, I suggest you use tfcausalimpact.

mare011rs avatar Apr 12 '24 20:04 mare011rs

Got it. Thanks!

patrick-le-shopify avatar Apr 12 '24 20:04 patrick-le-shopify

This package is outdated, I suggest you use tfcausalimpact.

It looks like tfcausalimpact uses this package underneath though (see the example and code underneath). So I'd expect this issue to occur there, as well (though haven't tested to confirm).

pemoriarty avatar Aug 23 '24 23:08 pemoriarty

@pemoriarty Are you basing this on the name of the package in the imports? tfcausalimpact is imported into your code in the same way as other CI packages as "from causalimpact import CausalImpact", which might be misleading.

mare011rs avatar Aug 24 '24 18:08 mare011rs

@pemoriarty Are you basing this on the name of the package in the imports? tfcausalimpact is imported into your code in the same way as other CI packages as "from causalimpact import CausalImpact", which might be misleading.

It was the wording on a few pages that made me wonder and then yeah, the imports using the same package name. But yep, looking deeper at model.py, I see I'm totally off. 🤦 Glad to be wrong- that'll make my life easier!

pemoriarty avatar Aug 26 '24 20:08 pemoriarty