bgnbd.PlotFrequencyInCalibration: BG/NBD Plot Frequency in Calibration Period

Description Usage Arguments Details Value Examples

View source: R/bgnbd.R

Description

Plots a histogram and returns a matrix comparing the actual and expected number of customers who made a certain number of repeat transactions in the calibration period, binned according to calibration period frequencies.

Usage

1
2
3
4
5
6
7
8
9
bgnbd.PlotFrequencyInCalibration(
  params,
  cal.cbs,
  censor,
  plotZero = TRUE,
  xlab = "Calibration period transactions",
  ylab = "Customers",
  title = "Frequency of Repeat Transactions"
)

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") and total time observed ("T.cal").

censor

integer used to censor the data. See details.

plotZero

If FALSE, the histogram will exclude the zero bin.

xlab

descriptive label for the x axis.

ylab

descriptive label for the y axis.

title

title placed on the top-center of the plot.

Details

This function requires a censor number, which cannot be higher than the highest frequency in the calibration period CBS. The output matrix will have (censor + 1) bins, starting at frequencies of 0 transactions and ending at a bin representing calibration period frequencies at or greater than the censor number. The plot may or may not include a bin for zero frequencies, depending on the plotZero parameter.

Value

Calibration period repeat transaction frequency comparison matrix (actual vs. expected).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
data(cdnowSummary)

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

# parameters estimated using bgnbd.EstimateParameters 
est.params <- c(0.243, 4.414, 0.793, 2.426) 
# the maximum censor number that can be used
max(cal.cbs[,"x"])

bgnbd.PlotFrequencyInCalibration(est.params, cal.cbs, censor=7)

Example output

Loading required package: hypergeo
[1] 29
             freq.0   freq.1   freq.2   freq.3   freq.4   freq.5   freq.6
n.x.actual   1411.0 439.0000 214.0000 100.0000 62.00000 38.00000 29.00000
n.x.expected 1406.5 460.8076 192.7094 101.3067 59.93608 38.17857 25.58969
              freq.7+
n.x.actual   64.00000
n.x.expected 71.34782

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