Learn R Programming

BTYD (version 2.4.3)

spend.marginal.likelihood: Gamma-gamma marginal likelihood

Description

Calculates the marginal likelihood of a customer's average transaction value.

Usage

spend.marginal.likelihood(params, m.x, x)

Arguments

params

a vector of gamma-gamma parameters: p, q, and gamma, in that order. p is the shape parameter for each transaction. The scale parameter for each transaction is distributed across customers according to a gamma distribution with parameters q (shape) and gamma (scale).

m.x

the customer's average observed transaction value in the calibration period. May also be a vector of average observed transaction values - see details.

x

the number of transactions the customer made in the calibration period. May also be a vector of frequencies - see details.

Value

The marginal distribution of a customer's average transaction value. If m.x or x has a length greater than 1, a vector of marginal likelihoods will be returned.

Details

m.x and x may be vectors. The standard rules for vector operations apply - if they are not of the same length, the shorter vector will be recycled (start over at the first element) until it is 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 a vector of probabilities.

This function will issue a warning if any of m.x or x is 0, and will return a marginal likelihood of 0 for those values.

f(m.x | p, q, gamma, x).

References

Fader, Peter S., Bruce G.S. Hardie, and Ka L. Lee. <U+201C>RFM and CLV: Using Iso-Value Curves for Customer Base Analysis.<U+201D> Journal of Marketing Research Vol.42, pp.415-430. November. 2005. Web.

See equation 3.

Examples

Run this code
# NOT RUN {
params <- c(6, 4, 16)

# calculate the marginal distribution of the average transaction value
# of a customer who spent an average of $35 over 3 transactions.
spend.marginal.likelihood(params, m.x=35, x=3)

# Several values can also be computed at once:
spend.marginal.likelihood(params, m.x=30:40, x=3)
spend.marginal.likelihood(params, m.x=35, x=1:10)
spend.marginal.likelihood(params, m.x=30:40, x=1:11)
# }

Run the code above in your browser using DataLab