backtest {BEKKs} | R Documentation |

## Backtesting via Value-at-Risk (VaR)

### Description

Method for backtesting a model obtained from bekk_fit in terms of VaR-forcasting accuracy using a rolling window approach.

### Usage

```
backtest(
x,
window_length = 1000,
p = 0.99,
portfolio_weights = NULL,
n.ahead = 1,
distribution = "empirical",
nc = 1
)
```

### Arguments

`x` |
An object of class "bekkFit" from the function bekk_fit. |

`window_length` |
An integer specifying the length of the rolling window. |

`p` |
A numerical value that determines the confidence level. The default value is set at 0.99 in accordance with the Basel Regulation. |

`portfolio_weights` |
A vector determining the portfolio weights to calculate the portfolio VaR. If set to "NULL", the univariate VaR for each series are calculated. |

`n.ahead` |
Number of periods to predict conditional volatility. Default is a one-period ahead forecast. |

`distribution` |
A character string determining the assumed distribution of the residuals. Implemented are "normal", "empirical" and "t". The default is assuming the empirical distribution of the residuals. |

`nc` |
Number of cores to be used for parallel computation. |

### Value

Returns a S3 class "backtest" object containing the VaR forecast, out-of-sample returns and backtest statistics according to the R-package "GAS". conf

### Examples

```
data(StocksBonds)
obj_spec <- bekk_spec()
x1 <- bekk_fit(obj_spec, StocksBonds, QML_t_ratios = FALSE, max_iter = 50, crit = 1e-9)
# backtesting
x2 <- backtest(x1, window_length = 6000, n.ahead = 1, nc = 1)
plot(x2)
# backtesting using 5 day-ahead forecasts
x3 <- backtest(x1, window_length = 6000, n.ahead = 5, nc = 1)
plot(x3)
# backtesting using 20 day-ahead forecasts and portfolio
x4 <- backtest(x1, window_length = 6000, portfolio_weights = c(0.5,0.5), n.ahead = 20, nc = 1)
plot(x4)
```

*BEKKs*version 1.4.4 Index]