Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Balance summary / Variance #47

Open
kali-alex opened this issue Mar 22, 2024 · 1 comment
Open

Balance summary / Variance #47

kali-alex opened this issue Mar 22, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@kali-alex
Copy link

  • How can we have the balance summary across each covariates for the propensity score ? (To calcul the Standardized Mean Difference for example)

  • Which estimator is use to compute the variance (and thus 95%CI) ?

@yqzhong7 yqzhong7 self-assigned this Mar 23, 2024
@yqzhong7 yqzhong7 added the enhancement New feature or request label Mar 23, 2024
@yqzhong7
Copy link
Owner

How can we have the balance summary across each covariates for the propensity score ? (To calcul the Standardized Mean Difference for example)

You could extract the propensity scores and put them into other packages like cobalt. Please refer to cobalt for more details. I'll add cobalt support in the near future.

Here's a short example for using cobalt to example the balance.

library(AIPW)
library(cobalt)
library(SuperLearner)

set.seed(123)
data("eager_sim_obs")
cov = c("eligibility","loss_num","age", "time_try_pregnant","BMI","meanAP")

AIPW_SL <- AIPW$new(Y= eager_sim_obs$sim_Y,
                    A= eager_sim_obs$sim_A,
                    W= subset(eager_sim_obs,select=cov), 
                    Q.SL.library = c("SL.mean","SL.glm"),
                    g.SL.library = c("SL.mean","SL.glm"),
                    k_split = 10,
                    verbose=FALSE)$
  fit()$ #for ATT please use stratified_fit()
  summary(g.bound = c(0.025,0.975)) #Default truncation of propsensity scores


ate.weights <- function(aipw_obj,estimand = c("ATE","ATT")) {
  call <- match.call()
  out <- list(treat = aipw_obj$.__enclos_env__$private$A,
              covs = aipw_obj$.__enclos_env__$private$g.set,
              distance = aipw_obj$obs_est$p_score, #change this to `aipw_obj$obs_est$raw_p_score` for untruncated ps
              weights = aipw_obj$obs_est$ip_weights,
              estimand = estimand,
              call = call)
  return(out)
}

out <- ate.weights(AIPW_SL,"ATE")

bal.tab(out)

Which estimator is use to compute the variance (and thus 95%CI) ?

We used the delta method for variance estimations. You can find more in our manuscript (Derivations are in the Appendix 2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants