R Programming Language Certification Risk Assessment & Management 5 — Questions and Answers
Question 1: In R, what does the `RiskMeasures::ES_tCopula()` approach model compared to Gaussian copula-based Expected Shortfall?
- Heavier tail dependence, capturing larger joint losses in crisis scenarios (Correct answer)
- Lighter tails, reducing estimated risk
- Independent marginals with no correlation
- Only linear correlation, same as Pearson
Correct answer: Heavier tail dependence, capturing larger joint losses in crisis scenarios
Student-t copulas have tail dependence, meaning extreme losses are more likely to co-occur, producing larger ES estimates than Gaussian copulas.
Question 2: Which R function computes the Herfindahl-Hirschman Index (HHI) relevant to concentration risk in a portfolio?
- sum(weights^2) where weights are portfolio weight fractions (Correct answer)
- var(weights)
- cor(weights, returns)
- mean(abs(weights))
Correct answer: sum(weights^2) where weights are portfolio weight fractions
HHI is the sum of squared portfolio weights; a higher value indicates greater concentration risk in fewer positions.
Question 3: When using `dplyr` for risk data aggregation, which function correctly computes group-level CVaR across scenarios?
- group_by(scenario) %>% summarise(cvar = mean(loss[loss > quantile(loss, 0.95)])) (Correct answer)
- group_by(scenario) %>% mutate(cvar = sum(loss))
- filter(loss > 0) %>% summarise(cvar = sd(loss))
- arrange(desc(loss)) %>% slice(1)
Correct answer: group_by(scenario) %>% summarise(cvar = mean(loss[loss > quantile(loss, 0.95)]))
CVaR at 95% is the mean of losses exceeding the 95th percentile, computed within each scenario group using `group_by` and `summarise`.
Question 4: In R's `quantreg` package, what is the advantage of quantile regression over OLS regression for risk factor modeling?
- It estimates the effect of predictors at specific quantiles of the outcome, capturing tail behavior (Correct answer)
- It always produces smaller standard errors
- It handles only categorical predictors
- It maximizes the likelihood of normally distributed errors
Correct answer: It estimates the effect of predictors at specific quantiles of the outcome, capturing tail behavior
Quantile regression models the conditional quantiles of the response, making it suitable for analyzing extreme outcomes in the tails of a loss distribution.
Question 5: Which R idiom correctly implements importance sampling to estimate a rare-event probability more efficiently than naive Monte Carlo?
- Simulate under a shifted distribution g, then weight samples by f(x)/g(x) (Correct answer)
- Increase the number of naive samples until the event appears frequently
- Use `set.seed()` with a fixed seed to force rare events
- Apply `replicate()` with a very large n
Correct answer: Simulate under a shifted distribution g, then weight samples by f(x)/g(x)
Importance sampling draws from a proposal distribution that makes the rare event more likely, then corrects with likelihood ratio weights to get unbiased estimates.
Question 6: In R, the `ggplot2` function `geom_ribbon()` is useful for risk visualization because it can display what?
- Confidence or prediction bands around a central estimate over time (Correct answer)
- Scatter plots of paired risk variables
- Heat maps of correlation matrices
- Bar charts of category frequencies
Correct answer: Confidence or prediction bands around a central estimate over time
`geom_ribbon()` fills the area between `ymin` and `ymax` aesthetics, ideal for showing uncertainty ranges or VaR/CVaR bands on a time-series plot.
Question 7: What R package provides the `ra()` function for automated risk aggregation across multiple risk categories using a dependency matrix?
- riskAggregation (Correct answer)
- PerformanceAnalytics
- quantmod
- rugarch
Correct answer: riskAggregation
The `riskAggregation` package implements copula-based aggregation of risk categories with user-specified inter-category dependence structures.
In R, what does the `RiskMeasures::ES_tCopula()` approach model compared to Gaussian copula-based Expected Shortfall?