causalis.data_contracts.causal_estimate

Module Contents

Classes

CausalEstimate

Result container for causal effect estimates.

API

class causalis.data_contracts.causal_estimate.CausalEstimate(/, **data: Any)

Bases: pydantic.BaseModel

Result container for causal effect estimates.

Parameters

estimand : str The estimand being estimated (e.g., ‘ATE’, ‘ATTE’, ‘CATE’). model : str The name of the model used for estimation. model_options : dict Options passed to the model. value : float The estimated absolute effect. ci_upper_absolute : float Upper bound of the absolute confidence interval. ci_lower_absolute : float Lower bound of the absolute confidence interval. value_relative : float, optional The estimated relative effect. ci_upper_relative : float, optional Upper bound of the relative confidence interval. ci_lower_relative : float, optional Lower bound of the relative confidence interval. alpha : float The significance level (e.g., 0.05). p_value : float, optional The p-value from the test. is_significant : bool Whether the result is statistically significant at alpha. n_treated : int Number of units in the treatment group. n_control : int Number of units in the control group. treatment_mean : float Mean outcome in the treatment group. For CUPED this is the raw observed mean, so treatment_mean - control_mean need not equal the adjusted ATE. control_mean : float Mean outcome in the control group; raw observed mean for CUPED. adjusted_treatment_mean : float, optional Regression-adjusted treatment mean when supplied by the estimator. CUPED evaluates this at the analysis-sample covariate mean (intercept plus treatment coefficient). adjusted_control_mean : float, optional Regression-adjusted control mean when supplied by the estimator. For CUPED this is the intercept; the difference of adjusted means is the adjusted ATE. For multiple arms the analysis sample is the selected active arm and control pair. outcome : str The name of the outcome variable. treatment : str The name of the treatment variable. confounders : list of str, optional The names of the confounders used in the model. time : str The date when the estimate was created (YYYY-MM-DD). diagnostic_data : DiagnosticData, optional Additional diagnostic data_contracts.

Initialization

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

model_config

‘ConfigDict(…)’

estimand: str

None

model: str

None

model_options: Dict[str, Any]

‘Field(…)’

value: float

None

ci_upper_absolute: float

None

ci_lower_absolute: float

None

value_relative: Optional[float]

None

ci_upper_relative: Optional[float]

None

ci_lower_relative: Optional[float]

None

alpha: float

None

p_value: Optional[float]

None

is_significant: bool

None

n_treated: int

None

n_control: int

None

treatment_mean: float

None

control_mean: float

None

adjusted_treatment_mean: Optional[float]

None

adjusted_control_mean: Optional[float]

None

outcome: str

None

treatment: str

None

confounders: List[str]

‘Field(…)’

time: str

‘Field(…)’

diagnostic_data: Optional[causalis.data_contracts.causal_diagnostic_data.DiagnosticData]

None

summary() → pandas.DataFrame

Return a summary DataFrame of the results.

CUPED estimates with diagnostics include variance reduction in percent, comparing adjusted and unadjusted effect variances with the same covariance estimator. Negative reductions are retained.

Returns

pd.DataFrame Summary DataFrame.