3

I am using Facebook's Prophet algorithm for change point detection in time series. When I was going over the tutorial on the website, I noticed there are multiple vectors in the output of the prophet() call that refer to change points.

Suppose m is your prophet output object, than m$changepoints outputs a vector with the dates of change and m$params$delta outputs the change rate (I suppose) as is described in the paper: "The generative model for the trend is that there are S changepoints over a history of T points, each of which has a rate change formula" (Taylor & Letham, 2018. P.40).

But what exactly is m$changepoints.t? At first, I thought this vector contained the values of the original time-series at time t where a change point was detected. But when I inspect the values of m$changepoints.t, it has values between 0 and 1, while my original time-series does not have values below 5.263.

Here is the code:

# load in the log number of views to Peyton Manning’s Wikipedia page
peytondf <- read.csv("https://raw.githubusercontent.com/facebook/prophet/ba9a5a2c6e2400206017a5ddfd71f5042da9f65b/examples/example_wp_log_peyton_manning.csv")

# make a prophet object
m <- prophet(peytondf)

# Prepare a dataframe with dates over which to predict new values
future <- make_future_dataframe(m, periods = 30)

# make a forecast over the dates in the future
forecast <- predict(m, future)

Let's compare some different outputs of change points, and the summary statistics of the original time series.

> print(m$params$delta)
              [,1]         [,2]      [,3]      [,4]         [,5]          [,6]       [,7]
[1,] -7.747987e-08 5.963255e-08 0.3511606 0.4575449 3.446425e-09 -3.234277e-05 -0.2446286
           [,8]        [,9]        [,10]         [,11]     [,12]     [,13]       [,14]
[1,] -0.2479764 2.22051e-08 4.905514e-08 -4.845165e-08 0.2993031 0.2125642 0.001508987
            [,15]      [,16]         [,17]         [,18]        [,19]     [,20]      [,21]
[1,] 0.0001771334 -0.8544597 -8.687544e-07 -8.719968e-08 7.831569e-07 0.4638492 0.01226102
            [,22]      [,23]        [,24]         [,25]
[1,] 1.597865e-07 -0.3350588 8.737527e-08 -3.928844e-08

> print(m$changepoints.t) 
 [1] 0.03307459 0.06513669 0.10327371 0.13533581 0.16672292 0.19811002 0.23152211 0.26425920
 [9] 0.29632130 0.33007087 0.36145798 0.39284509 0.42423220 0.45561930 0.48768140 0.51974350
[17] 0.55146811 0.58285521 0.61390483 0.64529193 0.67667904 0.70840364 0.73979075 0.77151536
[25] 0.80290246

> summary(peytondf)
      ds                  y         
 Length:2905        Min.   : 5.263  
 Class :character   1st Qu.: 7.515  
 Mode  :character   Median : 7.998  
                    Mean   : 8.139  
                    3rd Qu.: 8.580  
                    Max.   :12.847 
saQuist
  • 416
  • 7
  • 19

1 Answers1

2

By default, prophet uses 25 potential changespoints which are evenly spaced across your time series, but some of them go unused. print(m$changepoints.t) shows all of the potential changepoints. You can visualize the changepoints that were ultimately used with

plot(m, forecast) + add_changepoints_to_plot(m)

enter image description here

Trend Changespoints Prophet

Joe Erinjeri
  • 1,200
  • 1
  • 7
  • 15
  • Thank you for your answer, I am still a bit puzzled by what the values of the potential change points represent. Or do they not represent anything useful at all? Can it be , for instance, understood as some sort of number that assumes how likely a potential change point will translate to a real change point? – saQuist Oct 25 '21 at 09:33
  • If you look at the non-zero values of paras$delta, this is where there is an inflection point in the model. So as i understand it, this is where the change points occur. For locations where paras$delta is close to zero, the tread just continues without change. Note that by default, prophet only puts changepoints in the first 80% of the time series, so the values of m$changepoints.t are fractionalized distance across the times series. To see the 25 actual times, use m$changepoints. In summary, the actual change points that prophet uses are m$changepoints where m$paras$delta is non-zero. – Joe Erinjeri Oct 25 '21 at 10:13