Dear all,
I am trying to calculate inverse probability weights after multiple imputations due to missingness in a number of linear confounders. I am hoping for some feedback on my approach, given that this is my first try and nobody around me has any experience. I have done an extensive search on stata list as well as stack exchange and went through the whole stata manual on mi, but could unfortunately not find a solution. The code that I am currently using is the following:
I am trying to calculate inverse probability weights after multiple imputations due to missingness in a number of linear confounders. I am hoping for some feedback on my approach, given that this is my first try and nobody around me has any experience. I have done an extensive search on stata list as well as stack exchange and went through the whole stata manual on mi, but could unfortunately not find a solution. The code that I am currently using is the following:
Code:
##MI settings mi set mlong ##registering missing continuous variables mi register imputed age bmi sytolic_bp ##imputing missing data mi impute chained (regress) age bmi systolic_bp = country copd sex kidney_disease treatment, add(5) rseed(1235) mi estimate, eform saving(saved) : logistic treatment age bmi systolic_bp country copd sex kidney_disease #predicting linear predictors mi predict pi using saved #calculating probabilities quietly mi xeq: generate phat2 = invlogit(p3) #calculating inverse probability weights quietly mi xeq: gen ipw2=. quietly mi xeq: replace ipw2= 1/phat2 if ace_bi==1 quietly mi xeq: replace ipw2= 1/(1-phat2) if ace_bi==0 #setting survival settings mi stset time [pweight = ipw2], failure(death) #running survival analysis mi estimate, eform: stcox i.treatment

Comment