Claire
Claire

Reputation: 45

Cox PH with mixed effects - time to event and how to set up survival

I read through all of the questions similar to "how to calculate time to event/ time between events" and the documentation for Surv(), coxph, coxme. I still need help confirming if I've set up my data correctly. This represents my data:

library(data.table)
library(survival)
library(coxme)
snippet <- data.table(age=c(rep(74,3),rep(73,3),rep(69,3)),
                      sex=c(rep(0,3),rep(1,3),rep(0,3)),
                      year=c(0:2,0:2,0:2),
                      CHEM_376=c(0.036469233, 0.262701338, 0.120690616, -0.197499658, -0.231236627, -0.368920289, -0.106358638, -0.055245055, -0.141187835),
                      subject=c(rep(1,3),rep(2,3),rep(3,3)),
                      status=c(0,0,1,0,0,1,0,0,1))

I want to run cox proportional hazards regression with subject ID as the random effect (from package coxme), a chemical CHEM_376 measured at each year, some covariates like age and male. The following runs, but I'm not sure if it's correct:

coxph(Surv(time=year, event=status) ~ CHEM_376 + age + sex + cluster(subject), data=snippet)

Does the package understand that year is the year number when these observations occurred, not the time to status change? Do I need to calculate years until the status changes to 1 for each person? I'm not sure how to do that. Notice that year is not a posix date time format. Thanks for any help in advance.

Upvotes: 0

Views: 361

Answers (1)

yuk
yuk

Reputation: 19870

When you create Survival object with Surv, the time argument is an interval in number of years (or days, weeks, etc) between beginning of the observation and the time of the event. You can also provide time and time2 arguments to indicate the start and end times for survival intervals.

The argument event indicates if the event was occurred: 1 is yes (a subject is dead), 0 is no (a subject is alive or censored- dropped from the study, etc).

Google "Survival analysis with R" to find multiple articles about this.

Upvotes: 1

Related Questions