Fitting a Generalized Error Distribution for Parametric Value at Risk
Summary
The document addresses how to estimate the shape parameter of a generalized error distribution for a one-day parametric Value at Risk calculation. It presents a likelihood-based fitting approach that estimates the distribution’s mean, scale, and shape from observed log returns. A density is specified, and a numerical optimizer is used to find parameter values that maximize the likelihood, with an example using simulated normally distributed observations.
The example demonstrates the mechanics of fitting the shape along with the other distribution parameters, which can then be used to obtain a VaR quantile. It does not show a VaR calculation on actual market returns or compare the fitted distribution with alternatives. The answer also does not discuss convergence diagnostics, parameter constraints beyond the optimizer settings, tail validation, or out-of-sample risk performance. As a result, it offers an implementation outline rather than evidence that GED-based VaR is reliable for a particular return series.
Key ideas
- A generalized error distribution can be fitted to return observations using likelihood optimization.
- The fitting procedure estimates mean, scale, and shape parameters together.
- The estimated shape parameter determines the distribution used to obtain a risk quantile.
- The example uses simulated returns and does not establish the fit quality for market data.
- VaR validation and out-of-sample performance are not addressed.
Tags
Full text
# How to forecast Value-at-Risk in R with different assumptions?
# How to forecast Value-at-Risk in R with different assumptions?
I'm calculating 1-day parametric VaR estimates under the assumption that the returns are distributed as a generalized error distribution.
I have the historical observations of the returns, obtained as log-difference prices.
How do I estimate in R the shape parameter of the GED to use to find the quantile?
## Answer by AK88 (score 0)
https://quant.stackexchange.com/a/34762
Try the following (from this source):
```
dged <- function(x, mean = 0, sd = 1, nu = 2) {
z = (x - mean)/sd
lambda = sqrt(2^(-2/nu) * gamma(1/nu)/gamma(3/nu))
g = nu/(lambda * (2^(1 + 1/nu)) * gamma(1/nu))
density = g * exp(-0.5 * (abs(z/lambda))^nu)/sd
density
}
gedFit <- function(x, ...) {
start = c(mean = mean(x), sd = sqrt(var(x)), nu = 2)
loglik = function(x, y = x) {
f = -sum(log(dged(y, x[1], x[2], x[3])))
f
}
fit = nlminb(start = start, objective = loglik, lower = c(-Inf,
0, 0), upper = c(Inf, Inf, Inf), y = x, ...)
names(fit$par) = c("mean", "sd", "nu")
fit
}
```
Here you can change `data` to your calculated observations:
```
set.seed(2356)
data = rnorm(1000, 0, 0.09)
fitted = gedFit(data)
parameters = fitted$par
parameters
```
Your parameters, including `nu`:
```
mean sd nu
0.003114645 0.088738398 2.409166210
```Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.