WillianFuks / tfcausalimpact

Python Causal Impact Implementation Based on Google's R Package. Built using TensorFlow Probability.
Apache License 2.0
610 stars 72 forks source link

p-value in the `summary` has a cap of 0.5 #56

Open charlesdong1991 opened 2 years ago

charlesdong1991 commented 2 years ago

Hi, thanks for making this nice package!

Small question regarding the p-value from summary: From the doc here , it seems the range of p-value is from 0 to 1.

But when trying to use the package and checking the p-value from summary, it seems the cap of p-value is 0.5?

WillianFuks commented 2 years ago

Hi @charlesdong1991 ,

You are correct, the upper limit for the p-value is indeed 50%. This happens because the computation of signal is symmetric due the min operation. So 50% is indeed the maximum value it can reach.

I'll improve the docs for this function soon. Thanks for pointing that out!

Best,

Will

charlesdong1991 commented 2 years ago

Thank you very much for your fast reply!! Appreciate it a lot!!

Small follow up question: is the interpretation of p-value in this case changed? How do you suggest to interpret the p-value here, e.g. when p-value=0.5, what does it mean?

Thanks again!! 👍

WillianFuks commented 2 years ago

The p-value has the same definition as in statistics. It represents the likelihood of obtaining the observed results supposing the null-hypothesis is true, in other words, if p=0.5 it means there's a 50% chance of observing the post-intervention period when there's actually no impact. As the value is high then we don't consider that there was a meaningful impact from the intervention.

But if you run the same test and find p=0, that means that the chance of observing the results by random chance without the intervention is effectively zero. In this case, as the response is considered too far away from what is normally expected, we then consider that there was a meaningful impact.

So in a nutshell it's really the usual definition of p-statistics as defined in the literature.

charlesdong1991 commented 2 years ago

Great thanks for your detailed explanation!! 👍

marguegit commented 2 years ago

Thank you @WillianFuks !