Skip to content

Instantly share code, notes, and snippets.

@tvladeck
Created February 17, 2016 23:48
Show Gist options
  • Save tvladeck/d52df2a3c641a996a65a to your computer and use it in GitHub Desktop.
Save tvladeck/d52df2a3c641a996a65a to your computer and use it in GitHub Desktop.
log likelihood of beta nbd model
beta.nbd.ll <- function(x, n_x, r, alpha, a, b)
{
# params:
# x: vector of counts
# n_x: number of observations for each count
# r, alpha: nbd params
# a, b: beta params
# output:
# the log-likelihood of the model
probs <- sapply(x, function(y) beta.nbd.density(y, r, alpha, a, b))
lls <- n_x * log(probs)
ll <- sum(lls)
return(ll)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment