Fit models for customer spending (currently only the Gamma-Gamma model).

spending(family, data, optimx.args = list(), verbose = TRUE, ...)

Arguments

family

A spending model (currently only gg).

data

A clv.data object.

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.

...

Forwarded to model specified in family.

Value

Returns an object of the respective model which was fit.

See also

Spending models for family: gg.

latentAttrition to fit latent attrition models with a formula interface

Examples

# \donttest{

data("cdnow")
clv.cdnow <- clvdata(data.transactions = cdnow, date.format="ymd",
                     time.unit = "weeks")

# Fit gg
spending(family=gg, data=clv.cdnow)
#> Starting estimation...
#> Estimation finished!
#> Gamma-Gamma Model
#> 
#> Call:
#> spending(family = gg, data = clv.cdnow)
#> 
#> Coefficients:
#>      p       q   gamma  
#>  4.685   4.188  24.369  
#> KKT1: TRUE 
#> KKT2: TRUE 

# Fit gg with start params
spending(family=gg, data=clv.cdnow,
         start.params.model=c(p=0.5, q=15, gamma=2))
#> Starting estimation...
#> Estimation finished!
#> Gamma-Gamma Model
#> 
#> Call:
#> spending(family = gg, data = clv.cdnow, start.params.model = c(p = 0.5, 
#>     q = 15, gamma = 2))
#> 
#> Coefficients:
#>      p       q   gamma  
#>  4.683   4.190  24.391  
#> KKT1: TRUE 
#> KKT2: TRUE 

# Fit gg, do not remove first transaction
spending(family=gg, data=clv.cdnow, remove.first.transaction=FALSE)
#> Starting estimation...
#> Estimation finished!
#> Gamma-Gamma Model
#> 
#> Call:
#> spending(family = gg, data = clv.cdnow, remove.first.transaction = FALSE)
#> 
#> Coefficients:
#>      p       q   gamma  
#>  7.060   3.752  12.894  
#> KKT1: TRUE 
#> KKT2: TRUE 


## No formula may be given to specify covariates because currently
## no spending model uses covariates

# }