Thank you Clyde Schechter. To test my understanding, I ran -margins- after using ##, and I see (based on the output in #12) that it gave me the same HRs and standard errors (but slightly different Z, significance and confidence intervals).
A key benefit of this approach is that you get both the main and interaction effects in the output using ## and the total effects from the -margins- output. Is that what you meant?
Code:
. qui stcox i.hormon##i.x4 . margins x4, at(hormon=(0 1)) Adjusted predictions Number of obs = 686 Model VCE : OIM Expression : Predicted hazard ratio, predict() 1._at : hormon = 0 2._at : hormon = 1 ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- _at#x4 | 1 1 | 1 . . . . . 1 2 | 2.430562 .7320229 3.32 0.001 .9958238 3.865301 1 3 | 2.886813 .9192041 3.14 0.002 1.085206 4.68842 2 1 | .6954293 .3479263 2.00 0.046 .0135062 1.377352 2 2 | 1.61053 .5062316 3.18 0.001 .6183339 2.602725 2 3 | 2.533564 .902651 2.81 0.005 .7644 4.302727 ------------------------------------------------------------------------------
Comment