R/coxfun0.R

Defines functions coxfun0

coxfun0 <- function(Y, strata = NULL, method = "efron"){
    rs <- risksets(Y, strata = strata, members = FALSE)
    d <- rs$n.events
    n <- rs$size
    r <- length(d)
    if (method == "efron"){
        ll <- 0
        for (i in 1:r){
            tmp <- 0
            for (j in 1:d[i]){
                tmp <- tmp + log(n[i] - j + 1)
            }
            ll <- ll - tmp
        }
    }else{
        ll <- -sum(d * log(n))
    }
    ll
}
goranbrostrom/eha documentation built on March 9, 2024, 11:22 p.m.