Fits BG/NBD models on transactional data without and with static covariates.
# S4 method for clv.data
bgnbd(
clv.data,
start.params.model = c(),
optimx.args = list(),
verbose = TRUE,
...
)
# S4 method for clv.data.static.covariates
bgnbd(
clv.data,
start.params.model = c(),
optimx.args = list(),
verbose = TRUE,
names.cov.life = c(),
names.cov.trans = c(),
start.params.life = c(),
start.params.trans = c(),
names.cov.constr = c(),
start.params.constr = c(),
reg.lambdas = c(),
...
)
The data object on which the model is fitted.
Named start parameters containing the optimization start parameters for the model without covariates.
Additional arguments to control the optimization which are forwarded to optimx::optimx
.
If multiple optimization methods are specified, only the result of the last method is further processed.
Show details about the running of the function.
Ignored
Which of the set Lifetime covariates should be used. Missing parameter indicates all covariates shall be used.
Which of the set Transaction covariates should be used. Missing parameter indicates all covariates shall be used.
Named start parameters containing the optimization start parameters for all lifetime covariates.
Named start parameters containing the optimization start parameters for all transaction covariates.
Which covariates should be forced to use the same parameters for the lifetime and transaction process. The covariates need to be present as both, lifetime and transaction covariates.
Named start parameters containing the optimization start parameters for the constraint covariates.
Named lambda parameters used for the L2 regularization of the lifetime and the transaction covariate parameters. Lambdas have to be >= 0.
Depending on the data object on which the model was fit, bgnbd
returns either an object of
class clv.bgnbd or clv.bgnbd.static.cov.
The function summary
can be used to obtain and print a summary of the results.
The generic accessor functions coefficients
, vcov
, fitted
,
logLik
, AIC
, BIC
, and nobs
are available.
Model parameters for the BG/NBD model are r, alpha, a, and b
. r
: shape parameter of the Gamma distribution of the purchase process. alpha
: scale parameter of the Gamma distribution of the purchase process. a
: shape parameter of the Beta distribution of the dropout process.b
: shape parameter of the Beta distribution of the dropout process.
If no start parameters are given, r = 1, alpha = 3, a = 1, b = 3 is used. All model start parameters are required to be > 0. If no start values are given for the covariate parameters, 0.1 is used.
Note that the DERT expression has not been derived (yet) and it consequently is not possible to calculated values for DERT and CLV.
The BG/NBD is an "easy" alternative to the Pareto/NBD model that is easier to implement. The BG/NBD model slight adapts the behavioral "story" associated with the Pareto/NBD model in order to simplify the implementation. The BG/NBD model uses a beta-geometric and exponential gamma mixture distributions to model customer behavior. The key difference to the Pareto/NBD model is that a customer can only churn right after a transaction. This simplifies computations significantly, however has the drawback that a customer cannot churn until he/she makes a transaction. The Pareto/NBD model assumes that a customer can churn at any time.
The standard BG/NBD model captures heterogeneity was solely using Gamma distributions. However, often exogenous knowledge, such as for example customer demographics, is available. The supplementary knowledge may explain part of the heterogeneity among the customers and therefore increase the predictive accuracy of the model. In addition, we can rely on these parameter estimates for inference, i.e. identify and quantify effects of contextual factors on the two underlying purchase and attrition processes. For technical details we refer to the technical note by Fader and Hardie (2007).
The likelihood function is the likelihood function associated with the basic model where alpha, a, and b are replaced with alpha = alpha0*exp(-g1z1), a = a_0*exp(g2z2), and b = b0*exp(g3z2) while r remains unchanged. Note that in the current implementation, we constrain the covariate parameters and data for the lifetime process to be equal (g2=g3 and z2=z3).
Fader PS, Hardie BGS, Lee KL (2005). ““Counting Your Customers” the Easy Way: An Alternative to the Pareto/NBD Model” Marketing Science, 24(2), 275-284.
Fader PS, Hardie BGS (2013). “Overcoming the BG/NBD Model's #NUM! Error Problem” URL http://brucehardie.com/notes/027/bgnbd_num_error.pdf.
Fader PS, Hardie BGS (2007). “Incorporating time-invariant covariates into the Pareto/NBD and BG/NBD models.” URL http://www.brucehardie.com/notes/019/time_invariant_covariates.pdf.
Fader PS, Hardie BGS, Lee KL (2007). “Creating a Fit Histogram for the BG/NBD Model” URL https://www.brucehardie.com/notes/014/bgnbd_fit_histogram.pdf
clvdata
to create a clv data object, SetStaticCovariates
to add static covariates to an existing clv data object.
gg to fit customer's average spending per transaction with the Gamma-Gamma
model
predict
to predict expected transactions, probability of being alive, and customer lifetime value for every customer
plot
to plot the unconditional expectation as predicted by the fitted model
pmf
for the probability to make exactly x transactions in the estimation period, given by the probability mass function (PMF).
# \donttest{
data("apparelTrans")
clv.data.apparel <- clvdata(apparelTrans, date.format = "ymd",
time.unit = "w", estimation.split = 40)
# Fit standard bgnbd model
bgnbd(clv.data.apparel)
#> Starting estimation...
#> Estimation finished!
#> BG/NBD Standard Model
#>
#> Call:
#> bgnbd(clv.data = clv.data.apparel)
#>
#> Coefficients:
#> r alpha a b
#> 0.4837 3.2825 0.3760 4.2874
#> KKT1: TRUE
#> KKT2: TRUE
# Give initial guesses for the model parameters
bgnbd(clv.data.apparel,
start.params.model = c(r=0.5, alpha=15, a = 2, b=5))
#> Starting estimation...
#> Estimation finished!
#> BG/NBD Standard Model
#>
#> Call:
#> bgnbd(clv.data = clv.data.apparel, start.params.model = c(r = 0.5,
#> alpha = 15, a = 2, b = 5))
#>
#> Coefficients:
#> r alpha a b
#> 0.4837 3.2823 0.3755 4.2785
#> KKT1: TRUE
#> KKT2: TRUE
# pass additional parameters to the optimizer (optimx)
# Use Nelder-Mead as optimization method and print
# detailed information about the optimization process
apparel.bgnbd <- bgnbd(clv.data.apparel,
optimx.args = list(method="Nelder-Mead",
control=list(trace=6)))
#> Starting estimation...
#> fn is fn1
#> Looking for method = Nelder-Mead
#> Methods to be used:[1] "Nelder-Mead"
#> Function has 4 arguments
#> Analytic gradient not made available.
#> Analytic Hessian not made available.
#> Scale check -- log parameter ratio= 0 log bounds ratio= NA
#> optcfg:$fname
#> [1] "fn1"
#>
#> $npar
#> [1] 4
#>
#> $ctrl
#> $ctrl$follow.on
#> [1] FALSE
#>
#> $ctrl$save.failures
#> [1] TRUE
#>
#> $ctrl$trace
#> [1] 6
#>
#> $ctrl$kkt
#> [1] TRUE
#>
#> $ctrl$all.methods
#> [1] FALSE
#>
#> $ctrl$starttests
#> [1] TRUE
#>
#> $ctrl$maximize
#> [1] FALSE
#>
#> $ctrl$dowarn
#> [1] TRUE
#>
#> $ctrl$usenumDeriv
#> [1] FALSE
#>
#> $ctrl$kkttol
#> [1] 0.001
#>
#> $ctrl$kkt2tol
#> [1] 1e-06
#>
#> $ctrl$badval
#> [1] 8.988466e+307
#>
#> $ctrl$scaletol
#> [1] 3
#>
#> $ctrl$have.bounds
#> [1] FALSE
#>
#>
#> $usenumDeriv
#> [1] FALSE
#>
#> $ufn
#> function (par)
#> fn(par, ...)
#> <bytecode: 0x7fb5826c0950>
#> <environment: 0x7fb5a110c070>
#>
#> $have.bounds
#> [1] FALSE
#>
#> $method
#> [1] "Nelder-Mead"
#>
#> Method: Nelder-Mead
#> Nelder-Mead direct search function minimizer
#> function value for initial parameters = 2985.769409
#> Scaled convergence tolerance is 4.44914e-05
#> Stepsize computed as 0.109861
#> BUILD 5 3012.752572 2973.973439
#> EXTENSION 7 2993.373011 2943.829057
#> LO-REDUCTION 9 2985.769409 2943.829057
#> EXTENSION 11 2981.542423 2924.136709
#> LO-REDUCTION 13 2973.973439 2924.136709
#> EXTENSION 15 2948.255070 2905.355668
#> LO-REDUCTION 17 2943.829057 2905.355668
#> LO-REDUCTION 19 2924.512075 2905.355668
#> REFLECTION 21 2924.136709 2903.722832
#> LO-REDUCTION 23 2914.417772 2903.722832
#> LO-REDUCTION 25 2910.432354 2903.722832
#> EXTENSION 27 2906.938793 2900.310876
#> HI-REDUCTION 29 2905.762406 2900.310876
#> EXTENSION 31 2905.355668 2897.983732
#> EXTENSION 33 2903.963391 2892.824039
#> LO-REDUCTION 35 2903.722832 2892.824039
#> LO-REDUCTION 37 2900.310876 2892.824039
#> EXTENSION 39 2897.983732 2888.407512
#> EXTENSION 41 2895.428656 2886.461459
#> EXTENSION 43 2894.728449 2885.167328
#> LO-REDUCTION 45 2892.824039 2885.167328
#> LO-REDUCTION 47 2888.407512 2884.465033
#> LO-REDUCTION 49 2886.461459 2884.465033
#> HI-REDUCTION 51 2885.358936 2884.465033
#> LO-REDUCTION 53 2885.167328 2884.241545
#> HI-REDUCTION 55 2884.621344 2884.241545
#> HI-REDUCTION 57 2884.533026 2884.241545
#> HI-REDUCTION 59 2884.471900 2884.241545
#> LO-REDUCTION 61 2884.465033 2884.241545
#> HI-REDUCTION 63 2884.307960 2884.241545
#> LO-REDUCTION 65 2884.294155 2884.241545
#> HI-REDUCTION 67 2884.260398 2884.232491
#> HI-REDUCTION 69 2884.251403 2884.227891
#> REFLECTION 71 2884.242641 2884.214209
#> HI-REDUCTION 73 2884.241545 2884.214209
#> HI-REDUCTION 75 2884.232491 2884.214209
#> LO-REDUCTION 77 2884.227891 2884.214209
#> REFLECTION 79 2884.222247 2884.211910
#> LO-REDUCTION 81 2884.219542 2884.211910
#> REFLECTION 83 2884.216543 2884.208206
#> HI-REDUCTION 85 2884.214209 2884.208206
#> REFLECTION 87 2884.212109 2884.207571
#> REFLECTION 89 2884.211910 2884.204090
#> LO-REDUCTION 91 2884.209897 2884.204090
#> EXTENSION 93 2884.208206 2884.196287
#> LO-REDUCTION 95 2884.207571 2884.196287
#> LO-REDUCTION 97 2884.205801 2884.196287
#> LO-REDUCTION 99 2884.204090 2884.196287
#> EXTENSION 101 2884.200845 2884.187823
#> LO-REDUCTION 103 2884.200017 2884.187823
#> LO-REDUCTION 105 2884.197901 2884.187823
#> LO-REDUCTION 107 2884.196287 2884.187823
#> EXTENSION 109 2884.194098 2884.185217
#> REFLECTION 111 2884.192371 2884.184869
#> EXTENSION 113 2884.190371 2884.181057
#> REFLECTION 115 2884.187823 2884.179468
#> LO-REDUCTION 117 2884.185217 2884.179468
#> LO-REDUCTION 119 2884.184869 2884.179468
#> LO-REDUCTION 121 2884.182670 2884.179271
#> EXTENSION 123 2884.181057 2884.174673
#> LO-REDUCTION 125 2884.180099 2884.174673
#> EXTENSION 127 2884.179468 2884.170098
#> LO-REDUCTION 129 2884.179271 2884.170098
#> EXTENSION 131 2884.176628 2884.166480
#> EXTENSION 133 2884.174673 2884.161706
#> EXTENSION 135 2884.170454 2884.149121
#> LO-REDUCTION 137 2884.170098 2884.149121
#> LO-REDUCTION 139 2884.166480 2884.149121
#> EXTENSION 141 2884.161706 2884.134374
#> LO-REDUCTION 143 2884.157294 2884.134374
#> EXTENSION 145 2884.155098 2884.116203
#> EXTENSION 147 2884.149121 2884.090693
#> LO-REDUCTION 149 2884.141857 2884.090693
#> EXTENSION 151 2884.134374 2884.069820
#> EXTENSION 153 2884.116203 2883.997578
#> LO-REDUCTION 155 2884.093568 2883.997578
#> EXTENSION 157 2884.090693 2883.921060
#> LO-REDUCTION 159 2884.069820 2883.921060
#> EXTENSION 161 2884.001430 2883.768134
#> LO-REDUCTION 163 2883.997578 2883.768134
#> EXTENSION 165 2883.931248 2883.604649
#> LO-REDUCTION 167 2883.921060 2883.604649
#> EXTENSION 169 2883.788867 2883.342194
#> LO-REDUCTION 171 2883.768134 2883.342194
#> EXTENSION 173 2883.611557 2883.264365
#> LO-REDUCTION 175 2883.604649 2883.264365
#> LO-REDUCTION 177 2883.366603 2883.236876
#> LO-REDUCTION 179 2883.342194 2883.236876
#> HI-REDUCTION 181 2883.266722 2883.236876
#> LO-REDUCTION 183 2883.264365 2883.235914
#> HI-REDUCTION 185 2883.253315 2883.235914
#> HI-REDUCTION 187 2883.250570 2883.231901
#> REFLECTION 189 2883.238972 2883.223324
#> HI-REDUCTION 191 2883.236876 2883.223324
#> REFLECTION 193 2883.235914 2883.222976
#> LO-REDUCTION 195 2883.231901 2883.222976
#> REFLECTION 197 2883.230575 2883.219943
#> REFLECTION 199 2883.226230 2883.216983
#> REFLECTION 201 2883.223324 2883.215562
#> LO-REDUCTION 203 2883.222976 2883.215562
#> REFLECTION 205 2883.219943 2883.213091
#> EXTENSION 207 2883.216983 2883.209451
#> LO-REDUCTION 209 2883.216054 2883.209451
#> LO-REDUCTION 211 2883.215562 2883.209451
#> REFLECTION 213 2883.213091 2883.209182
#> REFLECTION 215 2883.210682 2883.206047
#> LO-REDUCTION 217 2883.210389 2883.206047
#> HI-REDUCTION 219 2883.209451 2883.206047
#> EXTENSION 221 2883.209182 2883.204351
#> EXTENSION 223 2883.206824 2883.201442
#> EXTENSION 225 2883.206198 2883.197598
#> EXTENSION 227 2883.206047 2883.194732
#> LO-REDUCTION 229 2883.204351 2883.194732
#> EXTENSION 231 2883.201442 2883.184381
#> EXTENSION 233 2883.197598 2883.179577
#> LO-REDUCTION 235 2883.196262 2883.179577
#> EXTENSION 237 2883.194732 2883.163859
#> EXTENSION 239 2883.186089 2883.155529
#> LO-REDUCTION 241 2883.184381 2883.155529
#> LO-REDUCTION 243 2883.179577 2883.155529
#> REFLECTION 245 2883.163859 2883.149003
#> LO-REDUCTION 247 2883.157131 2883.149003
#> LO-REDUCTION 249 2883.156818 2883.149003
#> LO-REDUCTION 251 2883.155529 2883.149003
#> LO-REDUCTION 253 2883.152542 2883.149003
#> LO-REDUCTION 255 2883.151799 2883.149003
#> LO-REDUCTION 257 2883.151213 2883.149003
#> LO-REDUCTION 259 2883.150774 2883.149003
#> EXTENSION 261 2883.149429 2883.146832
#> LO-REDUCTION 263 2883.149373 2883.146832
#> EXTENSION 265 2883.149111 2883.146446
#> REFLECTION 267 2883.149003 2883.145823
#> EXTENSION 269 2883.147235 2883.142518
#> LO-REDUCTION 271 2883.146832 2883.142518
#> LO-REDUCTION 273 2883.146446 2883.142518
#> LO-REDUCTION 275 2883.145823 2883.142518
#> EXTENSION 277 2883.144279 2883.140196
#> EXTENSION 279 2883.143353 2883.139006
#> EXTENSION 281 2883.143184 2883.136671
#> LO-REDUCTION 283 2883.142518 2883.136671
#> LO-REDUCTION 285 2883.140196 2883.136671
#> LO-REDUCTION 287 2883.139143 2883.136671
#> LO-REDUCTION 289 2883.139006 2883.136671
#> LO-REDUCTION 291 2883.138430 2883.136671
#> EXTENSION 293 2883.137091 2883.135142
#> LO-REDUCTION 295 2883.137055 2883.135142
#> LO-REDUCTION 297 2883.136876 2883.135142
#> LO-REDUCTION 299 2883.136671 2883.135142
#> LO-REDUCTION 301 2883.136256 2883.135142
#> EXTENSION 303 2883.135331 2883.134309
#> EXTENSION 305 2883.135314 2883.134212
#> REFLECTION 307 2883.135160 2883.133997
#> LO-REDUCTION 309 2883.135142 2883.133997
#> LO-REDUCTION 311 2883.134309 2883.133919
#> LO-REDUCTION 313 2883.134212 2883.133912
#> HI-REDUCTION 315 2883.134091 2883.133912
#> LO-REDUCTION 317 2883.133997 2883.133899
#> HI-REDUCTION 319 2883.133938 2883.133888
#> LO-REDUCTION 321 2883.133919 2883.133864
#> HI-REDUCTION 323 2883.133912 2883.133862
#> Exiting from Nelder Mead minimizer
#> 325 function evaluations used
#> Post processing for method Nelder-Mead
#> Successful convergence!
#> Compute Hessian approximation at finish of Nelder-Mead
#> Compute gradient approximation at finish of Nelder-Mead
#> Save results from method Nelder-Mead
#> $par
#> log.r log.alpha log.a log.b
#> -0.7265353 1.1885279 -0.9792292 1.4542322
#>
#> $value
#> [1] 2883.134
#>
#> $message
#> NULL
#>
#> $convcode
#> [1] 0
#>
#> $fevals
#> function
#> 325
#>
#> $gevals
#> gradient
#> NA
#>
#> $nitns
#> [1] NA
#>
#> $kkt1
#> [1] TRUE
#>
#> $kkt2
#> [1] TRUE
#>
#> $xtimes
#> user.self
#> 0.121
#>
#> Assemble the answers
#> Estimation finished!
# estimated coefs
coef(apparel.bgnbd)
#> r alpha a b
#> 0.4835815 3.2822459 0.3756005 4.2811953
# summary of the fitted model
summary(apparel.bgnbd)
#> BG/NBD Standard Model
#>
#> Call:
#> bgnbd(clv.data = clv.data.apparel, optimx.args = list(method = "Nelder-Mead",
#> control = list(trace = 6)))
#>
#> Fitting period:
#> Estimation start 2005-01-03
#> Estimation end 2005-10-10
#> Estimation length 40.0000 Weeks
#>
#> Coefficients:
#> Estimate Std. Error z-val Pr(>|z|)
#> r 0.48358 0.05366 9.012 < 2e-16 ***
#> alpha 3.28225 0.51360 6.391 1.65e-10 ***
#> a 0.37560 0.18360 2.046 0.0408 *
#> b 4.28120 2.92789 1.462 0.1437
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Optimization info:
#> LL -2883.1339
#> AIC 5774.2677
#> BIC 5788.3536
#> KKT 1 TRUE
#> KKT 2 TRUE
#> fevals 325.0000
#> Method Nelder-Mead
# predict CLV etc for holdout period
predict(apparel.bgnbd)
#> Predicting from 2005-10-11 until (incl.) 2006-07-16 (39.86 Weeks).
#> Estimating gg model to predict spending...
#> Starting estimation...
#> Estimation finished!
#> Id period.first period.last period.length actual.x actual.total.spending
#> 1: 1 2005-10-11 2006-07-16 39.85714 0 0.00
#> 2: 10 2005-10-11 2006-07-16 39.85714 0 0.00
#> 3: 100 2005-10-11 2006-07-16 39.85714 23 737.53
#> 4: 1000 2005-10-11 2006-07-16 39.85714 23 1069.91
#> 5: 1001 2005-10-11 2006-07-16 39.85714 11 364.00
#> ---
#> 246: 1219 2005-10-11 2006-07-16 39.85714 14 413.76
#> 247: 122 2005-10-11 2006-07-16 39.85714 0 0.00
#> 248: 1220 2005-10-11 2006-07-16 39.85714 0 0.00
#> 249: 1221 2005-10-11 2006-07-16 39.85714 9 302.65
#> 250: 1222 2005-10-11 2006-07-16 39.85714 0 0.00
#> predicted.mean.spending CET PAlive
#> 1: 39.95483 0.4243615 1.0000000
#> 2: 55.23031 1.1842170 0.5589646
#> 3: 43.57390 13.4903936 0.8918495
#> 4: 41.60921 13.2073200 0.9775625
#> 5: 45.58153 3.5970526 0.5114537
#> ---
#> 246: 33.58728 3.4747558 0.9215830
#> 247: 39.95483 0.4243615 1.0000000
#> 248: 39.95483 0.4243615 1.0000000
#> 249: 34.28958 4.1928882 0.9135946
#> 250: 47.35500 0.7949918 0.6210671
# predict CLV etc for the next 15 periods
predict(apparel.bgnbd, prediction.end = 15)
#> Predicting from 2005-10-11 until (incl.) 2006-01-23 (15 Weeks).
#> Estimating gg model to predict spending...
#> Starting estimation...
#> Estimation finished!
#> Id period.first period.last period.length actual.x actual.total.spending
#> 1: 1 2005-10-11 2006-01-23 15 0 0.00
#> 2: 10 2005-10-11 2006-01-23 15 0 0.00
#> 3: 100 2005-10-11 2006-01-23 15 10 224.71
#> 4: 1000 2005-10-11 2006-01-23 15 10 343.11
#> 5: 1001 2005-10-11 2006-01-23 15 6 206.65
#> ---
#> 246: 1219 2005-10-11 2006-01-23 15 11 325.05
#> 247: 122 2005-10-11 2006-01-23 15 0 0.00
#> 248: 1220 2005-10-11 2006-01-23 15 0 0.00
#> 249: 1221 2005-10-11 2006-01-23 15 7 158.46
#> 250: 1222 2005-10-11 2006-01-23 15 0 0.00
#> predicted.mean.spending CET PAlive
#> 1: 39.95483 0.1643356 1.0000000
#> 2: 55.23031 0.4660760 0.5589646
#> 3: 43.57390 5.4306174 0.8918495
#> 4: 41.60921 5.3123540 0.9775625
#> 5: 45.58153 1.4381151 0.5114537
#> ---
#> 246: 33.58728 1.3784751 0.9215830
#> 247: 39.95483 0.1643356 1.0000000
#> 248: 39.95483 0.1643356 1.0000000
#> 249: 34.28958 1.6677149 0.9135946
#> 250: 47.35500 0.3108782 0.6210671
# }
# \donttest{
# To estimate the bgnbd model with static covariates,
# add static covariates to the data
data("apparelStaticCov")
clv.data.static.cov <-
SetStaticCovariates(clv.data.apparel,
data.cov.life = apparelStaticCov,
names.cov.life = c("Gender", "Channel"),
data.cov.trans = apparelStaticCov,
names.cov.trans = c("Gender", "Channel"))
# Fit bgnbd with static covariates
bgnbd(clv.data.static.cov)
#> Starting estimation...
#> Estimation finished!
#> BG/NBD with Static Covariates Model
#>
#> Call:
#> bgnbd(clv.data = clv.data.static.cov)
#>
#> Coefficients:
#> r alpha a b life.Gender
#> 0.6388 19.4162 112.3599 1494.7095 -6.2899
#> life.Channel trans.Gender trans.Channel
#> 1.1070 1.3655 0.6995
#> KKT1: TRUE
#> KKT2: FALSE
#> Constraints: FALSE
#> Regularization: FALSE
# Give initial guesses for both covariate parameters
bgnbd(clv.data.static.cov, start.params.trans = c(Gender=0.75, Channel=0.7),
start.params.life = c(Gender=0.5, Channel=0.5))
#> Starting estimation...
#> Estimation finished!
#> BG/NBD with Static Covariates Model
#>
#> Call:
#> bgnbd(clv.data = clv.data.static.cov, start.params.life = c(Gender = 0.5,
#> Channel = 0.5), start.params.trans = c(Gender = 0.75, Channel = 0.7))
#>
#> Coefficients:
#> r alpha a b life.Gender
#> 0.6393 19.4913 2.1251 28.2174 -2.3357
#> life.Channel trans.Gender trans.Channel
#> 1.1016 1.3642 0.6993
#> KKT1: TRUE
#> KKT2: TRUE
#> Constraints: FALSE
#> Regularization: FALSE
# Use regularization
bgnbd(clv.data.static.cov, reg.lambdas = c(trans = 5, life=5))
#> Starting estimation...
#> Estimation finished!
#> BG/NBD with Static Covariates Model
#>
#> Call:
#> bgnbd(clv.data = clv.data.static.cov, reg.lambdas = c(trans = 5,
#> life = 5))
#>
#> Coefficients:
#> r alpha a b life.Gender
#> 0.4851703 3.3321229 0.3904548 4.5376573 -0.0001548
#> life.Channel trans.Gender trans.Channel
#> 0.0003939 0.0080547 0.0068149
#> KKT1: TRUE
#> KKT2: TRUE
#> Constraints: FALSE
#> Regularization: TRUE
# Force the same coefficient to be used for both covariates
bgnbd(clv.data.static.cov, names.cov.constr = "Gender",
start.params.constr = c(Gender=0.5))
#> Starting estimation...
#> Estimation finished!
#> BG/NBD with Static Covariates Model
#>
#> Call:
#> bgnbd(clv.data = clv.data.static.cov, names.cov.constr = "Gender",
#> start.params.constr = c(Gender = 0.5))
#>
#> Coefficients:
#> r alpha a b life.Channel
#> 0.64327 20.11566 0.05313 0.73089 1.22247
#> trans.Channel constr.Gender
#> 0.70163 1.38919
#> KKT1: TRUE
#> KKT2: TRUE
#> Constraints: TRUE
#> Regularization: FALSE
# Fit model only with the Channel covariate for life but
# keep all trans covariates as is
bgnbd(clv.data.static.cov, names.cov.life = c("Channel"))
#> Starting estimation...
#> Estimation finished!
#> BG/NBD with Static Covariates Model
#>
#> Call:
#> bgnbd(clv.data = clv.data.static.cov, names.cov.life = c("Channel"))
#>
#> Coefficients:
#> r alpha a b life.Channel
#> 0.6408 19.7857 0.2107 2.8324 1.1492
#> trans.Gender trans.Channel
#> 1.3801 0.7011
#> KKT1: TRUE
#> KKT2: TRUE
#> Constraints: FALSE
#> Regularization: FALSE
# }