I'm analyzing data from a survey that utilized multistage probability sampling. I'm using R and therefore the bulk of my analyses with these data utilize the survey package to account for the weighting. The survey package has the svycoxph function which accepts the survey design objects that indicate the survey weights.

The data set contains one row per case with time values for the covariate and event. However, CoxPH models that utilize time-dependent covariates require the data be set up with with multiple rows per case that have changes in the time-dependent covariate. For example, right now I have this (weights and other variables omitted):

  subject    cov event age
1       5     90   120 135

First question - my covariate is more of a dichotomous event than something that can continuously change over time. (e.g., cov = occurrence of a traumatic brain injury, event = development of depression). Is this the correct way to code the covariate to indicate that subject 5 experienced a TBI at 90 units of time and then developed depression at 120 units of time?

  subject time1 time2    cov event
1       5     0    90      0     0
2       5    90   120      1     1

The second question has to do the survey weighting and the implications of creating of additional rows for cases with changes in the time-dependent covariate. The options seem to be to either utilize the svycoxph function to consider the weights, or to use the coxph function and disregard the weights for this particular analysis.

svycoxph(Surv(time1, time2, event == 1) ~ cov, design = df.design, data = df)


coxph(Surv(time1, time2, event == 1) ~ cov, data = df)

The first method retains the survey weighting - but is that an issue because some cases now have multiple rows (weighting factored in twice)? The second discards the weighting information. Which would be more appropriate given the nature of these data? Are there other alternatives I haven't considered?

Thanks in advance for the help - please let me know if any additional information would be useful for these questions.


1 Answer 1


Since the weights reflect the sampling design, you must transform your data df into a long dataset as you describe, then merge the (inverse) probability weights one-to-many with each of the IDs in the df object and create a design object from those long data.

For instance, if Participant A is followed for 4 years with covariate value 0 then another 4 years with covariate value 1, in the unweighted sample they contribute 8 person years, 4 under condition 0 and 4 under 1. If that person in a weighted analysis has an inverse probability weight of 10, then their follow-up is representative of 40 person-years with condition 0 and 40 person-years with condition 1.

There are cases when the non-weighted Cox model is appropriate for analysis and inference. People do unweighted analyses of complex survey data all the time. But the same limitations and considerations apply in your cohort design as would apply in any other type of design.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.