Skip to content

Commit

Permalink
add IV balance
Browse files Browse the repository at this point in the history
  • Loading branch information
sdaza committed Jan 1, 2025
1 parent db824af commit e69425b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion experiment_utils/experiment_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(
propensity_score_method: str = 'logistic',
min_ps_score: float = 0.05,
max_ps_score: float = 0.95,
interaction_logistic_ipw: bool = False,
interaction_logistic_ipw: bool = True,
instrument_col: Optional[str] = None,
alpha: float = 0.05,
regression_covariates: Optional[List[str]] = None,
Expand Down Expand Up @@ -395,6 +395,14 @@ def get_effects(self, min_binary_count: int = 100, adjustment: Optional[str] = N
temp_pd[temp_pd[self.treatment_col] == 0].propensity_score)
self.logger.info('::::: Overlap: %.2f', np.round(overlap, 2))

if adjustment == "IV":
if self.instrument_col is None:
log_and_raise_error(self.logger, "Instrument column is required for IV estimation!")
iv_balance = self.calculate_smd(
data=temp_pd, covariates=final_covariates
)
self.logger.info('::::: IV Balance: %.2f', np.round(iv_balance["balance_flag"].mean(), 2))

# create adjustment label
relevant_covariates = set(self.final_covariates) & set(self.regression_covariates)

Expand Down

0 comments on commit e69425b

Please sign in to comment.