SyntheticControl.from_pre_period#

classmethod SyntheticControl.from_pre_period(data, control_units, treated_units, model=None, min_donor_correlation=0.0)[source]#

Create a design-phase SC fitted only on pre-period data.

Use this before running an experiment to assess design feasibility via donor_pool_quality(), validate_design(), and power_analysis().

All provided data is treated as pre-period (no post-period observations are required).

Parameters:
  • data (DataFrame) – Historical data (pre-period only). All rows are used for model fitting.

  • control_units (list[str]) – Column names for control units.

  • treated_units (list[str]) – Column names for treated units.

  • model (PyMCModel | RegressorMixin | None) – Model to fit. Defaults to WeightedSumFitter.

  • min_donor_correlation (float) – Minimum acceptable donor correlation (see constructor).

Returns:

A fitted instance whose design methods are ready to use. Plotting and effect summary methods are not available (no post-period data).

Return type:

SyntheticControl

Examples

>>> import causalpy as cp
>>> df = cp.load_data("sc")
>>> pre_data = df[df.index < 70]  # only historical data
>>> design = cp.SyntheticControl.from_pre_period(
...     pre_data,
...     control_units=["a", "b", "c", "d", "e", "f", "g"],
...     treated_units=["actual"],
...     model=cp.pymc_models.WeightedSumFitter(
...         sample_kwargs={"progressbar": False, "random_seed": 42}
...     ),
... )