Jul 30, 2024
Generate Propensity Scores
Logistic Regression Model
glm function (Generalized Linear Model) to predict net usage:
model_net <- glm(net ~ income + temperature + health, data = data, family = binomial(link = "logit"))
tidy(model_net) for log oddsGenerating Propensity Scores
nets_ipw <- augment(model_net)
augment_columns.Creating Inverse Probability Weights
nets_ipw <- nets_ipw %>% mutate(ipw = net_num / propensity + (1 - net_num) / (1 - propensity))
find_effect for modeling with IPW:
model_ipw <- lm(malaria_risk ~ net, data = nets_ipw, weights = ipw)
tidy(model_ipw) to view results of causal effect:
model_summary package to compare all models:
all_models <- list(naive = model_wrong, matched = model_matched, matched_weights = model_matched_weights, ipw = model_ipw)