API Reference
v0.0.1
Treatment Effect Estimation

medmodels.treatment_effect_estimation.continuous_estimators

average_treatment_effect

def average_treatment_effect(treated_set: pd.DataFrame,
                             control_set: pd.DataFrame,
                             outcome_variable: str) -> float

Calculates the Average Treatment Effect (ATE) as the difference between the outcome means of the treated and control sets. A positive ATE indicates that the treatment increased the outcome, while a negative ATE suggests a decrease.

The ATE is computed as follows when the numbers of observations in treated and control sets are N and M, respectively:

ATE=1Niy1(i)1Mjy0(j),\text{ATE} = \frac{1}{N} \sum_i y_1(i) - \frac{1}{M} \sum_j y_0(j),

where y1(i)y_1(i) and y0(j)y_0(j) represent outcome values for individual treated and control observations. In the case of matched sets with equal sizes (N = M), the formula simplifies to:

ATE=1Ni(y1(i)y0(i)).\text{ATE} = \frac{1}{N} \sum_i (y_1(i) - y_0(i)).

Arguments:

  • treated_set pd.DataFrame - DataFrame of the treated group.
  • control_set pd.DataFrame - DataFrame of the control group.
  • outcome_variable str - Name of the outcome variable.

Returns:

  • float - The average treatment effect.

    This function provides a simple yet powerful method for estimating the impact of a treatment by comparing average outcomes between treated and control groups.

cohen_d

def cohen_d(treated_set: pd.DataFrame,
            control_set: pd.DataFrame,
            outcome_variable: str,
            add_correction: bool = False) -> float

Calculates Cohen's D, the standardized mean difference between two sets, measuring the effect size of the difference between two outcome means. It's applicable for any two sets but is recommended for sets of the same size. Cohen's D indicates how many standard deviations the two groups differ by, with 1 standard deviation equal to 1 z-score.

A rule of thumb for interpreting Cohen's D:

  • Small effect = 0.2
  • Medium effect = 0.5
  • Large effect = 0.8

Arguments:

  • treated_set pd.DataFrame - DataFrame containing the treated group data.
  • control_set pd.DataFrame - DataFrame containing the control group data.
  • outcome_variable str - The name of the outcome variable to analyze.
  • add_correction bool, optional - Whether to apply a correction factor for small sample sizes. Defaults to False.

Returns:

  • float - The Cohen's D coefficient, representing the effect size.

    This metric provides a dimensionless measure of effect size, facilitating the comparison across different studies and contexts.

medmodels.treatment_effect_estimation.tests.test_continuous_estimators