bgnbd.PlotRecVsConditionalExpectedFrequency: BG/NBD Plot Actual vs. Conditional Expected Frequency by...

Description Usage Arguments Details Value Examples

View source: R/bgnbd.R

Description

Plots the actual and conditional expected number of transactions made by customers in the holdout period, binned according to calibration period recencies. Also returns a matrix with this comparison and the number of customers in each bin.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
bgnbd.PlotRecVsConditionalExpectedFrequency(
  params,
  cal.cbs,
  T.star,
  x.star,
  xlab = "Calibration period recency",
  ylab = "Holdout period transactions",
  xticklab = NULL,
  title = "Actual vs. Conditional Expected Transactions by Recency"
)

Arguments

params

BG/NBD parameters - a vector with r, alpha, a, and b, in that order. r and alpha are unobserved parameters for the NBD transaction process. a and b are unobserved parameters for the Beta geometric dropout process.

cal.cbs

calibration period CBS (customer by sufficient statistic). It must contain columns for frequency ("x"), recency ("t.x"), and total time observed ("T.cal"). Note that recency must be the time between the start of the calibration period and the customer's last transaction, not the time between the customer's last transaction and the end of the calibration period.

T.star

length of then holdout period.

x.star

vector of transactions made by each customer in the holdout period.

xlab

descriptive label for the x axis.

ylab

descriptive label for the y axis.

xticklab

vector containing a label for each tick mark on the x axis.

title

title placed on the top-center of the plot.

Details

This function does bin customers exactly according to recency; it bins customers according to integer units of the time period of cal.cbs. Therefore, if you are using weeks in your data, customers will be binned as follows: customers with recencies between the start of the calibration period (inclusive) and the end of week one (exclusive); customers with recencies between the end of week one (inclusive) and the end of week two (exclusive); etc.

The matrix and plot will contain the actual number of transactions made by each bin in the holdout period, as well as the expected number of transactions made by that bin in the holdout period, conditional on that bin's behavior during the calibration period.

Value

Matrix comparing actual and conditional expected transactions in the holdout period.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
data(cdnowSummary)

cal.cbs <- cdnowSummary$cbs 
# cal.cbs already has column names required by method

# number of transactions by each customer in the 39 weeks following 
# the calibration period 
x.star <- cal.cbs[,"x.star"]

# parameters estimated using bgnbd.EstimateParameters 
est.params <- c(0.243, 4.414, 0.793, 2.426)

# plot conditional expected holdout period transactions, 
# binned according to calibration period recencies
bgnbd.PlotRecVsConditionalExpectedFrequency(est.params, 
                                            cal.cbs, 
                                            T.star = 39,
                                            x.star)

BTYD documentation built on Nov. 18, 2021, 1:10 a.m.