Learn R Programming

BTYDplus (version 0.7.2)

pnbd.mcmc.DrawParameters: Pareto/NBD (HB) Parameter Draws

Description

Returns draws from the posterior distributions of the Pareto/NBD (HB) parameters, on cohort as well as on customer level.

Usage

pnbd.mcmc.DrawParameters(cal.cbs, mcmc = 2500, burnin = 500, thin = 50,
  chains = 2, mc.cores = NULL, use_data_augmentation = TRUE,
  param_init = NULL, trace = 100)

Arguments

cal.cbs

Calibration period customer-by-sufficient-statistic (CBS) data.frame. It must contain a row for each customer, and columns x for frequency, t.x for recency and T.cal for the total time observed. A correct format can be easily generated based on the complete event log of a customer cohort with elog2cbs.

mcmc

Number of MCMC steps.

burnin

Number of initial MCMC steps which are discarded.

thin

Only every thin-th MCMC step will be returned.

chains

Number of MCMC chains to be run.

mc.cores

Number of cores to use in parallel (Unix only). Defaults to min(chains, detectCores()).

use_data_augmentation

determines MCMC method to be used

param_init

List of start values for cohort-level parameters.

trace

Print logging statement every trace-th iteration. Not available for mc.cores > 1.

Value

2-element list:

  • level_1 list of mcmc.lists, one for each customer, with draws for customer-level parameters lambda, tau, z, mu

  • level_2 mcmc.list, with draws for cohort-level parameters r, alpha, s, beta

Details

See demo('pareto-ggg') for how to apply this model.

method 1) If use_data_augmentation==TRUE MCMC scheme takes advantage of conjugate priors for drawing lambda and mu, by augmentating the parameter space with unobserved lifetime 'tau' and activity status 'z'. See technical appendix to (Abe 2009).

method 2) If use_data_augmentation==FALSE then implementation follows Shao-Hui Ma & Jin-Lan Liu paper http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=4344404, i.e. no data augmentation and draws on individual level need to be done via slice sampling. As such it is 10x slower than method 1)

Estimating parameters via Pareto/NBD MCMC can be 10x slower than Pareto/NBD MLE, which itself can be 10x slower than BG/NBD. Both methods exhibit highly autocorrelated draws of r, alpha, s, beta and hence need to be run long, to generate 'enough' draws

References

Ma, Shao-Hui, and Jin-Lan Liu. 'The MCMC approach for solving the Pareto/NBD model and possible extensions.' Natural Computation, 2007. ICNC 2007. Third International Conference on. Vol. 2. IEEE, 2007. http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=4344404

Abe, Makoto. 'Counting your customers one by one: A hierarchical Bayes extension to the Pareto/NBD model.' Marketing Science 28.3 (2009): 541-553.

See Also

pnbd.GenerateData mcmc.DrawFutureTransactions mcmc.PAlive

Examples

Run this code
# NOT RUN {
cbs <- cdnow.sample()$cbs
param.draws <- pnbd.mcmc.DrawParameters(cbs, 
  mcmc = 200, burnin = 100, thin = 20, chains = 1) # short MCMC runs for demo purposes

# cohort-level parameter draws
as.matrix(param.draws$level_2)
# customer-level parameter draws for customer with ID '4'
as.matrix(param.draws$level_1[["4"]])

# estimate future transactions
xstar.draws <- mcmc.DrawFutureTransactions(cbs, param.draws, cbs$T.star)
xstar.est <- apply(xstar.draws, 2, mean)
head(xstar.est)
# }

Run the code above in your browser using DataLab