bachmannpatrick / CLVTools

R-Package for estimating CLV
54 stars 14 forks source link

Difficulty with introducing dynamic covariates #178

Closed notrlysure closed 1 year ago

notrlysure commented 3 years ago

Hello,

Thank you for developing this package. I've read through the CLVTools walkthrough and other issues on this github to see if there was an answer to my question, but I'm pretty sure there isn't.

I was wondering if I could have some help introducing dynamic covariates. Initially, I had created a dummy variable to indicate whether a purchase occurred during a month when there was a sale on (in this case, March is a month that had a sale), and I wanted to introduce that as a dynamic covariate. However, the time variable in the dataset only exists if a customer made an order on a particular date. Like this:

Screen Shot 2021-07-13 at 3 45 38 PM

However, when I tried to add the sale month as a dynamic covariate, I get an error because I don't have a weekly time-series column associated with each customer for each dummy variable - just the dates they actually made an order.

I introduced the 'week' variable so I could have a weekly time series data for each profile_id for the sale month. However, there are lots of NA values in the dataframe in order_created and sum_order_total_price because those columns only have values when there are actual purchases made by customers. When I tried to create a dataframe in the format dynamic covariates wants, the clv function didn't work because of the NA values.

Screen Shot 2021-07-13 at 3 52 06 PM

How do I introduce a dynamic covariate?

Also, on an unrelated note, how do I know when to perform a CLV analysis? If most of the data just has customers that have purchased once, is it worth trying to predict lifetime value? Or is a different form of analysis better?

Thanks in advance!

mmeierer commented 3 years ago

Please have a look at the following document (page 10): https://cran.r-project.org/web/packages/CLVTools/vignettes/CLVTools.pdf

At the bottom of this page you will find an example how to define a dynamic covariate (marketing) and additionally, also some statistic covariates. Be sure to check out how the object apparelDynCov is structured. This provides a pretty straightforward template how to prepare your data.

Also, on an unrelated note, how do I know when to perform a CLV analysis? If most of the data just has customers that have purchased once, is it worth trying to predict lifetime value? Or is a different form of analysis better?

This depends on the problem you are trying to solve, i.e. your use case. If you need for this a quantitative measure of a customer's future value than a CLV analysis is surely is the way to go. Otherwise, you might consider a simple binary classification model which only predicts which customers which become repeat buyers.