Hello, I would like to carry out a mediation analysis with multiple mediators using the Inverse Odds Ratio Weighting. Briefly it aims to identify the effect of a binary exposure (e.g. intervention to reduce obesity) on a contiunous outcome (e.g. change in BMI) through multiple mediators (e.g. change in physical activity, diet). The Inverse Odds Ratio Weighting allows to identify total, direct and indirect effect of the relation explained above. I found an article with the Stata code to compute it but, i'm unable to translate it into SAS code. Here is the article: https://www.ncbi.nlm.nih.gov/pubmed/25693776 And the Stata Code : NOTE: Bold sections are variables names, lists, or parameters chosen by the user.
*Define a user-written program ;
capture program drop IOW
program IOW , rclass
*Retain estimates of predicted probability, inverse odds, and inverse odds weights for later use ;
capture drop predprob inverseodds wt_iow
*Insert regression of binary treatment on mediators and covariates, using a logit model weighted by the
original sample weight (if the treatment is a normally distributed continuous variable, use a linear
regression model instead) ;
logit treatment mediator1 mediator2 covariate1 covariate2
*Obtain predicted probability for each individual based on the above regression model;
predict predprob , p
*Calculate each individual’s inverse odds from the predicted probability ;
gen inverseodds = ((1-predprob)/predprob)
*Calculate inverse odds weights; for control members (i.e., people without the treatment or exposure),
inverse odds weight = the original sampling weights (or 1 if there are no sample weights). For treatment
members, inverse odds weight = inverse odds x original sampling weights (or simply the inverse odds if
there are no sample weights) ;
gen wt_iow = 1if treatment==0
replace wt_iow = inverseodds if treatment==1
* Insert the total effect regression here and retain estimate of total effects for later use. Here we use
Poisson regression, but other weighted regression models can be utilized instead ;
glm outcome treatment covariate1 covariate2 , fam(poisson) link(log) vce(robust)
matrix bb_total= e(b)
scalar b_total=bb_total[1,1]
return scalar b_total=bb_total[1,1]
* Insert the direct effect regression, which is the same as the total effect regression but applying the
inverse odds weight. Retain estimate of direct effects. Calculate indirect effects as the difference
between total effects and direct effects. Any alternative expression of the indirect effects could also be
used (for example the % of the total effect that is indirect could be calculated as: (b_totalb_direct)/b_total ;
glm outcome treatment covariate1 covariate2 [pweight=wt_iow] , fam(poisson) link(log) vce(robust)
matrix bb_direct = e(b)
scalar b_direct=bb_direct[1,1]
return scalar b_direct=bb_direct[1,1]
return scalar b_indirect = b_total-b_direct
end
* Request bootstrapped estimates of indirect, direct and total effects. Provide initial value of the
random-number seed so estimates can be replicated at a later time. Request 1000 bootstrap
replications ;
bootstrap r(b_indirect) r(b_direct) r(b_total), seed(32222) reps(1000): IOW Can someone help to translate this code ? If I'm not clear enough, don't hesitate to ask me for clarification. In advance thank you Florian
... View more