Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when running Pareto NBD #51

Closed
ThoDuyNguyen opened this issue Dec 27, 2016 · 4 comments
Closed

Error when running Pareto NBD #51

ThoDuyNguyen opened this issue Dec 27, 2016 · 4 comments

Comments

@ThoDuyNguyen
Copy link

When I'm running Pareto NBD, it threw an error:

customer_by_sufficient_statistic_pnbd <-
  transaction_data %>%
  elog2cbs(elog = ., units = "days")

params_pnbd <- BTYD::pnbd.EstimateParameters(customer_by_sufficient_statistic_pnbd)
names(params_pnbd) <- c("r", "alpha", "s", "beta")
round(params_pnbd, 3) 
Error in optim(logparams, pnbd.eLL, cal.cbs = cal.cbs, max.param.value = max.param.value,  : 
  L-BFGS-B needs finite values of 'fn'

My data is transaction data sample:

knitr::kable(head(transaction_data, 50))
|cust          |date                | sales|
|:-------------|:-------------------|-----:|
|000000000000o |2016-08-24 06:36:28 |  3000|
|00000025      |2016-08-02 10:14:31 |  1000|
|00000027      |2016-08-02 13:18:19 |  3000|
|00000030      |2016-08-23 19:48:21 |  3000|
|00000030      |2016-08-25 11:25:29 |  3000|
|00000030      |2016-08-26 00:18:09 |  3000|
|00000030      |2016-08-26 13:56:38 |  1000|
|00000030      |2016-08-26 14:06:14 |  1000|
|00000112      |2016-08-05 16:32:23 |  1000|
|00000113      |2016-08-04 21:32:20 |  1000|
|00000134      |2016-08-03 17:45:27 |  1000|
|00000134      |2016-08-03 18:19:24 |  1000|
|00000134      |2016-08-04 11:10:53 |  1000|
|00000134      |2016-08-04 21:26:10 |  1000|
|00000139      |2016-08-07 00:40:19 |  1000|
|00000139      |2016-08-07 18:40:35 |  1000|
|00000139      |2016-08-07 18:41:35 |  1000|
|00000139      |2016-08-09 14:54:24 |  1000|
|00000139      |2016-08-09 14:55:31 |  1000|
|00000148      |2016-08-04 17:47:40 |  3000|
|00000148      |2016-08-04 18:36:44 |  5000|
|00000148      |2016-08-05 01:43:27 |  5000|
|00000148      |2016-08-05 11:53:36 |  1000|
|00000148      |2016-08-05 14:34:41 |  1000|
|00000148      |2016-08-10 13:15:12 |  5000|
|00000148      |2016-08-11 11:02:51 |  5000|
|00000148      |2016-08-12 13:38:01 |  5000|
|00000179      |2016-09-25 13:21:36 |  1000|
|00000180      |2016-08-02 19:16:07 |  3000|
|00000188      |2016-08-04 06:24:25 |  3000|
|00000188      |2016-08-04 06:24:49 |  3000|
|00000191      |2016-08-05 13:48:37 |  1000|
|00000191      |2016-08-08 12:26:30 |  1000|
|00000191      |2016-08-08 13:39:25 |  1000|
|00000191      |2016-08-08 13:41:20 |  1000|
|00000191      |2016-08-09 09:57:15 |  1000|
|00000191      |2016-08-09 13:58:22 |  1000|
|00000191      |2016-09-27 17:50:06 |  1000|
|00000222      |2016-08-02 20:09:57 |  1000|
|00000222      |2016-08-03 09:09:58 |   200|
|00000222      |2016-08-03 09:10:17 |   200|
|00000222      |2016-08-03 09:10:37 |   200|
|00000222      |2016-08-03 15:07:04 |   200|
|00000222      |2016-08-04 11:04:57 |   200|
|00000222      |2016-08-04 11:05:15 |   200|
|00000222      |2016-08-04 11:49:45 |   200|
|00000222      |2016-08-05 08:52:40 |   200|
|00000222      |2016-08-05 08:53:29 |   200|
|00000222      |2016-08-07 14:22:04 |   500|
|00000222      |2016-08-07 14:22:37 |   200|

My cbs sample:

knitr::kable(head(customer_by_sufficient_statistic_pnbd, 50))
|cust          |  x|        t.x|        litt| sales|first               |    T.cal|
|:-------------|--:|----------:|-----------:|-----:|:-------------------|--------:|
|000000000000o |  0|  0.0000000|    0.000000|  3000|2016-08-24 06:36:28 | 75.72418|
|00000025      |  0|  0.0000000|    0.000000|  1000|2016-08-02 10:14:31 | 97.57275|
|00000027      |  0|  0.0000000|    0.000000|  3000|2016-08-02 13:18:19 | 97.44512|
|00000030      |  4|  2.7624190|   -5.696879| 11000|2016-08-23 19:48:21 | 76.17426|
|00000112      |  0|  0.0000000|    0.000000|  1000|2016-08-05 16:32:23 | 94.31035|
|00000113      |  0|  0.0000000|    0.000000|  1000|2016-08-04 21:32:20 | 95.10205|
|00000134      |  3|  1.1532755|   -4.951050|  4000|2016-08-03 17:45:27 | 96.25961|
|00000139      |  4|  2.5938889|  -14.110905|  5000|2016-08-07 00:40:19 | 92.97150|
|00000148      |  7|  7.8266319|   -6.040406| 30000|2016-08-04 17:47:40 | 95.25807|
|00000179      |  0|  0.0000000|    0.000000|  1000|2016-09-25 13:21:36 | 43.44284|
|00000180      |  0|  0.0000000|    0.000000|  3000|2016-08-02 19:16:07 | 97.19664|
|00000188      |  1|  0.0002778|   -8.188689|  6000|2016-08-04 06:24:25 | 95.73255|
|00000191      |  6| 53.1676968|   -6.586634|  7000|2016-08-05 13:48:37 | 94.42407|
|00000222      | 13|  5.8879861|  -47.090180|  4100|2016-08-02 20:09:57 | 97.15926|
|00000227      |  0|  0.0000000|    0.000000|  1000|2016-08-03 14:14:16 | 96.40626|
|00000233      | 11| 67.8287731|  -16.401807| 16000|2016-08-12 22:34:53 | 87.05861|
|00000245      |  3|  2.3961111|   -1.882027|  4000|2016-08-03 09:16:11 | 96.61326|
|00000247      |  0|  0.0000000|    0.000000|  1000|2016-08-09 20:10:06 | 90.15916|
|00000252      | 13|  7.7163773|  -33.256233|  7300|2016-09-22 18:33:27 | 46.22627|
|00000268      |  1|  2.2652315|    0.817677|  4000|2016-08-02 17:04:13 | 97.28824|
|00000293      |  4|  6.7340046|   -9.404809|  5000|2016-08-02 18:00:45 | 97.24898|
|00000297      |  6|  0.9672569|  -12.129457|  7000|2016-08-02 15:58:47 | 97.33368|
|00000306      | 34| 39.8468981|  -49.574711| 62000|2016-08-02 18:23:14 | 97.23337|
|00000322      | 45| 37.1828356|  -71.839988| 46000|2016-08-05 10:16:48 | 94.57117|
|00000348      |  0|  0.0000000|    0.000000|  1000|2016-08-02 16:21:03 | 97.31822|
|00000358      |  0|  0.0000000|    0.000000|  1000|2016-08-05 14:46:34 | 94.38383|
|00000384      |  0|  0.0000000|    0.000000|  5000|2016-08-07 19:31:40 | 92.18584|
|00000388      |  0|  0.0000000|    0.000000|  1000|2016-08-02 17:38:09 | 97.26468|
|00000410      | 19|  2.9094792|  -55.245497| 24000|2016-08-02 14:25:06 | 97.39874|
|00000429      |  0|  0.0000000|    0.000000|  1000|2016-08-04 18:58:38 | 95.20878|
|00000449      | 37|  4.2021528| -188.924434| 80000|2016-08-02 13:03:11 | 97.45562|
|00000474      |  2|  0.7993750|   -2.135192|  3000|2016-08-02 20:04:38 | 97.16295|
|00000487      |  0|  0.0000000|    0.000000|  3000|2016-08-02 13:36:12 | 97.43270|
|00000508      | 19| 53.3256597|  -39.142569| 24000|2016-08-02 13:57:38 | 97.41781|
|00000533      |  1|  0.1032870|   -2.270243|  2000|2016-08-05 10:00:43 | 94.58234|
|00000543      |  1|  0.0118981|   -4.431373|  8000|2016-08-03 16:18:37 | 96.31991|
|00000550      |  0|  0.0000000|    0.000000|  5000|2016-08-02 18:17:33 | 97.23731|
|00000559      | 31| 36.2829051| -110.370241| 33900|2016-08-03 17:21:53 | 96.27597|
|00000562      |  4|  0.2167361|  -13.778951|  9000|2016-08-02 20:40:43 | 97.13789|
|00000567      |  0|  0.0000000|    0.000000|  1000|2016-08-02 19:19:55 | 97.19400|
|00000577      |  0|  0.0000000|    0.000000|  1000|2016-08-02 21:11:37 | 97.11644|
|00000580      | 30| 96.1238889|   17.855325| 31000|2016-08-03 16:11:21 | 96.32495|
|00000596      |  2|  3.9631134|    1.355179|  3000|2016-08-03 21:06:09 | 96.12023|
|0000060009    |  0|  0.0000000|    0.000000|  1000|2016-08-27 11:29:07 | 72.52095|
|00000603      |  0|  0.0000000|    0.000000|  1000|2016-08-02 22:51:40 | 97.04696|
|00000619      |  0|  0.0000000|    0.000000|  3000|2016-08-05 07:20:43 | 94.69345|
|00000637      |  2|  0.0893750|   -9.179702|  3000|2016-08-02 16:35:39 | 97.30808|
|00000654      |  0|  0.0000000|    0.000000|  3000|2016-09-15 17:13:16 | 53.28196|
|00000657      |  2| 27.8792130|    3.926673|  3000|2016-08-03 13:54:12 | 96.42020|
|00000661      |  1|  0.2140509|   -1.541541|  2000|2016-08-02 15:08:05 | 97.36889|

Does the data require any constraint in order to apply the method properly?

Thank you in advance.

@ThoDuyNguyen
Copy link
Author

I found an additional resource here:

https://github.com/theofilos/BTYD

@mplatzer
Copy link
Owner

mplatzer commented Dec 30, 2016 via email

@ThoDuyNguyen
Copy link
Author

Thank for your information

@daisybean0107
Copy link

Same issue here. Does your problem solved using BTYDplus?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants