Compute AIC in Survival Analysis (survfit/coxph)
Asked Answered
E

2

11

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?

Empiric answered 30/10, 2013 at 10:2 Comment(0)
F
14

The function extractAIC has a method for coxph

fit <- coxph(Surv(time, status) ~ sex, data = cancer)
extractAIC(fit)
Formant answered 6/10, 2014 at 8:27 Comment(1)
@George Dontas I am experiencing the same problem but with the surfvit() function. The error is the following one AIC(fit1) Error in UseMethod("logLik") : no applicable method for 'logLik' applied to an object of class "survfit"Sharecropper
K
6

I remember I was computing it by hand, like this

p <- 0;k <- 3 
AIC0 <- -2*cox$loglik[1] + 2*(p+k)
p <- length(cox$coef)
AIC1 <- -2*cox$loglik[2] + 2*(p+k)
Kozloski answered 30/10, 2013 at 10:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.