R/negll.R

Defines functions negll

#  Negative loglikelihood (nLL)
negll <- function(beta, x, y){
  .y <- y[,1]
  if( ncol(y) == 1 ){  .n <- 1  }else{ .n <- rowSums(y) }
  eta <- x %*% as.matrix(beta)
  llik <- dbinom(.y, size = .n, prob = exp( eta ), log = TRUE ) 
  .value <- -sum(llik)
  return(.value)
} 

Try the lbreg package in your browser

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

lbreg documentation built on Dec. 26, 2019, 5:06 p.m.