Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.

# Re: st: Why do the stcox CI differ when using margins?

 From William Buchanan To "statalist@hsphsun2.harvard.edu" Subject Re: st: Why do the stcox CI differ when using margins? Date Mon, 25 Feb 2013 05:16:53 -0800

```Hi Radoslaw,

Although this isn't a direct answer to your question, the best advice I could offer is to check the _methods and formulas_ section of the documentation for each of the respective commands.  Also, have you tried fitting the same model including the interaction effect that you estimated in the -margins- command.

HTH,
Billy

Sent from my iPhone

On Feb 25, 2013, at 4:50, Radoslaw Panczak <r.panczak@gmail.com> wrote:

> Dear Statalisters
>
> I'm trying to understand how the margins and marginsplot work after
> stcox command in Stata.
>
> Starting with a dumb example:
>
> webuse stan3
> stset
> stcox i.posttran i.surg
>
> We can obtain following results:
>
> ------------------------------------------------------------------------------
>          _t | Haz. Ratio   Std. Err.      z    P>|z|     [95% Conf. Interval]
> -------------+----------------------------------------------------------------
>  1.posttran |   1.173034   .3444712     0.54   0.587     .6597023    2.085801
>   1.surgery |   .3449043   .1482592    -2.48   0.013     .1485267    .8009264
> ------------------------------------------------------------------------------
>
> Now, when I use
>
> margins, over( posttran surgery )
>
> The output is
>
> Predictive margins                                Number of obs   =        172
> Model VCE    : OIM
>
> Expression   : Relative hazard, predict()
> over         : posttran surgery
>
> ----------------------------------------------------------------------------------
>                 |            Delta-method
>                 |     Margin   Std. Err.      z    P>|z|     [95%
> Conf. Interval]
> -----------------+----------------------------------------------------------------
> posttran#surgery |
>            0 0  |          1          .        .       .            .
>          .
>            0 1  |   .3449043   .1482592     2.33   0.020     .0543217
>   .6354869
>            1 0  |   1.173034   .3444712     3.41   0.001     .4978826
>   1.848185
>            1 1  |   .4045843   .2057569     1.97   0.049     .0013083
>   .8078604
> ----------------------------------------------------------------------------------
>
> What is puzzling me here is the fact that estimates and their Std.
> errors are the same as when using stcox. However - the CI, z and p are
> now different.
>
> What is causing such behaviour?
>
> Thank you for help,
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/
```