jamalsenouci / causalimpact

Python port of CausalImpact R library
Apache License 2.0
262 stars 62 forks source link

Think p-value was not calculated properly #21

Closed vukanv closed 2 years ago

vukanv commented 4 years ago

Thanks for this package!

assuming approximately normal distribution

    #calculate standard deviation from the 95% conf interval
    std_pred = (mean_upper - mean_pred) / 1.96
    #calculate z score
    z_score = (0 - mean_pred) / std_pred
    #convert to probability

think this takes values of original series, and these are almost always different from zero. Would be better to look at rel_effect_upper and rel_effect instead.

Also

p_value = st.norm.cdf(z_score) prob_causal = (100 - p_value)

p_value will be from 0 to 1, not sure if 1-p_value makes more sense..?