Learn R Programming

BTYDplus (version 0.7.2)

mcmc.DrawFutureTransactions: Samples number of future transactions based on MCMC parameter draws

Description

For each customer and each provided MCMC parameter draw this method will sample the number of transactions during the holdout period T.star. If argument size is provided then it returns a flexible number of draws, whereas for each customer and each draw it will first make a draw from the parameter draws.

Usage

mcmc.DrawFutureTransactions(cal.cbs, draws, T.star = cal.cbs$T.star,
  sample_size = NULL)

Arguments

cal.cbs

Calibration period customer-by-sufficient-statistic (CBS) data.frame.

T.star

Length of period for which future transactions are counted.

sample_size

Number of samples to draw. Defaults to the same number of parameter draws that are passed to draws.

Value

2-dim matrix [draw x cust] with sampled future transactions.

Examples

Run this code
# NOT RUN {
cbs <- cdnow.sample()$cbs 
param.draws <- pnbd.mcmc.DrawParameters(cbs, mcmc = 200, burnin = 100, thin = 20, chains = 1)
xstar.draws <- mcmc.DrawFutureTransactions(cbs, param.draws)
cbs$xstar.est <- apply(xstar.draws, 2, mean)
cbs$pactive <- mcmc.PActive(xstar.draws)
head(cbs)
# }

Run the code above in your browser using DataLab