Risk Measures in Finance

Jan Hurt

Charles University of Prague

2008 Risk Measures in Finance: http://library.wolfram.com/infocenter/Conferences/7230/

Introduction

Preliminaries

Notation

Let (Subscript[S, 0]),(Subscript[S, 1,]),... be the prices of securities at times t=0,1,.... Let

(Subscript[R, t])=(((Subscript[S, t+1])-(Subscript[S, t]))/(Subscript[S, t]))

denote the rates of return or shortly returns and

(Subscript[L, t])=-(Subscript[R, t])

denote the losses. In what follows, R will be considered as the return random variable and L=-R will be the loss random variable. The distributions of R and L in this contribution are assumed to be absolutely continuous.

Calculation of Returns/Losses

From definitions 1 and 2 we get

Clear[returns,losses];returns[prices_?VectorQ]:=((Rest[prices]-Most[prices])/(Most[prices]))
losses[prices_?VectorQ]:=((Most[prices]-Rest[prices])/(Most[prices]))

losses[{p0,p1,p2,p3}]

Measures of risk

Standard Deviation

The simplest measure of financial risk is the standard deviation of the loss distribution

σ=(Sqrt[var L])=(Sqrt[var R])

It plays an important role in Markowitz theory of portfolio. One of the disadvantages of σ is that it measure the global volatility of either the return or the loss. While left-hand tail of the loss distribution is of interest for shareholders in a pleasant way, the right-hand tail is a nightmare not only for the shareholders. Some decades ago this observation led financial analysts to the introduction of a new measure known as quantile to statisticians distinctively called Value-at-Risk. In statistical books there are only sections devoted to quantiles but in financial literature there are whole books on Value-at-Risk.

Value-at-Risk

Let F and f be the distribution and density function of the loss random variable L, respectively, and

(F^(-1))(y)=inf{x: F(x)≥y}, 0<y<1,

be the quantile function of L. If the distribution function is increasing on the support of the respective distribution, then (F^(-1)) is simply the inverse function of F. For a specific value of y, the value (F^(-1))(y) is called the y-quantile. The α-quantile of L

(Subscript[VaR, α])(L):=(Subscript[VaR, α])=(F^(-1))(α)

is called Value-at-Risk at level α, shortly VaR. The probability that the loss exceeds (Subscript[VaR, α]) is 1-α. The typical values for α are 0.99 (Bankers Trust), 0.95 (J P Morgan) or 0.954 for Citibank. VaR is still today the most popular risk  measure for market risk quantification. Mathematicians were thinking on the properties of VaR, however, and discovered that a good risk measure should fulfill some postulates which are summarized below.

Coherent Risk Measure

A coherent risk measure is a real function 𝓇 on a space of random variables 𝒫 that for X,Y∈𝒫 and a∈ℝ possesses the following properties:

A1    X≤Y almost surely ⟹ 𝓇(X)⩽𝓇(Y)(Monotonicity)

A2    𝓇(X+Y)⩽𝓇(X)+𝓇(Y)(Subaditivity)

A3    𝓇(a X)=a 𝓇(X) (Positive homogeneity)

A4    𝓇(a+X)=a + 𝓇(X) (Translation equivariance).

The VaR does not meet A2 in general. Moreover, VaR does not say how large losses above this value may be.

Conditional Value-at-Risk

More intuitive measure of risk and even a coherent measure is the Conditional Value-at-Risk, also called Tail Conditional Expectation or Expected Shortfall. Note that if the loss distribution is not absolutely continuous, these definitions slightly differ. Conditional Value-at-Risk at level α  is defined as

(Subscript[CVaR, α])(L)=(Subscript[CVaR, α])=E{L|L≥(Subscript[VaR, α])(L)}.

Another advantage of this measure is that it says how large average loss may be after exceeding VaR. Note that even this measure is not a novelty. In reliability theory and survival data analysis an analogue is the mean residual lifetime defined later.

Parametric Methods

Value-at-Risk (VaR)

The Procedure

From the definition of VaR we have

Clear[VaR];
VaR[distribution_,α_]:=Quantile[distribution,α]

Conditional Value-at-Risk (CVaR)

CVaR and the Mean Residual Lifetime

Suppose that random variable X possesses the distribution function G and the power density function g. In reliability theory, survival data analysis, and life insurance the function called mean residual lifetime is often used. It is defined as m(x)=E(X-x|X≥x), x∈ℝ. If X takes only positive values then

m(x)=(1/(1-G(x)))(∫_( x)^∞)(1-G(y))dy.

For X arbitrary   we have

m(x)=(1/(1-G(x)))(∫_( x)^∞)y g(y)dy -x.

