Facebook Prophet is an open-source algorithm for generating time-series models. It is particularly good at modeling time series that have multiple seasonality and doesn’t face some of the above drawbacks of other algorithms. At its core is the sum of three functions of time plus an error term: growth g(t), seasonality s(t), holidays h(t) , and error e_t
The Growth Function(Change Points)
Models the overall trend of the data.
Trend can be present at all points in the data and can be altered.
New concept of Changepoints was added by prophet model.
Changepoints are the moments in the data where the data shifts direction.
The Seasonality Function
Fourier Series as a function of time
Prophet will automatically detect the Fourier order/manually also can be added.
Seasonal component can be daily, weekly, yearly e.t.c
The Holiday/Event Function
The holiday function allows Facebook Prophet to adjust forecasting when a holiday or major event may change the forecast. It takes a list of dates and when each date is present in the forecast adds or subtracts value from the forecast from the growth and seasonality terms based on historical data on the identified holiday dates.
Section 2
Prophet Decomposition
Code
prophet_plot_components(model,forecast)
The sales price has exhibited a steady upward trend since mid-2021, which is mainly attributed to the post-Covid-19 ease in the housing market. Additionally, there appears to be a seasonal pattern in the sales price, with prices rising during the summer months, specifically in June, and declining during the fall and end of the year.
Decomposing the new model and comparing it with the original model. We can observe that the yearly seasonality remains the same and trend is also close to original model.
Code
prophet_plot_components(model_new,forecast1)
Saturating Minimum/Maximum point
Defining the min and max point help the users help check the wild values in the plot and for will be very useful in stock price forecasting when the decision(sell/buy) need to be taken on price value. In our case its not very revelant.
Code
suppressMessages({sixmnths_future_df =make_future_dataframe(model,periods =27)sixmnths_forecast_df =predict(model,sixmnths_future_df)# Set "floor" in training datasales_train$floor =850000sales_train$cap =1500000future$floor =850000future$cap =1200000# Set floor in forecsat datasixmnths_future_df$floor =850000sixmnths_future_df$cap =1200000sat_model =prophet(sales_train,growth='logistic')sat_six_mnths_forecast =predict(sat_model,sixmnths_future_df)plot(sat_model,sat_six_mnths_forecast)+ylim(850000,1200000)+theme_bw()+xlab("Date")+ylab("SF Housing Price")})
Section 3
Seasonality Identification
Code
prophet_plot_components(model,forecast)
The sales price has exhibited a steady upward trend since mid-2021, which is mainly attributed to the post-Covid-19 ease in the housing market. Additionally, there appears to be a seasonal pattern in the sales price, with prices rising during the summer months, specifically in June, and declining during the fall and end of the year.
From the plot we can infer that it shows multiplicative seasonality.The amplitude of the seasonal fluctuations changes over time, the seasonality is multiplicative.
Magnitude of Fluctuations
Below code will illustrate that the seasonality is multiplicative. We can see that the graphs plotted are similar.
We don’t see much holiday impact in the plot, couple of towers are present but its not something that is present in all years. We should not consider the holiday component for our time series.
Section 4
Cross Validation
Code
df.cv <-cross_validation(model, initial =1000, period =180, horizon =180, units ='days')
Making 3 forecasts with cutoffs between 2021-01-10 and 2022-01-05
These metrics can be used to evaluate the performance of a Prophet model in a cross-validation context. For example, rmse and mae are commonly used to evaluate the accuracy of point forecasts, while mape is used to evaluate the accuracy of percentage error forecasts.