Learn R Programming

BTYD 2.4.2

A patch for the pnbd.LL() function in the original BTYD package, first proposed by Theo Strinopoulos. Now on CRAN, so you can get it the usual way, with install.packages().

Justification

In its original version the Pareto/NBD (pnbd) part of the BTYD package failed for me, as it did for Theo, for reasons he explained here. So, I implemented his fix, rebuilt from source, and then it worked. This is the short version. The long version is that in the process of implementing the fix I made some changes to the choice of optimization routine (now using optimx as opposed to optim), Gaussian hypergeometric (now you have the option of using the hypergeo package) and I found some opportunities for refactoring functions defined in both the pnbd and the bgnbd (Beta-Geometric Negative Binomial) groups. I explained these changes are explained in separate documentation (fix_pnbd.html). Finally, I rebuilt BTYD and checked that it would return the same numbers as BTYD 2.4 did when running the examples in the original BTYD vignette (see threeway_walkthrough.R).

How to install from here

First git clone.

If you use devtools, then at the R console just call document(); build(); install(build_vignettes = TRUE). Done.

Otherwise, build the standard way in two steps:

  1. At the command line, build and check the source tarball:
R CMD build BTYD
R CMD check BTYD_2.4.2.tar.gz
  1. Then, at the R console, install it:
install.packages("BTYD2_2.4.2.tar.gz", repos = NULL, type = "source")
# works only in RStudio:
.rs.restartR()

Copy Link

Version

Install

install.packages('BTYD')

Monthly Downloads

450

Version

2.4.3

License

GPL-3

Maintainer

Last Published

November 17th, 2021

Functions in BTYD (2.4.3)

addLogs

Add Logs
bgbb.LL

BG/BB Log-Likelihood
bgbb.DERT

BG/BB Discounted Expected Residual Transactions
bgbb.PAlive

BG/BB P(Alive)
bgbb.HeatmapHoldoutExpectedTrans

BG/BB Heatmap of Holdout Period Expected Transactions
bgbb.ConditionalExpectedTransactions

BG/BB Conditional Expected Transactions
bgbb.PlotDropoutRateHeterogeneity

BG/BB Plot Dropout Rate Heterogeneity
bgbb.EstimateParameters

BG/BB Parameter estimation
BTYD-package

bgbb.PlotTrackingCum

BG/BB Tracking Cumulative Transactions Plot
bgbb.PosteriorMeanLmProductMoment

BG/BB Posterior Mean (l,m)th Product Moment
bgbb.PosteriorMeanTransactionRate

BG/BB Posterior Mean Transaction Rate
bgbb.pmf.General

BG/BB General Probability Mass Function
bgnbd.PlotTransactionRateHeterogeneity

BG/NBD Plot Transaction Rate Heterogeneity
bgbb.rf.matrix.PosteriorMeanTransactionRate

BG/BB Posterior Mean Transaction Rate using a recency-frequency matrix
bgbb.PlotFrequencyInHoldout

BG/BB Plot Frequency in Holdout
bgbb.rf.matrix.PosteriorMeanDropoutRate

BG/BB Posterior Mean Dropout Rate using a recency-frequency matrix
bgnbd.LL

BG/NBD Log-Likelihood
bgbb.PlotRecVsConditionalExpectedFrequency

BG/BB Plot Recency vs Conditional Expected Frequency
bgnbd.cbs.LL

BG/NBD Log-Likelihood Wrapper
bgbb.Expectation

BG/BB Expectation
bgbb.PlotTrackingInc

BG/BB Tracking Incremental Transactions Plot
bgbb.rf.matrix.DERT

BG/BB Discounted Expected Residual Transactions using a recency-frequency matrix
bgbb.pmf

BG/BB Probability Mass Function
bgbb.rf.matrix.LL

BG/BB Log-Likelihood using a recency-frequency matrix
dc.InputCheck

Check the inputs to functions that use this common pattern
bgnbd.PlotDropoutRateHeterogeneity

BG/NBD Plot Dropout Probability Heterogeneity
bgnbd.PlotFreqVsConditionalExpectedFrequency

BG/NBD Plot Frequency vs. Conditional Expected Frequency
bgnbd.PAlive

BG/NBD P(Alive)
bgbb.PlotTransactionRateHeterogeneity

BG/BB Plot Transaction Rate Heterogeneity
bgbb.PosteriorMeanDropoutRate

BG/BB Posterior Mean Dropout Rate
bgnbd.Expectation

BG/NBD Expectation
cdnowElog

CDNOW event log data
bgnbd.pmf

BG/NBD Probability Mass Function
bgnbd.ExpectedCumulativeTransactions

BG/NBD Expected Cumulative Transactions
bgnbd.generalParams

Define general parameters
bgnbd.pmf.General

Generalized BG/NBD Probability Mass Function
bgnbd.PlotFrequencyInCalibration

BG/NBD Plot Frequency in Calibration Period
bgnbd.PlotRecVsConditionalExpectedFrequency

