Prophet: Encounter "Stan does not support NA" when using prophet function

Created on 31 Mar 2017  路  6Comments  路  Source: facebook/prophet

OS: Windows 10 Pro, R version: 3.3.3, Gui: RStudio
Screen shot attached of RStudio code and execution, plus the used data set pm.xlsx

The issue can be seen in the attached images. When I load a similar Wikipedia page traffic data set, and use the prophet function I receive the following error. The steps used was sourced from the following URL. (https://facebookincubator.github.io/prophet/docs/quick_start.html#r-api)

"Error in FUN(x[[i]],...) : Stan does not support NA (in t) in data failed to preprocess the data; optimization not done
Error in matrix(m$params[[name]], nrow = n.iteration) : 'data' must be of a vector type, was 'NULL'"

When I validate my source data set I do not see null or NA values. Would this error be contributed to a formatting error when the prophet function runs?

capture

pm.xlsx

bug

Most helpful comment

It looks like parsing the dates is failing. We use the zoo package to convert the ds column to date format, and you can see that this is introducing a bunch of NAs if you run:

ds <- zoo::as.Date(history$ds)

You can see the issue by trying to run it on a single date:

> zoo::as.Date('8/13/2015')
Error in charToDate(x) : 
  character string is not in a standard unambiguous format

The solution is to convert it to date format before passing it in to Prophet.

https://github.com/facebookincubator/prophet/commit/68f88e2b733d2f91769359e7e245472ccc87a2bf raises an exception if the date parsing fails, which should make this issue less opaque in the future.

All 6 comments

It looks like parsing the dates is failing. We use the zoo package to convert the ds column to date format, and you can see that this is introducing a bunch of NAs if you run:

ds <- zoo::as.Date(history$ds)

You can see the issue by trying to run it on a single date:

> zoo::as.Date('8/13/2015')
Error in charToDate(x) : 
  character string is not in a standard unambiguous format

The solution is to convert it to date format before passing it in to Prophet.

https://github.com/facebookincubator/prophet/commit/68f88e2b733d2f91769359e7e245472ccc87a2bf raises an exception if the date parsing fails, which should make this issue less opaque in the future.

I've tried the steps of correcting date and y formats and removing nulls, and still get this error message:
Error in FUN(X[[i]], ...) : Stan does not support NA (in y) in data failed to preprocess the data; optimization not done Error in matrix(m$params[[name]], nrow = n.iteration) : 'data' must be of a vector type, was 'NULL' Called from: matrix(m$params[[name]], nrow = n.iteration)

Also, my code is in a loop and tried to fix things with the suggestions in this link (https://github.com/facebookincubator/prophet/issues/93), but still to no avail.

Only breaking on loops of 12 iterations.

Can you check what version of prophet you are using? Is there any chance you can post the data that is failing so that I can replicate?

I'm using prophet version 0.1.1.

I managed to pinpoint the issue, which occurs with non-unique y-values. For example, it breaks if the y-value is all 0.

Thanks, we do currently scale data by dividing by max(abs(y)), which divides by zero if all y's are 0. This needs to be fixed.

I'm going to close the issue here to consolidate it with #251 , where it will be fixed.

Was this page helpful?
0 / 5 - 0 ratings