So far I have just theoretical knowledge of risk measure and never used them in application. Therefore I have some basic question how risk measures are used in reality and how they are implemented in R.

  1. Let's assume you are managing a portfolio containing some assets. In particular I'm interested in VaR and CVaR. VaR is a quantile of the loss distribution. In reality one would calculate the VaR for the returns to see what the current risk of your portfolio is. This leads to a series of VaR over time, is this correct?
  2. How CVaR implemented in R? I know there is the PerformanceAnalytics package containing the function ES. But how does this function calculate the CVaR? Moreover, this function (ES) has as argument a vector, matrix, data frame, timeSeries or zoo object of asset returns. How does the calculation differs if the argument is a data frame of asset returns or a timeSeries object?
  3. Closely related to 2. How are Time Series used to calculate VaR/CVar?

I'm very thankful for any explanations / references.


For the first, people regularly compute VaR or CVaR over time and plot the results.

For two and three, the documentation for the ETL function says that you can either calculate it using a Gaussian approach or Cornish-Fisher expansion. These are both analytical methods. The Gaussian approach uses only the mean and variance (effectively assuming that the distribution of returns is a Gaussian distribution with whatever mean and variance you provide), while the Cornish-Fisher also takes into account the skewness and kurtosis of the distribution.

You can use the function to calculate a univariate CVaR for one or more series. The underlying formula would not change for different data types so long as you are considering a univariate CVaR. However, if you choose to calculate the CVaR of a portfolio (by changing the portfolio_method parameter, I believe), then the formulas change to handle the multivariate relationships between the different securities. In this case, the Cornish-Fisher expansion typically becomes burdensome for large portfolios because the co-skewness and co-kurtosis matrices become huge.

To resolve this issue, the more general way to calculate VaR and CVaR is to represent the distribution of returns by scenarios. Some people use the historical distribution of returns in this way, but you can also use simulations from more general distributions. Given a vector of portfolio weights, you can calculate the portfolio returns for each scenario. Then you can find the VaR of the portfolio by the quantile function. The CVaR is then just the average of the returns less than the VaR. This can be done quite easily in just about any language.

I wouldn't say time series are used to calculate VaR and CVaR. Rather, time series methods or techniques can be used to produce estimates of the expected distribution of returns. VaR and CVaR are functions on those distributions. xts is used in PerformanceAnalytics mainly as a data container, i.e. to make it easier to work with returns and dates.

  • $\begingroup$ I'm very thankful for your answer. But I don't understand the use of time series in this context. Could please provide some additional information, e.g. how is time series analysis used in reality? Let's say your portfolio contains 3 stocks. You also have some historical data (returns) of all these stocks. How would you proceed? $\endgroup$ – math Apr 11 '14 at 16:40
  • $\begingroup$ What is time series is really too basic for this site. Start with en.wikipedia.org/wiki/Time_series, then get a book on the subject if you want to learn more. $\endgroup$ – John Apr 11 '14 at 17:35
  • $\begingroup$ That was not my question. I know what a time series is. I would like to know how they are used to calculating VaR / CVar in reality. For example, for a portfolio containing different assets are you using a multivariate time series or for each stock separately. How are they used further in the estimation of VaR/CVaR. $\endgroup$ – math Apr 11 '14 at 17:50
  • $\begingroup$ You are implicitly using time series analysis when you go from raw security prices to (log) returns, fitting a mean and covariance to those returns, and then assuming that distribution is what you will expect in the future when using those parameters to get portfolio means, variances, VaRs, or CVaRs. Further, like going from univariate variance to portfolio variance, univariate VaR or CVaR will not aggregate to the portfolio level by themselves since you assume away the correlation between the securities. $\endgroup$ – John Apr 11 '14 at 18:41
  • 1
    $\begingroup$ More or less, yes. If you use the mean and covariance of returns to calculate Gaussian VaR/CVaR, you are implicitly making assumptions about the distribution of the securities in the future. For the second point, all measures of portfolio risk I'm aware of depend on correlations to some extent. Finally, the documentation for PerformanceAnalytics makes it clear that the sigma argument is variance if univariate and a covariance matrix if multivariate. $\endgroup$ – John Apr 11 '14 at 20:23

A risk measure $\rho$ applied to time series $X \in \mathbb{R^n}$ yields $Y \in \mathbb{R} $. i.e. $\rho: \mathbb{R^n} \rightarrow \mathbb{R}$

As for implementation (using R), see here.

A look at the formulas for VAR and ES (which is exactly the same as CVAR) should clear up any confusion.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.