I have monthly data with month/year in one column and price on another. I would like to get a yearly trend with fb prophet library in python (how to use monthly data with the library is explained at the end of this page ).

This is my code:

import fbprophet
import pandas as pd
import matplotlib.pyplot as plt

data = pd.read_csv('data.csv', sep=';')
data_prophet = fbprophet.Prophet(interval_width=0.95, changepoint_range=0.9, changepoint_prior_scale=0.15, seasonality_mode='multiplicative', n_changepoints=100)

# Make a future dataframe for 5 years
data_forecast = data_prophet.make_future_dataframe(periods=12 * 5, freq='M')
# Make predictions
data_forecast = data_prophet.predict(data_forecast)

data_prophet.plot(data_forecast, xlabel = 'Date', ylabel = 'Price')


This is what I got: enter image description here enter image description here

At the first glance, seems that minimums/maximums at the yearly trend correspond to mid-month, but they are not at the same point each month. The picks are shifted a little bit.

How to draw a correct yearly plot? And does this make sense for monthly data?


1 Answer 1


As explained in the link you provided, you will encouter problems with monthly data when you try to see what happen at a timestep below. They do not exactly use the same graph as yours but they say that : "The seasonality has low uncertainty at the start of each month where there are data points". It seems to be what happen here : on your graph you can see that there is no seasonal effect on a monthly basis, as the multiplicative coefficient seems to be 1 at the start of each month :

start of month highlight

Below the monthly time-step there seems to be oscilations. I am not 100% sure but it might be a practical exemple of Runge's phenomenon, where oscillations appears while doing interpolation. Below is a graphical exemple with the Runge function : some oscilations appears when you try to approximate it with polynomials, and quite counterintuitively, the size of those oscillations may grow as you try to improve the model by increasing the number of estimation knots.


This might be what happen here as you dont have a perfectly flat effect and the interpolation create oscilations between your monthly dates.

Generally speaking for the prophet framework the way to deal with this are mentionned in the link you provide :

  • use monthly regressor if you only want to get monthly effect. As said : "this approach would avoid the within-month unidentifiability seen above. Be sure to use yearly_seasonality=False if monthly extra regressors are being added."
  • only make monthly forecasts, which can be done by passing the frequency into make_future_dataframe (freq='MS')

Obviously the main alternative being to use another framework that might be more transparent on what it does exactly.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.