risk: Compute Risk Measures

View source: R/risk.R

riskR Documentation

Compute Risk Measures

Description

Computes Value-at-Risk (VaR) and Tail Value-at-Risk (TVaR) based on simulated insurance cash flows. The function supports discounting for multi-year horizons and can evaluate loss ratio (LR) or balance (BAL).

Usage

risk(
  cf,
  time_horizon = c(1),
  level = c(0.005, 0.01, 0.1, 0.2, 0.5, 0.8, 0.9, 0.99, 0.995),
  discount = 0,
  output = "LR"
)

Arguments

cf

A data.frame containing simulated cash flow results. Must include columns: split, sim_n, PREM, CLAIM, DURATION.

time_horizon

A numeric vector specifying time horizons (e.g., c(1, 5, 10)).

level

A numeric vector of confidence levels for risk quantification (e.g., c(0.01, 0.1, 0.99)).

discount

Annual discount rate to convert future cash flows to present value. Default is 0 (no discount).

output

The metric to be analyzed: "LR" for loss ratio or "BAL" for balance. Default is "LR".

Value

A data.frame summarizing VaR and TVaR values across the specified horizons and confidence levels.

Examples

# Using example_simulation dataset (assumes data is loaded)
result <- risk(example_simulation,
               time_horizon = c(1, 10),
               level = c(0.01, 0.99),
               discount = 0.02,
               output = "BAL")
print(result)

volrisk documentation built on June 14, 2025, 9:07 a.m.