Date: 2020-12-08

# stochvolTMB: Likelihood estimation of stochastic volatility models

#### 8 December 2020

# Summary

Stochastic volatility models are often used to model financial returns that exhibit time-varying and autocorrelated variance. It was introduced by Taylor (1982) and models the logarithm of the variance as an autoregressive process of order one. Parameter estimation of stochastic volatility models can be challenging and a variety of methods have been probosed, such as simulated likelihood Liesenfeld (2006), quasi-maximum likelihood Harvey, Ruiz, and Shephard (1994) and Bayesian MCMC methods (Pitt and Shephard (1999), Kastner (2016)). The `R`-package `stochvol` (Kastner (2016)) implements an efficient MCMC algorithm. `stochvolTMB` takes a frequentist approach and estimates parameter using maximum likelihood. The latent volatility is integrated out using the Laplace approximation. The models is implemented in C++ using the package `TMB` (Kristensen et al. (2016)) for fast and efficient estimation. This can lead to substantial speed-up compared to MCMC methods.

# Implementation

`stochvolTMB` implements stochastic volatility models on the form

\[\begin{equation} \begin{aligned} y_t &= \sigma_y e^{h_t/2} \epsilon_t, \quad t = 1, \dots, T, \\ h_{t+1} &= \phi h_{t} + \sigma_h \eta_t, \quad t = 1, \dots, T-1, \\ \eta_t &\stackrel{\text{iid}}{\sim} \mathcal{N}(0,1), \\ \epsilon_t &\stackrel{\text{iid}} {\sim} F, \\ h_1 &\sim \mathcal{N} \bigg (0, \frac{\sigma_h}{\sqrt{(1 - \phi^2)}} \bigg ) \end{aligned} \end{equation}\] where \(y_t\) is the observed log returns, \(h_t\) is the logarithm of the variance on day \(t\). It supports four distribution for \(\epsilon_t\): (1) standard normal distribution; (2) t-distribution; (3) skew-normal distribution; and (4) the leverage model where \((\epsilon_t, \eta_t)\) are multivariate normal with zero mean and correlation coefficient \(\rho\). It also supports generic functions such as `plot`, `summary`, `predict` and `AIC`. The plotting is implemented using `ggplot2` (Wickham (2016)) and data processing utilize the `R`-package `data.table` (Dowle and Srinivasan (2019)).

As an example we compare the different models on log-returns for the S&P index from 2005 to 2018:

    library(stochvolTMB)

    ##
    ## Attaching package: 'stochvolTMB'

    ## The following object is masked from 'package:stats':
    ##
    ##     residuals

    ## The following object is masked from 'package:utils':
    ##
    ##     demo

    gaussian = estimate_parameters(spy$log_return, model = "gaussian", silent = TRUE)
    t_dist = estimate_parameters(spy$log_return, model = "t", silent = TRUE)
    skew_gaussian = estimate_parameters(spy$log_return, model = "skew_gaussian", silent = TRUE)
    leverage = estimate_parameters(spy$log_return, model = "leverage", silent = TRUE)

To compare competing models we can use model selection tools such as AIC (Akaike (1998)):

    AIC(gaussian,
        t_dist,
        skew_gaussian,
        leverage)

Clearly the leverage model is preferred in this example. Notice that the Gaussian model performs the worst and shows that

# References

Akaike, Hirotogu. 1998. “Information Theory and an Extension of the Maximum Likelihood Principle.” In Selected Papers of Hirotugu Akaike, 199–213. Springer.

Dowle, Matt, and Arun Srinivasan. 2019. data.table: Extension of ‘Data.frame‘. https://CRAN.R-project.org/package=data.table.

Harvey, Andrew, Esther Ruiz, and Neil Shephard. 1994. “Multivariate Stochastic Variance Models.” Review of Economic Studies 61 (2): 247–64. http://EconPapers.repec.org/RePEc:oup:restud:v:61:y:1994:i:2:p:247-264.

Kastner, Gregor. 2016. “Dealing with Stochastic Volatility in Time Series Using the R Package stochvol.” Journal of Statistical Software 69 (5): 1–30. https://doi.org/10.18637/jss.v069.i05.

Kristensen, Kasper, Anders Nielsen, Casper Berg, Hans Skaug, and Bradley Bell. 2016. “TMB: Automatic Differentiation and Laplace Approximation.” Journal of Statistical Software, Articles 70 (5): 1–21. https://doi.org/10.18637/jss.v070.i05.

Liesenfeld, Richard. 2006. “Classical and Bayesian Analysis of Univariate and Multivariate Stochastic Volatility Models.” http://www.tandfonline.com/doi/abs/10.1080/07474930600713424.

Pitt, Michael K., and Neil Shephard. 1999. “Time-Varying Covariances: A Factor Stochastic Volatility Approach.” In Bayesian Statistics, 6 (Alcoceber, 1998), 547–70. Oxford Univ. Press, New York.

Taylor, S. J. 1982. “Financial Returns Modelled by the Product of Two Stochastic Processes-a Study of the Daily Sugar Prices 1961-75.” Time Series Analysis : Theory and Practice 1: 203–26. https://ci.nii.ac.jp/naid/10018822959/en/.

Wickham, Hadley. 2016. Ggplot2: Elegant Graphics for Data Analysis. Springer-Verlag New York. https://ggplot2.tidyverse.org.