Original link:tecdat.cn/?p=3186

Original source:Tuo End number according to the tribe public number

 

This article shows how to fit and predict value at risk (VaR) based on the underlying ArMA-GARCH model (and, of course, QRM more broadly).

Simulate (log-return) data from the Arma-GarCH process

We consider the ARMA (1,1) -garch (1,1) process using the t-distribution.

Simulate a sequence (for illustrative purposes).

 
nu <- 3  
fixed.p <- list(mu = 0.# mu (intercept)
                ar1 = 0.5.# phi_1 (AR(1) of mu_t)
                ma1 = 0.3.# theta_1 (MA(1) of mu_t)
                omega = 4.# alpha_0 (intercept)
                alpha1 = 0.4.# alpha_1 (GARCH(1) of sigma_t^2)
                beta1 = 0.2.# beta_1 (GARCH(1) of sigma_t^2)
                shape = nu) #  
armaOrder <- c(1.1) # ARMA model parameters
garchOrder <- c(1.1) # GARCH parameters
varModel <- list(model = "sGARCH", garchOrder = garchOrder)
spec <- ugarchspec(varModel, mean.model = list(armaOrder = armaOrder),
                   fixed.pars = fixed.p, distribution.model = "std") # t standard residual
Copy the code

As an integrity check, let’s plot simulation sequences, conditional standard deviations, and residuals.

plot(X,   type = "l", xlab = "t", ylab = expression(X[t]))
​
plot(sig, type = "h", xlab = "t", ylab = expression(sigma[t]))

​
Copy the code

plot(eps, type = "l", xlab = "t", ylab = expression(epsilon[t]))
Copy the code

Fit the ArMA-GARCH model to the (simulated) data

Fitting arMA-GARCH model.

Let’s also consider some health checks.

ARMA(1,1) -garch (1,1) model spec < -ugarchspec (varModel, mean.model = list(armaOrder = armaOrder), distribution.model = "std") # fit <- ugarchfit(spec, Data = X) # # # the fit mu. < - fitted (fit) # fitting hat {mu} _t (= hat {X} _t) sig. < - sigma (fit) # fitting hat _t # # {sigma} stopifnot(all.equal(as.numeric(mu.), fit@fit$fitted.values), all.equal(as.numeric(sig.), fit@fit$sigma))Copy the code

Calculate the VaR time series

Calculate the VaR estimate. Note that we can also use a GPD based estimation model here.

Backtest VaR Estimated value

Let’s go back and test VaR’s estimate.

## [1] 10
## [1] 12
## [1] "Correct Exceedances"
## [1] "Fail to Reject H0"
## [1] "Correct Exceedances & Independent"
## [1] "Fail to Reject H0"
Copy the code

Predict VaR based on fitting model

Now predict VaR.

The future trajectory of X_t is simulated and the corresponding VaR is calculated

Simulate the sequence, estimate the VaR for each simulated path (note quantile() is not available here, so we have to build VaR manually) and calculate the bootstrap confidence interval for VaR _alpha.

Results contrast

Finally, we display all the results.

 

Thank you very much for reading this article, please leave a comment below if you have any questions!


Most welcome insight

1. Empirical research on R language fitting and prediction based on ArMA-GarCH-VAR model

2. Stochastic model of time-varying parameter VAR in R language

3. Stochastic model of time-varying parameter VAR in R language

4. VAR fitting and prediction based on ARMA-GARCH process for R language

5. VaR comparison of GARCH (1,1), MA and historical simulation method

6. Stochastic model of time-varying parameter VAR in R language

7.R language to achieve vector automatic regression VAR model

8.R language random search variable selection SSVS estimation Bayesian vector autoregression (BVAR) model

9. Impulse response analysis of different types of VAR models in R language