# 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

## closed as off-topic by Tim♦Sep 6 '18 at 11:33

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question appears to be off-topic because EITHER it is not about statistics, machine learning, data analysis, data mining, or data visualization, OR it focuses on programming, debugging, or performing routine operations within a statistical computing platform. If the latter, you could try the support links we maintain." – Tim
If this question can be reworded to fit the rules in the help center, please edit the question.

I think your code is not suitable because it calculates survival function from the birth date of subjects.

tdata$time <- tdata$age_attained - tdata\$age_entry # age_attained should be not NULL and time > 0
model <- coxph(Surv(time, status) ~ disease + sex + age_entry, data= tdata)
summary(model)

• Many thanks @JKim. Might I ask you one last thing? Why you adjusted for age_entry? Is it more precise if we do? – kakukeshi pani Sep 6 '18 at 22:57
• In the Cox regression model, covariate is 1) disease, 2) sex, 3) age at entry. The 'time' value in Surv() represents the time period from index date (start date of follow-up). If you use time at entry in Surv(), the index date is set to the birth date of patient. – JKim Sep 7 '18 at 4:50
• Yes @JKim I understand the model. I just wanted to ask you why we need to use age at entry as a covariate? – kakukeshi pani Sep 7 '18 at 9:58