View source: R/f_interface_setstaticcovariates.R
SetStaticCovariates | R Documentation |
Add static covariate data to an existing data object of class clv.data
.
The returned object then can be used to fit models with static covariates.
No covariate data can be added to a clv data object which already has any covariate set.
At least 1 covariate is needed for both processes and no categorical covariate may be of only a single category.
SetStaticCovariates(
clv.data,
data.cov.life,
data.cov.trans,
names.cov.life,
names.cov.trans,
name.id = "Id"
)
clv.data |
CLV data object to add the covariates data to. |
data.cov.life |
Static covariate data as |
data.cov.trans |
Static covariate data as |
names.cov.life |
Vector with names of the columns in |
names.cov.trans |
Vector with names of the columns in |
name.id |
Name of the column to find the Id data for both, |
data.cov.life
and data.cov.trans
are data.frame
s or data.table
s that
each contain exactly one single row of covariate data for every customer appearing in the
transaction data. Covariates of class character
or factor
are converted
to k-1 numeric dummy variables.
An object of class clv.data.static.covariates
.
See the class definition clv.data.static.covariates
for more details about the returned object.
data("apparelTrans")
data("apparelStaticCov")
# Create a clv data object without covariates
clv.data.apparel <- clvdata(apparelTrans, time.unit="w",
date.format="ymd")
# Add static covariate data
clv.data.apparel.cov <-
SetStaticCovariates(clv.data.apparel,
data.cov.life = apparelStaticCov,
names.cov.life = "Gender",
data.cov.trans = apparelStaticCov,
names.cov.trans = "Gender",
name.id = "Id")
# more summary output
summary(clv.data.apparel.cov)
# fit model with static covariates
pnbd(clv.data.apparel.cov)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.