BG/NBD Plot Actual vs. Conditional Expected Frequency by Recency
cdnowSummary

CDNOW repeat transaction data summary
bgbb.PlotFreqVsConditionalExpectedFrequency

BG/BB Plot Frequency vs Conditional Expected Frequency
bgbb.PlotFrequencyInCalibration

BG/BB Plot Frequency in Calibration Period
bgnbd.ConditionalExpectedTransactions

BG/NBD Conditional Expected Transactions
dc.MakeRFmatrixHoldout

Make Holdout Period Recency-Frequency Matrix
dc.MakeRFmatrixSkeleton

Make Recency-Frequency Matrix Skeleton
dc.CreateFreqCBT

Create Frequency Customer-by-Time Matrix
dc.BuildCBTFromElog

Build Customer-by-Time Matrix from Event Log
dc.ElogToCbsCbt

Convert Event Log to CBS and CBT Matrices
dc.FilterCustByBirth

Filter Customer by Birth
dc.BuildCBSFromCBTAndDates

Build CBS matrix from CBT matrix
bgnbd.EstimateParameters

BG/NBD Parameter Estimation
dc.CumulativeToIncremental

Cumulative to Incremental
dc.SplitUpElogForRepeatTrans

Split Up Event Log for Repeat Transactions
dc.ReadLines

Read Lines
dc.DissipateElog

Dissipate Event Log
dc.WriteLine

Write Line
dc.PlotLogLikelihoodContour

Plot Log-Likelihood Contour
dc.PlotLogLikelihoodContours

Plot Log-Likelihood Contours
dc.MakeRFmatrixCal

Make Calibration Period Recency-Frequency Matrix
discreteSimElog

Discrete simulated annual event log data
dc.MergeCustomers

Merge Customers
pnbd.DERT

Pareto/NBD Discounted Expected Residual Transactions
pnbd.PlotFreqVsConditionalExpectedFrequency

Pareto/NBD Plot Frequency vs. Conditional Expected Frequency
pnbd.generalParams

Define general parameters
donationsSummary

Discrete donation data summary
pnbd.pmf.General

Generalized Pareto/NBD Probability Mass Function
pnbd.PlotFrequencyInCalibration

Pareto/NBD Plot Frequency in Calibration Period
bgnbd.PlotTrackingCum

BG/NBD Tracking Cumulative Transactions Plot
dc.CreateReachCBT

Create Reach Customer-by-Time Matrix
bgnbd.PlotTrackingInc

BG/NBD Tracking Incremental Transactions Comparison
dc.CreateSpendCBT

Create Spend Customer-by-Time Matrix
dc.RemoveTimeBetween

Remove Time Between
pnbd.EstimateParameters

Pareto/NBD Parameter Estimation
pnbd.LL

Pareto/NBD Log-Likelihood
pnbd.PlotTrackingCum

Pareto/NBD Tracking Cumulative Transactions Plot
pnbd.PAlive

Pareto/NBD P(Alive)
pnbd.PlotTrackingInc

Pareto/NBD Tracking Incremental Transactions Comparison
dc.MergeTransactionsOnSameDate

Merge Transactions on Same Day
pnbd.cbs.LL

Pareto/NBD Log-Likelihood
pnbd.PlotTransactionRateHeterogeneity

Pareto/NBD Plot Transaction Rate Heterogeneity
dc.GetFirstPurchasePeriodsFromCBT

Get First Purchase Periods from Customer-by-Time Matrix
pnbd.ExpectedCumulativeTransactions

Pareto/NBD Expected Cumulative Transactions
pnbd.Expectation

Pareto/NBD Expectation
h2f1

Use Bruce Hardie's Gaussian hypergeometric implementation
spend.LL

Spend Log-Likelihood
dc.GetLastPurchasePeriodsFromCBT

Get Last Purchase Periods from Customer-by-Time Matrix
spend.expected.value

Conditional expected transaction value
pnbd.Plot.DERT

Pareto/NBD Plot Discounted Expected Residual Transactions
pnbd.pmf

Pareto/NBD Probability Mass Function
pnbd.ConditionalExpectedTransactions

Pareto/NBD Conditional Expected Transactions
spend.EstimateParameters

Spend Parameter Estimation
pnbd.PlotDropoutRateHeterogeneity

Pareto/NBD Plot Dropout Rate Heterogeneity
pnbd.PlotRateHeterogeneity

Plot Pareto/NBD Rate Heterogeneity
subLogs

Subtract Logs
pnbd.PlotRecVsConditionalExpectedFrequency

Pareto/NBD Plot Actual vs. Conditional Expected Frequency by Recency
spend.plot.average.transaction.value

Plot Actual vs. Expected Average Transaction Value
dc.check.model.params

Check model params
dc.compress.cbs

Compress Customer-by-Sufficient-Statistic (CBS) Matrix
spend.marginal.likelihood

Gamma-gamma marginal likelihood
spend.generalParams

Define general parameters