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
- Conditional and marginal are different numbers. Measured (100 groups of 5, true b = 1, frailty variance 2, 150 runs): Cox without frailty or with cluster on average 0.749 (± 0.013), frailty 1.01 (± 0.015). That is no weakness of the cluster, but a different question.
- The p value of the row "frailty" in the R output is not a test for variance 0. Statable uses the likelihood ratio with a halved p, because the variance cannot be below 0 (boundary of the parameter space).
- The variance can go to 0 (example kidney: 5·10⁻⁹). Then there are no differences between the groups beyond the predictors, and the coefficients are as without frailty. Statable says so.
- At least two groups with at least two rows each; otherwise the calculation is blocked. Under 20 groups Statable warns (rule of thumb without a source): standard errors and variance are then uncertain. Groups with a single row add nothing.
- The frailty is assumed to be gamma distributed. A normally distributed frailty (coxme) gives other numbers: for rats b = 0.730 and variance 1.32. Statable does not offer it.
- Tied times: Efron (default) or Breslow, the numbers differ slightly (rats: b = 0.727 against 0.721; variance 2.02 against 1.98). There are no time-dependent covariates with an identifier.
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