BaseExperiment#

class causalpy.experiments.base.BaseExperiment[source]#

Base class for quasi experimental designs.

Subclasses should set _default_model_class to a PyMC model class (e.g. LinearRegression) so that model=None instantiates a sensible Bayesian default. To use an OLS/sklearn model — or, for experiments that declare supports_pymc_forecast, a PyMCForecastModel — pass one explicitly.

Parameters:

model (PyMCModel | RegressorMixin | PyMCForecastModel | None) – Model instance to use. If None and _default_model_class is set, an instance of that default class is constructed.

Notes

Optional maketables integration is exposed through __maketables_* hooks. Users can control the HDI interval level used by ETable(result) via set_maketables_options(), for example: result.set_maketables_options(hdi_prob=0.95).

Methods

BaseExperiment.build()

Construct the model graph without sampling anything.

BaseExperiment.effect_summary(*[, group])

Generate a decision-ready summary of causal effects.

BaseExperiment.fit(**kwargs)

Run the posterior phase and populate result.

BaseExperiment.generate_report(*[, ...])

Generate a self-contained HTML report for this experiment.

BaseExperiment.print_coefficients([round_to])

Ask the model to print its posterior coefficients.

BaseExperiment.sample_prior_predictive(**kwargs)

Run the optional prior phase and populate prior_result.

BaseExperiment.set_maketables_options(*[, ...])

Set optional maketables rendering options for this experiment.

Attributes

has_prior_predictive

Whether the prior phase has run (draws, and bundle where kept).

idata

Return fitted DataTree when the model backend supports it.

is_built

Whether the model graph / fit design exists (no draws implied).

is_configured

design matrices are ready.

is_fitted

Whether posterior draws and the posterior result bundle exist.

model

The underlying model instance.

prior_result

Prior-group result bundle; raises before prior sampling.

result

Posterior-group result bundle; raises before fit().

supports_pymc_forecast

labels

data

supports_bayes

supports_ols

__init__(model=None)[source]#
Parameters:

model (PyMCModel | RegressorMixin | PyMCForecastModel | None)

Return type:

None

classmethod __new__(*args, **kwargs)#