Search code examples
rfacebookstringindexoutofbounds

subscript out of bounds error in R programming


Getting following error while using prophet library:

Error in [<-(*tmp*, m$history$t >= m$changepoints.t[i], i, value = 1) : subscript out of bounds

Code : m <- prophet(data) this data I've loaded from csv file.

My dataset looks like this :

                   ds        y 
1 2017-05-23 08:07:00 21.16641
2 2017-05-23 08:07:10 16.79345
3 2017-05-23 08:07:20 16.40846
4 2017-05-23 08:07:30 16.24653
5 2017-05-23 08:07:40 16.14694
6 2017-05-23 08:07:50 15.89552

ds column is of following type :"POSIXct" "POSIXt" y column is of following type :"numeric" (these are log values of some count values)

Being new to R, i don't have any clue on how to resolve this. Please help.


Solution

  • Your data does not have any change points (points of interest in your data series where there is change in the local trend direction). This error seems like a bug in the Prophet package which is not handling this situation gracefully. However you can fix this by setting the changepoint tuning parameters.

    Quick fix: set changespoints to 0 by using param:

    n.changepoints = 0
    

    in your prophet call.