Skip to contents

frailty_test() tests whether the frailty variance of a cox_ph() fit with a shared frailty is 0, which would mean no extra variation between the clusters beyond what the covariates explain. It's a likelihood ratio test. For a gamma frailty it compares the marginal likelihood of the clusters' event counts at the estimated variance with that at a variance near 0. For a lognormal frailty it compares the Laplace approximation of the marginal likelihood with the likelihood of the model without frailty. A variance of 0 is the smallest possible, so the p-value is half the chi-squared (1 df) tail probability.

Usage

frailty_test(fit)

Arguments

fit

A cox_ph() fit with a frailty() term or a frailty argument.

Value

A data frame with one row: distribution, theta (the estimated variance), statistic, df, and p_value.

Examples

lung <- data.frame(
  time = c(306, 455, 1010, 210, 883, 1022, 310, 361, 218, 166, 170, 654, 728, 71, 567, 144,
    613, 707, 61, 88),
  status = c(2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2),
  age = c(74, 68, 56, 57, 60, 74, 68, 71, 53, 61, 57, 68, 68, 60, 57, 67, 70, 63, 56, 57),
  inst = c(3, 3, 3, 5, 1, 12, 7, 11, 1, 7, 6, 12, 2, 16, 11, 21, 12, 1, 22, 16)
)
fit <- cox_ph(Surv(time, status) ~ age + frailty(inst), data = lung, ties = "breslow")
frailty_test(fit)
#>   distribution        theta    statistic df   p_value
#> 1        gamma 1.377972e-08 2.913317e-05  1 0.4978467