statable Statistics for study and research

Several rows of the same person or group: cluster and frailty

In brief

If several rows belong to the same person or group (litters, centers, repeated events), they are not independent. In the card "How long does it take until an event?" the identifier has two ways under "More options". Cluster (default) changes only the standard errors (robust, sandwich); the hazard ratios stay exactly the same and apply on average over the groups (marginal). Frailty (gamma, advanced) gives each group a tendency of its own and estimates its variance; the hazard ratio applies within the same group (conditional). Statable never calculates both at once. The identifier goes to R as a numeric code, not as text.

An example with numbers

rats: 300 rats in 100 litters, 42 events, treatment rx. Without identifier: b = 0.714, standard error 0.309, HR = 2.04, p = .021. With cluster: the same b, robust standard error 0.271, z = 2.63, p = .008. With frailty (gamma, Efron): b = 0.727, HR = 2.07, variance of the frailty 2.02, p = .022. The test for variance 0 is a likelihood ratio: χ² = 10.23, halved p = .0007.

Limits and traps

Reporting the result

Cox regression with cluster (100 groups): HR = 2.04, 95% CI [1.20, 3.47], p = .008 (treatment); 300 rows, 42 events

For specialists

library(survival)
m1 <- coxph(Surv(time, status) ~ rx + cluster(litter), data = rats)
m2 <- coxph(Surv(time, status) ~ rx + frailty(litter, distribution = "gamma"), data = rats)
m2$history[[1]]$theta   # Varianz der Frailty

Related

Open in Statable