Add residual-noise sensitivity checks to power_analysis#917
Open
bhemaraju138-pixel wants to merge 1 commit into
Open
Conversation
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Contributor
|
👋 Welcome to CausalPy, @bhemaraju138-pixel! Thank you for opening your first pull request! We're excited to have you contribute to the project. 🎉 Here are a few tips to help your PR get merged smoothly:
A maintainer will review your changes soon. Thanks for helping make CausalPy better! 🚀 💼 LinkedIn Shoutout: Once your PR is merged, we'd love to give you a shoutout on LinkedIn to thank you for your contribution! If you're interested, just drop your LinkedIn profile URL in a comment below. |
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
Closes #914.
This PR keeps the existing iid Gaussian residual-noise simulation in
SyntheticControl.power_analysis()as the default, and adds two opt-in residual simulation methods for sensitivity analysis:noise_method="block_bootstrap"noise_method="ar1"It also documents the assumptions behind the default iid Gaussian scheme, clarifies that the resulting power curve is heuristic, and adds tests for the default and alternative methods.
Motivation
The existing implementation perturbs only the treated unit’s pre-period values with iid Gaussian noise scaled by a scalar residual standard deviation. That is simple and backward-compatible, but it assumes independent and homoscedastic residual variation. For synthetic-control time series, residuals may be autocorrelated, seasonal, heteroscedastic, or affected by structural misfit.
This PR does not replace the default. Instead, it makes the assumptions explicit and gives users opt-in sensitivity checks for whether the power curve changes under residual-noise models that preserve short-range dependence.
Design
iid_gaussianpreserves the current behavior.block_bootstrapresamples centered pre-period residuals in overlapping contiguous blocks. Whenblock_length=None, it usesceil(sqrt(n_pre)); users can override it.ar1centers the residual path, estimatesphiby least squares on lagged residuals, clips it to the stationary range, estimates the innovation scale, and simulates a zero-mean AR(1) residual path.block_length.random_seednow makes both residual noise and generated refit seeds reproducible unless the user explicitly suppliessample_kwargs["random_seed"].These methods are intentionally framed as sensitivity checks, not as canonical SC sampling-distribution power analysis. Users should still compare against placebo-in-space and placebo-in-time diagnostics.
Tests
Added coverage for:
noise_methodblock_lengthDocumentation
Updated the
power_analysis()docstring and the Prop 99 notebook narrative to describe the residual resampling assumptions and show a sensitivity comparison across noise methods.References
The iid Gaussian treated-only perturbation is documented as a heuristic because I did not find a clean SC reference endorsing that exact scheme. The block-bootstrap alternative is motivated by Künsch (1989), while Abadie (2021) is cited for general synthetic-control feasibility and placebo-diagnostic framing.
Validation
.venv/bin/python -m pytest causalpy/tests/test_sc_design.py -k "PowerAnalysis or noise" --no-cov.venv/bin/prek run --all-files