11
$\begingroup$

Context

I'm attempting to understand how R's coxph() accepts and handles repeated entries for subjects (or patient/customer if you prefer). Some call this Long format, others call it 'repeated measures'.

See for example the data set that includes the ID column in the Answers section at:

Best packages for Cox models with time varying covariates

Also assume covariates are time-varying throughout and there is exactly one censor (i.e. event) variable, which is binary.

Questions

1) In the above link's answer, if ID is not given as a parameter in the call to coxph() should the results be the same as including cluster(ID) as a parameter in coxph()?

I attempted to search for documentation, but the following doesn't seem to clearly address (1): https://stat.ethz.ch/pipermail/r-help//2013-July/357466.html

2) If the answer to (1) is 'no', then (mathematically) why? It seems cluster() in coxph() seeks correlations between subjects as per subsection 'cluster' on pg. 20 at

https://cran.r-project.org/web/packages/survival/survival.pdf

3) Vague question: how does coxph() with repeated measures compare to R's frailtypack regression methods?

Addenda

The following hints at using cluster(ID):

Is there a repeated measures aware version of the logrank test?

as does:

https://stat.ethz.ch/pipermail/r-help//2013-July/357466.html

GEE approach: add "+ cluster(subject)" to the model statement in coxph Mixed models approach: Add " + (1|subject)" to the model statment in coxme.

Thanks in advance!

$\endgroup$
1
  • $\begingroup$ Thanks a lot for your explanations. Does any one know whether "using id=id in coxph function" are the same as 1) using (1|id) in coxme function or 2) using cluster(id) in the coxph function I've did a simmulation analyses, the results seem to be very similar to 2) using clster(id); but a little different with the 1) There is any explanation for this? Thanks a lot. Best, Cui. $\endgroup$
    – vicky Guo
    Commented Jun 16, 2021 at 3:54

2 Answers 2

15
$\begingroup$
  1. Including cluster(ID) does not change the point estimates of the parameters. It does change the way that the standard errors are computed however.

    More details can be found in Therneau & Grambsch's book Extending the Cox Model, chapter 8.2. Note that in their example, they use method = "breslow" as correction for ties, but also with the default (method = "efron") a similar calculation for the se's will be used, and appears in the summary as "robust se".

  2. If cluster(ID) is used, a "robust" estimate of standard errors is imposed and possible dependence between subjects is measured (e.g. by standard errors and variance scores). Not using cluster(ID), on the other hand, imposes independence on each observation and more "information" is assumed in the data. In more technical terms, the score function for the parameters does not change, but the variance of this score does. A more intuitive argument is that 100 observations on 100 individuals provide more information than 100 observations on 10 individuals (or clusters).

  3. Vague indeed. In short, +frailty(ID) in coxph() fits standard frailty models with gamma or log-normal random effects and with non-parametric baseline hazard / intensity. frailtypack uses parametric baseline (also flexible versions with splines or piecewise constant functions) and also fits more complicated models, such as correlated frailty, nested frailty, etc.

Finally, +cluster() is somewhat in the spirit of GEE, in that you take the score equations from a likelihood with independent observations, and use a different "robust" estimator for the standard errors.

edit: Thanks @Ivan for the suggestions regarding the clarity of the post.

$\endgroup$
8
  • $\begingroup$ Thank you. Regarding (2): can "This is because if you (wrongly) assume..." be replaced by "If you do not use cluster(ID) in the call to coxph(), then you wrongly assume...." $\endgroup$
    – user76943
    Commented Oct 28, 2015 at 16:20
  • $\begingroup$ I meant: if the observations are clustered, then they might or might not be independent. Assuming that they are independent (i.e. not using cluster(id) ) is almost certainly wrong in this case, but there is no idea of knowing that beforehand $\endgroup$
    – Theodor
    Commented Oct 29, 2015 at 15:56
  • $\begingroup$ (2) may be rephrased as: if cluster(ID) is used, a "robust" estimate of standard errors is imposed and possible dependence between subjects is measured (e.g. by standard errors and variance scores). Not using cluster(ID), on the other hand, imposes independence on each observation and more "information" is assumed in the data. $\endgroup$
    – user76943
    Commented Oct 31, 2015 at 15:41
  • $\begingroup$ The reference link you provided in (1) should be: springer.com/us/book/9780387987842 (assuming you're citing Therneau and Grambsch's book) $\endgroup$
    – user76943
    Commented Nov 2, 2015 at 2:39
  • $\begingroup$ Also note: as explained in Therneau and Grambsch's book, the reason the answer in (1) above is correct is because coxph() uses the Breslow method as default for ties. $\endgroup$
    – user76943
    Commented Nov 8, 2015 at 3:41
3
$\begingroup$

Here's an answer from a survival package vignette I found helpful - it's linked in the first answer to the first question you linked to:

Best packages for Cox models with time varying covariates

They're referring to the long form data setup, or data with repeated entries for subjects.

One common question with this data setup is whether we need to worry about correlated data, since a given subject has multiple observations. The answer is no, we do not. The reason is that this representation is simply a programming trick. The likelihood equations at any time point use only one copy of any subject, the program picks out the correct row of data at each time. There two exceptions to this rule:

  • When subjects have multiple events, then the rows for the events are correlated within subject and a cluster variance is needed.
  • When a subject appears in overlapping intervals. This however is almost always a data error, since it corresponds to two copies of the subject being present in the same strata at the same time, e.g., she could meet herself at a party.

The example they give is

fit <- coxph(Surv(time1, time2, status) ~ age + creatinine, data=mydata)

suggesting that if you provide two times (start and end of period) to Surv instead of one, coxph() will figure out the rest.

$\endgroup$
1
  • 2
    $\begingroup$ Unless I have misunderstood something, I think this comment is misleading? We do need to worry about correlated data if we want to get accurate estimates of the variance, hence why adding a + cluster(ID) term changes the estimated variance terms? $\endgroup$
    – AP30
    Commented Jan 10, 2019 at 12:07

Your Answer

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