Fits Gamma-Gompertz/NBD models on transactional data with static and without covariates.

# S4 method for clv.data
ggomnbd(
  clv.data,
  start.params.model = c(),
  optimx.args = list(),
  verbose = TRUE,
  ...
)

# S4 method for clv.data.static.covariates
ggomnbd(
  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(),
  ...
)

Arguments

clv.data

The data object on which the model is fitted.

start.params.model

Named start parameters containing the optimization start parameters for the model without covariates.

optimx.args

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.

verbose

Show details about the running of the function.

...

Ignored

names.cov.life

Which of the set Lifetime covariates should be used. Missing parameter indicates all covariates shall be used.

names.cov.trans

Which of the set Transaction covariates should be used. Missing parameter indicates all covariates shall be used.

start.params.life

Named start parameters containing the optimization start parameters for all lifetime covariates.

start.params.trans

Named start parameters containing the optimization start parameters for all transaction covariates.

names.cov.constr

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.

start.params.constr

Named start parameters containing the optimization start parameters for the constraint covariates.

reg.lambdas

Named lambda parameters used for the L2 regularization of the lifetime and the transaction covariate parameters. Lambdas have to be >= 0.

Value

Depending on the data object on which the model was fit, ggomnbd returns either an object of class clv.ggomnbd or clv.ggomnbd.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.

Details

Model parameters for the GGompertz /NBD model are r, alpha, beta, b and s.
r: shape parameter of the Gamma distribution of the purchase process. The smaller r, the stronger the heterogeneity of the purchase process.
alpha: scale parameter of the Gamma distribution of the purchase process.
beta: scale parameter for the Gamma distribution for the lifetime process.
b: scale parameter of the Gompertz distribution (constant across customers).
s: shape parameter of the Gamma distribution for the lifetime process. The smaller s, the stronger the heterogeneity of customer lifetimes.

If no start parameters are given, r = 1, alpha = 1, beta = 1, b = 1, s = 1 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 Gamma-Gompertz/NBD model

There are two key differences of the gamma/Gompertz/NBD (GGom/NBD) model compared to the relative to the well-known Pareto/NBD model: (i) its probability density function can exhibit a mode at zero or an interior mode, and (ii) it can be skewed to the right or to the left. Therefore, the GGom/NBD model is more flexible than the Pareto/NBD model. According to Bemmaor and Glady (2012) can indicate substantial differences in expected residual lifetimes compared to the Pareto/NBD. The GGom/NBD tends to be appropriate when firms are reputed and their offerings are differentiated.

References

Bemmaor AC, Glady N (2012). “Modeling Purchasing Behavior with Sudden “Death”: A Flexible Customer Lifetime Model” Management Science, 58(5), 1012-1021.

See also

clvdata to create a clv data object, SetStaticCovariates to add static covariates to an existing clv data object.

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

The generic functions vcov, summary, fitted.

Examples

