I am trying to evaluate the proportional hazard assumption of a Cox PH model that includes both an interaction term and a frailty term. When I call cox.zph, I get this error:
Error in imatr[kk, kk] : subscript out of bounds
I don't get the error when I remove the frailty term from the model, and, in the reduced model, all of my fixed factors meet the proportional hazards assumption. Do I need to run cox.zph on my full model as well? If so, how can I get around the error message I'm getting?
This code should recreate the error message I'm getting:
library(survival)
set.seed(80)
fake.data <- data.frame(event = c(rbinom(75, 1, 0.7), rbinom(75, 1, 0.4)),
time = runif(150, min=0, max=3),
time.period = rep(c("pre", "peri", "post")),
condition = rep(c("fed", "not fed")),
momID = floor(runif(150, min=1, max=35)))
phmodel <- coxph(Surv(time, event) ~ time.period*condition + frailty(momID) , data = fake.data )
assump.check <- cox.zph(phmodel)
Thanks!