Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 404
JMarcelino Avatar asked Oct 30 '13 10:10

JMarcelino


2 Answers

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)
like image 66
George Dontas Avatar answered Sep 28 '22 03:09

George Dontas


The function extractAIC has a method for coxph

fit <- coxph(Surv(time, status) ~ sex, data = cancer)
extractAIC(fit)
like image 36
junkka Avatar answered Sep 28 '22 04:09

junkka