Mean residual lifetime completely specifies the distribution of X since for so called failure rate (hazard rate, mortality rate) defined as h(x)=g(x)/(1-G(x))

h(x)=((m'(x)+1)/(m(x)))

holds and

1-G(x)=exp{-(∫_( 0)^( x))h(y)dy}.

Note that sometimes the expected shortfall is defined as m(x)=

(Subscript[ES, α])(L)=E(L-(Subscript[VaR, α])|L≥(Subscript[VaR, α]))=m((Subscript[VaR, α])).

The Procedure

The calculation of the conditional expected value is based on the well-known formula

E(L|L≥z)=(1/(1-F(z)))(∫_( z)^( ∞))y f(y)dy

Clear[ConditionalExpectation];
ConditionalExpectation[distribution_,z_]:=
	(1/(1-CDF[distribution,z]))(∫_( z)^( ∞))y PDF[distribution,y]\[DifferentialD]y
Clear[CVaR];
CVaR[distribution_,α_]:=
ConditionalExpectation[distribution,Quantile[distribution,α]]

Example (Normal Distribution)

Here we have an explicit formula for CVaR in N(μ,σ) case.

CVaRnormal[μ_,σ_,α_]=Assuming[σ>0,CVaR[NormalDistribution[μ,σ],α]]

Plot[{VaR[NormalDistribution[0,1],x],CVaRnormal[0,1,x]},{x,0.9,0.99},PlotRange->All,AxesOrigin->{0.9,0}]

This is the ratio of CVaR and VaR for N(μ,σ) is invariant with respect to standard deviation but it changes with the mean.

Plot[{((CVaR[NormalDistribution[0,1],x])/(VaR[NormalDistribution[0,1],x]))//Evaluate,((CVaR[NormalDistribution[1,1],x])/(VaR[NormalDistribution[1,1],x]))},{x,0.9,0.99},PlotRange->All]

Here is the ratio CVaR/VaR

Manipulate[Plot[((CVaRnormal[μ,1,x])/(VaR[NormalDistribution[μ,1],x])),{x,0.9,0.999},PlotRange->{1,1.5}],{μ,0,3}]

Example (Heavy tails)

This example is rather artificial because it is based on Student's t-distribution that can hardly be observed in practice. It is popular for illustrations since it has heavy tails for small degrees of freedom. For one degree of freedom it coincides with Cauchy distribution:

PDF[StudentTDistribution[n],x]/.n->1

Calculation of CVaR in this case results in a rather complicated formula.

Clear[CVaRStudentcalculated];CVaRStudentcalculated[n_,α_]=Assuming[n>1&&n∈Integers&&(1/2)<α<1,CVaR[StudentTDistribution[n],α]]//Simplify

Here is just a hard copy of the result.

Clear[CVaRStudent];
CVaRStudent[n_,α_]=-(2 (Sqrt[n]) ((InverseBetaRegularized[1,1-2 α,(n/2),(1/2)])^((1/2) (-1+n))))/((-1+n) Beta[(n/2),(1/2)] (-1+BetaRegularized[n/(n+n (-1+1/InverseBetaRegularized[1,(1-2 α) Sign[-1+2 α],(n/2),(1/2)]) ((Sign[1-2 α])^2)),1,(n/2),(1/2)] (Sqrt[Sign[n]]) Sign[-1+2 α] √Sign[-1+1/InverseBetaRegularized[1,(1-2 α) Sign[-1+2 α],(n/2),(1/2)]]));

Plot[{VaR[StudentTDistribution[3],x],CVaRStudent[3,x]},{x,0.9,0.99},PlotRange->All,AxesOrigin->{0.9,0}]

Manipulate[Plot[((CVaRStudent[n,x])/(VaR[StudentTDistribution[n],x])),{x,0.9,0.999},PlotRange->{1,2}],{n,3,50,1}]

In usual statistical inference the recommended practice is to approximate Student's distribution by a normal distribution for higher degrees of freedom, n>30, say. Next we see that for measures heavily dependent on tails this approximation might not work satisfactorily.

Manipulate[Plot[((CVaRStudent[n,x])/(VaR[StudentTDistribution[n],x]))-((CVaRnormal[0,1,x])/(VaR[NormalDistribution[0,1],x])),{x,0.9,0.999},PlotRange->{0,0.2}],{n,5,50,1}]

Remark

In [10] Chandler conditional tail expectation for various parametric distributions of positive random variables is considered:

http://demonstrations.wolfram.com/TailConditionalExpectations/

Nonparametric Methods

Value-at-Risk (VaR)

Sample data

The following function generates a list of normal random numbers.

lossesnormal[n_]:=RandomReal[NormalDistribution[0,1],{n}]

SeedRandom[13];
lossesnormal1000=lossesnormal[1000]

The Procedure

Clear[VaRsample];
VaRsample[losses_?VectorQ,α_]:=Quantile[losses,α]

varsample1000=VaRsample[lossesnormal1000,0.9]

Remark

We have not considered statistical properties of the above measures. A nice demonstration of computing standard errors of nonparametric VaR by bootstrapping is in [7] Hamrick:

http://demonstrations.wolfram.com/BootstrappingToComputeValueAtRiskStandardErrors/

Conditional Value-at-Risk (CVaR)

The Procedure

The sample conditional Value-at-Risk is just the sample equivalent to the theoretical CVaR, i. e., the sample conditional mean. We select data above VaR and calculate their average.

Clear[CVaRsample];
CVaRsample[losses_?VectorQ,α_]:=
Mean[Select[losses,#>VaRsample[losses,α]&]]

Example (Normal Distribution)

varsample1000=VaRsample[lossesnormal1000,0.9]

CVaRsample[lossesnormal1000,0.9]

Compare with the theoretical values:

{VaR[NormalDistribution[0,1],0.9],CVaR[NormalDistribution[0,1],0.9]}

The following calculation takes a long time!!!

Plot[{VaR[NormalDistribution[0,1],x],CVaRnormal[0,1,x],VaRsample[lossesnormal1000,x],CVaRsample[lossesnormal1000,x]},{x,0.9,0.99},PlotRange->All,AxesOrigin->{0.9,0}]

Example (Dow Jones Industrial)

Reference for the components of ^DJI and the names of symbols

http : // finance.yahoo.com/q/cp?s = %5 EDJI

We randomly select one of the stocks in DJI:

fd=FinancialData["^DJI","Members"]
Print["Random choice from DJI: ",rdf=RandomChoice[fd]]
pricesDJI=Map[Last,Partition[Flatten[FinancialData[rdf,"Jan. 1, 2008"]],4]]
DateListPlot[FinancialData[rdf,"Jan. 1, 2008"]]

returnspricesDJI=returns[pricesDJI];
ListPlot[returnspricesDJI,Joined->True,PlotRange->All,AxesLabel->{days,rdf}]
lossespricesDJI=losses[pricesDJI];

Needs["Histograms`"];
{meanrdf=Mean[lossespricesDJI],serdf=StandardDeviation[lossespricesDJI]}
Histogram[lossespricesDJI]

Comparison of parametric and nonparametric approach for selected confidence levels:

Table[{α,VaR[NormalDistribution[meanrdf,serdf],α],
VaRsample[lossespricesDJI,α],
CVaR[NormalDistribution[meanrdf,serdf],α],CVaRsample[lossespricesDJI,α]},
{α,{0.9,0.95,0.99}}]//TableForm

Remark

A relevant demonstration is in [9] Hamrick, J., Cawley, J.

http://demonstrations.wolfram.com/ExpectedReturnsOfTheDowIndustrialsBetaModel/

Risk of Portfolios

Preliminaries

Let us consider N assets 1,...,N with the expected returns er:=((Subscript[r, 1]),...,(Subscript[r, N])) and the covariance matrix of the returns covmat:=V. A portfolio is a vector x=((Subscript[x, 1]),...,(Subscript[x, N])) of weights representing investments (amounts of money) into respective assets. Usually it is supposed that the investor has the unit wealth so that

(∑_(n=1)^N)(Subscript[x, n])=1.

The expected return on portfolio is

(Subscript[r, p])=(∑_(n=1)^N)(Subscript[x, n])(Subscript[r, n])

with the risk (= standard deviation of the return on portfolio)

(Subscript[σ, p])=(Sqrt[(x^T)V x]).

Some problems in portfolio theory deal with optimal portfolios introduced by Markowitz. By optimality we usually mean some reasonable compromise between the expected return and risk. Here we restrict ourselves to the following problem: Find the portfolio with the prescribed expected return μ while minimizing the risk. In other words, find x such that (Subscript[σ, p]) is minimum and (Subscript[r, p])=μ. If the components of x are allowed to be negative, we say that short sales are allowed and if the components of x must be nonnegative, we say that short sales are not allowed. In the first case, the problem is solved using the standard methods of calculus (Lagrange multipliers) while the second case is a problem of quadratic programming (find a minimum of a positive semidefinite quadratic form under linear constraints. We will solve the second problem using the built-in function NMinimize.

Portfolio with prescribed expected return and minimum risk (short sales are not allowed)

Clear[optimalportfolio];optimalportfolio[er_?VectorQ,V_?MatrixQ,μ_]:=
Module[{x=Table[Unique[],{Length[er]}],solution,optportfolio},
solution=NMinimize[{x.V.x,{Total[x]==1,x.er≥μ,Thread[x≥0]}//Flatten},x];
Print["     Risk =  ",(Sqrt[solution[[1]]]),
"   Portfolio =  ",optportfolio=x/.solution[[2]],"\n     Expected return on portfolio = ",optportfolio.er];
optportfolio
	     ]

Example (DJI data)

The data used are actual up to October 22, 2008. The expected returns of all assets are negative. But still it is of interest to seek for an optimal portfolio since without investment money might loose their purchasing power due to inflation say. By investment we can minimize the loss.

fd=FinancialData["^DJI","Members"];
Print["     Random sample of 5 stocks from DJI: ",rdf5=RandomSample[fd,5]]

rdf5={"MMM","VZ","BAC","DD","MCD"};

findata5=Map[FinancialData[#,"Jan. 1, 2008"]&,rdf5]

(prices5=Map[Last,Map[Partition[#,4]&,Map[Flatten[#]&,findata5]],{2}])//Dimensions

returns5=Map[returns,prices5];
means5=Map[Mean,returns5]
(cov5=Covariance[returns5//Transpose])//MatrixForm
Max[means5]

optportfolio5=optimalportfolio[means5,cov5,-0.001]

VaR and CVaR

Parametric approach

First we must switch to losses:

losses5=-returns5;
meanslosses5=-means5

The covariance matrix remains cov5. We assume that the join distribution of losses is multivariate normal without unknown mean and covariance matrix. We estimate these parameters by meanslosses5 and cov5, respectively. The loss of portfolio x is approximately distributed as N(meanslosses5.x,(Sqrt[x.cov5.x])). Then the VaR's on different confidence levels are

Table[{α,VaR[NormalDistribution[meanslosses5.optportfolio5,(Sqrt[optportfolio5.cov5.optportfolio5])],α],CVaR[NormalDistribution[meanslosses5.optportfolio5,(Sqrt[optportfolio5.cov5.optportfolio5])],α]},{α,{0.9,0.95,0.99}}]//TableForm

Next we look on the first asset

rdf5[[1]]

VaR and CVaR for this asset are

tab5=Table[{α,VaR[NormalDistribution[meanslosses5[[1]],(Sqrt[cov5[[1,1]]])],α],CVaR[NormalDistribution[meanslosses5[[1]],(Sqrt[cov5[[1,1]]])],α]},{α,{0.9,0.95,0.99}}]//TableForm

Nonparametric approach

For the first asset we simply have

Table[{α,VaRsample[losses5[[1]],α],CVaRsample[losses5[[1]],α]},{α,{0.9,0.95,0.99}}]//TableForm

Dimensions[losses5]

For the optimal portfolio we first create the corresponding sample of daily values of portfolio and then use the standard procedures

portfoliodaily5=optportfolio5.losses5

Table[{α,VaRsample[portfoliodaily5,α],CVaRsample[portfoliodaily5,α]},{α,{0.9,0.95,0.99}}]//TableForm

Compare with the parametric case:

tab5

Acknowledgments

The research has been supported by Grant of Czech Ministry of Education MSM 0021620839, Methods of modern mathematics and their applications.

References

[1] Pflug, G. Ch. (2000): Chapter 1 Some Remarks on the Value-at-Risk and the Conditional Value-at-Risk.
http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.32.8541

[2] Bluhm, Ch., Overbeck, L., Wagner, Ch. (2002): Credit Risk Modeling. Chapman & Hall/CRC, Boca Raton.

[3] Dupacova, J., Hurt, J., Stepan, J. (2002): Stochastic Modeling in Economics and Finance. Kluwer, Dordrecht.

[4] Franke, J., Haerdle, W., Hafner, Ch. M. (2004): Statistics of Financial Markets. Springer, Berlin.

[5] Dupacova, J., Polivka, J. (2007): Stress testing for VaR and CVar. Quantitative Finance, Vol. 7, No. 4, pp. 411-421.

[6] Szegoe, G. (2002): Measures of risk. J. of Banking & Finance, Vol. 26, pp. 1253-1272.

[7] Hamrick, J. (2008): Bootstrapping to Compute Value-at-Risk Standard Errors. The Wolfram Demonstration Project.

[8] Benninga, S., Wiener, Z. (1998): Value-at-Risk (VaR). Mathematica in Education and Research, Vol. 7, No. 4.

[9] Hamrick, J., Cawley, J. (2008): Expected Returns of the Dow Industrials, Beta Model. om The Wolfram Demonstrations Project.

[10] Chandler, S. J. (2008): Tail Conditional Expectations. The Wolfram Demonstration Project.