# \donttest{
data("apparelTrans")
data("apparelStaticCov")
clv.nocov <-
clvdata(apparelTrans, time.unit="w", date.format="ymd")
# Create static covariate data with 2 covariates
clv.staticcov <-
SetStaticCovariates(clv.nocov,
data.cov.life = apparelStaticCov,
names.cov.life = c("Gender", "Channel"),
data.cov.trans = apparelStaticCov,
names.cov.trans = c("Gender", "Channel"))
# Fit models without covariates.
# Note that NO formula may be specified in this case
latentAttrition(formula =, family=pnbd, data=clv.nocov)
latentAttrition(formula =, family=bgnbd, data=clv.nocov)
latentAttrition(formula =, family=ggomnbd, data=clv.nocov)
# Fit pnbd with start parameters and correlation
# required args are passed as part of '...'
latentAttrition(formula =, family=pnbd, data=clv.nocov,
use.cor=TRUE,
start.params.model=c(r=1, alpha=10, s=2, beta=8))
# Fit pnbd with all present covariates
latentAttrition(formula=~.|., family=pnbd, data=clv.staticcov)
# Fit pnbd with selected covariates
latentAttrition(formula=~Gender|Channel+Gender, family=pnbd,
data=clv.staticcov)
# Fit pnbd with start parameters for covariates
latentAttrition(formula=~Gender|., family=pnbd,
data=clv.staticcov,
start.params.life = c(Gender = 0.6),
start.params.trans = c(Gender = 0.6, Channel = 0.4))
# Fit pnbd with transformed covariate data
latentAttrition(formula=~Gender|I(log(Channel+2)), family=pnbd,
data=clv.staticcov)
# Fit pnbd with all covs and regularization
latentAttrition(formula=~.|., family=pnbd, data=clv.staticcov,
reg.lambdas = c(life=3, trans=8))
# Fit pnbd with all covs and constraint parameters for Channel
latentAttrition(formula=~.|., family=pnbd, data=clv.staticcov,
names.cov.constr='Channel')
# }
Run the code above in your browser using DataLab