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 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
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.
Thank you in advance for your advise!
Best wishes
Martin
Comment