📊

Lecture Notes on Inverse Probability Weighting

Jul 30, 2024

Lecture Notes on Inverse Probability Weighting

Introduction to Inverse Probability Weighting

  • Last approach for adjustment: inverse probability weighting (IPW)
  • Advantage: Retain data instead of throwing it away (e.g., 600 rows eliminated in matching)
  • Goal: Weight observations to account for unusual cases

Steps to Implement Inverse Probability Weighting

  1. Generate Propensity Scores

    • Model predicted probabilities for each observation
    • Use confounders from DAG (Directed Acyclic Graph) including:
      • Nighttime temperature
      • Income
      • Health
    • Use logistic regression to build a model to predict net usage.
  2. Logistic Regression Model

    • Use the glm function (Generalized Linear Model) to predict net usage: model_net <- glm(net ~ income + temperature + health, data = data, family = binomial(link = "logit"))
    • Extract results with tidy(model_net) for log odds
    • Exponentiate coefficients to interpret as odds ratios.
    • Example observations:
      • Temperature increase: 6% less likely to use a net
      • Income increase: 0.2% more likely to use a net
  3. Generating Propensity Scores

    • Create a new dataset with predicted probabilities: nets_ipw <- augment(model_net)
    • Keep necessary columns without losing data using augment_columns.
    • Convert predictions to propensities (0 to 1 probability scale).
  4. Creating Inverse Probability Weights

    • Add a new column for weights (IPW): nets_ipw <- nets_ipw %>% mutate(ipw = net_num / propensity + (1 - net_num) / (1 - propensity))
    • Sorting helps identify outliers with high inverse probability weights.

Estimation of Effects

  • Create a new section called find_effect for modeling with IPW: model_ipw <- lm(malaria_risk ~ net, data = nets_ipw, weights = ipw)
  • Use tidy(model_ipw) to view results of causal effect:
    • Causal effect estimated at negative 10, improved accuracy compared to previous models.

Comparing All Models

  • Use model_summary package to compare all models:
    • Combine models into a list:
    all_models <- list(naive = model_wrong, matched = model_matched, matched_weights = model_matched_weights, ipw = model_ipw)
  • Results display each model’s coefficients, standard errors, and causal effects.

Conclusion

  • Importance of making causal adjustments based on a DAG:
    • Results indicate the effectiveness of mosquito nets in reducing malaria risk through observational data.
    • Final report can be generated in R Markdown for sharing findings.