Time series forecasting
With the parameter estimates having been defined, we're finally in a position to use our model for forecasting. We've actually already written most of the code we need to do this: we have an arma
function that's capable of generating an autoregressive moving-average series based on some seed data and the model parameters p and q. The seed data will be our measured values of y from the airline data, and the values of p and q will be the parameters that we calculated using the Nelder-Mead method.
Let's plug those numbers into our ARMA model and generate a sequence of predictions for y:
(defn ex-9-32 [] (let [data (i/log (airline-passengers)) diff-1 (difference 1 data) diff-12 (difference 12 diff-1) forecast (->> (arma (take 9 (reverse diff-12)) [] (:ar params) (:ma params) 0) (take 100) (undifference 12...