Balance CheckingΒΆ
- class CEM_LinearInf.balance(df_match: pd.DataFrame, df_all: pd.DataFrame, confounder_cols: list, cont_confounder_cols: list, col_y: str = 'Y', col_t: str = 'T')ΒΆ
Class of balance assessment for the matched data.
When we finish the coarsened exact matching, it is necessary to evaluate the quality of the matching with imbalance checking methods.
When the covariate balance is achieved, the resulting effect estimate is less sensitive to model misspecification and ideally close to true treatment effect (Greifer, 2023).
- The imbalance checking methods provided include:
βL1β: Calculate and return the L1 imbalance score.
βsmdβ: Print the standardized mean difference summary table and plots of confounders.
βksβ: Plot Kolmogorov-Smirnov Statistics of confounders before and after matching.
βdensityβ: Return density plots of confounders before and after matching.
βecdfβ: Return empirical cumulative density plots of confounders before and after matching.
- Parameters:
df_match (pd.Dataframe) β The dataframe after matching.
df_all (pd.Dataframe) β The original dataframe before matching.
confounder_cols (list) β The column names of confounders among all variables X.
cont_confounder_cols (list) β The column names of all continuous variables among confounders.
col_y (str) β The column name of result Y in your dataframe. If not specified, it would be βYβ.
col_t (str) β The column name of treatment T in your dataframe. If not specified, it would be βTβ.
- balance_assessing(self, method: str = 'smd', threshold: list = [0.1, 2], _print: bool = True)ΒΆ
Method for generating the imbalance assessing result.
- Parameters:
method (str) β
The method to be used for balance assessment. If itβs not specified, the default method is βsmdβ.
βL1β: Calculate and return the L1 imbalance score.
βsmdβ: Print the standardized mean difference summary table and plots of confounders.
βksβ: Plot Kolmogorov-Smirnov Statistics of confounders before and after matching.
βdensityβ: Return density plots of confounders before and after matching.
βecdfβ: Return empirical cumulative density plots of confounders before and after matching.
βallβ: Implement all the methods above.
threshold (list) β
When you choose βsmdβ to assess the balance, you can set the balance thresholds for smd and variance ratio.
If itβs not specified, the default thresholds are 0.1 and 2 for standardized mean difference and variance ratio respectively.
_print (bool) β Whether to print the L1 score.