# How to calculate HR using attained age? [closed]

I want to calculate the hazard ratio for death by comparing individuals with a disease versus others without the disease, but I don't know if the calculation that I'm doing is correct.

Participants were asked for the presence of the disease one day between 2006-2010 (entry point), and then the deaths of those participants were tracked until a specific date in 2016 (exit point). The attained age was defined as the age of death (for death participants) or the age at the exit point (for participants alive).

if:

• disease = 0 (no disease) and disease = 1 (disease)
• status = 0 (alive) and status = 1 (dead)
• age_entry = age at entry point
• age_attained = attained age
• sex = 0 (male) and sex = 1 (female)

I'm using coxph(Surv(time = age_entry, time2 = age_attained, event = statis, origin = 0) ~ disease + sex)

Is this correct? Thanks

tdata$time <- tdata$age_attained - tdata\$age_entry # age_attained should be not NULL and time > 0