The methods documented here are to be used together with predict to obtain
the expected number of transactions of an average newly alive customer.
It describes the number of transactions a single, average new customer is expected to make in
the num.periods
periods since making the first transaction ("coming alive"). This prediction is only
sensible for customers who just came alive and have not had the chance to reveal any more of their behavior.
The data required for this new customer prediction is produced by the methods described here. This is mostly covariate data for static and dynamic covariate models. See details for the required format.
newcustomer(num.periods)
newcustomer.static(num.periods, data.cov.life, data.cov.trans)
newcustomer.dynamic(
num.periods,
data.cov.life,
data.cov.trans,
first.transaction
)
A positive, numeric scalar indicating the number of periods to predict.
Numeric-only covariate data for the lifetime process for a single customer, data.table
or data.frame
. See details.
Numeric-only covariate data for the transaction process for a single customer, data.table
or data.frame
. See details.
For dynamic covariate models only: The time point of the first transaction of the customer ("coming alive") for which a prediction is made. Has to be within the time range of the covariate data.
An object of class clv.newcustomer.no.cov
An object of class clv.newcustomer.static.cov
An object of class clv.newcustomer.dynamic.cov
The covariate data has to contain one column for every covariate parameter in the fitted model. Only numeric values are allowed, no factors or characters. No customer Id is required because the data on which the model was fit is not used for this prediction.
For newcustomer.static()
: One column for every covariate parameter in the estimated model.
No column Id
. Exactly 1 row of numeric covariate data.
For example: data.frame(Gender=1, Age=30, Channel=0)
.
For newcustomer.dynamic()
: One column for every covariate parameter in the estimated model.
No column Id
. A column Cov.Date
with time points that mark the start of the period defined by time.unit
.
For every Cov.Date
, exactly 1 row of numeric covariate data.
For example for weekly covariates: data.frame(Cov.Date=c("2000-01-03", "2000-01-10"), Gender=c(1,1), High.Season=c(0, 1), Marketing=c(-0.5,1.12))
If Cov.Date
is of type character, the date.format
given when creating the the clv.data
object is used to parse it.
The data has to cover the time from the customer's first transaction first.transaction
to the end of the prediction period given by t
. It does not have to cover the same time range as when fitting the model.
See examples.
For models with dynamic covariates, the time point of the first purchase (first.transaction
) is
additionally required because the exact covariates that are active during the prediction period have
to be known.
predict to use the output of the methods described here.
# \donttest{
data("apparelTrans")
data("apparelStaticCov")
data("apparelDynCov")
clv.data.apparel <- clvdata(apparelTrans, date.format = "ymd",
time.unit = "w", estimation.split = 40)
clv.data.static.cov <-
SetStaticCovariates(clv.data.apparel,
data.cov.life = apparelStaticCov,
names.cov.life = "Gender",
data.cov.trans = apparelStaticCov,
names.cov.trans = c("Gender", "Channel"))
clv.data.dyn.cov <-
SetDynamicCovariates(clv.data = clv.data.apparel,
data.cov.life = apparelDynCov,
data.cov.trans = apparelDynCov,
names.cov.life = c("Marketing", "Gender"),
names.cov.trans = c("Marketing", "Gender"),
name.date = "Cov.Date")
#> The Lifetime covariate data before 2005-01-02 (period of estimation start) is cut off.
#> The Transaction covariate data before 2005-01-02 (period of estimation start) is cut off.
# No covariate model
p.apparel <- pnbd(clv.data.apparel)
#> Starting estimation...
#> Estimation finished!
# Predict the number of transactions an average new
# customer is expected to make in the first 3.68 weeks
predict(
p.apparel,
newdata=newcustomer(num.periods=3.68)
)
#> [1] 0.5155953
# Static covariate model
p.apparel.static <- pnbd(clv.data.static.cov)
#> Starting estimation...
#> Estimation finished!
# Predict the number of transactions an average new
# customer who is female (Gender=1) and who was acquired
# online (Channel=1) is expected to make in the first 3.68 weeks
predict(
p.apparel.static,
newdata=newcustomer.static(
num.periods=3.68,
# For the lifetime process, only Gender was used when fitting
data.cov.life=data.frame(Gender=1),
data.cov.trans=data.frame(Gender=1, Channel=0)
)
)
#> [1] 0.4988839
if (FALSE) { # \dontrun{
# Dynamic covariate model
p.apparel.dyn <- pnbd(clv.data.dyn.cov)
# Predict the number of transactions an average new
# customer who is male (Gender=0), who was contacted
# 4, 0, and 7 times with direct marketing, and who was
# acquired on "2005-02-16" (first.transaction) is expected
# to make in the first 2.12 weeks.
# Note that the time range is very different from the one used
# when fitting the model. Cov.Date still has to match the
# beginning of the week.
predict(
p.apparel.dyn,
newdata=newcustomer.dynamic(
num.periods=2.12,
data.cov.life=data.frame(
Cov.Date=c("2051-02-12", "2051-02-19", "2051-02-26"),
Gender=c(0, 0, 0),
Marketing=c(4, 0, 7)),
data.cov.trans=data.frame(
Cov.Date=c("2051-02-12", "2051-02-19", "2051-02-26"),
Gender=c(0, 0, 0),
Marketing=c(4, 0, 7)),
first.transaction = "2051-02-16"
)
)
} # }
# }