We’ll look at some historical housing prices for zipcode 79907 from 1996 to 2018 for our time series analysis. We start off with the assumption that an ARIMA model has been analyzed and stored in the variable model
.
The question is, what do you do next, now that you have a model?
Starting with the end in mind, our out-of-sample forecast analysis will produce these results:
How we get there
We’ll start off with showing the full code execution and walk through its major components. You’ll notice there is a DataFrame (df
) being used as a parameter in the function below — it has additional information (city, state) that will be used to populate the final table.
Creating forecasts from an ARIMA model (full code)
Read on below to know more about the major components of the function.
Breaking it down
To start, the forecast period needs to be determined. The number of periods to forecast is passed in under the period
parameter — in this case, we are using months, as the time series data is in this unit of time.
Next, we will use statsmodels
built-in function, forecast()
, to predict values over the forecast period and also create a 95% confidence interval.
Let’s see what this data looks like by plotting the original time series and the out-of-sample forecast.
After visually producing the results, we’ll quantify the predictions via calculating percentage changes in the forecasts.
As an added step, the initial investment of purchasing a property in this zipcode will be calculated using market estimates.
Finally, we create the summary table that provides the out-of-sample forecast percentages and zipcode information.
There you have it
This is one method to produce out-of-sample forecasts and view the confidence interval in which the prediction occurs, as well. As a final note, here is the full function in its entirety: