Closed pschil closed 8 months ago
Source of the problem in line 44 in pnbd_dyncov_createwalks
:
cov.dt[is.na(Next.Cov.Date.Minus.Eps), Next.Cov.Date.Minus.Eps := This.Cov.Start.Date]
The last period of covariates has its interval end set to the start time so transactions happening later than the start date are lost in the foverlap
call. Simple fix is to set the interval end to be 1 period later (minus 1 second) consistent with all other periods of covariates, as follows:
cov.dt[is.na(Next.Cov.Date.Minus.Eps), Next.Cov.Date.Minus.Eps := This.Cov.Start.Date - 1L +
switch(clv.time@name.time.unit, Hours = hours(1), Days = days(1), Weeks = weeks(1), Years = years(1))]
(sorry to submit as a comment rather than pull request, I'm unfamiliar with GitHub)
Thanks again for reporting!
This has been addressed in version 0.10 when we refactored the dyncov walk creation & implemented the LL in Rcpp. (a test with the above reprex was added)
If there are covariates only for the calibration period, AuxTrans are lost for customers who have an ordinary transaction after the last covariate date. Subsequently, the dyncov LL cannot be fit. The error seems to originate from
foverlaps()
/the interval join that apparently ignores any 2nd transaction after the end of the covariate. Not clear yet whether ordinary transactions (=walks) are lost as well.Reprex: