goranbrostrom / eha

eha
6 stars 1 forks source link

missing logLik function for aftreg #15

Open simonCodeZzz opened 8 months ago

simonCodeZzz commented 8 months ago

Hi there,

I attempted to check the AIC of my aftreg fitted object, and it did not work because logLik is not defined for aftreg. I looked up your source code in logLik.R and I think this issue can be fixed by adding the same code as you have in logLik.phreg. Something like this:

logLik.aftreg <- function(object, ...){
  out <- object$loglik[2]
  dd <- diag(object$var)
  attr(out, "df") <- sum(!is.na(dd) & dd > 0) #Stolen from logLik.survreg
  class(out) <- "logLik"
  out
}

Cheers, Simon