PrePostNEGD#
- class causalpy.experiments.prepostnegd.PrePostNEGD[source]#
A class to analyse data from pretest/posttest designs
- Parameters:
data (
DataFrame
) – A pandas dataframeformula (
str
) – A statistical model formulagroup_variable_name (
str
) – Name of the column in data for the group variable, should be either binary or booleanpretreatment_variable_name (
str
) – Name of the column in data for the pretreatment variablemodel – A PyMC model
Example
>>> import causalpy as cp >>> df = cp.load_data("anova1") >>> seed = 42 >>> result = cp.PrePostNEGD( ... df, ... formula="post ~ 1 + C(group) + pre", ... group_variable_name="group", ... pretreatment_variable_name="pre", ... model=cp.pymc_models.LinearRegression( ... sample_kwargs={ ... "target_accept": 0.95, ... "random_seed": seed, ... "progressbar": False, ... } ... ) ... ) >>> result.summary(round_to=1) ==================Pretest/posttest Nonequivalent Group Design=================== Formula: post ~ 1 + C(group) + pre Results: Causal impact = 2, $CI_{94%}$[2, 2] Model coefficients: Intercept -0.5, 94% HDI [-1, 0.2] C(group)[T.1] 2, 94% HDI [2, 2] pre 1, 94% HDI [1, 1] sigma 0.5, 94% HDI [0.5, 0.6]
Methods
PrePostNEGD.__init__
(data, formula, ...[, model])PrePostNEGD.bayesian_plot
([round_to])Generate plot for ANOVA-like experiments with non-equivalent group designs.
Validate the input data and model formula for correctness
PrePostNEGD.ols_plot
(*args, **kwargs)Abstract method for plotting the model.
PrePostNEGD.plot
(*args, **kwargs)Plot the model.
PrePostNEGD.print_coefficients
([round_to])Ask the model to print its coefficients.
PrePostNEGD.summary
([round_to])Print summary of main results and model coefficients.
Attributes
idata
Return the InferenceData object of the model.
supports_bayes
supports_ols
- __init__(data, formula, group_variable_name, pretreatment_variable_name, model=None, **kwargs)[source]#
- __new__(**kwargs)#