Search code examples
rsurvival-analysis

Compute AIC in Survival Analysis (survfit/coxph)


I want to compute the AIC value for my survival analysis objects (suvfit/coxph). When I try to do it, it says:

> AIC(cox)
  Error in UseMethod("logLik") : 
   no applicable method for 'logLik' applied to an object of class "coxph"

For what I understand that's a software limitation. Can anyone help me to solve this problem without computing the AIC value by hand?


Solution

  • The function extractAIC has a method for coxph

    fit <- coxph(Surv(time, status) ~ sex, data = cancer)
    extractAIC(fit)