bgnbd.LL {BTYD}R Documentation

BG/NBD Log-Likelihood


Calculates the log-likelihood of the BG/NBD model.


bgnbd.LL(params, x, t.x,



BG/NBD parameters - a vector with r, alpha, a, and b, in that order. r and alpha are unobserved parameters for the NBD transaction process. a and b are unobserved parameters for the Beta geometric dropout process.


number of repeat transactions in the calibration period, or a vector of transaction frequencies.


time of most recent repeat transaction, or a vector of recencies.

length of calibration period, or a vector of calibration period lengths.


x, t.x and may be vectors. The standard rules for vector operations apply - if they are not of the same length, shorter vectors will be recycled (start over at the first element) until they are as long as the longest vector. It is advisable to keep vectors to the same length and to use single values for parameters that are to be the same for all calculations. If one of these parameters has a length greater than one, the output will be also be a vector.


A vector of log-likelihoods as long as the longest input vector (x, t.x, or

See Also



data(cdnowSummary) <- cdnowSummary$cbs
# already has column names required by method

# random assignment of parameters
params <- c(0.5, 6, 1.2, 3.3)
# returns the log-likelihood of the given parameters (params,

# compare the speed and results to the following: <-,

# Returns the log likelihood of the parameters for a customer who
# made 3 transactions in a calibration period that ended at t=6,
# with the last transaction occurring at t=4.
bgnbd.LL(params, x=3, t.x=4,

# We can also give vectors as function parameters:
x <- sample(1:4, 10, replace = TRUE)
t.x <- sample(1:4, 10, replace = TRUE) <- rep(4, 10)
bgnbd.LL(params, x, t.x,

[Package BTYD version 2.4.3 Index]