SyntheticControl#

class causalpy.experiments.prepostfit.SyntheticControl[source]#

A wrapper around the PrePostFit class

Parameters:
  • data (DataFrame) – A pandas dataframe

  • treatment_time (Union[int, float, Timestamp]) – The time when treatment occured, should be in reference to the data index

  • formula (str) – A statistical model formula

  • model – A PyMC model

Example

>>> import causalpy as cp
>>> df = cp.load_data("sc")
>>> treatment_time = 70
>>> seed = 42
>>> result = cp.SyntheticControl(
...     df,
...     treatment_time,
...     formula="actual ~ 0 + a + b + c + d + e + f + g",
...     model=cp.pymc_models.WeightedSumFitter(
...         sample_kwargs={
...             "target_accept": 0.95,
...             "random_seed": seed,
...             "progressbar": False,
...         }
...     ),
... )

Methods

SyntheticControl.__init__(data, ...[, model])

SyntheticControl.bayesian_plot(*args, **kwargs)

Plot the results

SyntheticControl.input_validation(data, ...)

Validate the input data and model formula for correctness

SyntheticControl.ols_plot([round_to])

Plot the results

SyntheticControl.plot(*args, **kwargs)

Plot the model.

SyntheticControl.print_coefficients([round_to])

Ask the model to print its coefficients.

SyntheticControl.summary([round_to])

Print summary of main results and model coefficients.

Attributes

expt_type

idata

Return the InferenceData object of the model.

supports_bayes

supports_ols

__init__(data, treatment_time, formula, model=None, **kwargs)#
Parameters:
Return type:

None

__new__(**kwargs)#