I'm using tfcausalimpact (https://github.com/WillianFuks/tfcausalimpact).
When I run the analysis, I know that I can access the p-value by instantiating the model
ci = CausalImpact(data,pre_period,post_period)
ci.summary()
But that gives a wrapped-up text summary, and I want to save the P-value as a variable. How can I do this?
I couldn't find the answer in the documentation. However, on this line of the source code, the
CausalImpact.summarymethod passesself.p_valueto another function. The method that computed the p-value describes it as:You can see in the summary template that the "Posterior prob. of a causal effect" is computed as
(1 - p_value) * 100)(and some rounding).In your code, you should be able to access it programmatically as
ci.p_value.