In this project I am exploring the forecasting of a time series using Meta’s Prophet. Forecasting passenger demand to travel is important in the aviation industry as it allows for correct planning, staffing and pricing. Having these forecasts can assist companies to make better decisions and allocation of resources. The aim is to analyse data, prior patterns and predict forecasts for any future passenger numbers, using the built in ‘AirPassengers’ dataset in R and then using Meta’s Prophet forecasting model to analyse the data.
The AirPassengers dataset contains monthly totals of
international airline passengers from 1949 to 1960. The data is well
suited for a forecasting using this analysis as the data is recorded
monthly we can look out for any recurring seasonal patterns and
trends.
## [1] 1949 1
## [1] 1960 12
## [1] 12
In order to use Prophet the dataframe must consist of two columns: ‘ds’ for dates and ‘y’ for t
## ds y
## 1 1949-01-01 112
## 2 1949-02-01 118
## 3 1949-03-01 132
## 4 1949-04-01 129
## 5 1949-05-01 121
## 6 1949-06-01 135
The data has now successfully been converted into the correct format to allow us to use Meta’s Prophet model. The ‘ds’ column contains the monthly dates and the ‘y’ column contains the passenger totals.
Before fitting the forecasting model, it is useful to visualise the time series. This helps identify whether the data shows trend, seasonality, or any unusual behaviour.
# Prophet Model
We now fit a Prophet model to the passenger data in order to generate forecasts.
The model has been successful and will automatically look out for any main trends and patterns within the series.
Using the model from the prior section I generate forecasts for the next 24 months
## ds yhat yhat_lower yhat_upper
## 1 1949-01-01 86.56984 57.46908 113.7768
## 2 1949-02-01 80.04221 52.44063 107.8449
## 3 1949-03-01 111.46624 82.06577 140.1194
## 4 1949-04-01 109.16992 80.56953 139.5569
## 5 1949-05-01 112.50439 84.62689 141.4945
## 6 1949-06-01 152.61695 124.35476 180.3173
The table above shows the predicted values ‘yhat’ together with the lower and upper uncertainty bounds.
We now visualise the prior airline passenger numbers combined with the future numbers obtained by the Prophet model, in the graph below.
# Model Components
We can also use Prophet to visualise the main long term trends and any seasonal trends.
## Warning: `aes_string()` was deprecated in ggplot2 3.0.0.
## ℹ Please use tidy evaluation idioms with `aes()`.
## ℹ See also `vignette("ggplot2-in-packages")` for more information.
## ℹ The deprecated feature was likely used in the prophet package.
## Please report the issue at <https://github.com/facebook/prophet/issues>.
## This warning is displayed once per session.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
From the analysis I have picked up on three key findings: 1. From the data I can see a strong indication of seasonality, there are regular peaks and troughs repeating around the same periods each year. 2. The Prophet forecast shows that passenger demand would continue to rise as it has done from the past data and the future follows those trends. 3. The number of airline passengers indicate a upward trend across the sample period.
The results and findings prove that Prophet can depict growth and seasonality in this data.
This project successfully shows that Prophet can be used to model and forecast airline passenger demand. The model performs well as it clearly shows a clear trend and seasonal structure in the data. However, the data does not take into account external factors such as, fuel costs, policy changes or economical changes. Overall, the project demonstrates well how modern tools can be used in time series analysis in a practical way.