feat: R-compatible summary format with full CausalImpactResults#6
Merged
Conversation
…ible summary format CausalImpactResults に14個の新フィールドを追加し、summary() 出力を R CausalImpact と同等のフォーマットに改修。 Why: v0.1.0の summary() 出力には「-」プレースホルダーが残っており、 Actual行やPrediction (s.d.)行が表示できない状態だった。 Changes: - analysis.py: actual, predictions_sd, average_prediction_sd/lower/upper, cumulative_prediction_sd/lower/upper, average_effect_sd, cumulative_effect_sd, relative_effect_sd/lower/upper の14フィールド追加 - analysis.py: compute_effects() に cross-sample 集約計算を追加 (n_samples=1 の ddof=1 NaN を 0 にクランプ) - summary.py: R互換フォーマット実装 (Actual行、Prediction(s.d.)行、 3つのCI行、Posterior prob. 常時表示) - test_summary.py: CI行の行番号修正 (7→8、新フォーマットで行位置変更)
- test_plot.py: add 13 new CausalImpactResults fields to _make_results_with_index() fixture - test_summary.py: shorten test method name to fix E501 - test_analysis.py: shorten two test method names to fix E501
YuminosukeSato
added a commit
that referenced
this pull request
Mar 23, 2026
feat: R-compatible summary format with full CausalImpactResults
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CausalImpactResultsto match R CausalImpact summary outputn_samples=1to preventddof=1NaNChanged files
python/causal_impact/analysis.pyCausalImpactResults+ cross-sample aggregation incompute_effectspython/causal_impact/summary.pytests/test_summary.pysummary() output (Before → After)
Before:
After:
Test plan
test_analysis.py: 28 passed (2 previously Red tests now Green)test_summary.py: 8 passed (all 8 previously Red tests now Green)