---
title: "Estimating ARIMA Models"
author: "Daniel Dala and Asael Alonzo Matamoros"
date: "`r Sys.Date()`"
output:
html_vignette:
toc: yes
vignette: >
%\VignetteIndexEntry{Estimating ARIMA Models}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r SETTINGS-knitr, include = FALSE}
stopifnot(require(knitr))
options(width = 90)
knitr::opts_chunk$set(collapse = TRUE,comment = "#>")
knitr::opts_chunk$set(echo = TRUE,
message = FALSE,
warning = FALSE,
dev = "png",
dpi = 150,
fig.asp = 0.8,
fig.width = 5,
out.width = "60%",
fig.align = "center")
library(bayesforecast)
library(ggplot2)
```
## Introduction
The core inflation index is used to measure aggregate demand pressures that the action of monetary policy can modify; it is a partial measure derived from inflation calculated through the Consumer Price Index (CPI). This vignette explains how to estimate a ARIMA model to predict the CPI in Honduras for the next years using the functions check_residuals
and stan_sarima
in the **bayesforecast** package.
Here we will show how to carry out a few parts of the analysis from Chapter 8.7 of Hyndman & Khandakar, 2008 that is:
check_residuals
function estimates the posterior mean of the residuals and plots them. This plot is not sufficient to corroborate the assumptions of normality and stationarity but is an initial indicator of the adjustment.
```{r,residuals_ipc}
check_residuals(sf1)
```
The series of residuals (*upper part*) shows that the model does not explain the period between 1900-2000 due to the intense volatility present in that decade. The histogram and quantile graph (*middle part*) show that the model has heavy tails due to the high volatility of the series. Finally, the residuals' auto-correlation presents a certain periodicity. Therefore, a seasonal period was not enough to model the seasonal pattern.
## Forecast
Finally, we predict the model for the next year:
```{r,forecast_ipc}
autoplot(object = forecast(sf1,h = 12),ylab="CPI")
```
## References
- Hyndman, R.J., & Athanasopoulos, G. (2018) *Forecasting: principles and practice*, 2nd edition, OTexts: Melbourne, Australia. OTexts.com/fpp2. Accessed on February 17, 2021.
- Carpenter, B., Gelman, A., Hoffman, M., Lee, D., Goodrich, B., Betancourt, M., Brubaker, M., Guo, J., Li, P., & Riddell, A. (2017). *Stan: A Probabilistic Programming Language*. Journal of Statistical Software, 76(1), 1 - 32. doi:http://dx.doi.org/10.18637/jss.v076.i01,
- Hyndman, R., & Khandakar, Y. (2008). *Automatic Time Series Forecasting: The forecast Package for R*. Journal of Statistical Software, 27(3), 1 - 22. doi:http://dx.doi.org/10.18637/jss.v027.i03.