stan_garch: Fitting for a GARCH(s,k,h) model.

View source: R/stan_models.R

stan_garchR Documentation

Fitting for a GARCH(s,k,h) model.

Description

Fitting a GARCH(s,k,h) model in Stan.

Usage

stan_garch(
  ts,
  order = c(1, 1, 0),
  arma = c(0, 0),
  xreg = NULL,
  genT = FALSE,
  asym = "none",
  chains = 4,
  iter = 2000,
  warmup = floor(iter/2),
  adapt.delta = 0.9,
  tree.depth = 10,
  prior_mu0 = NULL,
  prior_sigma0 = NULL,
  prior_ar = NULL,
  prior_ma = NULL,
  prior_mgarch = NULL,
  prior_arch = NULL,
  prior_garch = NULL,
  prior_breg = NULL,
  prior_gamma = NULL,
  prior_df = NULL,
  series.name = NULL,
  ...
)

Arguments

ts

a numeric or ts object with the univariate time series.

order

a vector of length three specifying the GARCH model. The three components c(s, k, h) are the ARCH order, the GARCH order, and the MGARCH orders respectively.

arma

a vector of length two with the ARMA model configuration. The two components c(p, q) are the AR, and the MA orders respectively.

xreg

Optionally, a numerical matrix of external regressors, which must have the same number of rows as ts. It should not be a data frame.

genT

a bool value to specify for a generalized t-student GARCH model.

asym

a string value for the asymmetric function for an asymmetric GARCH process. By default, the value "none" for standard GARCH process. "logit" option a specifies a logistic function for asymmetry, and option "exp" defines an exponential function.

chains

an integer of the number of Markov Chains chains to be run. By default, chains = 4.

iter

an integer of total iterations per chain including the warm-up. By default, iter = 2000.

warmup

a positive integer specifying number of warm-up (aka burn-in) iterations. This also specifies the number of iterations used for step-size adaptation, so warm-up samples should not be used for inference. The number of warmup iteration should not be larger than iter.By default, warmup = iter/2.

adapt.delta

an optional real value between 0 and 1, the thin of the jumps in a HMC method. By default, is 0.9.

tree.depth

an integer of the maximum depth of the trees evaluated during each iteration. By default, is 10.

prior_mu0

The prior distribution for the location parameter in an ARIMA model. By default, sets student(7,0,1) prior.

prior_sigma0

The prior distribution for the scale parameter in an ARIMA model. By default, declares a student(7,0,1) prior.

prior_ar

The prior distribution for the auto-regressive parameters in an ARIMA model. By default, sets a normal(0,0.5) priors.

prior_ma

The prior distribution for the moving average parameters in an ARIMA model. By default, sets a normal(0,0.5) priors.

prior_mgarch

The prior distribution for the mean GARCH parameters in a GARCH model. By default, sets normal(0,0.5) priors.

prior_arch

The prior distribution for the ARCH parameters in a GARCH model. By default, sets normal(0,0.5) priors.

prior_garch

The prior distribution for the GARCH parameters in a GARCH model. By default, sets normal(0,0.5) priors.

prior_breg

The prior distribution for the regression coefficient parameters in an ARIMAX model. By default, sets student(7,0,1) priors.

prior_gamma

The prior distribution for the asymmetric parameters in MGARCH model. By default, sets normal(0,0.5) priors.

prior_df

The prior distribution for the degree freedom parameters in a t-student innovations GARCH model. By default, sets a gamma(2,0.1) prior.

series.name

an optional string vector with the series names.

...

Further arguments passed to varstan function.

Details

The function returns a varstan object with the fitted model.

By default the garch() function generates a GARCH(1,1) model. The genT = TRUE option defines a t-student innovations GARCH model (see Ardia (2010)). For Asymmetric GARCH models use the option asym for specify the asymmetric functions, see Fonseca, et. al (2019) for more details.

The default priors used in a GARCH(s,k,h) model are:

  • ar ~ normal(0,0.5)

  • ma ~ normal(0,0.5)

  • mu0 ~ t-student(0,2.5,6)

  • sigma0 ~ t-student(0,1,7)

  • arch ~ normal(0,0.5)

  • garch ~ normal(0,0.5)

  • mgarch ~ normal(0,0.5)

  • dfv ~ gamma(2,0.1)

  • breg ~ t-student(0,2.5,6)

For changing the default prior use the function set_prior().

Value

A varstan object with the fitted GARCH model.

Author(s)

Asael Alonzo Matamoros.

References

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.

Fonseca, T. and Cequeira, V. and Migon, H. and Torres, C. (2019). The effects of degrees of freedom estimation in the Asymmetric GARCH model with Student-t Innovations. arXiv doi: arXiv: 1910.01398.

Ardia, D. and Hoogerheide, L. (2010). Bayesian Estimation of the GARCH(1,1) Model with Student-t Innovations. The R Journal. 2(7), 41-47. doi: 10.32614/RJ-2010-014.

See Also

Sarima, auto.arima, and set_prior.

Examples


 # Declaring a garch(1,1) model for the ipc data.
 sf1 = stan_garch(ipc,order = c(1,1,0),iter = 500,chains = 1)

 # Declaring a t-student M-GARCH(2,3,1)-ARMA(1,1) process for the ipc data.
 sf2 = stan_garch(ipc,order = c(2,3,1),arma = c(1,1),genT = TRUE,iter = 500,chains = 1)



bayesforecast documentation built on June 8, 2025, 10:42 a.m.