Theoretical examples
| Example 1 In this example, we estimate the association between age (x) and hospitalization for attempted suicide (y) among individuals ages 18 to 45 over a five-year period. The failure event is hospitalization for attempted suicide (0=No event, 1=Event). Age is coded into three categories: 1=Ages 18-25, 2=Ages 26-35, and 3=Ages 36-45. Ages 36-45 is selected as the reference category (HR=1.00). For Ages 18-25, HR=3.77; for Ages 26-35, HR=1.08. This means that, compared to individuals ages 36-45, individuals ages 18-25 have a 3.77 times higher risk for hospitalization for attempted suicide, whereas individuals ages 26-35 have a 1.08 times higher risk for hospitalization compared to the reference category. |
| Example 2 We are interested in the relationship between marital status (x) and death attributable to Covid-19 over a six-month period. The failure event is death due to Covid-19 (y) (0=No event, 1=Event). Marital status is coded in four categories: 1=Married (reference category), 2=Divorced, 3=Widowed, and 4=Never married. The HRs for divorced, widowed, and never married individuals are 1.56, 1.98, and 2.47, respectively. Relative to those who are married, divorced, widowed, and never-married individuals have a higher hazard of mortality from Covid-19. |
| Note This example is largely based on the following publication: Drefahl, S., et al. (2020). Socio-demographic risk factors of COVID-19 deaths in Sweden: A nationwide register study. Stockholm Research Reports in Demography. |
Practical example
| Dataset |
| StataData1.dta |
| Variable name | cvd |
| Variable label | Out-patient care due to CVD (Ages 41-50, Year 2011-2020) |
| Value labels | 0=No 1=Yes |
| Variable name | marstat40 |
| Variable label | Marital status (Age 40, Year 2010) |
| Value labels | 1=Married 2=Unmarried 3=Divorced 4=Widowed |
sum cvd marstat40 if pop_cox==1 |

The variable marstat40 has four categories: 1=Married, 2=Unmarried, 3=Divorced, and 4=Widowed. Here, we (with ib1) specify that the first category (Married) will be the reference category.
stcox ib1.marstat40 if pop_cox==1, noshow |

When we look at the results for the dummies for marstat40, we see that the hazard ratio is 2.87 for Unmarried, 3.11 for Divorced, and 2.46 for Widowed. Thus, all three groups have much higher hazards of out-patient care due to CVD compared to those who are married.
All three dummies for marstat40 are significantly different from the reference category, as reflected in the p-values and the 95% confidence intervals.
Kaplan-Meier curves
It is possible to illustrate survival curves (or failure curves) separately for the categories of marstat40, by means of the Kaplan-Meier estimator. Due to the few cases occurring in the category Widowed, however, the confidence intervals go bananas. Therefore, we will not include the ci option below.
sts graph if pop_cox==1, survival noorigin ylabel(.90(0.02)1) xlabel(40(1)51) by( |

More informationhelp sts graph |
While we already know this from the Cox regression analysis, it is possible to use a log-rank test to assess whether the differences between the curves of married, unmarried, divorced, and widowed individuals are statistically significant. This tests the hypothesis that there is no difference between the groups. If the test is statistically significant (p<0.05), we reject this hypothesis.
sts test marstat40 if pop_cox==1, noshow |

In this case, the p-value (Pr>chi2) is below 0.05 (0.000), suggesting that there is a statistically significant difference between the categories of marital status in the probability of out-patient care due to CVD.
More informationhelp sts test |
| Note Since marstat40 is not an ordinal variable, there is no point of using marginsplot to plot any trend. |
| Summary At age 40, being unmarried, divorced, or widowed is associated with significantly higher risks of out-patient care due to CVD, as compared to being married. |