Skip to content

Add residual-noise sensitivity checks to power_analysis#917

Open
bhemaraju138-pixel wants to merge 1 commit into
pymc-labs:feature/sc-design-workflowfrom
bhemaraju138-pixel:issue-914-noise-sensitivity
Open

Add residual-noise sensitivity checks to power_analysis#917
bhemaraju138-pixel wants to merge 1 commit into
pymc-labs:feature/sc-design-workflowfrom
bhemaraju138-pixel:issue-914-noise-sensitivity

Conversation

@bhemaraju138-pixel
Copy link
Copy Markdown

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_gaussian preserves the current behavior.
  • block_bootstrap resamples centered pre-period residuals in overlapping contiguous blocks. When block_length=None, it uses ceil(sqrt(n_pre)); users can override it.
  • ar1 centers the residual path, estimates phi by least squares on lagged residuals, clips it to the stationary range, estimates the innovation scale, and simulates a zero-mean AR(1) residual path.
  • Very short pre-periods are handled explicitly: AR(1) requires at least three residual observations, while block bootstrap validates block_length.
  • random_seed now makes both residual noise and generated refit seeds reproducible unless the user explicitly supplies sample_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:

  • default iid Gaussian behavior
  • block-bootstrap and AR(1) power-analysis calls
  • invalid noise_method
  • invalid block_length
  • AR(1) short-pre-period validation
  • reproducible helper draws under fixed seeds
  • autocorrelation sanity checks on synthetic AR(1) residuals

Documentation

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

@review-notebook-app
Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@github-actions
Copy link
Copy Markdown
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:

  • ✅ Make sure all CI checks pass (tests, linting, type checking)
  • 📝 Run prek run --all-files locally before pushing
  • 📖 Check our Contributing Guide for more details

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.

@bhemaraju138-pixel bhemaraju138-pixel marked this pull request as ready for review May 14, 2026 18:14
@read-the-docs-community
Copy link
Copy Markdown

Documentation build overview

📚 causalpy | 🛠️ Build #32693558 | 📁 Comparing bffd72a against latest (f4d8801)

  🔍 Preview build  

216 files changed · + 25 added · ± 135 modified · - 56 deleted

+ Added

± Modified

- Deleted

@juanitorduz juanitorduz requested a review from drbenvincent May 19, 2026 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants