mcmc.DrawFutureTransactions {BTYDplus}R Documentation

Draws 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.

draws

MCMC draws as returned by *.mcmc.DrawParameters

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 customer] with sampled future transactions.

Examples

data("groceryElog")
cbs <- elog2cbs(groceryElog, T.cal = "2006-12-31")
param.draws <- pnbd.mcmc.DrawParameters(cbs,
  mcmc = 100, burnin = 50, thin = 10, chains = 1) # short MCMC to run demo fast
xstar.draws <- mcmc.DrawFutureTransactions(cbs, param.draws)
cbs$xstar.est <- apply(xstar.draws, 2, mean)
cbs$pactive <- mcmc.PActive(xstar.draws)
head(cbs)

[Package BTYDplus version 1.2.0 Index]