# \donttest{ data("apparelTrans") clv.data.apparel <- clvdata(apparelTrans, date.format = "ymd", time.unit = "w", estimation.split = 40) # Fit standard ggomnbd model ggomnbd(clv.data.apparel)
#> Starting estimation...
#> Estimation finished!
#> GGompertz/NBD Standard Model #> #> Call: #> ggomnbd(clv.data = clv.data.apparel) #> #> Coefficients: #> r alpha b s beta #> 7.865e-01 5.334e+00 4.903e-07 3.573e-01 5.703e-06 #> KKT1: TRUE #> KKT2: FALSE
# Give initial guesses for the model parameters ggomnbd(clv.data.apparel, start.params.model = c(r=0.5, alpha=15, b=5, beta=10, s=0.5))
#> Starting estimation...
#> Estimation finished!
#> GGompertz/NBD Standard Model #> #> Call: #> ggomnbd(clv.data = clv.data.apparel, start.params.model = c(r = 0.5, #> alpha = 15, b = 5, beta = 10, s = 0.5)) #> #> Coefficients: #> r alpha b s beta #> 0.694315 4.918703 9.074435 0.001513 0.625261 #> KKT1: TRUE #> KKT2: FALSE
# pass additional parameters to the optimizer (optimx) # Use Nelder-Mead as optimization method and print # detailed information about the optimization process apparel.ggomnbd <- ggomnbd(clv.data.apparel, optimx.args = list(method="Nelder-Mead", control=list(trace=6)))
#> Starting estimation...
#> fn is fn #> Looking for method = Nelder-Mead #> Methods to be used:[1] "Nelder-Mead" #> optcfg:$fname #> [1] "fn" #> #> $npar #> [1] 5 #> #> $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] FALSE #> #> $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 (LL.params, LL.param.names.to.optimx, LL.function.sum, #> use.interlayer.constr, use.interlayer.reg, reg.lambda.trans, #> reg.lambda.life, use.cor, ...) #> { #> all.other.args <- list(...) #> names(LL.params) <- LL.param.names.to.optimx #> interlayers.to.use <- list(callLL = interlayer_callLL) #> if (use.cor == T & !anyNA(use.cor)) #> interlayers.to.use <- c(correlation = interlayer_correlation, #> interlayers.to.use) #> if (use.interlayer.reg == T & !is.null(reg.lambda.trans) & #> !anyNA(reg.lambda.trans) & !is.null(reg.lambda.life) & #> !anyNA(reg.lambda.life)) { #> interlayers.to.use <- c(regularization = interlayer_regularization, #> interlayers.to.use) #> } #> if (use.interlayer.constr == TRUE) { #> interlayers.to.use <- c(constraints = interlayer_constraints, #> interlayers.to.use) #> } #> interlayer.call.args <- list(next.interlayers = interlayers.to.use, #> LL.function.sum = LL.function.sum, LL.params = LL.params, #> reg.lambda.life = reg.lambda.life, reg.lambda.trans = reg.lambda.trans) #> interlayer.call.args <- modifyList(interlayer.call.args, #> all.other.args) #> return(do.call(what = interlayer_callnextinterlayer, args = interlayer.call.args)) #> } #> <bytecode: 0x7fb3a3faa4a8> #> <environment: namespace:CLVTools> #> #> $have.bounds #> [1] FALSE #> #> $method #> [1] "Nelder-Mead" #> #> Method: Nelder-Mead #> Nelder-Mead direct search function minimizer #> function value for initial parameters = 7135.028461 #> Scaled convergence tolerance is 0.00010632 #> Stepsize computed as 0.100000 #> BUILD 6 7601.506541 7119.715103 #> EXTENSION 8 7601.506541 6551.338914 #> EXTENSION 10 7158.281161 6037.513352 #> LO-REDUCTION 12 7135.028461 6037.513352 #> LO-REDUCTION 14 7120.679158 6037.513352 #> EXTENSION 16 7119.715103 5383.511468 #> EXTENSION 18 6551.338914 4690.867542 #> LO-REDUCTION 20 6407.902236 4690.867542 #> EXTENSION 22 6168.906218 4191.553467 #> LO-REDUCTION 24 6037.513352 4191.553467 #> EXTENSION 26 5383.511468 3460.012466 #> LO-REDUCTION 28 4978.908267 3460.012466 #> LO-REDUCTION 30 4690.867542 3460.012466 #> REFLECTION 32 4211.205075 3420.897750 #> REFLECTION 34 4191.553467 3347.024278 #> REFLECTION 36 3564.368966 3306.075340 #> LO-REDUCTION 38 3484.060645 3306.075340 #> LO-REDUCTION 40 3460.012466 3306.075340 #> HI-REDUCTION 42 3420.897750 3306.075340 #> EXTENSION 44 3360.906285 3249.494945 #> EXTENSION 46 3355.169338 3177.258603 #> LO-REDUCTION 48 3347.024278 3177.258603 #> LO-REDUCTION 50 3320.849704 3177.258603 #> LO-REDUCTION 52 3306.075340 3177.258603 #> EXTENSION 54 3273.448592 3126.508670 #> LO-REDUCTION 56 3249.494945 3126.508670 #> EXTENSION 58 3244.766463 3053.745820 #> EXTENSION 60 3213.848103 2976.546260 #> LO-REDUCTION 62 3177.258603 2976.546260 #> EXTENSION 64 3132.215016 2966.834537 #> REFLECTION 66 3126.508670 2947.715342 #> LO-REDUCTION 68 3053.745820 2943.458875 #> LO-REDUCTION 70 2984.745015 2943.458875 #> HI-REDUCTION 72 2976.546260 2943.458875 #> HI-REDUCTION 74 2966.834537 2943.458875 #> REFLECTION 76 2959.194063 2931.290958 #> LO-REDUCTION 78 2955.728569 2931.290958 #> LO-REDUCTION 80 2947.715342 2931.290958 #> EXTENSION 82 2945.749591 2910.691924 #> LO-REDUCTION 84 2943.458875 2910.691924 #> REFLECTION 86 2939.904064 2910.078049 #> LO-REDUCTION 88 2938.148136 2910.078049 #> HI-REDUCTION 90 2931.290958 2910.078049 #> EXTENSION 92 2925.652202 2899.477011 #> LO-REDUCTION 94 2921.692144 2899.477011 #> EXTENSION 96 2913.280407 2889.676951 #> LO-REDUCTION 98 2910.691924 2889.676951 #> LO-REDUCTION 100 2910.078049 2889.676951 #> LO-REDUCTION 102 2903.117478 2889.676951 #> LO-REDUCTION 104 2899.477011 2889.676951 #> LO-REDUCTION 106 2893.310771 2889.595748 #> LO-REDUCTION 108 2893.204167 2889.595748 #> HI-REDUCTION 110 2891.149473 2889.595748 #> LO-REDUCTION 112 2890.442814 2888.986058 #> HI-REDUCTION 114 2889.977167 2888.986058 #> HI-REDUCTION 116 2889.970098 2888.986058 #> HI-REDUCTION 118 2889.676951 2888.986058 #> HI-REDUCTION 120 2889.595748 2888.986058 #> HI-REDUCTION 122 2889.178411 2888.983546 #> HI-REDUCTION 124 2889.113981 2888.915364 #> HI-REDUCTION 126 2889.089142 2888.892026 #> LO-REDUCTION 128 2888.992848 2888.856251 #> HI-REDUCTION 130 2888.986058 2888.851384 #> HI-REDUCTION 132 2888.983546 2888.828646 #> REFLECTION 134 2888.915364 2888.803918 #> LO-REDUCTION 136 2888.892026 2888.798226 #> REFLECTION 138 2888.856251 2888.789774 #> LO-REDUCTION 140 2888.851384 2888.765020 #> LO-REDUCTION 142 2888.828646 2888.765020 #> EXTENSION 144 2888.803918 2888.676231 #> LO-REDUCTION 146 2888.798226 2888.676231 #> LO-REDUCTION 148 2888.789774 2888.676231 #> LO-REDUCTION 150 2888.769507 2888.676231 #> LO-REDUCTION 152 2888.765020 2888.676231 #> EXTENSION 154 2888.736045 2888.597050 #> LO-REDUCTION 156 2888.715116 2888.597050 #> HI-REDUCTION 158 2888.707924 2888.597050 #> LO-REDUCTION 160 2888.690153 2888.597050 #> EXTENSION 162 2888.676231 2888.502717 #> LO-REDUCTION 164 2888.663956 2888.502717 #> LO-REDUCTION 166 2888.640703 2888.502717 #> LO-REDUCTION 168 2888.609471 2888.502717 #> EXTENSION 170 2888.597050 2888.382369 #> LO-REDUCTION 172 2888.543721 2888.382369 #> EXTENSION 174 2888.535603 2888.309287 #> LO-REDUCTION 176 2888.514759 2888.309287 #> EXTENSION 178 2888.502717 2888.127086 #> EXTENSION 180 2888.385486 2887.907764 #> LO-REDUCTION 182 2888.382369 2887.907764 #> EXTENSION 184 2888.316554 2887.664092 #> LO-REDUCTION 186 2888.309287 2887.664092 #> EXTENSION 188 2888.127086 2887.039334 #> LO-REDUCTION 190 2888.014226 2887.039334 #> EXTENSION 192 2887.907764 2886.518976 #> LO-REDUCTION 194 2887.679675 2886.518976 #> EXTENSION 196 2887.664092 2885.899786 #> EXTENSION 198 2887.259417 2884.907469 #> LO-REDUCTION 200 2887.039334 2884.907469 #> EXTENSION 202 2886.574065 2884.328374 #> EXTENSION 204 2886.518976 2883.794179 #> LO-REDUCTION 206 2885.899786 2883.794179 #> REFLECTION 208 2885.210263 2883.541083 #> LO-REDUCTION 210 2884.907469 2883.541083 #> LO-REDUCTION 212 2884.328374 2883.541083 #> LO-REDUCTION 214 2883.934387 2883.541083 #> LO-REDUCTION 216 2883.829988 2883.541083 #> LO-REDUCTION 218 2883.794179 2883.541083 #> LO-REDUCTION 220 2883.782612 2883.541083 #> EXTENSION 222 2883.685721 2883.400072 #> LO-REDUCTION 224 2883.642556 2883.400072 #> LO-REDUCTION 226 2883.599999 2883.400072 #> EXTENSION 228 2883.564787 2883.308266 #> LO-REDUCTION 230 2883.541083 2883.308266 #> LO-REDUCTION 232 2883.468012 2883.308266 #> LO-REDUCTION 234 2883.418052 2883.306199 #> LO-REDUCTION 236 2883.400072 2883.306199 #> LO-REDUCTION 238 2883.323743 2883.306199 #> HI-REDUCTION 240 2883.311312 2883.305223 #> REFLECTION 242 2883.310127 2883.304818 #> HI-REDUCTION 244 2883.308335 2883.302027 #> HI-REDUCTION 246 2883.308266 2883.300185 #> LO-REDUCTION 248 2883.306199 2883.300090 #> LO-REDUCTION 250 2883.305223 2883.300090 #> HI-REDUCTION 252 2883.304818 2883.300090 #> HI-REDUCTION 254 2883.302027 2883.299983 #> HI-REDUCTION 256 2883.300344 2883.299669 #> REFLECTION 258 2883.300317 2883.299194 #> LO-REDUCTION 260 2883.300185 2883.299057 #> HI-REDUCTION 262 2883.300090 2883.298750 #> HI-REDUCTION 264 2883.299983 2883.298750 #> LO-REDUCTION 266 2883.299669 2883.298750 #> EXTENSION 268 2883.299194 2883.298015 #> HI-REDUCTION 270 2883.299057 2883.298015 #> LO-REDUCTION 272 2883.299025 2883.298015 #> LO-REDUCTION 274 2883.298804 2883.298015 #> LO-REDUCTION 276 2883.298750 2883.298015 #> EXTENSION 278 2883.298553 2883.297571 #> HI-REDUCTION 280 2883.298422 2883.297571 #> LO-REDUCTION 282 2883.298380 2883.297571 #> LO-REDUCTION 284 2883.298279 2883.297571 #> EXTENSION 286 2883.298148 2883.296809 #> LO-REDUCTION 288 2883.298015 2883.296809 #> LO-REDUCTION 290 2883.297743 2883.296809 #> LO-REDUCTION 292 2883.297632 2883.296809 #> EXTENSION 294 2883.297571 2883.296772 #> EXTENSION 296 2883.297233 2883.295620 #> LO-REDUCTION 298 2883.297112 2883.295620 #> LO-REDUCTION 300 2883.296827 2883.295620 #> EXTENSION 302 2883.296809 2883.295605 #> LO-REDUCTION 304 2883.296772 2883.295605 #> EXTENSION 306 2883.295826 2883.293410 #> LO-REDUCTION 308 2883.295782 2883.293410 #> LO-REDUCTION 310 2883.295776 2883.293410 #> LO-REDUCTION 312 2883.295620 2883.293410 #> EXTENSION 314 2883.295605 2883.292723 #> EXTENSION 316 2883.294609 2883.289572 #> LO-REDUCTION 318 2883.293997 2883.289572 #> LO-REDUCTION 320 2883.293762 2883.289572 #> EXTENSION 322 2883.293410 2883.286270 #> LO-REDUCTION 324 2883.292723 2883.286270 #> LO-REDUCTION 326 2883.290936 2883.286270 #> EXTENSION 328 2883.290621 2883.283268 #> EXTENSION 330 2883.289572 2883.278231 #> LO-REDUCTION 332 2883.286998 2883.278231 #> LO-REDUCTION 334 2883.286272 2883.278231 #> EXTENSION 336 2883.286270 2883.270565 #> LO-REDUCTION 338 2883.283268 2883.270565 #> LO-REDUCTION 340 2883.280953 2883.270565 #> EXTENSION 342 2883.278967 2883.263534 #> LO-REDUCTION 344 2883.278231 2883.263534 #> EXTENSION 346 2883.272985 2883.251432 #> LO-REDUCTION 348 2883.270853 2883.251432 #> EXTENSION 350 2883.270565 2883.238136 #> LO-REDUCTION 352 2883.263964 2883.238136 #> EXTENSION 354 2883.263534 2883.229625 #> EXTENSION 356 2883.255152 2883.216446 #> EXTENSION 358 2883.251432 2883.204430 #> EXTENSION 360 2883.242396 2883.202079 #> EXTENSION 362 2883.238136 2883.169805 #> LO-REDUCTION 364 2883.229625 2883.169805 #> LO-REDUCTION 366 2883.216446 2883.169805 #> LO-REDUCTION 368 2883.204430 2883.169805 #> LO-REDUCTION 370 2883.202079 2883.169805 #> LO-REDUCTION 372 2883.197022 2883.169805 #> LO-REDUCTION 374 2883.191411 2883.169805 #> EXTENSION 376 2883.190426 2883.165323 #> EXTENSION 378 2883.186334 2883.141877 #> EXTENSION 380 2883.180422 2883.122569 #> EXTENSION 382 2883.170577 2883.100133 #> EXTENSION 384 2883.169805 2883.063949 #> LO-REDUCTION 386 2883.165323 2883.063949 #> EXTENSION 388 2883.141877 2883.011666 #> EXTENSION 390 2883.122569 2882.937129 #> LO-REDUCTION 392 2883.100133 2882.937129 #> EXTENSION 394 2883.070135 2882.831742 #> EXTENSION 396 2883.063949 2882.738245 #> EXTENSION 398 2883.011666 2882.630856 #> EXTENSION 400 2882.941382 2882.528348 #> EXTENSION 402 2882.937129 2882.420613 #> EXTENSION 404 2882.831742 2882.302142 #> EXTENSION 406 2882.738245 2882.020821 #> LO-REDUCTION 408 2882.630856 2882.020821 #> LO-REDUCTION 410 2882.528348 2882.020821 #> LO-REDUCTION 412 2882.420613 2882.020821 #> REFLECTION 414 2882.302142 2882.012199 #> REFLECTION 416 2882.170239 2882.005497 #> REFLECTION 418 2882.135074 2881.990807 #> REFLECTION 420 2882.043244 2881.926713 #> EXTENSION 422 2882.020821 2881.851125 #> HI-REDUCTION 424 2882.012199 2881.851125 #> LO-REDUCTION 426 2882.005497 2881.851125 #> LO-REDUCTION 428 2881.990807 2881.851125 #> LO-REDUCTION 430 2881.926713 2881.846532 #> REFLECTION 432 2881.919198 2881.819054 #> LO-REDUCTION 434 2881.905029 2881.819054 #> LO-REDUCTION 436 2881.851619 2881.819054 #> LO-REDUCTION 438 2881.851125 2881.819054 #> LO-REDUCTION 440 2881.848764 2881.819054 #> LO-REDUCTION 442 2881.846532 2881.819054 #> REFLECTION 444 2881.825776 2881.803843 #> LO-REDUCTION 446 2881.823536 2881.803843 #> HI-REDUCTION 448 2881.823029 2881.803843 #> LO-REDUCTION 450 2881.820846 2881.803843 #> EXTENSION 452 2881.819054 2881.800244 #> EXTENSION 454 2881.813008 2881.788903 #> LO-REDUCTION 456 2881.810210 2881.788903 #> EXTENSION 458 2881.808841 2881.782684 #> EXTENSION 460 2881.803843 2881.774659 #> EXTENSION 462 2881.800244 2881.761178 #> LO-REDUCTION 464 2881.795478 2881.761178 #> REFLECTION 466 2881.788903 2881.758899 #> LO-REDUCTION 468 2881.782684 2881.758899 #> LO-REDUCTION 470 2881.774659 2881.758899 #> REFLECTION 472 2881.769603 2881.749476 #> HI-REDUCTION 474 2881.768143 2881.749476 #> LO-REDUCTION 476 2881.761178 2881.749476 #> LO-REDUCTION 478 2881.760836 2881.749476 #> HI-REDUCTION 480 2881.759550 2881.749476 #> LO-REDUCTION 482 2881.758899 2881.749476 #> REFLECTION 484 2881.755954 2881.746958 #> HI-REDUCTION 486 2881.754370 2881.746958 #> LO-REDUCTION 488 2881.753467 2881.746958 #> LO-REDUCTION 490 2881.752460 2881.746958 #> REFLECTION 492 2881.750015 2881.746107 #> LO-REDUCTION 494 2881.749476 2881.746107 #> LO-REDUCTION 496 2881.748688 2881.746107 #> HI-REDUCTION 498 2881.748420 2881.746107 #> REFLECTION 500 2881.747639 2881.745752 #> HI-REDUCTION 502 2881.747257 2881.745752 #> LO-REDUCTION 504 2881.747126 2881.745752 #> EXTENSION 506 2881.746958 2881.745432 #> LO-REDUCTION 508 2881.746951 2881.745432 #> HI-REDUCTION 510 2881.746609 2881.745432 #> HI-REDUCTION 512 2881.746247 2881.745432 #> HI-REDUCTION 514 2881.746107 2881.745432 #> LO-REDUCTION 516 2881.746028 2881.745432 #> LO-REDUCTION 518 2881.745901 2881.745392 #> HI-REDUCTION 520 2881.745752 2881.745392 #> HI-REDUCTION 522 2881.745638 2881.745392 #> HI-REDUCTION 524 2881.745574 2881.745392 #> HI-REDUCTION 526 2881.745573 2881.745392 #> HI-REDUCTION 528 2881.745567 2881.745392 #> HI-REDUCTION 530 2881.745509 2881.745392 #> REFLECTION 532 2881.745471 2881.745359 #> HI-REDUCTION 534 2881.745467 2881.745359 #> Exiting from Nelder Mead minimizer #> 536 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.b log.s log.beta #> -0.3673579 1.5919801 -8.9486321 6.0617963 1.4036926 #> #> $value #> [1] 2881.745 #> #> $message #> NULL #> #> $convcode #> [1] 0 #> #> $fevals #> function #> 536 #> #> $gevals #> gradient #> NA #> #> $nitns #> [1] NA #> #> $kkt1 #> [1] TRUE #> #> $kkt2 #> [1] FALSE #> #> $xtimes #> user.self #> 0.478 #> #> Assemble the answers
#> Estimation finished!
# estimated coefs coef(apparel.ggomnbd)
#> r alpha b s beta #> 6.925617e-01 4.913469e+00 1.299148e-04 4.291456e+02 4.070202e+00
# summary of the fitted model summary(apparel.ggomnbd)
#> GGompertz/NBD Standard Model #> #> Call: #> ggomnbd(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 6.926e-01 1.098e-01 6.306 2.86e-10 *** #> alpha 4.913e+00 8.493e-01 5.785 7.23e-09 *** #> b 1.299e-04 8.552e-05 1.519 0.129 #> s 4.291e+02 5.410e-02 7932.865 < 2e-16 *** #> beta 4.070e+00 5.758e-01 7.068 1.57e-12 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #> #> Optimization info: #> LL -2881.7454 #> AIC 5773.4907 #> BIC 5791.0980 #> KKT 1 TRUE #> KKT 2 FALSE #> fevals 536.0000 #> Method Nelder-Mead
# predict CLV etc for holdout period predict(apparel.ggomnbd)
#> 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 1.799972 0.4157734 #> 2: 55.23031 4.370424 0.3653550 #> 3: 43.57390 21.278243 0.8492175 #> 4: 41.60921 24.359085 0.9936311 #> 5: 45.58153 7.927577 0.3834394 #> --- #> 246: 33.58728 14.914337 0.9223629 #> 247: 39.95483 1.799972 0.4157734 #> 248: 39.95483 1.799972 0.4157734 #> 249: 34.28958 15.832742 0.8977081 #> 250: 47.35500 3.413481 0.3882902
# predict CLV etc for the next 15 periods predict(apparel.ggomnbd, 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.7946941 0.4157734 #> 2: 55.23031 1.9295576 0.3653550 #> 3: 43.57390 9.3944194 0.8492175 #> 4: 41.60921 10.7546219 0.9936311 #> 5: 45.58153 3.5000533 0.3834394 #> --- #> 246: 33.58728 6.5847324 0.9223629 #> 247: 39.95483 0.7946941 0.4157734 #> 248: 39.95483 0.7946941 0.4157734 #> 249: 34.28958 6.9902115 0.8977081 #> 250: 47.35500 1.5070640 0.3882902
# } # \donttest{ # To estimate the ggomnbd 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 ggomnbd with static covariates ggomnbd(clv.data.static.cov)
#> Starting estimation...
#> Estimation finished!
#> GGompertz/NBD with Static Covariates Model #> #> Call: #> ggomnbd(clv.data = clv.data.static.cov) #> #> Coefficients: #> r alpha b s beta #> 1.43123 35.57345 0.05532 0.15114 0.24512 #> life.Gender life.Channel trans.Gender trans.Channel #> 2.22430 -2.67448 1.43832 0.37309 #> KKT1: TRUE #> KKT2: TRUE #> Constraints: FALSE #> Regularization: FALSE
# Give initial guesses for both covariate parameters ggomnbd(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!
#> GGompertz/NBD with Static Covariates Model #> #> Call: #> ggomnbd(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 b s beta #> 1.42882 35.57508 0.05692 0.14949 0.25683 #> life.Gender life.Channel trans.Gender trans.Channel #> 2.26738 -2.69762 1.44023 0.37271 #> KKT1: TRUE #> KKT2: TRUE #> Constraints: FALSE #> Regularization: FALSE
# Use regularization ggomnbd(clv.data.static.cov, reg.lambdas = c(trans = 5, life=5))
#> Starting estimation...
#> Estimation finished!
#> GGompertz/NBD with Static Covariates Model #> #> Call: #> ggomnbd(clv.data = clv.data.static.cov, reg.lambdas = c(trans = 5, #> life = 5)) #> #> Coefficients: #> r alpha b s beta #> 0.7926996 5.4497686 0.0000601 0.3591047 0.0007010 #> life.Gender life.Channel trans.Gender trans.Channel #> -0.0004862 -0.0023863 0.0106830 0.0087755 #> KKT1: TRUE #> KKT2: FALSE #> Constraints: FALSE #> Regularization: TRUE
# Force the same coefficient to be used for both covariates ggomnbd(clv.data.static.cov, names.cov.constr = "Gender", start.params.constr = c(Gender=0.5))
#> Starting estimation...
#> Estimation finished!
#> GGompertz/NBD with Static Covariates Model #> #> Call: #> ggomnbd(clv.data = clv.data.static.cov, names.cov.constr = "Gender", #> start.params.constr = c(Gender = 0.5)) #> #> Coefficients: #> r alpha b s beta #> 1.44975 34.82124 0.03625 0.18018 0.11832 #> life.Channel trans.Channel constr.Gender #> -2.27283 0.37961 1.39891 #> KKT1: TRUE #> KKT2: TRUE #> Constraints: TRUE #> Regularization: FALSE
# Fit model only with the Channel covariate for life but # keep all trans covariates as is ggomnbd(clv.data.static.cov, names.cov.life = c("Channel"))
#> Starting estimation...
#> Estimation finished!
#> GGompertz/NBD with Static Covariates Model #> #> Call: #> ggomnbd(clv.data = clv.data.static.cov, names.cov.life = c("Channel")) #> #> Coefficients: #> r alpha b s beta #> 1.52883 32.06390 0.09904 0.10168 0.01608 #> life.Channel trans.Gender trans.Channel #> -3.51559 1.28502 0.35036 #> KKT1: TRUE #> KKT2: TRUE #> Constraints: FALSE #> Regularization: FALSE
# }