I'm working with the CLVTools package to predict customer life time values.
Looks like I'm having a similar issue to this SO user.
Here are two data frames:
df_fail <- structure(list(ID = c(1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3), TRANSACTION_DT = structure(c(18539, 18544, 18539,
18551, 18539, 18555, 18555, 18555, 18574, 18541, 18541, 18542,
18574, 18543, 18543, 18543, 18543), class = "Date"), AMOUNT = c(1999,
199, 799, 499, 499, 299, 199, 199, 299, 999, 199, 199, 299, 199,
199, 299, 299)), row.names = c(NA, -17L), class = "data.frame")
df_succeed <- structure(list(ID = c(1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 4, 4, 4, 4, 5, 5), TRANSACTION_DT = structure(c(18555, 18540,
18608, 18574, 18550, 18549, 18566, 18579, 18573, 18573, 18551,
18540, 18540, 18543, 18540, 18576, 18576, 18546, 18540, 18550
), class = "Date"), AMOUNT = c(999, 199, 499, 199, 199, 299,
999, 999, 299, 299, 999, 499, 1999, 299, 199, 299, 199, 199,
199, 199)), row.names = c(NA, -20L), class = "data.frame")
I am able to fit a clvtools data object with the suceed df:
CLVTools::clvdata(
df_succeed,
date.format = 'ymd',
time.unit = 'w',
estimation.split = 6,
name.id = 'ID',
name.date = 'TRANSACTION_DT',
name.price = 'AMOUNT'
)
CLV Transaction Data
Call:
CLVTools::clvdata(data.transactions = df_succeed, date.format = "ymd",
time.unit = "w", estimation.split = 6, name.id = "ID", name.date = "TRANSACTION_DT",
name.price = "AMOUNT")
Total # customers 5
Total # transactions 17
Spending information TRUE
Time unit Weeks
Estimation start 2020-10-05
Estimation end 2020-11-16
Estimation length 6.0000 Weeks
Holdout start 2020-11-17
Holdout end 2020-12-12
Holdout length 3.571429 Weeks
But when I try to do the same with the fail df I get:
CLVTools::clvdata(
df_fail,
date.format = 'ymd',
time.unit = 'w',
estimation.split = 6,
name.id = 'ID',
name.date = 'TRANSACTION_DT',
name.price = 'AMOUNT'
)
Error: Parameter estimation.split needs to indicate a point at least 2 periods before the last transaction!
Perhaps I've bee staring at the rows a bit too long but I cannot 'see it'. Why does one df allow me to create the clv object and one does not?