Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Margins after stcox with negative lower 95% CI - is there a fix?






    Dear all

    I have the following dataset with three binary variables, i.e. outcome (death after six months), older_65 (age above 65) and sex, as well as two continous variable, follow_up_days and age_years:

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float(age_years follow_up_days) byte(outcome older_65 sex_female1)
    72 358 0 1 0
    72 363 0 1 0
    76 357 0 1 0
    87 209 1 1 0
    66 363 0 1 0
    80 359 0 1 0
    61 360 0 0 0
    73 358 0 1 1
    81 359 1 1 0
    end
    label values outcome yes_no_lab
    label values sex_female1 sex_lab
    label values older_65 yes_no_lab
    label def yes_no_lab 0 "No", modify
    label def yes_no_lab 1 "Yes", modify
    label def sex_lab 0 "Male", modify
    label def sex_lab 1 "Female", modify
    I declared the data to be survival-time data and ran a cox regression with an interaction between older age (older 65 years) and sex and age as a covariate.
    I wanted to obtain the predicted hazard ratios according to the different strata adjusted for age, thus I used the - margins - respectively - marginsplot - command.

    Code:
    stset follow, failure(outcome)
    stcox i.older_65##i.sex_female1 age_years
    margins i.older_65#i.sex_female1
    marginsplot
    In the plot shown and the margins output (not shown) the 95% CI for the predicted Hazard ratios seem to be wrong as they are negative.

    Click image for larger version

Name:	Graph_1.png
Views:	2
Size:	232.5 KB
ID:	1654998

    Steve Samuels wrote here on a similar topic https://www.statalist.org/forums/for...ns-after-stcox an explanation why this happens, but unfortunately I could not find a fix for it:

    Margins uses the delta method to compute standard errors, then forms CIs by adding ± a multiple of the standard error. As a general purpose command, margins doesn't "know" that hazard ratios are supposed to be positive, so the CI extends below zero.
    Is there a fix for it? How can I get the correct 95% CI?

    Thank you in advance for your advise!

    Best wishes
    Martin
    Attached Files

  • #2
    https://www.statalist.org/forums/for...ns-after-stcox

    Useful? But you can't use marginsplot - you'll need to write your code to draw a plot.

    Comment


    • #3
      Dear Andrea

      Sorry for overseen your post. This was of great help!

      Thank you.

      Best wishes
      Martin

      Comment

      Working...
      X