risk: Risk Measures of Fitted Objects

View source: R/fit_risk.R

riskR Documentation

Risk Measures of Fitted Objects

Description

risk computes the VaR, ES and expectiles at a given level for fitted distribution.

Usage

risk(
  model,
  alpha,
  expectile = TRUE,
  plot = FALSE,
  ggplot = FALSE,
  text_ylim = -0.15,
  size = 1
)

## S3 method for class 'PNP'
risk(
  model,
  alpha = 0.05,
  expectile = TRUE,
  plot = FALSE,
  ggplot = FALSE,
  text_ylim = -0.15,
  size = 1
)

## S3 method for class 'GNG'
risk(
  model,
  alpha = 0.05,
  expectile = TRUE,
  plot = FALSE,
  ggplot = FALSE,
  text_ylim = -0.15,
  size = 1
)

Arguments

model

output object of GNG_fit() or PNP_fit().

alpha

levels of risk measures.

expectile

logical, if also expectiles should be computed, default: TRUE.

plot

plot the results?, default: FALSE.

ggplot

plot the results with ggplot2?, default: FALSE.

text_ylim

y coordinate for annotation in ggplot2, default: -0.15.

size

size of the text indicating the risk measures in the plot, default: 1.

Details

VaR are computed using the q() call of the fitted distribution.

ES is computed directly (i.e. the integrals are precomputed, not numerically) as an integral of the quantile function.

Expectiles can be obtained as a unit-root solution of the identity between quantiles and expectiles. These are equivalent for corresponding τ and α if

τ=(α q(α) -G(α))/(μ - 2G(α)-(1-2α)q(α))

where μ is mean, q() is the quantile function and G(α) =\int_{-∞}^{q(α)} y dF(y).

Value

List of class risk_measures.

Examples

## Not run: 
 GNG <- GNG_fit(stocks$SAP)
 PNP <- PNP_fit(stocks$MSFT)

 risk(PNP, alpha = c(0.01,0.05,0.08,0.1))
 risk(GNG, alpha = c(0.01,0.05,0.08,0.1), plot = TRUE)

## End(Not run)

mistr documentation built on March 7, 2023, 7:42 p.m.