This data set has 398 observations and contains the variables Date and IPG2211A2N. The data set outlines monthly Electric Production in the united states. The records were taken from 1985 to 2018.
The code defines the training and testing datasets for time series forecasting by holding up the last 6 months of the data for calculating forecasting errors. This sets up the data for time series forecasting, allowing different forecasting models to be fitted to the training dataset and evaluated on the testing dataset to measure their accuracy.
This uses four baseline forecasting methods and the first 30 data values to forecast the next 6 month’s data values.
The output shows the predicted values for each model for the 15 periods ahead of the time series. The first column represents the predicted values using the mean model, the second column shows the predicted values using the naive model, the third column represents the predicted values using the seasonal naive model, and the fourth column shows the predicted values using the random walk with drift model.
| pred.mv | pred.naive | pred.snaive | pred.rwf |
|---|---|---|---|
| 88.2564 | 91.4867 | 93.0628 | 91.53652 |
| 88.2564 | 91.4867 | 103.2203 | 91.58634 |
| 88.2564 | 91.4867 | 117.0837 | 91.63616 |
| 88.2564 | 91.4867 | 106.6688 | 91.68598 |
| 88.2564 | 91.4867 | 95.3548 | 91.73580 |
| 88.2564 | 91.4867 | 89.3254 | 91.78562 |
| 88.2564 | 91.4867 | 90.7369 | 91.83544 |
| 88.2564 | 91.4867 | 104.0375 | 91.88526 |
| 88.2564 | 91.4867 | 114.5397 | 91.93508 |
| 88.2564 | 91.4867 | 115.5159 | 91.98490 |
| 88.2564 | 91.4867 | 102.7637 | 92.03472 |
| 88.2564 | 91.4867 | 91.4867 | 92.08454 |
| 88.2564 | 91.4867 | 93.0628 | 92.13436 |
| 88.2564 | 91.4867 | 103.2203 | 92.18418 |
| 88.2564 | 91.4867 | 117.0837 | 92.23400 |
A time series plot is now created with the predicted values. Looking at the graph the seasonal naive method performed the best, with moving average, naive, and drift performing poorly comparitavely.
This table shows the overall performance of four forecasting methods based on three error metrics: Mean Absolute Percentage Error (MAPE), Mean Absolute Deviation (MAD), and Mean Squared Error (MSE). With the four forecasting methods being Moving Average, Naive, Seasonal Naive, and Drift.
Seasonal Naive has the lowest MAPE, MAD, and MSE values, indicating that it is the most accurate method among the four. Moving Average has the highest values for all three error metrics, indicating that it is the least accurate method among the four.
Naive and Drift have intermediate performance, with Naive having the lowest MSE value and Drift having the lowest MAD value. However, when considering all three metrics together, Seasonal Naive appears to be the best forecasting method.
| MAPE | MAD | MSE | |
|---|---|---|---|
| Moving Average | 14.159986 | 234.5564 | 362.50149 |
| Naive | 11.491031 | 192.3692 | 271.91123 |
| Seasonal Naive | 4.428782 | 72.3599 | 37.29849 |
| Drift | 11.154238 | 186.9886 | 260.83043 |