Add dynamic covariate data to an existing data object of class The returned object can be used to fit models with dynamic 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.

  names.cov.trans, = "Id", = "Date"


CLV data object to add the covariates data to.

Dynamic covariate data as data.frame or data.table for the lifetime process.


Dynamic covariate data as data.frame or data.table for the transaction process.

Vector with names of the columns in that contain the covariates.


Vector with names of the columns in data.cov.trans that contain the covariates.

Name of the column to find the Id data for both, and data.cov.trans.

Name of the column to find the Date data for both, and data.cov.trans.


An object of class See the class definition for more details about the returned object.

Details and data.cov.trans are data.frames or data.tables that each contain exactly 1 row for every combination of timepoint and customer. For each customer appearing in the transaction data there needs to be covariate data at every timepoint that marks the start of a period as defined by time.unit. It has to range from the start of the estimation sample (timepoint.estimation.start) until the end of the period in which the end of the holdout sample (timepoint.holdout.end) falls. See the the provided data apparelDynCov for illustration. Covariates of class character or factor are converted to k-1 numeric dummies.

Date as character If the Date column in the covariate data is of type character, the date.format given when creating the the object is used for parsing.


if (FALSE) { data("apparelTrans") data("apparelDynCov") # Create a clv data object without covariates <- clvdata(apparelTrans, time.unit="w", date.format="ymd") # Add static covariate data <- SetDynamicCovariates(, = apparelDynCov, = c("Marketing", "Gender", "Channel"), data.cov.trans = apparelDynCov, names.cov.trans = c("Marketing", "Gender", "Channel"), = "Id", = "Cov.Date") # summary output about covariates data summary( # fit pnbd model with dynamic covariates pnbd( }