Convert Event Log to customer-level summary statistics and create an input list for the STAN model.
Arguments
- elog
Event log, a data.frame with field
custfor the customer ID and fielddatefor the date/time of the event, which should be of type Date or POSIXt. Ifsalesorreturnsfield is present, it will be aggregated. Seedetailsfor more information.- config
Configuration list created by
appraise_configure()- items_and_returns
Aggregated items and returns per customer.
Details
The elog dataset has 1 row per transaction and should look like this;
| cust | date | sales |
|------- |------------ |------- |
| <dbl> | <dttm> | <dbl> |
| 101 | 2017-10-13 | 300 |
| 101 | 2018-07-31 | 150 |
| 101 | 2019-07-31 | 150 |
The items_and_returns dataset is aggregated at the customer level and
should look like this. If there is no returns column, we won't use them.
| cust | items | returns |
|------- |------- |--------- |
| <dbl> | <dbl> | <dbl> |
| 101 | 30 | 3 |
| 102 | 6 | 0 |
| 103 | 10 | 6 |
Examples
config <- appraise_configure(sample = FALSE,
cpa = c(25, 50, 75, 100, 125, 150, 200),
cm = c(.2, .3, .432, .5),
currency = '$',
n_forecast = 5 * 52)
elog_validated <- validate_elog(elog)
#> Checking sales data...
#> -------------------------
#> Following `elog` issues were found:
#> nonpos_items nonpos_sales
#> 1 188
items_and_returns_validated <- validate_items_returns(returns)
#>
#> Checking returns data...
#> -------------------------
#> Following `items_and_returns` issues were found:
#> more_returns
#> 5
full_cbs <-
elog_to_stan(elog_validated$elog,
config,
items_and_returns_validated$items_and_returns)
#> Elog conversion finished. Ready to start modeling.
#>