Calculate AIC in survival analysis (survfit / coxph)

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

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

For what I understand that software limitation. Can someone help me solve this problem without calculating the AIC value manually?

+6
source share
2 answers

extractAIC function has a method for coxph

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

I remember that I calculated it manually, 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) 
+3
source

Source: https://habr.com/ru/post/957018/


All Articles