Hello,
I am wanting to examine whether the effect of age at first sex (categorical) on any condom use varies by race (categorical). I would like to use the margins command to examine this interaction effect. However, I get different predictions of margins depending on whether # is used or the option “over.” Can anyone tell if my understanding of these approaches is correct, and if one approach is preferred over the other?
Am I correct in that the first approach (using #) gives me the predicted probabilities of my outcome for each level of combination of race and agesex, averaged over the entire sample, but the second approach (using the over option) gives me the average predicted probability for cases where, for example, race=1 & agesex=10-14, using each case’s observed values of the remaining covariates (agecat, forborn)?
FIRST
SECOND
Thank you,
Pina
I am wanting to examine whether the effect of age at first sex (categorical) on any condom use varies by race (categorical). I would like to use the margins command to examine this interaction effect. However, I get different predictions of margins depending on whether # is used or the option “over.” Can anyone tell if my understanding of these approaches is correct, and if one approach is preferred over the other?
Am I correct in that the first approach (using #) gives me the predicted probabilities of my outcome for each level of combination of race and agesex, averaged over the entire sample, but the second approach (using the over option) gives me the average predicted probability for cases where, for example, race=1 & agesex=10-14, using each case’s observed values of the remaining covariates (agecat, forborn)?
FIRST
Code:
qui svy, subpop(analysis): logistic anycondom i.agecat i.forborn i.r_race#i.agesex
margins i.r_race#i.agesex, vce(unconditional) subpop(analysis) post
-------------------------------------------------------------------------------
| Linearized
| Margin Std. Err. t P>|t| [95% Conf. Interval]
--------------+----------------------------------------------------------------
r_race#agesex |
white#10-14 | .7736561 .0292001 26.49 0.000 .7161024 .8312098
white#15-17 | .8008249 .0160967 49.75 0.000 .7690983 .8325516
white#18+ | .8213903 .0257654 31.88 0.000 .7706065 .8721741
black#10-14 | .6576579 .0368583 17.84 0.000 .58501 .7303058
black#15-17 | .8082099 .0255963 31.58 0.000 .7577594 .8586604
black#18+ | .7698533 .0474066 16.24 0.000 .6764146 .863292
hisp#10-14 | .7336142 .0353473 20.75 0.000 .6639443 .803284
hisp#15-17 | .8012716 .024969 32.09 0.000 .7520576 .8504856
hisp#18+ | .6773357 .0503757 13.45 0.000 .5780449 .7766265
-------------------------------------------------------------------------------
SECOND
Code:
qui svy, subpop(analysis): logistic anycondom i.agecat i.forborn i.r_race#i.agesex
margins, subpop(analysis) over(agesex) at(r_race=(1(1)3)) vce(unconditional) post
------------------------------------------------------------------------------
| Linearized
| Margin Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_at#agesex |
1#10-14 | .7330589 .0319435 22.95 0.000 .670098 .7960198
1#15-17 | .8123765 .0152806 53.16 0.000 .7822583 .8424948
1#18+ | .8298955 .0235333 35.26 0.000 .7835111 .8762799
2#10-14 | .6079378 .0367743 16.53 0.000 .5354553 .6804202
2#15-17 | .8194623 .0245447 33.39 0.000 .7710845 .8678401
2#18+ | .7796862 .0479434 16.26 0.000 .6851895 .8741829
3#10-14 | .6890951 .0373569 18.45 0.000 .6154643 .7627259
3#15-17 | .8128054 .0243265 33.41 0.000 .7648576 .8607532
3#18+ | .6886188 .050042 13.76 0.000 .5899857 .787252
------------------------------------------------------------------------------
Thank you,
Pina

Comment