R/auxiliary_functions.R

Defines functions l_ld

# loss function and its first derivative
l_ld <- function(beta, x, n, Start, Stop, Event){
  fit.cox <- coxph(Surv(Start, Stop, Event) ~ x,
                   init = beta,
                   control = coxph.control(iter.max = 0, timefix = FALSE))
  l <- - fit.cox$loglik[1]/n
  ld <- - fit.cox$first/n
  return(c(l, ld))
}

Try the sox package in your browser

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

sox documentation built on June 8, 2025, 1:51 p.m.