I try to estimate relative risks (RRs) using - margins - after fitting a logistic model. Since log(RR) would is more normally distributed than RR, I am thinking of estimating log (RR) instead of RR, then exponentiate the point estimate and confidence interval. I see examples in the Stata pdf documentation and other posts that calculate RR directly, but I do not feel comfortable with the confidence interval symmetric around the point estimate. Also, I plan to obtain a p-value based on the test for log(RR) = 0. However, I wonder if estimating log(RR) would be a valid approach when estimating RRs based on predicted probabilities.
Code:
. use https://www.stata-press.com/data/r16/bangladesh, clear
. logit c_use i.urban age i.child3, or nolog
. margins child3, post
Predictive margins Number of obs = 1,934
Model VCE : OIM
Expression : Pr(c_use), predict()
------------------------------------------------------------------------------
| Delta-method
| Margin Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
child3 |
0 | .3677632 .0153692 23.93 0.000 .3376401 .3978862
1 | .432382 .0214472 20.16 0.000 .3903462 .4744177
------------------------------------------------------------------------------
. nlcom (RR: _b[1.child3] / _b[0.child3])
RR: _b[1.child3] / _b[0.child3]
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
RR | 1.175708 .0849553 13.84 0.000 1.009198 1.342217
------------------------------------------------------------------------------
. nlcom (log_RR: log(_b[1.child3] / _b[0.child3]))
log_RR: log(_b[1.child3] / _b[0.child3])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
log_RR | .1618703 .0722589 2.24 0.025 .0202455 .3034951
------------------------------------------------------------------------------
. local b = exp(r(b)[1,1])
. local lb = exp(r(b)[1,1] - 1.96*sqrt(r(V)[1,1]))
. local ub = exp(r(b)[1,1] + 1.96*sqrt(r(V)[1,1]))
. display %8.6f `b' " (" `lb' ", " `ub' ")"
1.175708 (1.0204492, 1.3545885)
Comment