Dear Statalist
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:
I wonder if there is a better way to obtain the HR for female vs. male in each age group than running the model twice and changing the baseline category. Margins is kind of tricky after stcox (see for instance https://www.statalist.org/forums/for...ns-after-stcox),
=> I obtain the age-adjusted HR comparing females with males in the older_65 == 0 (baseline group) in row for sex_female.
After changing the baseline category of older_65, I can obtain the age-adjusted HR comparing females with males in the older_65 == 1 (new baseline category) group (output omitted).
When the model takes a lot of time to calculate, it is odd to run it twice. Is there another way e.g. with lincom?
Thank you in advance for your help.
Martin
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 wonder if there is a better way to obtain the HR for female vs. male in each age group than running the model twice and changing the baseline category. Margins is kind of tricky after stcox (see for instance https://www.statalist.org/forums/for...ns-after-stcox),
Code:
stset follow, failure(outcome) stcox i.sex_female1##i.older_65 age_years Cox regression with Breslow method for ties No. of subjects = 1,746 Number of obs = 1,746 No. of failures = 449 Time at risk = 535,017 LR chi2(4) = 121.65 Log likelihood = -3227.9518 Prob > chi2 = 0.0000 _t Haz. ratio Std. err. z P>z [95% conf. interval] older_65 No 1.00 (base) Yes 1.87 0.24 4.95 0.000 1.46 2.39 sex_female1 Male 1.00 (base) Female 0.77 0.11 -1.77 0.077 0.58 1.03 older_65#sex_female1 Yes#Female 0.87 0.17 -0.70 0.481 0.60 1.27 age_years 1.03 0.00 7.40 0.000 1.02 1.04
After changing the baseline category of older_65, I can obtain the age-adjusted HR comparing females with males in the older_65 == 1 (new baseline category) group (output omitted).
Code:
stcox i.sex_female1##ib1.older_65 age_years
Thank you in advance for your help.
Martin
Comment