# \donttest{
data("apparelTrans")
clv.data.apparel <- clvdata(apparelTrans, date.format = "ymd",
time.unit = "w", estimation.split = 52)
# Fit standard ggomnbd model
ggomnbd(clv.data.apparel)
# 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))
# 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)))
# estimated coefs
coef(apparel.ggomnbd)
# summary of the fitted model
summary(apparel.ggomnbd)
# predict CLV etc for holdout period
predict(apparel.ggomnbd)
# predict CLV etc for the next 15 periods
predict(apparel.ggomnbd, prediction.end = 15)
# }
# \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)
# 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))
# Use regularization
ggomnbd(clv.data.static.cov, reg.lambdas = c(trans = 5, life=5))
# 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))
# 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"))
# }
Run the code above in your browser using DataLab