R/coxLoglik.r

Defines functions coxLoglik

Documented in coxLoglik

coxLoglik <- function(beta, ttf, tf, Z){

pro <- Z %*% beta
S1 <- sum(tf * pro)
S2 <- 0

event <- ttf[tf == 1]

for (j in 1:sum(tf)){
     risk <- ttf >= event[j]
     risk <- (1:length(tf)) * risk
     risk <- risk[risk > 0]
     S2 <- S2 + log(sum(exp(pro[risk])))
}

L <- S1 - S2
return(list("L" = L))
}

Try the OrdFacReg package in your browser

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

OrdFacReg documentation built on May 1, 2019, 10:06 p.m.