私はPythonで因果的影響分析を行っています。これは、対照群と比較した場合の介入後の治療群の影響を測定するのに役立ちます(A / Bテスト)。Python を使い始めるには、https://github.com/jamalsenouci/causalimpact/blob/master/GettingStarted.ipynbを参照しました。
私のデータが以下の形式になると仮定します:
Period_1 を処理、Period_2 をコントロールと見なす
次のコードは完全に機能します。
from causalimpact import CausalImpact
pre_period = [pd.to_datetime(date) for date in [start_date,cut_date_1]]
post_period = [pd.to_datetime(date) for date in [cut_date_2,end_date]]
impact = CausalImpact(df_AA.loc[start_date:end_date_AA], pre_period, post_period, model_args={"nseasons":7})
impact.run()
impact.plot()
2 つ下のグラフが表示されますが、予測値の信頼区間が実際の値と重なっているため、動きは統計的に有意ではないようです
しかし、私は最終的に動きが統計的に有意であるかどうかに答えたいと思います.治療と対照の間のp値は何ですか? そのために私が使用した
print(impact.summary())
print(impact.summary("report"))
私が得た結果は以下です。そして、p値は0.0であり、正の動きを示す統計があります。これは正しくないようです。実際と予測の差が非常に大きく、予測のCIではなく、実際と重複していない別のデータを試してみましたが、p値はまだ0でした。計算されたp値はこの値では正しくないようです。この因果関係ライブラリの p 値を自己計算するためのポインタはありますか、またはこのライブラリを修正する方法はありますか?
Average Cumulative
Actual 15 247
Predicted 15 246
95% CI [15, 15] [244, 249]
Absolute Effect 0 1
95% CI [0, 0] [3, -1]
Relative Effect 0.4% 0.4%
95% CI [1.5%, -0.6%] [1.5%, -0.6%]
P-value 0.0%
Prob. of Causal Effect 100.0%
None
During the post-intervention period, the response variable had an average value of approx. 15. By contrast, in the
absence of an intervention, we would have expected an average response of 15. The 90% interval of this counterfactual
prediction is [15, 15]. Subtracting this prediction from the observed response yields an estimate of the causal effect
the intervention had on the response variable. This effect is 0 with a 90% interval of [0, 0]. For a discussion of the
significance of this effect, see below.
Summing up the individual data points during the post-intervention period (which can only sometimes be meaningfully
interpreted), the response variable had an overall value of 247. By contrast, had the intervention not taken place, we
would have expected a sum of 247. The 90% interval of this prediction is [244, 249]
The above results are given in terms of absolute numbers. In relative terms, the response variable showed an increase
of 0.4%. The 90% interval of this percentage is [1.5%, -0.6%]
This means that the positive effect observed during the intervention period is statistically significant and unlikely
to be due to random fluctuations. It should be noted, however, that the question of whether this increase also bears
substantive significance can only be answered by comparing the absolute effect 0 to the original goal of the underlying
intervention.
None