spending: Formula Interface for Spending Models

View source: R/f_interface_spending.R

spendingR Documentation

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)

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.

Value

Returns an object of the respective model which was fit.

See Also

Spending models for inputs: gg.

latentAttrition to fit latent attrition models with a formula interface

Examples



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





bachmannpatrick/CLVTools documentation built on Oct. 29, 2023, 2:16 p.m.