I’ve been looking at time series regression recently. Just for fun I coded up an example using a raw Python (with the NumPy library for numerical functions) neural network. For my example I used a standard benchmark data set that has the total number of airline passengers for the 144 months from January 1949 through December 1960.
(Click image to enlarge)
I used a rolling window approach, with a window size of 4. This means that I used each consecutive four months to predict the next month. So the first data item is (1.12 1.18, 1.32, 1.29, 1.21). I normalized the raw data by dividing each passenger count by 100,000. So the first item means in months 1-4 there were 112,000, 118,000, 132,000, and 129,000 passengers. Those values are used to predict the passenger count for month 5, which is 121,000. The second item is (1.18, 1.32, 1.29, 1.21, 1.35) — the counts for months 2-5 are used to predict the count for month 6.
After I created my prediction model, I used it to print out the actual and predicted passenger counts. I dropped that data into Excel and made a graph. The model worked pretty well. Time series regression can be extremely complicated, but this was an interesting little exercise.