# \donttest{
data("cdnow")
clv.cdnow <- clvdata(data.transactions = cdnow, date.format="ymd",
time.unit = "weeks", estimation.split=37)
pnbd.cdnow <- pnbd(clv.cdnow)
# bootstrapped model coefs while sampling 50 percent
# of customers without replacement
clv.bootstrapped.apply(pnbd.cdnow, num.boots=5, fn.boot.apply=coef,
fn.sample=function(x){
sample(x, size = as.integer(0.5*length(x)), replace = FALSE)})
# sample customers with built-in standard logic and
# return predictions until end of holdout period in original
# data.
# prediction.end is not required because the bootstrapped
# data contains the same estimation and holdout periods
# as the original data, even if the transactions of the sampled
# customers .
clv.bootstrapped.apply(pnbd.cdnow, num.boots=5, fn.sample=NULL,
fn.boot.apply=function(x){predict(x)})
# return the fitted models
# forward additional arguments to the model fitting method
clv.bootstrapped.apply(pnbd.cdnow, num.boots=5, fn.sample=NULL,
fn.boot.apply=return,
# args for ..., forwarded to pnbd()
verbose=FALSE, optimx.args=list(method="Nelder-Mead"),
start.params.model=coef(pnbd.cdnow))
# }
Run the code above in your browser using DataLab