The foreign exchange consists of converting one currency into another
at a specific rate known as the foreign exchange rate. The conversion
rates are constantly changing as they are driven by the market forces of
supply and demand. In this vignette, we will model the volatility of the
series of daily observations of the foreign exchange between Germany and
the United Kingdom proposed by Ardia
y Hoogerheide (2010) using the stan_garch
function of
the bayesforecast package. The records correspond from
January 3, 1984, to December 31, 1991. However, for this work, we will
use the first 350 observations.
The steps for estimating the model are:
Plot the data and identify any unusual observations.
Create de GARCH Model through the stan_garch
function of
the bayesforecast package.
Plot and observe the residuals of the model. If the residuals look like white noise, we proceed to make the prediction. Otherwise, we will choose another model. Plot the data and identify any unusual observations.
Plotting the data:
The model proposed by Ardia y Hoogerheide (2010) in their bayesGARCH package is a GARCH(1,1) with t-student innovations of the form:
$$ y_t = \mu + \left(\dfrac{v-2}{v}\lambda_t \sigma_t \right)^{1/2} \epsilon_t,\\ \sigma^2_t = \sigma_0 + \alpha_1\epsilon_{t-1}^2 + \beta_1\sigma^2_{t-1}\\ \epsilon_t \sim N(0,1)\\ \lambda_t \sim IG(v/2,v/2) $$
where σ0 > 0,α1, β1 and v > 2, moreover N(0, 1) denotes the standard normal distribution; IG denotes the inverted gamma distribution. The restriction on the degrees of freedom parameter v ensures the conditional variance to be finite and the restrictions on the GARCH parameters σ0, α1 and β guarantee its positivity.
This model can be run in bayesforecast like:
#> mean se 5% 95% ess Rhat
#> mu0 0.0268 0.0006 -0.0055 0.0578 946.0796 0.9997
#> sigma0 0.7282 0.0137 0.2446 1.5938 1132.0127 0.9994
#> arch 0.4394 0.0082 0.0523 0.8944 964.0771 1.0001
#> garch 0.4199 0.0082 0.0520 0.9059 907.7679 1.0007
#> v 2.1200 0.0022 2.0439 2.2485 1075.5370 0.9993
#> loglik -170.5725 0.2532 -184.2946 -157.1627 1286.9329 0.9991
In the model proposed by Ardia y Hoogerheide (2010) they use truncated normal priors on the GARCH parameters β and α = (σ0, α1)′
$$ p(\alpha)\propto\phi_{N_2}(\alpha|\mu_\alpha,\Sigma_\alpha) 1 \{\alpha\in R_+^2\}\\ p(\beta)\propto\phi_{N_1}(\beta|\mu_\beta,\Sigma_\beta) 1 \{\beta\in R_+\}\\ $$ where μ• and Σ• are the hyperparameters, 1{•} is the indicator function and ϕNd is the d-dimensional normal density.
The prior distribution of vector λ = (λ1, ...λT)′ conditional on v is found by noting that the components λt are independent and identically distributed from the inverted gamma, which yields
$$ p(\lambda|v)=\left(\frac{v}{2} \right)^{\frac{Tv}{2}}\left[ \Gamma\left(\frac{v}{2}\right)\right]^{-T}\left(\prod_{t=1}^T\lambda_t\right)^{-\frac{v}{2}-1}exp\left[-\frac{1}{2}\sum_{t=1}^T\frac{v}{\lambda_t}\right] $$ furthermore the prior distribution on the degrees of freedom parameters is a translated exponencial with parameters λ* > 0 y δ ≥ 2
p(v) = λ*exp[−λ*(v − δ)]1{v > δ} The priors used by Ardia y Hoogerheide (2010) are slightly similar to the prior by default in bayesforecast, these were defined by default following the recommendations proposed by Stan.
prior_summary(sf1)
#>
#> y ~ garch(1,1,0)
#> Generalized t-student model
#> 350 observations and 1 dimension
#>
#> Priors:
#> Intercept:
#> [1] "mu0 [ ] ~ normal ( mu = 0 ,sd = 1 )"
#>
#> Scale Parameter:
#> [1] "sigma0 [ ] ~ student ( mu = 0 ,sd = 1 ,df = 7 )"
#>
#> [,1]
#> [1,] "arch [ 1 ] ~ normal ( mu = 0 ,sd = 0.5 )"
#> [,1]
#> [1,] "garch [ 1 ] ~ normal ( mu = 0 ,sd = 0.5 )"
#>
#> Generalized t-student
#>
#> lambda ~ G(v/2,v/2)
#> [1] "df [ ] ~ gamma ( shape = 2 ,rate = 0.1 )"
Based on these previously defined parameters, the obtained posteriors are:
It is observed that the posteriors converge. Additionally, when
following the model’s fit, it does not entirely fit the data because the
model does not capture the dependency structure in the location
parameter. Then we proceed to review the model residuals. The
check_residuals
function estimates the posterior mean of
the residuals and plots them. Note that the plot is not sufficient to
corroborate the normality and stationarity assumptions, but they are an
initial indicator of the adjustment.
The residual series (Upper part) seems to be stationary. However, the histogram and quantile graph (middle part) show that the model has heavy tails due to the series’s high volatility.
Based on the previous results, we finally predict the model for the next few days:
Ardia, D., & Hoogerheide, L. F. (2010). Bayesian estimation of the GARCH(1,1) model with student-t innovations. The R Journal, 2(2), 41-47.
Ardia, D. (2008). Financial Risk Management with Bayesian Estimation of GARCH Models: Theory and Applications. volume 612 series Lecture Notes in Economics and Mathematical Systems. Springer-Verlag, Berlin, Germany. https://doi.org/10.1007/978-3-540-78657-3
Vrontos, I., Dellaportas, P., & Politis, D. (2000). Full Bayesian Inference for GARCH and EGARCH Models. Journal of Business & Economic Statistics, 18(2), 187-198.
Engle, R. (1982). Autoregressive Conditional Heteroscedasticity with Estimates of the Variance of United Kingdom Inflation. Econometrica, 50(4), 987-1007. url: http://www.jstor.org/stable/1912773.
Bollerslev, T. (1986). Generalized autoregressive conditional heteroskedasticity. Journal of Econometrics. 31(3), 307-327. doi: https://doi.org/10.1016/0304-4076(86)90063-1