Description Usage Arguments Details Value References Examples
Log-likelihood function for the BG
1 | equi.bg.LL(params, x, t, n)
|
params |
A vector of the two Beta-Geometric parameters gamma and delta. |
x |
A vector with the number of transactions at discrete times t. |
t |
The timeline of transactions in vector x. |
n |
The total possible number of transactions at time t. |
The log-likelihood function is a building block for estimating the value of
params
given a buying pattern x
observed over time t
. See the example.
The log likelihood of observing the combination of transactions x
over timeline t
given that x
follows a Beta-Geometric distribution with
parameters params
.
Peter S. Fader, Bruce G. S. Hardie, Daniel McCarthy & Ramnath Vaidyanathan (2019) Exploring the Equivalence of Two Common Mixture Models for Duration Data, The American Statistician, 73:3, 288-295, DOI: 10.1080/00031305.2018.1543134 Web
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | # Get the calibration data. Remember that
# counts of households are cumulative, so
# turn them to incremental:
library(tidyverse)
data("ace_snackfoods")
data <- ace_snackfoods$calibration %>%
rename(x = `Number of households`) %>%
mutate(bought = x - lag(x)) %>%
mutate(bought = if_else(is.na(bought), x, bought))
# Get maximum likelihood estimates:
mlset <- optim(par = c(0, 3),
fn = equi.bg.LL,
x = data$bought,
t = data$Week,
n = 1499,
method="BFGS",
control=list(fnscale=-1))
# Log-likelihood maximum:
LL <- mlset$value
# Parameter estimates:
# Recall that bg.LL exponentiates par in
# order to enforce gamma > 0, delta > 0.
params <- exp(mlset$par)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.