mcmc.DrawFutureTransactions | R Documentation |
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.
mcmc.DrawFutureTransactions(
cal.cbs,
draws,
T.star = cal.cbs$T.star,
sample_size = NULL
)
cal.cbs |
Calibration period customer-by-sufficient-statistic (CBS) data.frame. |
draws |
MCMC draws as returned by |
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 |
2-dim matrix [draw x customer] with sampled future transactions.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.