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

Description Usage Arguments Value Examples

View source: R/mcmc.R

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

1
2
3
4
5
6
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

1
2
3
4
5
6
7
8
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)

BTYDplus documentation built on Jan. 21, 2021, 5:10 p.m.