Learn R Programming

CLVTools (version 0.10.0)

spending: Formula Interface for Spending Models

Description

Fit latent Gamma-Gamma model for customer spending with a formula interface

Usage

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

Value

Returns an object of the respective model which was fit.

Arguments

formula

Formula specifying the model to be fit. See Details.

data

Either a clv.data object or a data.frame containing transaction data on which the model specified in formula will be fit.

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.

See Also

Spending models for inputs: gg.

latentAttrition to fit latent attrition models with a formula interface

Examples

Run this code
# \donttest{

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

# Fit gg
spending(~gg(), data=clv.cdnow)

# Fit gg with start params
spending(~gg(start.params.model=c(p=0.5, q=15, gamma=2)),
         data=clv.cdnow)

# Fit gg, do not remove first transaction
spending(~gg(remove.first.transaction=FALSE), data=clv.cdnow)
# same, abreviate parameters
spending(~gg(remo=F), data=clv.cdnow)

# Fit gg on given data.frame transaction data, no split
spending(data()~gg(), data=cdnow)

# Fit gg on given data.frame, split after 39 periods
spending(data(split=39)~gg(), data=cdnow)
# same but also give date format and period definition
spending(data(split=39, format=ymd, unit=w)~gg(), data=cdnow)

## No covariate may be selected or covariate data.frame may be
## given because currently no spending model uses covariates

# }


Run the code above in your browser using DataLab