R/log.likelihood.calc.R

Defines functions log.likelihood.calc

log.likelihood.calc <-
function(X, beta, death.times, ordered.time){
  log.likeli <- 0
  
  for(i in 1:length(death.times)){
    
    numer.ind <- which(ordered.time == death.times[i])
    denom.ind <- which(ordered.time >= death.times[i])
    numer <- sum(X[numer.ind,] %*% beta)
    denom <- (sum(exp(X[denom.ind,] %*% beta)))^length(numer.ind)

    log.likeli <- log.likeli + numer - log(denom)
  }
  return(-log.likeli)
}

Try the SGL package in your browser

Any scripts or data that you put into this service are public.

SGL documentation built on Sept. 28, 2019, 1:03 a.m.