Skip to content

Filtering

filter_common_support

filter_common_support(df: DataFrame, ps_col: str = PS_COL, treatment_col: str = TREATMENT_COL, threshold: float = 0.05) -> pd.DataFrame

Filters individuals based on common support in propensity scores, removing those outside the range.

Parameters:

Name Type Description Default
df DataFrame

Input DataFrame containing columns for the propensity score and treatment status.

required
ps_col str

Column name for the propensity score.

PS_COL
treatment_col str

Column name for the treatment status (1 for treated, 0 for control).

TREATMENT_COL
threshold float

Quantile threshold (default 0.05) to trim the tails of the distribution for better common support.

0.05

Returns:

Type Description
DataFrame

DataFrame after removing individuals without common support.

Source code in CausalEstimate/filter/propensity.py
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
def filter_common_support(
    df: pd.DataFrame,
    ps_col: str = PS_COL,
    treatment_col: str = TREATMENT_COL,
    threshold: float = 0.05,
) -> pd.DataFrame:
    """
    Filters individuals based on common support in propensity scores, removing those outside the range.

    Args:
        df: Input DataFrame containing columns for the propensity score and treatment status.
        ps_col: Column name for the propensity score.
        treatment_col: Column name for the treatment status (1 for treated, 0 for control).
        threshold: Quantile threshold (default 0.05) to trim the tails of the
            distribution for better common support.

    Returns:
        DataFrame after removing individuals without common support.
    """
    common_min, common_max = get_common_support_range(
        df, treatment_col, ps_col, threshold
    )
    filtered_df = filter_column(df, ps_col, common_min, common_max)
    return filtered_df