NMFM507

Advanced Topics of Financial Management

$LicenseExpirationDate

Úvod

Termíny zkoušek

13. 01. 2015 11:00 K11 nebo K4 
29. 01. 2014 11:00 K11 nebo K4  
04. 02. 2014 11:00 K11 nebo K4

Literatura

[1] Dupačová, J., Hurt, J., Štěpán, J.: Stochastic Modeling in Economics and Finance. Kluwer Academic Publishers. Dordrecht 2002.

[2] Cipra, T.: Finanční ekonometrie. Ekopress, Praha 2008.

[3] Cipra, T.: Matematika cenných papírů. Kamil Mařík Professional Publishing. Praha 2013.

[4] Hurt, J.: Yield curves with Mathematica 6.0. In: Wolfram Technology Conference 2007. http://library.wolfram.com/infocenter/Conferences/6956/ . Champaign (IL) 2007.

[5] Hurt, J.: Risk measures in finance. In: 2008 International Mathematica User Conference. http://library.wolfram.com/infocenter/Conferences/7230/.  Champaign (IL) 2008.

[6] Hurt, J.: Risk measures in finance revisited. In: Wolfram Technology Conference 2010. http://library.wolfram.com/infocenter/Conferences/7861/  . Champaign (IL) 2010.

[7] Sciencedirect:  http://www.sciencedirect.com/

[8] Mathematica Cookbook

[9] Luenberger, D.: Investment Science. Oxford University Press. New York 1998.

[10] Hurt, J.: Finanční management. Přednáška MFF UK.
http://www.karlin.mff.cuni.cz/~hurt/Financni_management_prednaska.nb

[11] Brigham, E. F.: Fundamentals of Financial Management. Dryden Press. 6th edition Fortt Worth 1992. Chapter 7, The Cost of Capital.

Odstavce označené hvězdičkami je třeba interpretovat takto:

*   Slouží k procvičení, znalost ke zkoušce nutná.

** Obsahuje důležité informace, ale jejich neznalost při zkoušce není fatální, zkouškou je možné “projít”.

***Inspirativní náměty nebo zatím přednášejícím nezpracovaná témata. Leckdy užitečné pro řešení problémů v budoucnosti.

Pozadavky k SZZ FPM

http://www.karlin.mff.cuni.cz/~garant/stud/nmgr_ob_fpm _szz.shtml

Lekce 1 (2. 10. 2014)

Teorie portfolia

SetDirectory["C:\\Dokumenty\\Knihy Uvod do financi et Financni management 2005\\Financni mangement kniha 20050318"]

Výnosy dvou perfektně negativně korelovaných aktiv:

Import["fig3.eps"]

Eficientní hranice portfolia dvou aktiv:

Import["EfficientFrontier.eps"]

Example 9.2.1 from [1], p. 82

Manipulate[ParametricPlot[{(Sqrt[36-72 x1+45 (x1^2)+36 x1 ρ-36 (x1^2) ρ]),14-6 x1},{x1,0,1},AxesOrigin->{0,8},AspectRatio->3/4,AxesLabel->{Style["(Subscript[σ, p])",Italic,16],Style["(Subscript[r, p])",Italic,16]},AxesStyle->Directive[14],PlotPoints->50,PlotStyle->{Black,Thick,Dashing[0.01+0.01rho]}],{{ρ,0},-1,1,Appearance->"Labeled"},SaveDefinitions->True]

Portfolia s minimálním rizikem:

Import["portfoliorisky2.eps"]

Portfolia s minimálním rizikem při existenci bezrizikového aktiva:

Import["portfolior2riskyplusriskless.eps"]

Lekce 2 (9. 10. 2014)

Lekce 3 (16. 10. 2014)

Lekce 4 (23. 10. 2014)

Přednáška odpadá, nahrazena kontrolovanou četbou:

Alternativní přístup k teorii portfolia z knihy

[3] Cipra, T.: Matematika cenných papírů. Kamil Mařík Professional Publishing. Praha 2013.

Kapitola 2. 3. Analýza akcie z hlediska výnosnosti a rizika, str. 145-175 (bez odstavce 2. 3. 5.)

Úkol 1: přeformulovat v jazyce a symbolice užívané v přednášce a v [1].

Lekce 5 (30. 10. 2014)

Lekce 6 (6. 11. 2014)

Capital Asset Pricing Model (CAPM)

Market Portfolio (Tržní portfolio, New Jan 8, 2015)

Hyperlink[Button[" Tržní portfolio v modelu CAPM "],"http://www.karlin.mff.cuni.cz/~hurt/Market_Portfolio_in_CAPM.pdf"]

Security Market Line

[3] Cipra, T.: Matematika cenných papírů. Kamil Mařík Professional Publishing. Praha 2013.

Kapitola 2. 3. Analýza akcie z hlediska výnosnosti a rizika, str. 145-175 (bez odstavce 2. 3. 5.)

Úkol 2: Vysvetlit, co znamenaji zvyraznene body v levem grafu.

Capital Market Line

Lekce 7 (13. 11. 2014)

Lekce 8 (20. 11. 2014)

Lekce 9 (27. 11. 2014)

Lekce 10 (4. 12. 2014)

General Procedure for Characteristics

In Mathematica, the Normal and related distributions have the second parameter standard deviation σ and not the variance (σ^2)!!!

Clear[characteristicsofstochasticprocess];characteristicsofstochasticprocess[process_,s_,t_]:=Module[{a},Text@Grid[{{"Process:   ",   Style["  "<>( process//HoldForm//ToString)<>"  ",Bold]},{"Mean   ",Mean[process[t]]//FullSimplify//TraditionalForm},
{"Variance   ",Variance[process[t]]//FullSimplify//TraditionalForm},
{"Skewness   ",Skewness[process[t]]//FullSimplify//TraditionalForm},
{"Kurtosis   ",Kurtosis[process[t]]//FullSimplify//TraditionalForm},
{"Covariance function   ",CovarianceFunction[process,s,t]//FullSimplify//TraditionalForm},{"Slice distribution   ",SliceDistribution[process,t]//FullSimplify//TraditionalForm}},Frame->All]]

Wiener process

Clear[μ,σ,s,t];
characteristicsofstochasticprocess[WienerProcess[μ,σ],s,t]

SeedRandom[13131];ListLinePlot[RandomFunction[WienerProcess[μ,σ]/.{μ->1,σ->0.05},{0,1,0.01}],ImageSize->{350,300}]

SeedRandom[13131];
Manipulate[BlockRandom[SeedRandom[r];ListLinePlot[RandomFunction[WienerProcess[μ,σ],{0,T,0.01}],ImageSize->{350,300},PlotRange->{-5,5},PlotTheme->"Detailed",PlotLabel->"Wiener process\n"]],
Style["Time horizon",Bold],
{{T,1},1,10,1/250.,Appearance->"Labeled",ImageSize->Tiny},
Style["Drift",Bold],
{{μ,0},-1,1,0.1,Appearance->"Labeled",ImageSize->Tiny},
Style["Diffusion",Bold],
{{σ,1},0.001,2,0.1,Appearance->"Labeled",ImageSize->Tiny},
Delimiter,
{{r,0,""},Button["randomize",r=RandomInteger[2^64-1]]&},
SaveDefinitions->True,ControlPlacement->Left]

Geometric Brownian Motion Process

Clear[μ,σ,S,s,t];
characteristicsofstochasticprocess[GeometricBrownianMotionProcess[μ,σ,S],s,t]

SeedRandom[13131];ListLinePlot[RandomFunction[GeometricBrownianMotionProcess[μ,σ,s0]/.{μ->1,σ->0.05,s0->100},{0,1,0.01}],ImageSize->{350,300}]

SeedRandom[13131];
Manipulate[BlockRandom[SeedRandom[r];ListLinePlot[RandomFunction[GeometricBrownianMotionProcess[μ,σ,s0],{0,T,0.01}],ImageSize->{350,300},PlotRange->{-5,300},PlotTheme->"Detailed",PlotLabel->"Geometric Brownian Motion\n"]],
Style["Time horizon",Bold],
{{T,1},1,10,1/250.,Appearance->"Labeled",ImageSize->Tiny},
Style["Drift",Bold],
{{μ,0},-1,1,0.1,Appearance->"Labeled",ImageSize->Tiny},
Style["Diffusion",Bold],
{{σ,1},0.001,2,0.1,Appearance->"Labeled",ImageSize->Tiny},
Delimiter,
Style["Initial value (Subscript[S, 0])",Bold],
{{s0,100},10,150,10,Appearance->"Labeled",ImageSize->Tiny},
{{r,0,""},Button["randomize",r=RandomInteger[2^64-1]]&},
SaveDefinitions->True,ControlPlacement->Left]

Fractional Brownian Motion

Clear[μ,σ,s,t,h];
characteristicsofstochasticprocess[FractionalBrownianMotionProcess[μ,σ,h],s,t]

SeedRandom[13131];
Manipulate[BlockRandom[SeedRandom[r];ListLinePlot[RandomFunction[FractionalBrownianMotionProcess[μ,σ,h],{0,T,0.01}],ImageSize->{350,300},PlotRange->{-5,5},PlotTheme->"Detailed",PlotLabel->"Fractional Brownian Motion Process\n"]],
Style["Time horizon",Bold],
{{T,1},1,10,1/250.,Appearance->"Labeled",ImageSize->Tiny},
Style["Drift",Bold],
{{μ,0},-1,1,0.1,Appearance->"Labeled",ImageSize->Tiny},
Style["Diffusion",Bold],
{{σ,1},0.001,2,0.1,Appearance->"Labeled",ImageSize->Tiny},
Style["Hurst coefficient",Bold],
{{h,0.5},0.05,.95,0.1,Appearance->"Labeled",ImageSize->Tiny},
Delimiter,
{{r,0,""},Button["randomize",r=RandomInteger[2^64-1]]&},
SaveDefinitions->True,ControlPlacement->Left]

Jump Diffusion Processes, Illustration of CLT, 3σ Rule

Poisson Process

Let {N(t),t≥0} be a homogeneous Poisson process with intensity λ, i. e., a stochastic process with independent increments, N(0)=) w. p. 1, and N(t)-N(s)\[Distributed]Poisson(λ|t-s|). The trajectories are nondecreasing with jumps of magnitude 1.

Clear[λ,s,t];
characteristicsofstochasticprocess[PoissonProcess[λ],s,t]

SeedRandom[13131];
Manipulate[BlockRandom[SeedRandom[r];ListLinePlot[RandomFunction[PoissonProcess[λ],{0,T,0.01}],ImageSize->{350,300},PlotRange->{0,2 λ T},PlotTheme->"Detailed",PlotStyle->Thick,PlotLabel->"Poisson Process\n",InterpolationOrder->0]],
Style["Time horizon",Bold],
{{T,1},1,10,1/250.,Appearance->"Labeled",ImageSize->Tiny},
Style["Intensity λ",Bold],
{{λ,20},1,100,10,Appearance->"Labeled",ImageSize->Tiny},
Delimiter,
{{r,0,""},Button["randomize",r=RandomInteger[2^64-1]]&},
SaveDefinitions->True,ControlPlacement->Left]

Compound Poisson Process

Let {N(t),t≥0} be a homogeneous Poisson process with intensity λ, independent of iid (Subscript[Z, 1]),(Subscript[Z, 2]),... . Then

({{{({{X(t):=(∑_(i=1)^(N(t)))(Subscript[Z, i])}}), t≥0}}})

is a compound Poisson process. Note that (Subscript[Z, i])'s may be of arbitrary sign.

Built-in function:CompoundPoissonProcess[λ, distribution of jumps]

Example

Clear[λ,μ,ν,s,t];
characteristicsofstochasticprocess[CompoundPoissonProcess[λ,ExponentialDistribution[ν]],s,t]

SeedRandom[13131];
Manipulate[BlockRandom[SeedRandom[r];ListLinePlot[RandomFunction[CompoundPoissonProcess[λ,ExponentialDistribution[ν]],{0,T,0.01}],ImageSize->{350,300},PlotRange->{0,100 λ T},PlotTheme->"Detailed",PlotStyle->Thick,PlotLabel->"Compound Poisson Process\n",InterpolationOrder->0]],
Style["time horizon",Bold],
{{T,1},1,10,1/250.,Appearance->"Labeled",ImageSize->Tiny},
Style["jumps",Bold],
{{ν,0.01},0.01,0.2,0.01,Appearance->"Labeled",ImageSize->Tiny},
Style["rate parameter λ",Bold],
{{λ,20},10,100,10,Appearance->"Labeled",ImageSize->Tiny},
Delimiter,
{{r,0,""},Button["randomize",r=RandomInteger[2^64-1]]&},
SaveDefinitions->True,ControlPlacement->Left]

Insurance Example (see Mathematica Help)

Jumps follow iid Pareto type II distribution with the density function

PDF[ParetoDistribution[k,α,μ],x]//TraditionalForm

For α>2

Text@Row@{"Mean:   ", Mean[ParetoDistribution[k,α,μ]][[1,1,1]]//TraditionalForm,Spacer[20],"Variance:    ",Variance[ParetoDistribution[k,α,μ]][[1,1,1]]//TraditionalForm}

Aggregate claims from a risk follow a compound Poisson process with Poisson parameter 200. The claim amount distribution is a Pareto distribution with minimum value parameter 300,shape parameter 3,and location parameter 0. The insurer has effected excess of loss reinsurance with retention level 300. Simulate the claims process for four years:

The mean of the corresponding Pareto distribution is

Mean[TransformedDistribution[Max[0,x-300], x\[Distributed]ParetoDistribution[300,3,0.]]]

and the standard deviation

StandardDeviation[TransformedDistribution[Max[0,x-300], x\[Distributed]ParetoDistribution[300,3,0.]]]

claimsProcess=CompoundPoissonProcess[200, TransformedDistribution[Max[0,x-300], x\[Distributed]ParetoDistribution[300,3,0]]];

characteristicsofstochasticprocess[claimsProcess,s,t]

SeedRandom[13131];
Manipulate[ListLinePlot[RandomFunction[claimsProcess,{0,4},n],InterpolationOrder->0,PlotStyle->Thick,PlotTheme->"Detailed"],
Style["Number of trajectories",Bold],
{{n,8},2,100,2,Appearance->"Labeled",ImageSize->Tiny},
SaveDefinitions->True,ControlPlacement->Left]

Slice distributions for the first four years:

Histogram[Table[RandomVariate[TruncatedDistribution[{0,50000},claimsProcess[t]],5 10^3],{t,4}],150,"PDF",ChartLegends->(StringJoin["t = ",ToString[#]]&/@Range[4])]

Mean and standard deviation of the reinsurer’s aggregate claims for the first four years:

Table[Mean[claimsProcess[t]], {t,4}]

Table[StandardDeviation[claimsProcess[t]], {t,4}]//N

Illustration of the Central Limit Theorem

Define a random number generator (n=12 in practise)

Clear[generator];
generator[n_]:=Module[{i},((∑_(i=1)^n)RandomVariate[UniformDistribution[{0,1}]]-n/2)/(Sqrt[n/12])]

Functional programming approach, results are the same but this generator is much more faster:

Clear[generator2];
generator2[n_?(IntegerQ[#]&&Positive[#]&)]:=(Total[RandomReal[{0,1},n]]-n/2)/(Sqrt[n/12])

Illustration

SeedRandom[13131];
{generator[12],generator[12],generator[12]}
SeedRandom[13131];
{generator2[12],generator2[12],generator2[12]}

SeedRandom[13131];
tab10000=Table[generator2[12],{10000}];//Timing
Show[{Plot[PDF[NormalDistribution[],x],{x,-4,4},PlotStyle->Thick],Histogram[tab10000,100,"PDF"]}]
Text@Row@{"p-value:   ",DistributionFitTest[tab10000]}

{Mean[tab10000],StandardDeviation[tab10000],Skewness[tab10000],Kurtosis[tab10000]}

More generally for more samples (numberOfSamples) of the same size (sizeOfSample) . Implicitely, random seed is set to 13131.

tableOfpValues[sizeOfSample_,numberOfSamples_,seedrandom_:13131]:=(SeedRandom[seedrandom];Map[DistributionFitTest,Table[Table[generator2[12],{sizeOfSample}],{numberOfSamples}]])

(* 10 samples of size 10000 *)
tableOfpValues[10000,10]

(* 100 samples of size 10000 *)
pValues100=tableOfpValues[10000,100]

Histogram[pValues100,10]
Text@Row@{"Minimum of p-values:  ",Min[pValues100],Spacer[20],"Maximum of p-values:   ",Max[pValues100]}
(* Number of p-values ≤ 0.05 and ≥0.95 *)
Text@Row@{"Out of ",Length[pValues100],"  p-values ",Count[pValues100,_?(#≤0.05&)]," are less or equal 0.05 and ",Count[pValues100,_?(#≥0.95&)],"  p-values are greater or equal 0.95."}

pos=Position[pValues100,0.00008228157715383714`]

3σ Rule and 2σ Rule

Probability[Abs[X-μ]<3σ,X\[Distributed]NormalDistribution[μ,σ]]//N

Probability[Abs[X-μ]<2σ,X\[Distributed]NormalDistribution[μ,σ]]//N

Compound Poisson Process with drift

Let {N(t),t≥0} be a homogeneous Poisson process with intensity λ, independent of iid (Subscript[Z, 1]),(Subscript[Z, 2]),... . Then

({{{({{X(t):=(∑_(i=1)^(N(t)))(Subscript[Z, i])}}), t≥0}}})

is a compound Poisson process and

({{Y(t)=(Subscript[y, 0])+c t+X(t)}})

is a compound Poisson process with drift c, (Subscript[y, 0]) an initial value.

Example

Clear[c,λ,x,μ,s,t];
CompoundPoissonProcessWithDrift[c_,λ_,μ_,y0_]:=TransformedProcess[y0+c t+x[t],x\[Distributed]CompoundPoissonProcess[λ,ExponentialDistribution[μ]],t]

characteristicsofstochasticprocess[CompoundPoissonProcessWithDrift[c,λ,μ,y0],s,t]

Skewness and kurtosis:

{Skewness[CompoundPoissonProcessWithDrift[c,λ,μ,y0][t]],Kurtosis[CompoundPoissonProcessWithDrift[c,λ,μ,y0][t]]}//FullSimplify[#,Assumptions->μ>0∧λ>0∧t>0]&

Jump Diffusion Processes

Gauss-Poisson Process

({{Y(t)=W(t)+N(t)}})

where {W(t),t>0} is a standard Wiener process and {N(t),t≥0} is a homogeneous Poisson process, W and N independent.

Slice distribution:

({{({{P(Y(t)≤x)=(∑_(k=1)^∞)P(Y(t)≤x,N(t)=k)=}})(∑_(k=1)^∞)P(W(t)≤x-k,N(t)=k)=}, {(∑_(k=1)^∞)P(W(t)≤x-k)P(N(t)=k)=(∑_(k=1)^∞)(e^(-λt))((((λt))^k)/(k!))Φ(x-k)}})

Gauss-Compound-Poisson Jump Process with Drift

({{Y(t)=(Subscript[y, 0])+μ t+σ W(t)+X(t)}})

where {W(t),t≥0} is a standard Wiener process, {X(t),t≥0} a compound Poisson process, (Subscript[Z, 1]),(Subscript[Z, 2]),... iid independent of {N(t),t≥0}, W and X independent. Recall that (Subscript[Z, i])'s may be of arbitrary sign.

Example

Clear[λ,y0,μ,σ,s,t];
GaussCompoundPoissonProcessWithDrift[λ_,μ_,σ_,ν_,y0_]:=TransformedProcess[y0+μ t+σ w[t]+x[t],{w\[Distributed]WienerProcess[],x\[Distributed]CompoundPoissonProcess[λ,ExponentialDistribution[ν]]},t]

characteristicsofstochasticprocess[GaussCompoundPoissonProcessWithDrift[λ,μ,σ,ν,y0],s,t]

SeedRandom[13131];
Manipulate[BlockRandom[SeedRandom[r];ListLinePlot[RandomFunction[GaussCompoundPoissonProcessWithDrift[λ,μ,σ,ν,y0],{0,T,0.01}],ImageSize->{350,300},PlotRange->All(*{-10 λ T,100 λ T}*),PlotTheme->"Detailed",PlotStyle->Thick,PlotLabel->"Gauss Compound Poisson Process\n",InterpolationOrder->0]],
Style["time horizon",Bold],
{{T,1},1,10,1/250.,Appearance->"Labeled",ImageSize->Tiny},
Style["drift",Bold],
{{μ,2},0.1,100,0.1,Appearance->"Labeled",ImageSize->Tiny},
Style["volatility",Bold],
{{σ,50},0.1,300,0.1,Appearance->"Labeled",ImageSize->Tiny},
Style["jumps",Bold],
{{ν,0.01},0.01,0.2,0.01,Appearance->"Labeled",ImageSize->Tiny},
Style["rate parameter λ",Bold],
{{λ,20},1,100,10,Appearance->"Labeled",ImageSize->Tiny},
Style["initial value",Bold],
{{y0,10},1,200,1,Appearance->"Labeled",ImageSize->Tiny},
Delimiter,
{{r,0,""},Button["randomize",r=RandomInteger[2^64-1]]&},
SaveDefinitions->True,ControlPlacement->Left]

Lekce 10 (11. 12. 2014)

Short-rate models, lognormals positive, calibration

Ornstein-Uhlenbeck Process, Vasicek Model

The state X(t) of a Ornstein–Uhlenbeck process satisfies an Ito differential equation

dX(t)==θ (μ-X(t))dt +σ dW(t),

with long-term mean μ, volatility σ, and mean reversion speed θ. Part μ-X(t) is the mean reverting drift pulled to a level μ at rate θ. Here θ>0, σ>0, μ∈ℝ. A drawback of the solution is that X(t) may attain negative values.

Oldrich Alfons Vasicek (1977): spot rate r(t), α>0

dr=α(γ-r)dt+ρdz

In contrast to the random walk (the Wiener process), which is an unstable process
and after a long time will diverge to infinite values, the Ornstein-Uhlenbeck
process possesses a stationary distribution. The instantaneous drift α(γ-r)
represents a force that keeps pulling the process towards its long-term mean γ
with magnitude proportional to the deviation of the process from the mean.
The stochastic element, which has a constant instantaneous variance (ρ^2), causes
the process to fluctuate around the level γ in an erratic, but continuous, fashion.
The conditional expectation and variance level are ...

Clear[μ,σ,s,t,θ,r0(* initial value of arbitrary sign *)];
characteristicsofstochasticprocess[OrnsteinUhlenbeckProcess[μ,σ,θ,r0],s,t]

SeedRandom[13131];
Manipulate[BlockRandom[SeedRandom[r];ListLinePlot[RandomFunction[OrnsteinUhlenbeckProcess[μ,σ,θ,r0],{0,T,0.01}],ImageSize->{350,300},PlotRange->{-5,5},PlotTheme->"Detailed",PlotLabel->"Ornstein Uhlenbeck Process\n"]],
Style["Time horizon",Bold],
{{T,1},1,10,1/250.,Appearance->"Labeled",ImageSize->Tiny},
Style["Drift",Bold],
{{μ,0.04},0.01,0.11,0.01,Appearance->"Labeled",ImageSize->Tiny},
Style["Diffusion",Bold],
{{σ,1},0.01,2,0.01,Appearance->"Labeled",ImageSize->Tiny},
Style["Rate θ",Bold],
{{θ,0.2},0.05,0.5,0.05,Appearance->"Labeled",ImageSize->Tiny},
Delimiter,
Style["Initial value (Subscript[r, 0])",Bold],
{{r0,0.02},0.01,0.3,0.001,Appearance->"Labeled",ImageSize->Tiny},
{{r,0,""},Button["randomize",r=RandomInteger[2^64-1]]&},
SaveDefinitions->True,ControlPlacement->Left]

Cox-Ingersoll-Ross Process (CIR)

CoxIngersollRossProcess

The state X(t) of a Cox-Ingersoll-Ross process (CIR) satisfies an Ito differential equation

dX(t)==θ (μ-X(t))dt+σ (Sqrt[X(t)]) dW(t),

with long-term mean μ, volatility σ, speed of adjustment θ, and (possible) initial condition (Subscript[x, 0])>0. Here σ>0, θ μ>0, usually μ>0. The last condition means that both θ and μ must be nonzero and of the same sign. As compared with the Ornstein-Uhlenbeck, CIR can never attain negative values. It can be shown that X(t)>0 a. s. if (σ^2)≤2θ,μ.

Clear[μ,σ,s,t,θ,r0(* initial value positive *)];
characteristicsofstochasticprocess[CoxIngersollRossProcess[μ,σ,θ,r0],s,t]

Limit of the variance:

Limit[(((σ^2) (E^(-2 θ t)) ((E^(θ t))-1) (2 r0+μ ((E^(θ t))-1)))/(2 θ)),t->∞,Assumptions->θ>0&&r0>0&&μ>0]

Skewness and kurtosis:

Text@Row@{"The limits of skewness:  ",Limit[(((Sqrt[2]) (3 r0+μ ((E^(θ t))-1)))/((2 r0+μ ((E^(θ t))-1)) (Sqrt[((θ (μ+((2 r0)/((E^(θ t))-1))))/(σ^2))]))),t->∞,Assumptions->θ>0&&r0>0&&μ>0]//TraditionalForm,Spacer[20],"and kurtosis:   ",Limit[((3 (σ^2) (1-((4 (r0^2))/(((2 r0+μ ((E^(θ t))-1)))^2))))/(θ μ))+3,t->∞,Assumptions->θ>0&&r0>0&&μ>0]}

SeedRandom[13131];
Manipulate[BlockRandom[SeedRandom[r];ListLinePlot[RandomFunction[CoxIngersollRossProcess[μ,σ,θ,r0],{0,T,0.01}],ImageSize->{350,300},PlotRange->{-0.05,0.05},PlotTheme->"Detailed",PlotLabel->"Cox Ingersoll Ross Process\n"]],
Style["Time horizon",Bold],
{{T,1},1,10,1/250.,Appearance->"Labeled",ImageSize->Tiny},
Style["Drift",Bold],
{{μ,0.06},0.01,0.11,0.01,Appearance->"Labeled",ImageSize->Tiny},
Style["Diffusion",Bold],
{{σ,0.05},0.01,1,0.01,Appearance->"Labeled",ImageSize->Tiny},
Style["Rate θ",Bold],
{{θ,0.15},0.05,0.5,0.05,Appearance->"Labeled",ImageSize->Tiny},
Delimiter,
Style["Initial value (Subscript[r, 0])",Bold],
{{r0,0.02},0.01,0.1,0.001,Appearance->"Labeled",ImageSize->Tiny},
{{r,0,""},Button["randomize",r=RandomInteger[2^64-1]]&},
SaveDefinitions->True,ControlPlacement->Left]

Ito process 1

ItoProcess

dX(t)==a(X(t),t)dt+b(X(t),t).dW(t)

is represented as ItoProcess[{a,b},x,t]]. It may be multidimensional.

Alternatively, it may be defined by a stochastic differential equation (SDE): ItoProcess[SDEquations, expr, x,t,w\[Distributed]dproc]  represents an Ito process specified by a stochastic differential equation(s) sdeqns, output expression expr, with state x and time t, driven by w following the stochastic process dproc.

Row@{Hyperlink[Button["Ito Process"],"paclet:ref/ItoProcess"],Spacer[20],Hyperlink[Button["Stochastic Differential Equation Processes"],"paclet:guide/StochasticDifferentialEquationProcesses"],Spacer[20],Hyperlink[Button["Heston Model"],"paclet:example/HestonModel"]}

Built-in functions ending with “Process”:

?*Process

?*PoissonProcess

Example 1

example1ItoProcess=ItoProcess[\[DifferentialD]x[t]==-x[t]\[DifferentialD]t+(Sqrt[1+x[t]^2])\[DifferentialD]w[t],x[t],{x,1},t,w\[Distributed]WienerProcess[]]

characteristicsofstochasticprocess[example1ItoProcess,s,t]

SeedRandom[131311];
ListLinePlot[Table[RandomFunction[example1ItoProcess,{0.,5.,0.01}],{5}],PlotStyle->Thick,PlotTheme->"Detailed",PlotRange->All]

example1SliceDistribution=SliceDistribution[example1ItoProcess,t]

Mean[example1SliceDistribution]

CovarianceFunction[example1ItoProcess,s,t]

Plot3D[CovarianceFunction[example1ItoProcess,s,t]//Evaluate,{s,0,5},{t,0,5},ColorFunction->"Rainbow"]

SDE: deterministic solutions via DSolve

See: S. M. Iacus (University of Milan), Chicago, R/Finance 2011, April 29th

Statistical data analysis of financial time series and option pricing in R

Geometric Brownian motion

gBm

DSolve[{x'[t]==μ x[t],x[0]==x0},x[t],t]

Cox-Ingersoll-Ross (CIR)

Clear[y];
y[t_,θ1_,θ2_,x0_]=x[t]/.DSolve[{x'[t]==(θ1+θ2 x[t]),x[0]==x0},x[t],t]//FullSimplify//First

y[t,(Subscript[θ, 1]),(Subscript[θ, 2]),1]

Manipulate[Plot[(y[t,(Subscript[θ, 1]),(Subscript[θ, 2]),1])//Evaluate,{t,0,10},PlotStyle->Thick],{(Subscript[θ, 1]),0.1,10},{(Subscript[θ, 2]),0.1,10},SaveDefinitions->True]

Chan-Karolyi-Longstaff-Sanders (CKLS)

The same as CIR, the difference is only in the stochastic term.

Nonlinear mean reversion (Aït-Sahalia)

DSolve[{x'[t]==((Subscript[α, -1])/(x[t]))+(Subscript[α, 0])+(Subscript[α, 1])x[t]+(Subscript[α, 2])((x[t])^2),x[0]==x0},x[t],t]//ToRadicals

Double Well potential (bimodal behaviour, highly nonlinear)

DSolve[{x'[t]==(x[t]-((x[t])^3)),x[0]==x0},x[t],t]

Test

D[-((E^t)/(Sqrt[-1+(E^(2 t))+(1/(x0^2))])),t]==-((E^t)/(Sqrt[-1+(E^(2 t))+(1/(x0^2))]))-(((-((E^t)/(Sqrt[-1+(E^(2 t))+(1/(x0^2))]))))^3)

Jacobi diffusion (political polarization)

DSolve[{x'[t]==-θ(x[t]-(1/2)),x[0]==x0},x[t],t]//FullSimplify

Ohrenstein-Uhlenbeck (OU)

It differs from gBm only in the stochastic term.

Radical Ohrenstein-Uhlenbeck

DSolve[{x'[t]==(θ/(x[t]))-x[t],x[0]==x0},x[t],t]//FullSimplify

Hyperbolic diffusion (dynamics of sand)

DSolve[{x'[t]==(θ/(x[t]))-x[t],x[0]==x0},x[t],t]//FullSimplify

Ito process 2

Example 2

μ,σ,θ,r0

example2ItoProcess[μ_,σ_,θ_,r0_]:=ItoProcess[\[DifferentialD]x[t]==θ(μ-x[t])\[DifferentialD]t+σ(Sqrt[x[t]])\[DifferentialD]w[t],x[t],{x,x0},t,w\[Distributed]WienerProcess[]]

Exercise. What is the name of this process?

example2SliceDistribution=SliceDistribution[example2ItoProcess[μ,σ,θ,r0],t]

Mean[example2SliceDistribution]

characteristicsofstochasticprocess[example2ItoProcess[μ,σ,θ,r0],s,t]

Ho-Lee model

({{({{dX(t)=θ(t)dt+σdW(t)}})}})

Hull-White model

({{({{dX(t)=(θ(t)-α(t)X(t))dt+σ(t)(X^β)(t)dW(t)}})}})

The mean reversion level is given by θ(t)/α(t). For Vasicek model β=0, other parameters constant. For CIR, β=1/2.

Black-Karasinski model

({{({{d log,X(t)=(θ(t)-α(t) log,X(t))dt+σ(t)dW(t)}})}})

In practise often α(t) and σ(t) are supposed to be constant so that the model reads:

({{({{d log,X(t)=(θ(t)-α)dt+σdW(t)}})}})

Black-Derman-Toy model

({{({{d log,X(t)=(θ(t)-α(t) log,X(t))dt+σ(t)dW(t)}})}})

is a special case of Black-Karasinski where α(t)=σ'(t)/σ(t).

Bond value under the deterministic interest rate

B(t) ... price of a bond at time t≤T, T ... maturity date of the bond, k(t) ... coupon rate, face value F supposed F=1 so that B(T)=1, r(t) ... the deterministic riskless rate. It means that the change in value of the bond in time interval (t,t+Δ,t) is approximately

({{({{((d,B)/(d,t))Δ,t}})}})

the coupon recieved is k(t)Δ,t, and by no-arbitrage principle says that the sum of the above amounts must be the riskless interest return r(t)B(t)Δ,t. Thus

({{({{((d,B)/(d,t))+k(t)=r(t)B(t).}})}})

A solution

sol=DSolve[{B'[t]+k[t]==r[t] B[t],B[T]==1},B[t],t]
sol/.{K[1]->τ,K[2]->s}//FullSimplify

cf. Kwok (2), p.315:

({{({{B(t)=exp{-(∫_t^T)r(s)ds} [F+(∫_t^T)k(τ) exp{(∫_τ^T)r(s)ds}dτ]}})}})

For zero coupon bonds

sol0=DSolve[{B'[t]==r[t] B[t],B[T]==1},B[t],t]
sol0/.K[1]->s

Term structure of interest rates 
(Časová struktura úrokových měr)

Dekompozice úrokové míry

1+r=(1+(Subscript[r, 0]))(1+(Subscript[r, infl])) (1+(Subscript[r, default]))  (1+(Subscript[r, liquid])) (1+(Subscript[r, mat]))

r ... nominalni, kotovana urokova mira v zobecnenem slova smyslu

Zde (Subscript[r, 0]) označuje bezrizikou, riskless, riskfree ůrokovou míru bez vlivu inﬂace (složka závislá na ekonomických podmínkách vnitřních i mezinárodních, časové preferenci spotřeby), (Subscript[r, inﬂ]) (prémie za inﬂaci, inﬂation premium) je očekávaná míra inﬂace, (Subscript[r, default]) (prémie za riziko nesplacení, kreditní riziko, default, credit risk) je přirážka, která zohledňuje situaci, kdy dlužník nebude schopen dostát svým závazkům, splatit jistinu či úrok nebo obojí, úplně či částečně, úmyslně či neúmyslně. Člen (Subscript[r, liquid]) (prémie za likviditu, liquidity premium) zohledňuje riziko pramenící ze ztížené možnosti dané aktivum rychle a bez podstatných ztrát proměnit na hotovost. Konečně (Subscript[r, mat]) (prémie za riziko v okamžiku splatnosti, riziko z vypršení, maturity risk premium) je prémie za riziko vzniklé případnými změnami sazeb během období trvání kontraktu, jinak řečeno životností aktiva. V podstatě vzniká tento typ rizika ze dvou příčin: první spočívá ve změnách úrokové míry (riziko úrokové míry, interest rate risk) během trvání obchodovatelného kontraktu, druhá pak v možné bezmocnosti investora, co dělat s utrženými penězi: v okamžiku splatnosti se totiž investiční příležitosti (měřené mírou výnosnosti) mohou diametrálně lišit od představ investora investujícího před řadou let. Toto riziko se nazývá reinvestiční riziko, reinvestment rate risk. V případě dlouhodobých dluhopisů jde skutečně o riziko změny úrokové míry: jestliže tržní úrokové míry rostou, ceny dluhopisů klesají. U krátkodobých dluhopisů vzniká již zmíněný problém reinvestice: když jsou v okamžiku splatnosti dluhopisu úrokové míry nízké, vyústí věřiteli (tj. emitentovi dluhopisu) splacená částka v úrokovou ztrátu.

(Subscript[r, nominalni])==(1+(Subscript[r, 0]))(1+(Subscript[r, infl])) (1+(Subscript[r, default]))  (1+(Subscript[r, liquid])) (1+(Subscript[r, mat]))-1

Rating

Bezriziková ú. m. (Subscript[r, 0infl]) se zahrnutím inflace:

(1+(Subscript[r, 0infl]))=(1+(Subscript[r, 0]))(1+(Subscript[r, infl]))

Příklad (výpočet (Subscript[r, default]))

Společnosti s ratingem AAA, AA, A v roce 1984 a v roce 1991

(* v procentním vyjádření *)Solve[1+(r/100)==(1+(r0infl/100))(1+(rdefault/100)),rdefault]

{{" ","(Subscript[r, 1991])","\!\(\*SubscriptBox[\(r\), \(default\\ 1991\)]\)","(Subscript[r, 1984])","\!\(\*SubscriptBox[\(r\), \(default\\ 1984\)]\)"},
{"T-bonds",8,0,12.34,0},
{"AAA",8.9,((100 (r-r0infl))/(100+r0infl))/.{r->8.9,r0infl->8},12.50,((100 (r-r0infl))/(100+r0infl))/.{r->12.50,r0infl->12.34}},
{"AA",9.1,((100 (r-r0infl))/(100+r0infl))/.{r->9.1,r0infl->8},12.70,((100 (r-r0infl))/(100+r0infl))/.{r->12.50,r0infl->12.34}},{"A",9.4,((100 (r-r0infl))/(100+r0infl))/.{r->9.4,r0infl->8},13.41,((100 (r-r0infl))/(100+r0infl))/.{r->13.41,r0infl->12.34}}}//TableForm

Příklad (Matice pravděpodobností přechodu)

Credit Rating Transition Probabilities

Kreditní třídy (v terminologii markovských řetězců stavy řetězce): AAA, AA, A, BBB, BB, B, CCC, D (klasifikace podle Standard & Poor’s). AAA jsou firmy s nejvyšší kredibilitou, D jsou zkrachovalé firmy.

Matice pravděpodobností přechodu mezi kreditními křídami je čtvercová matice P=((Subscript[p, i,j])), i,j= AAA, AA, A, BBB, BB, B, CCC, D. Jestliže v čase t je firma ve třídě i, pak (Subscript[p, i,j]) je pravděpodobnost, že v čase t+1 se ocitne ve třídě j. Čas se v drtivé většině případů uvádí v rocích. Ve finanční literatuře se obvykle poslední řádek vynechává, neboť je vždy ve tvaru (0,0,...,0,1). Třída D je pohlcující: firma, která do ní spadne se z ní nemůže dostat.

Jestliže pravděpodobnosti přechodu zůstávají v čase konstantní (tzv. homogenní markovský řetězec), pak matice pravděpodobností přechodu z času t do času t+n je n-tá mocnina (P^((n)))=(P^n).

Dimitrios Kavvathas 
Goldman Sachs Group, Inc.
Estimating Credit Rating Transition Probabilities for Corporate Bonds,
AFA 2001 New Orleans Meetings 
http://web.sakarya.edu.tr/~adurmus/basel_II/SSRN-id252517 %20 rating.pdf

Odpovídající matice

(transitionmatrix={{0.9446`,0.0477`,0.006`,0.001`,0.0007,0.0001`,0.`,0.`},{0.0049`,0.9179`,0.0694`,0.0059`,0.0007,0.0009`,0.0002`,0.0001`},{0.001`,0.0187`,0.9198999999999999`,0.052199999999999996`,0.0055000000000000005`,0.0025`,0.0001`,0.0001`},{0.0004`,0.0032`,0.0547`,0.8819`,0.0496`,0.0083`,0.0007,0.0011`},{0.0004`,0.0014,0.0084`,0.0675`,0.8388`,0.0713`,0.0072`,0.005`},{0.0001`,0.0007,0.0027`,0.006`,0.0562`,0.8479,0.0481`,0.0384`},{0.0012`,0.0001`,0.0051`,0.0046`,0.017`,0.0891`,0.5401`,0.3428`},{0.`,0.`,0.`,0.`,0.`,0.`,0.`,1.`}})//MatrixForm

Matice přechodu po 3 letech

Map[PaddedForm[#,{4,4}]&,MatrixPower[transitionmatrix,3],{2}]//MatrixForm

Matice přechodu po 5 letech

Map[PaddedForm[#,{4,4}]&,MatrixPower[transitionmatrix,5],{2}]//MatrixForm

MatrixPower[transitionmatrix,5]//MatrixForm

Lekce 12 (18. 12. 2014)

Časová struktura úrokových měr

Časova struktura urokovych měr, term structure of interest rates osvětluje vztahy mezi
vynosy srovnatelnych investic pro lišici se doby do splatnosti (trvani investice). Take se
hovoři o investicich stejne kvality. Většinou je prezentovana pro dluhopisy, ale můžeme
ji užit prakticky pro libovolne investice. Srovnatelnosti myslime to, že uvažujeme např.
množinu všech dluhopisů s různou dobou splatnosti v kategorii (s ratingem) AAA. Časova
struktura se v čase měni, a proto si musime uvědomit, že se vždy vztahuje k určitemu
časovemu okamžiku.

Mluvi se take o časove struktuře urokovych měr vnořenych do času t, zde pro jednoduchost t=0 .

(Subscript[R, t]) okamžité,  (Subscript[f, t]) forwardové úrokové míry

(((1+(Subscript[R, t])))^t)=(∏_(j=1)^t)(1+(Subscript[f, j])),  t=1,...,T

Výnosové křivky (Yield Curves, YC)

YC ...  závislost úrokové míry na době splatnosti: r=r(t), graf této závislosti

Výnosová křivka, yield curve, Y,C je graf urokovych měr v zavislosti na době do splat-
nosti, obecněji nastroj pro zkoumani struktury urokovych měr v zavislosti na době do
splatnosti. Proto se i v teto souvislosti mluvi o časove struktuře urokovych měr. Obvykle
se použiva pro cenne papiry s urokovym vynosem, jako jsou dluhopisy nebo na obligace
s nulovym kuponem (zero-coupon bonds). Vynosove křivky je však možne použit na li-
bovolne investice. Smysl ma analyzovat pouze srovnatelne investice. Vynosova křivka
statnich pokladničnich poukazek (T-bills) s dobami do splatnosti 1, 3, 6, 9, 12 měsiců
bude mit ve stejnem čase (dejme tomu pro rok 2011) jiny tvar než křivka sestrojena z
vynosů firemnich dluhopisů společnosti s ratingem AA se stejnymi dobami splatnosti,
symbolicky Y,(Subscript[C, T-bills,2011])≠Y,(Subscript[C, AA,2011]). Měli bychom tež brat v uvahu rizikove faktory (viz
dekompozice urokovych měr) a srovnatelne daňove podminky.
Avšak i pro stejny typ investic se tvar vynosove křivky měni v čase. V roce 2009 bude
mit vynosova křivka jiny tvar než v roce 2010 pro stejny typ investice za jinak nezměně-
nych podminek, symbolicky Y,(Subscript[C, AA,2011])≠Y,(Subscript[C, AA,2010]). Tuto odlišnost je možne vysvětlit
řadou faktorů jako je změna bezrizikove urokove miry, inflaci, očekavanimi a ostatnimi
exogennimi faktory. Dalšim podstatnym faktorem je potřeba emitentů po kratkodobych,
střednědobych a dlouhodobych zdrojich.

(Subscript[R, t])-(Subscript[R, 1]) ... výnosové rozpětí, yield spread

Příklad (Porovnání výnosových křivek v různých časech, Treasury YC USA)

December 15, 2014:

January 5, 2015:

https://www.imf.org/external/pubs/ft/wp/2010/wp10258.pdf

Příklad (Oldřich Alfons Vasicek, EWGFM Oct 2010 Prague)

Na eficientním trhu nemůže být výnosová křivka konstantní. Předpokládejme, že je tomu naopak a r(t)=0.05=:r, 1≤t≤10, čas v rocích. Předpokládejme počáteční investici W=100. Můžeme si vybrat ze dvou možností:

Portfolio (investice) A: pětiletý bezkuponový dluhopis s výše uvedeným výnosem r=0.05. Odpovídající peněžní tok cfA je

cfA=Cashflow[{-100,0,0,0,0,100(((1+r))^5)}/.r->0.05]

Portfolio (investice) B: kombinace jednoročního bezkuponového dluhopisu ((Subscript[B, 1])) a desetiletého bezkuponového dluhopisu ((Subscript[B, 10])) s pětiletou průměrnou dobou splatnosti (průměrná doba splatnosti ne ve smyslu durace!). Nechť w je váha (Subscript[B, 1]) a tedy 1-w váha  (Subscript[B, 10]). w tedy musí splňovat rovnici

({{({{1,w+10(1-w)=5}})}})

w0=w/.Solve[1 w+10(1-w)==5,w]//First

Odpovídající peněžní tok cfB je tedy

Clear[cfB];cfB[w_,r_]:=Cashflow[{-100,w 100(1+r),0,0,0,0,0,0,0,0,(1-w)100(((1+r))^10)}]
cfBw0=cfB[w0,0.05]

Současné hodnoty při hodnotící úrokové míře i:

{npvA=TimeValue[cfA,i],npvBw0=TimeValue[cfBw0,i]}//Simplify

Rozdíl mezi současnou hodnotou portfolia B a současnou hodnotou portfolia A v závisloti na úrokové míře:

Plot[npvBw0-npvA,{i,0,0.1},PlotStyle->Thick,PlotTheme->"Marketing",PlotLabel->"PV(B)-PV(A)"]

Investice (portfolio) B poskytuje tedy vždy minimálně stejný výnos jako investice A. Na eficientním trhu nabídka a poptávka budou stlačovat cenu dluhopisu A dolů a cenu kombinace B nahoru.

Table[{i,npvBw0-npvA}/.i->i1,{i1,{0,0.03,0.04,0.05,0.06,0.07,0.1}}]//TableForm

***Příklad (Pokračování: Stejné durace)

Místo “durace” ve výše uvedeném příkladu použít skutečnou duraci.

Wolfram|Alpha Yield Curves

{WolframAlpha["yield curves",{{"TreasuryYieldCurve:EconomicData",1},"Input"},PodStates->{"TreasuryYieldCurve:EconomicData__More"}],WolframAlpha["yield curves",{{"TreasuryYieldCurve:EconomicData",2},"Input"},PodStates->{"TreasuryYieldCurve:EconomicData__More"}],WolframAlpha["yield curves",{{"TreasuryYieldCurve:EconomicData",3},"Input"},PodStates->{"TreasuryYieldCurve:EconomicData__More"}]}

ListLinePlot[{{1,0.02`},{3,0.04`},{6,0.11`},{12,0.22`},{24,0.6`},{36,1.03`},{60,1.58`},{84,1.9`},{120,2.12`},{240,2.45`},{360,2.74`}},PlotStyle->Thick, PlotTheme->"Detailed"]

Statistické a numerické metody konstrukce výnosových křivek

N srovnatelných aktiv (cenných papírů) 1,...,N,
pozorované, kótované výnosy (úrokové míry) (Subscript[y, 1]),...,(Subscript[y, N]) v časech (Subscript[T, 1]),...,(Subscript[T, N])

Pro účely finančního rozhodování je zapotřebí znát výnosy také v časech různých od kótovaných minimálně v intervalu [(Subscript[T, 1]),(Subscript[T, N])].

Numerický přístup (interpolace)

Intepolační funkce y=f(t) musí splňovat (Subscript[y, n])=f((Subscript[T, n])), n=1,...,N.

Příklad (v grafech pozor na počátky souřadnic)

Data ir2 jsou reálná ve tvaru {splatnost (ve dnech), okamžitá (spotová) úroková míra (v procentech)}, N=12. Jedná se o termínovaný vklad České spořitelny, sazby z února 1999.

plot2=ListPlot[ir2={{7,5.4`},{14,5.4`},{30,6.2`},{60,6.1`},{90,6.1`},{120,6.`},{150,6.`},{180,5.9`},{210,5.9`},{240,5.9`},{270,5.9`},{290,5.8`}},PlotStyle->{Red,PointSize[0.015]}]

Data ir3 jsou reálná ve tvaru {splatnost (ve dnech), okamžitá (spotová) úroková míra (v procentech)}, N=22.

plot3=ListPlot[(ir3={{7,4.74},{14,4.728},{30,4.705},{60,4.595},{90,4.53},{180,4.42},{270,4.415},{360,4.41},{730,4.51},{1095,4.68},{1460,4.85},{1825,4.99},{2190,5.09},{2555,5.19},{2920,5.27},{3285,5.33},{3650,5.38},{4015,5.42},{4380,5.46},{4745,5.49},{5110,5.51},{5475,5.54}}),PlotStyle->{Red,PointSize[0.015]}]

Nejjednodušší v řadě případů nejlepší) je lineární interpolace, tj. pospojování bodů úsečkami.

int21=Interpolation[ir2,InterpolationOrder->1];
plotint21=Plot[int21[t],{t,7,290},PlotRange->All,PlotStyle->Thick];
Show[plot2,plotint21]

int31=Interpolation[ir3,InterpolationOrder->1];
plotint31=Plot[int31[t],{t,7,10000}];
Show[plot3,plotint31]

V detailu

Katastrofální výsledky dává interpolace polynomy.

poly2=InterpolatingPolynomial[ir2,t];
poly2plot=Plot[poly2,{t,Min[First[ir2][[1]]],Max[Last[ir2][[1]]]},PlotRange->All,PlotStyle->Thick];
Show[plot2,poly2plot,PlotRange->All]

Interpolační polynom je stupně N-1, v našem případě 11:

poly2//Expand//TraditionalForm

Koeficienty polynomů nejsou malá čísla. Uvědomme si, že t∈[7,290], takže třeba (200^11)=2.048×(10^25).

poly3=InterpolatingPolynomial[ir3,t];
poly3plot=Plot[poly3,{t,Min[First[ir3][[1]]],Max[Last[ir3][[1]]]},PlotRange->All,PlotStyle->Thick];
Show[plot3,poly3plot,PlotRange->All]

Interpolační polynom je stupně 21:

poly3//Expand//TraditionalForm

Interpolace polynomy nižšího stupně, dáno volbou InterpolationOrder. Polynomy na sebe vzájemně navazují (viz pospojování bodů úsečkami, InterpolationOrder → 1):

Manipulate[intpol2=Interpolation[ir2,InterpolationOrder->order];
Show[plotpol2=Plot[intpol2[t],{t,Min[First[ir2][[1]]],Max[Last[ir2][[1]]]},PlotRange->All],plot2,PlotRange->All],
{{order,4,"order"},1,11,1,Appearance->"Labeled"},SaveDefinitions->True]

Manipulate[intpol3=Interpolation[ir3,InterpolationOrder->order];
Show[plotpol3=Plot[intpol3[t],{t,Min[First[ir3][[1]]],Max[Last[ir3][[1]]]},PlotRange->All],plot3,PlotRange->All],
{{order,4,"order"},1,21,1,Appearance->"Labeled"},SaveDefinitions->True]

Check it by fitting by the least squares method. If the degree of the polynomial is number of observed pairs minus one, the resulting function is the interpolating polynomial.

(t^(Range[Length[ir3]]-1))

Fit[ir3,(t^(Range[Length[ir3]]-1)),t]

Show[Plot[Fit[ir3,(t^(Range[Length[ir3]]-1)),t]//Evaluate,{t,0,5475},PlotRange->All],plot3]

Statistický přístup (vyrovnání, fitting): parametrický

V nejjednodušším případě hledáme funkci y=g(t) takovou, že g((Subscript[T, n])) se od (Subscript[y, n]) “příliš neliší”, např. ve smyslu součtu čtverců odchylek.

Příklad (vyrovnání kubickým polynomem)

g(t; (Subscript[β, 0]), (Subscript[β, 1]),(Subscript[β, 2]),(Subscript[β, 3]))=(Subscript[β, 0])+(Subscript[β, 1])t+(Subscript[β, 2])(t^2)+(Subscript[β, 3])(t^3)

(Subscript[β, i]) neznámé parametry

{(Subscript[β, 0]),(Subscript[β, 1]),(Subscript[β, 2]),(Subscript[β, 3])}

(cubic2fit=LinearModelFit[ir2,{t,(t^2),(t^3)},t])//Normal
Show[plot2,Plot[cubic2fit[t],{t,Min[First[ir2][[1]]],Max[Last[ir2][[1]]]}]]

(cubic3fit=LinearModelFit[ir3,{t,(t^2),(t^3)},t])//Normal
Show[plot3,Plot[cubic3fit[t],{t,Min[First[ir3][[1]]],Max[Last[ir3][[1]]]}]]

**Příklad (Bradley-Crane)

(Subscript[g, B,C])(t;α,β,γ)=α,(t^β)(e^(γ,t))

α, β, γ neznámé parametry

Transformace, která převede funkci nelineární v parametrech na funkci lineární v parametrech; pak je možné použít metod lineární regrese. V našem případě logaritmická transformace

(y^★)= log g(t;α,β,γ)=log α +β log ,t+γ,t, po reparamerizaci (α^★):=log α je

(y^★)=(α^★)+β log ,t+γ,t

(* Logaritmy kótovaných výnosů (y^★) *)
(ir2log=Map[{#//First,Log[#//Last]}&,ir2])//Transpose//TableForm
(BC2fit=NonlinearModelFit[ir2log,αstar+β Log[t]+γ t,{αstar,β,γ},t]//Normal//Exp//Simplify)
Show[plot2,Plot[BC2fit,{t,7,290},PlotStyle->Thick]]

(* Logaritmy kótovaných výnosů (y^★) *)
(ir3log=Map[{#//First,Log[#//Last]}&,ir3])//Transpose//TableForm
(BC3fit=NonlinearModelFit[ir3log,αstar+β Log[t]+γ t,{αstar,β,γ},t]//Normal//Exp//Simplify)
Show[plot3,Plot[BC3fit,{t,Min[First[ir3][[1]]],Max[Last[ir3][[1]]]},PlotStyle->Thick]]

!Příklad (Nelson-Siegel)

(Subscript[g, N,S])(t;(Subscript[β, 0]),(Subscript[β, 1]),(Subscript[β, 2]),c)= ...

Clear[nelsonsiegelspot]; (* Spot curve or zero-coupon*)
nelsonsiegelspot[b0_,b1_,b2_,c_,t_]:=b0+(((b1+b2) (1-(E^(-(t/c)))))/(t/c))-b2 (E^(-(t/c)))

The parameters have the following meaning: the function starts at level b,0+b,1 at time 0 and has asymptote at level b,0; a local extreme is determined by parameter c.

Limit[nelsonsiegelspot[b0,b1,b2,c,t],t->0]
Limit[nelsonsiegelspot[b0,b1,b2,c,t],t->∞,Assumptions->{b0>0∧b1>0∧b2>0∧c>0}]

Manipulating spot:

Manipulate[Plot[nelsonsiegelspot[b0,b1,b2,c,t],{t,0,10000},PlotRange->{{0,10000},{3,6}},AxesOrigin->{0,3},PlotStyle->{Thick}],
{{b0,5.8,"b0"},5,6,0.1,Appearance->"Labeled"},
{{b1,-1,"b1"},-2,-0.5,0.1,Appearance->"Labeled"},
{{b2,-3,"b2"},-5,-1,0.2,Appearance->"Labeled"},
{{c,400,"c"},100,1000,10,Appearance->"Labeled"},SaveDefinitions->True
]

Remember: r ... spot rate, f ...forward rate, then

R(t)=(1/t)(∫_0^t)f(τ)dτ

(the integral mean, integrální průměr)

Motivation:

({{({{log (1+(Subscript[R, t]))}}) .....}})

(* Forward curve *)
Clear[nelsonsiegelforward];
nelsonsiegelforward[b0_,b1_,b2_,c_,t_]:=b0+b1 (E^(-t/c))+b2 (t/c) (E^(-t/c))

Both spot and forward curves

Manipulate[Plot[{nelsonsiegelspot[b0,b1,b2,c,t],nelsonsiegelforward[b0,b1,b2,c,t]},{t,0,10000},PlotRange->{{0,10000},{3,6}},AxesOrigin->{0,3},PlotStyle->{{Blue,Thick},{Orange,Thick}}],
{{b0,5.8,"b0"},5,6,0.1,Appearance->"Labeled"},
{{b1,-1,"b1"},-2,-0.5,0.1,Appearance->"Labeled"},
{{b2,-3,"b2"},-5,-1,0.2,Appearance->"Labeled"},
{{c,400,"c"},100,1000,10,Appearance->"Labeled"},SaveDefinitions->True
]

Fitting Nelson-Siegel: on the graph, estimated spot is blue and estimated forward is orange.

fitnelsonsiegel2= FindFit[ir2,nelsonsiegelspot[b0,b1,b2,c,t],{b0,b1,b2,c},t]
curvenel2=nelsonsiegelspot[b0,b1,b2,c,t]/.fitnelsonsiegel2;
curvenelfc2[t_]:=nelsonsiegelspot[b0,b1,b2,c,t]/.fitnelsonsiegel2;
curvenel2forward=nelsonsiegelforward[b0,b1,b2,c,t]/.fitnelsonsiegel2;
Show[plot2,Plot[curvenel2forward,{t,7,290},PlotRange->All,PlotStyle->{Orange,Thick}],Plot[curvenel2,{t,7,290},PlotRange->All,PlotStyle->Thick],PlotRange->All]

fitnelsonsiegel3= FindFit[ir3,nelsonsiegelspot[b0,b1,b2,c,t],{b0,b1,b2,c},t]
curvenel3=nelsonsiegelspot[b0,b1,b2,c,t]/.fitnelsonsiegel3;
curvenelfc3[t_]:=nelsonsiegelspot[b0,b1,b2,c,t]/.fitnelsonsiegel3;
curvenel3forward=nelsonsiegelforward[b0,b1,b2,c,t]/.fitnelsonsiegel3;
Show[plot3,Plot[curvenel3forward,{t,0,10000},PlotRange->All,PlotStyle->{Orange,Thick}],Plot[curvenel3,{t,0,10000},PlotRange->All,PlotStyle->Thick],PlotRange->All]

!Příklad (Swensson)

Zobecňuje předchozí, obsahuje navíc dva parametry.

(Subscript[g, S,w])(t;(Subscript[β, 0]),(Subscript[β, 1]),(Subscript[β, 2]),(Subscript[β, 3]),(Subscript[c, 1]),(Subscript[c, 2]))= ...

Začneme s jednošším tvarem forwardové křivky:

Clear[swenssonforward];swenssonforward[b0_,b1_,b2_,b3_,c1_,c2_,t_]:=b0+b1 (E^(-t/c1))+b2 (t/c1) (E^(-t/c1))+b3 (t/c2)(E^(-t/c2))

Spotovou křivku dostaneme jako integrální průměr:

Clear[swenssonspot];
(swenssonspot[b0_,b1_,b2_,b3_,c1_,c2_,t_]=(1/t)(∫_0^t)swenssonforward[b0,b1,b2,b3,c1,c2,τ]\[DifferentialD]τ//Simplify)//TraditionalForm

The parameters have the following meaning: the function starts at level b,0+b,1 at time 0 and has asymptote at level b,0; a local extreme is determined by parameter c.

Limit[swenssonspot[b0,b1,b2,b3,c1,c2,t],t->0,Assumptions->{b0>0&&b1>0&&b2>0&&b3>0&&c1>0&&c2>0}]
Limit[swenssonspot[b0,b1,b2,b3,c1,c2,t],t->∞,Assumptions->{b0>0&&b1>0&&b2>0&&b3>0&&c1>0&&c2>0}]

Manipulating spot:

Manipulate[Plot[swenssonspot[b0,b1,b2,b3,c1,c2,t],{t,0,10000},PlotRange->{{0,10000},{3,6}},AxesOrigin->{0,3},PlotStyle->{Thick}],
{{b0,5.8,"b0"},5,6,0.1,Appearance->"Labeled"},
{{b1,-1,"b1"},-2,-0.5,0.1,Appearance->"Labeled"},
{{b2,-3,"b2"},-5,-1,0.2,Appearance->"Labeled"},
{{b3,-3,"b3"},-5,-1,0.2,Appearance->"Labeled"},
{{c1,200,"c1"},100,1000,10,Appearance->"Labeled"},
{{c2,5000,"c2"},100,10000,10,Appearance->"Labeled"},SaveDefinitions->True
]

Remeber: r ... spot rate, f ...forward rate, then

R(t)=(1/t)(∫_0^t)f(τ)dτ

Both spot and forward curves

Manipulate[Plot[{swenssonspot[b0,b1,b2,b3,c1,c2,t],swenssonforward[b0,b1,b2,b3,c1,c2,t]},{t,0,10000},PlotRange->{{0,10000},{3,6}},AxesOrigin->{0,3},PlotStyle->{{Blue,Thick},{Orange,Thick}}],
{{b0,5.8,"b0"},5,6,0.1,Appearance->"Labeled"},
{{b1,-1,"b1"},-2,-0.5,0.1,Appearance->"Labeled"},
{{b2,-3,"b2"},-5,-1,0.2,Appearance->"Labeled"},
{{b3,-3,"b3"},-5,-1,0.2,Appearance->"Labeled"},
{{c1,200,"c1"},100,1000,10,Appearance->"Labeled"},
{{c2,5000,"c2"},100,10000,10,Appearance->"Labeled"},SaveDefinitions->True
]

Fitting Swensson: on the graph, estimated spot is blue and estimated forward is orange.

fitswensson2= FindFit[ir2,swenssonspot[b0,b1,b2,b3,c1,c2,t],{b0,b1,b2,b3,c1,c2},t]
(curveswe2=swenssonspot[b0,b1,b2,b3,c1,c2,t]/.fitswensson2)//Simplify;
curveswefc2[t_]:=swenssonspot[b0,b1,b2,b3,c1,c2,t]/.fitswensson2
(curveswe2forward=swenssonforward[b0,b1,b2,b3,c1,c2,t]/.fitswensson2)//Simplify;
Show[plot2,Plot[curveswe2,{t,7,290},PlotRange->All,PlotStyle->Thick],Plot[curveswe2forward,{t,7,290},PlotRange->{4.5,6.6},(* ,ClippingStyle->Directive[Red,Thick]] *)PlotStyle->{Orange,Thick}],PlotRange->All]

fitswensson3= FindFit[ir3,swenssonspot[b0,b1,b2,b3,c1,c2,t],{b0,b1,b2,b3,c1,c2},t]
(curveswe3=swenssonspot[b0,b1,b2,b3,c1,c2,t]/.fitswensson3)//Simplify;
curveswefc3[t_]:=swenssonspot[b0,b1,b2,b3,c1,c2,t]/.fitswensson3
(curveswe3forward=swenssonforward[b0,b1,b2,b3,c1,c2,t]/.fitswensson3)//Simplify;
Show[plot3,Plot[curveswe3,{t,0,10000},PlotRange->All,PlotStyle->Thick],Plot[curveswe3forward,{t,0,10000},PlotRange->All,PlotStyle->{Orange,Thick}],PlotRange->All]

!Statistický přístup (vyrovnání, fitting): spliny

Ilustrace je na datech   ir3

Hyperlink[Button[" Fitting by cubic splines "],"http://www.karlin.mff.cuni.cz/~hurt/Fitting_by_cubic_splines.pdf"]

***Statistický přístup (vyrovnání, fitting): neparametrický: jádrové odhady (kernel estimators)

***Příklad

Užití výnosových křivek pro hodnocení investic

Based on the present value of the cash flow CF using spot rates R=((Subscript[R, 1]),...(Subscript[R, T]))  taken from the yield curve

({{({{PV(CF,R)}})=(∑_(t=0)^T)((Subscript[CF, t])/(((1+(Subscript[R, t])))^t))}})

Lekce 13 (8. 1. 2015)

Hodnota firmy, Value of the Firm, The Cost of the Capital

[11] Brigham, E. F.: Fundamentals of Financial Management. Dryden Press. 6th edition Fortt Worth 1992. Chapter 7, The Cost of Capital.

Hyperlink[Button[" Hodnota firmy, cena kapitálu "],"http://www.karlin.mff.cuni.cz/~hurt/Value_of _the_firm_WACC.pdf"]

Despite the explanation in the above reference is rather short, about 15 rows, it takes some time to understand the essence of the topic thoroughly.

Míry rizika (risk measures)

The procedures as well as numbered references in

Hyperlink[Button[" Míry rizika revidované "],"http://www.karlin.mff.cuni.cz/~hurt/WTC2010JanHurtRiskMeasuresRevisited2withReference.nb"]

(Subscript[S, 0]),(Subscript[S, 1]),... prices of a financial asset (random variables), rate of return (ROR, míra výnosnosti) or shortly return (výnos):

({{({{(Subscript[ρ, t])=(((Subscript[S, t+1])-(Subscript[S, t]))/(Subscript[S, t]))}})}})

loss (ztráta):

({{({{(Subscript[L, t])=-(Subscript[ρ, t])}})}})

In literature we can often find very misleading assumptions that returns or losses are always nonnegative, hidden in the assumptions about lognormal distribution of returns (losses) &c.  It is obviously nonsense.

In what follows we alternatively denote loss as L, (Subscript[L, t]), X, ... .

Probability distributions

The Laplace Distribution and Generalizations
A Revisit with New Applications
Samuel Kotz
Department of Engineering Management & System Engineering
The George Washington University, Washington, DC 20052
Tomasz J. Kozubowski
Department of Mathematics
University of Nevada, Reno, NV 89557
Krzysztof Podg´orski
Department of Mathematical Sciences
Indiana University–Purdue University, Indianapolis, IN 46202.
January 24, 2001

Asymmetric Laplace distribution (ALD)

See [21] Trindade for an introduction and statistical inference to ALD. Also the standardized ALD is discussed there.

See also http://www.mathestate.com/tools/Financial/s07b/Laplace.html

Probability density function (definition)

The density of ALD is

f(x;θ,τ,κ)=((κ (Sqrt[2]))/(τ(1+(κ^2))))exp{-((κ(Sqrt[2]))/τ)(x-θ)},    x≥θ,
f(x;θ,τ,κ)=((κ (Sqrt[2]))/(τ(1+(κ^2))))exp{-((Sqrt[2])/(κ τ))(θ-x)},        x<θ,

where real θ is a location parameter, τ>0 is a scale parameter, and κ>0 is a shape parameter.

Definition of ALD in Mathematica

Clear[AsymmetricLaplaceDistribution];Unprotect[Mean, Variance, StandardDeviation, Skewness, Kurtosis,
         PDF, CDF, ExpectedValue, DistributionParameterQ,
         DistributionDomainQ,DistributionDomain,
         CharacteristicFunction,Quantile,RandomReal];
AsymmetricLaplaceDistribution/: PDF[AsymmetricLaplaceDistribution[θ_,τ_,κ_],x_]:=((κ(Sqrt[2]))/(τ(1+(κ^2))))Which[x≥θ,Exp[-((κ(Sqrt[2]))/τ)(x-θ)],
			   x<θ,Exp[-((Sqrt[2])/(κ τ))(θ-x)]]
AsymmetricLaplaceDistribution/: CDF[AsymmetricLaplaceDistribution[θ_,τ_,κ_],x_]:=Which[x≤θ,(((E^(((Sqrt[2]) (x-θ))/(κ τ))) (κ^2))/(1+(κ^2))),
						 x>θ,((1-(E^(((Sqrt[2]) (-x+θ) κ)/τ))+(κ^2))/(1+(κ^2)))];
AsymmetricLaplaceDistribution/: Mean[AsymmetricLaplaceDistribution[θ_,τ_,κ_]]:=θ-(((-1+(κ^2)) τ)/((Sqrt[2]) κ))
AsymmetricLaplaceDistribution/: 
Variance[AsymmetricLaplaceDistribution[θ_,τ_,κ_]]:=(((1+(κ^4)) (τ^2))/(2 (κ^2)))
AsymmetricLaplaceDistribution/: 
StandardDeviation[AsymmetricLaplaceDistribution[θ_,τ_,κ_]]:=Sqrt[(((1+(κ^4)) (τ^2))/(2 (κ^2)))]
AsymmetricLaplaceDistribution/: 
Skewness[AsymmetricLaplaceDistribution[θ_,τ_,κ_]]:=((2 (1-(κ^6)))/((((κ^4)+1))^(3/2)))
AsymmetricLaplaceDistribution/: 
Kurtosis[AsymmetricLaplaceDistribution[θ_,τ_,κ_]]:=((9+6 (κ^4)+9 (κ^8))/(((1+(κ^4)))^2))
AsymmetricLaplaceDistribution/: Quantile[AsymmetricLaplaceDistribution[θ_,τ_,κ_],q_]:=
	Which[0<q≤((κ^2)/(1+(κ^2))),θ+((κ τ Log[q (1+(1/(κ^2)))])/(Sqrt[2])),
		  ((κ^2)/(1+(κ^2)))<q<1,θ-((τ Log[-(-1+q) (1+(κ^2))])/((Sqrt[2]) κ))]
AsymmetricLaplaceDistribution/: RandomReal[AsymmetricLaplaceDistribution[θ_,τ_,κ_]]:=Quantile[AsymmetricLaplaceDistribution[θ,τ,κ],Random[]]
Protect[Mean, Variance, StandardDeviation, Skewness, Kurtosis,
         PDF, CDF, ExpectedValue, DistributionParameterQ,
         DistributionDomainQ,DistributionDomain,
         CharacteristicFunction,Quantile,RandomReal];

Illustrations

Plot[(Quantile[AsymmetricLaplaceDistribution[θ,τ,κ],q]/.{θ->0,τ->4,κ->1/2}),{q,0.01,0.99},AxesLabel->{"α","Quantile"}]

Due to the three parameters the distribution is apparently flexible. Nevertheless its kurtosis is always high (≥6), which might be unsatisfactory in some practical situations.

Text@Row[{"Minimal kurtosis is ", FindMinimum[Kurtosis[AsymmetricLaplaceDistribution[θ,τ,κ]],{κ,2}]//First//Round, " and is achieved for κ = ",κ/.(FindMinimum[Kurtosis[AsymmetricLaplaceDistribution[θ,τ,κ]],{κ,2}]//Last)//Round,"."}]

Plot[{Skewness[AsymmetricLaplaceDistribution[θ,τ,κ]],Kurtosis[AsymmetricLaplaceDistribution[θ,τ,κ]]},{κ,0,3},AxesLabel->{"κ"," "}]

Probability density function (illustration)

Manipulate [Plot[PDF[AsymmetricLaplaceDistribution[θ,τ,κ],y]//Evaluate,{y,-6,6},PlotPoints->70,PlotRange->All],{{θ,0},-5,5},{{τ,4},0.1,5},{{κ,1/2},0.1,10},SaveDefinitions->True]

Study specific parameters for ALD and simulation

In specific numerical illustrations we will consider the distributions with the same mean and standard deviation for comparisons. We have chosen AsymmetricLaplaceDistribution[0, 4, 1/2] as a standard (sometimes called reference distribution in the sequel). The corresponding moments are:

Text@Grid[{{"Mean ",Mean[AsymmetricLaplaceDistribution[0.,4,0.5]]},{"SD  ",StandardDeviation[AsymmetricLaplaceDistribution[0.,4,0.5]]},{"Skewness     ",Skewness[AsymmetricLaplaceDistribution[0.,4,0.5]]},{"Kurtosis",Kurtosis[AsymmetricLaplaceDistribution[0.,4,0.5]]}},Frame->All,Alignment->Left]

Simulation

t1=Table[RandomReal[AsymmetricLaplaceDistribution[0.,4,0.5]],{10000}];
Text@Grid[{{"Mean ",Mean[t1]},{"SD  ",StandardDeviation[t1]},{"Skewness     ",Skewness[t1]},{"Kurtosis",Kurtosis[t1]}},Frame->All,Alignment->Left]
Histogram[t1]

Definitions of risk measures

Standard deviation (směrodatná odchylka)

({{({{σ=(Sqrt[var ρ ])=(Sqrt[var L])}})}})

Value at Risk at level 1-α (VaR)

The definitions of Value at Risk differ. Particularly, what concerns the significance level. Logic of VaR is to determine the value over which the loss will exceed with a small probabaility. Thus, in any case, our interest is in the right-hand tails of the the distributions of losses, or in the left-hand tails of profits (rates of return). In this course we suppose the significance level  1-α but in other sources often you can find α instead of 1-α.

Here is an example of the VaR in terms of  profits. The example comes from Nagy Gergely, the Graduate from Charles University, Financial & Insurance Mathematics. Licensed users may download the source code and take a benefit from the technics and tricks in Mathematica coding.

http://demonstrations.wolfram.com/ValueAtRisk/

Value at risk at level 1-α is simply the α-quantile of X, sometimes denoted by (Subscript[q, α]).

(Subscript[VaR, α])(X)=(F^(-1))(α)=inf{x:F(x)≥α}.

The usual interpretation is that loss will exceed (Subscript[VaR, α])(X) with a (small) probability 1-α with typical values of α=0.95, 0.99 or in some extreme cases even α=0.999. In practice the time horizons are one day or one week but often longer time horizons are of interest but they need a special care.

Conditional Value at Risk (CVaR)

Conditional value at risk (also called Expected Shortfall, Tail Conditional Expectation, Mean Excess Loss, Tail VaR) is the mean of the truncated distribution of X truncated at point (Subscript[VaR, α])(X) from the left:

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

Note that sometimes an analogue to the mean residual lifetime is considered:

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

For absolutely continuous distributions we have

(Subscript[CVaR, α])(X)=(1/(1-α))(∫_((Subscript[Var, α])(X))^∞)y f(y)dy.

Average Value at Risk at level 1-α (AVaR)

Average value at risk is defined as

(Subscript[AVaR, α])(X)=(1/(1-α))(∫_α^1)VaR(Subscript[,, p])(X)dp=(1/(1-α))(∫_α^1)(F^(-1))(p)dp.

After substitution y=(F^(-1))(p) we get

(Subscript[AVaR, α])(X)=(1/(1-α))(∫_((Subscript[VaR, α])(X))^∞)ydF(y)=(Subscript[CVaR, α])(X).

Hence both characteristics coincide but they differ in interpretation.

Weighted VaR (WVaR)

(Subscript[WAVaR, μ])(X)=(∫_0^1)AVaR(Subscript[,, λ])(X)μ(dλ),

where μ is a probability measure on [0,1].

Median Value at Risk (Median Shortfall, Tail Conditional Median)

Median value at risk is defined as the median of the conditional distribution given that the loss exceeded value at risk.

(Subscript[MVaR, α])(X)=Median{X|X≥(Subscript[VaR, α])(X)}.

Therefore, (Subscript[MVaR, α])(X) is a value satisfying

P(X≥ (Subscript[MVaR, α])(X)|X≥(Subscript[VaR, α])(X))=((P(X≥ (Subscript[MVaR, α])(X),X≥(Subscript[VaR, α])(X)))/(P(X≥(Subscript[VaR, α])(X))))=(1/2)

or

P(X≥ (Subscript[MVaR, α])(X),X≥(Subscript[VaR, α])(X))=(1/2)(1-α).

Since P(X≥(Subscript[VaR, α])(X))=1-α>(1/2)(1-α), (Subscript[MVaR, α])(X)>=(Subscript[VaR, α])(X), and therefore

P(X≥ (Subscript[MVaR, α])(X),X≥(Subscript[VaR, α])(X))=P(X≥ (Subscript[MVaR, α])(X))=(1/2)(1-α)

so that P(X<(Subscript[MVaR, α])(X))=((1+α)/2) and

(Subscript[MVaR, α])(X)=(Subscript[VaR, (1+α)/2])(X).

Sometimes median residual lifetime is considered:

(Subscript[MVaR, α])(X)-(Subscript[VaR, α])(X)=Median{X-(Subscript[VaR, α])(X)|X≥(Subscript[VaR, α])(X)}.

Quantile Value at Risk

Quantile Value at Risk (Quantile Shortfall, Tail Conditional Quantile) is defined as

(Subscript[QVaR, α,β])(X)=β-quantile of the conditional distribution{X|X≥(Subscript[VaR, α])(X)}.

It means that the probability of loss greater than QVaR given that it exceeded VaR will be 1-β.

Thus (Subscript[QVaR, α,β])(X) satisfies the relation

P(X≥ (Subscript[QVaR, α,β])(X)|X≥(Subscript[VaR, α])(X))=((P(X≥ (Subscript[QVaR, α,β])(X),X≥(Subscript[VaR, α])(X)))/(P(X≥(Subscript[VaR, α])(X))))=1-β,

and, since it has sense to consider (Subscript[QVaR, α])(X)≥(Subscript[VaR, α])(X) only, we have

P(X≥ (Subscript[QVaR, α,β])(X))=(1-β)(1-α),

so that (due to 1-(1-β)(1-α)=α+β-α β)

P(X< (Subscript[QVaR, α,β])(X))=α+β-α β.

It follows

(Subscript[QVaR, α,β])(X)=(F^(-1))(α+β-α β)=(α+β-α β)-quantile of X.

Spectral measures

Suppose that ϕ is a non-decreasing non-negative real function defined on [0,1], (∫_0^1)ϕ(p)dp=1, sometimes called spectrum. (ϕ is simply non-decreasing PDF with support [0,1].The quantity

(Subscript[M, ϕ])(X)=(∫_0^1)(F^(-1))(p)ϕ(p)dp

is called spectral risk measure. If F is absolutely continuous with the probability density function f and strictly increasing on its support then after substitution (F^(-1))(p)=y we obtain

(Subscript[M, ϕ])(X)=(∫_(-∞)^∞)y ϕ(F(y))f(y)dy.

In fact, ϕ is a weighting function giving higher weights to higher losses.

Expectiles

We start with motivation given in [22] Yao (1996) despite the idea originates in [18] Newey and Powell (1987). First we give an alternative approach for defining quantiles through an optimization problem. Define

(Subscript[R, α])(x)=(1-α)|x| ,   x≤0,
(Subscript[R, α])(x)=α|x| ,                 x>0.

The α-quantile (Subscript[q, α]) of X may be defined as

(Subscript[q, α])=arg (min_a) E,(Subscript[R, α])(X-a).

Obviously α=P(X≤(Subscript[q, α])). In order to have an analogy with expectiles, write

α=((E,I{X≤(Subscript[q, α])})/(E,1)),

where I means the indicator function.

To define expectiles, let us define

(Subscript[Q, ω])(x)=(1-ω)(x^2) ,   x≤0,
(Subscript[Q, ω])(x)=ω (x^2) ,                 x>0.

The ω-expectile of X is defined as the minimizer

(Subscript[τ, ω])=arg (min_a) E,(Subscript[Q, ω])(X-a),

see [22] Yao (1996), e.g. For ω=(1/2)  we have (Subscript[τ, 1/2])=E,X. Since (Subscript[Q, ω])(.) has a continuous first derivative, (Subscript[τ, ω]) satisfies the equation

E,(Subscript[L, ω])(X-(Subscript[τ, ω]))=0

where

(Subscript[L, ω])(x)=(1-ω)x ,   x≤0,
(Subscript[L, ω])(x)=ω x ,                 x>0.

Hence (Subscript[τ, ω]) satifies

ω=((E,[|X-(Subscript[τ, ω])|I{X≤(Subscript[τ, ω])}] )/(E|X-(Subscript[τ, ω])|)).

Distribution Specific Calculations

Normal distribution

VaR

VaRNormal[α_,μ_,σ_]=VaR[NormalDistribution[μ,σ],α]

CVaR

CVaRNormal[α_,μ_,σ_]=CVaR[NormalDistribution[μ,σ],α,Re[(σ^2)]>0]

AVaR

AVaRNormal[α_,μ_,σ_]=AVaR[NormalDistribution[μ,σ],α]//PowerExpand//Simplify

Spectral measure

Recall that throughout the paper if we speak on  specific distributions, we consider distributions with mean and standard deviation equal to

{3 (Sqrt[2]),(Sqrt[34])}//N

We start with the spectral risk for a normal distribution.

Manipulate[Plot[NSpectralRisk[NormalDistribution[3. (Sqrt[2]),σ],ϕdual[#,ν]&],{ν,1,10},AxesOrigin->{0,0},PlotRange->{0,20},AxesLabel->{"ν","Spectral risk"}],{{σ,5.83},4,10},SaveDefinitions->True]

Manipulate[Plot[NSpectralRisk[NormalDistribution[3. (Sqrt[2]),σ],ϕArrowPratt[#,k]&],{k,0.1,10},AxesOrigin->{0,0},PlotRange->{0,20},AxesLabel->{k,"σ"}],{{σ,5.83},4,10},SaveDefinitions->True]

The reader will simply discover that such plots are rather boring. More interesting and more important are the ratios of the risk measures.

Expectiles of the normal distribution

Text@Grid[Prepend[tableExpectile2Normal=Table[{ω,Expectile2[NormalDistribution[3. (Sqrt[2]),5.83],ω]},{ω,0.85,0.99,0.01}],{"ω","Expectile2"}],Frame->All]

ListPlot[tableExpectile2Normal,Joined->True,AxesOrigin->{0.85,8},AxesLabel->{"ω","Expectile"}]

Laplace distribution

VaR

VaRLaplace[α_,μ_,β_]=VaR[LaplaceDistribution[μ,β],α,β>0&&(1/2)<α<1]

CVaR

CVaRLaplace[α_,μ_,β_]=CVaR[LaplaceDistribution[μ,β],α,β>0&&(1/2<α<1)]

For (1/2)<α<1 we have 2-2α<1 so that μ-β Log[2-2α]>μ and thus

CVaRLaplace[α_,μ_,β_]=Assuming[β>0,(((∫_(μ-β Log[2-2 α])^∞)(((E^(-((y-μ)/β))) y)/(2 β))\[DifferentialD]y)/(1-α))]//FullSimplify

Observe that direct calculation of the AVaR (which coincides with CVaR) is straightforward and does need any manual adjustment.

AVaR

AVaRLaplace[α_,μ_,β_]=AVaR[LaplaceDistribution[μ,β],α,β>0&&(1/2<α<1)]

Spectral measure

We choose the parameters to have the same mean and standard deviation as in the normal case. We have

{Mean[LaplaceDistribution[μ,β]],StandardDeviation[LaplaceDistribution[μ,β]]}

{μ,(Sqrt[2]) β}

so that a solution to these equations returns the equivalent parameters.

Solve[{μ==3. (Sqrt[2]),(Sqrt[2]) β==5.83},{μ,β}]

For ϕdual the computation mostly takes longer time than for ϕArrowPratt, e.g. However, the absolute exponential risk aversion is, fortunately, most popular in practice. Thus it would be convenient to give some examples with the Arrow-Pratt spectrum only.

Nevertheless, we start with ϕdual:

Text@Grid[Prepend[Table[{ν,NSpectralRisk[LaplaceDistribution[4.24264,4.12243],ϕdual[#,ν]&]},{ν,1,10}],{"ν","Spectral Risk   "}]//Transpose,Frame->True]

And now for the absolute exponential risk aversion.

Manipulate[Plot[NSpectralRisk[LaplaceDistribution[4.24264,β],ϕArrowPratt[#,k]&],{k,0.1,10},AxesOrigin->{0,0},PlotRange->{0,20}],{{β,4.12243},1,10},SaveDefinitions->True]

Expectiles

Expectile2[LaplaceDistribution[4.24264,4.12243],0.75]//Timing

On an  old HP notebook the following calculation appeared to be too ambitious.

tableExpectile2Laplace=Table[{ω,Expectile2[LaplaceDistribution[4.24264,4.12243],ω]},{ω,0.85,0.99,0.01}]

Aborted after 5349 seconds.

Asymmetric Laplace distribution (ALD)

VaR

VaRALD[α_,θ_,τ_,κ_]=VaR[AsymmetricLaplaceDistribution[θ,τ,κ],α]

Manipulate[Plot[VaRALD[α,θ,τ,κ],{α,1/2,1},AxesOrigin->{1/2,0},PlotRange->{0,20},AxesLabel->{"α","VaR"}],{{θ,0},-3,3},{{τ,4},1/2,10},{{κ,1/2},0.1,4},SaveDefinitions->True]

CVaR

See Section Calculations for explanation.

CVaRALD[α_,θ_,τ_,κ_]=Which[0<α≤((κ^2)/(1+(κ^2))),(1/(1-α))(1/2) (1+(κ^2)) τ (-2 (-1+α) θ+(((Sqrt[2]) τ (1+(κ^2) (-1+α-α (Log[α]+Log[1+(1/(κ^2))]))))/κ)),
((κ^2)/(1+(κ^2)))<α<1,-(1/(1-α))(((-1+α) (1+(κ^2)) τ ((Sqrt[2]) θ κ+τ-τ Log[-(-1+α) (1+(κ^2))]))/((Sqrt[2]) κ))];

Manipulate[Plot[CVaRALD[α,θ,τ,κ],{α,1/2,1},AxesOrigin->{1/2,0},AxesLabel->{"α","CVaR"}],{{θ,0},-3,3},{{τ,4},1/2,10},{{κ,1/2},0.1,4},SaveDefinitions->True]

AVaR

See Section Calculations for details.

AVaRALD[α_,θ_,τ_,κ_]=Which[0<α≤((κ^2)/(1+(κ^2))),-((2 θ κ-2 α θ κ+(Sqrt[2]) τ-(Sqrt[2]) (κ^2) τ+(Sqrt[2]) α (κ^2) τ-(Sqrt[2]) α (κ^2) τ (Log[α]+Log[1+(1/(κ^2))]))/(2 (-1+α) κ)),
((κ^2)/(1+(κ^2)))<α<1,((2 θ κ+(Sqrt[2]) τ-(Sqrt[2]) τ Log[1-α]-(Sqrt[2]) τ Log[1+(κ^2)])/(2 κ))];

Plot[AVaRALD[α,0,4,1/2],{α,0,1},AxesLabel->{"α","AVaR"}]

Spectral measure

NSpectralRisk[AsymmetricLaplaceDistribution[0,4,1/2],ϕdual[#,1]&]//Timing

Table[NSpectralRisk[AsymmetricLaplaceDistribution[0,4,1/2],ϕArrowPratt[#,k]&],{k,0.1,10}]

Manipulate[Plot[NSpectralRisk[AsymmetricLaplaceDistribution[θ,τ,κ],ϕArrowPratt[#,k]&],{k,0.1,10},AxesOrigin->{0,0},AxesLabel->{"k","Spectral risk"}],{{θ,0},-3,3},{{τ,4},1/2,10},{{κ,1/2},0.1,4},SaveDefinitions->True]

Expectiles

First illustration:

Expectile2[AsymmetricLaplaceDistribution[0,4,1/2],0.75]//Timing

(tableExpectile2ALD=Table[{ω,Expectile2[AsymmetricLaplaceDistribution[0.,4.,1./2],ω]}//Flatten,{ω,0.85,0.99,0.01}])

Text@Grid[Prepend[{{0.87`,9.257299332722239`},{0.88`,9.54517970636458`},{0.89`,9.859036271596631`},{0.9`,10.204110341986302`},{0.91`,10.587353105732982`},{0.9199999999999999`,11.018251652751681`},{0.9299999999999999`,11.51021881284805`},{0.94`,12.08307975792722`},{0.95`,12.767884865996166`},{0.96`,13.617254460402796`},{0.97`,14.731159451739403`},{0.98`,16.337714446735852`},{0.99`,19.181023514893155`}},{"ω","Expectile2"}],Frame->True
]

The plot of the expectiles for the reference distribution

ListPlot[tableExpectile2ALD,AxesLabel->{"ω","Expectiles"},AxesOrigin->{0.85,8},Joined->True]

Value at Risk (VaR, hodnota v riziku)

at confidence level 1-α is the α-quantile of the loss distribution of L, shortly (Subscript[VaR, α])(L):

({{({{P(L≤(Subscript[VaR, α])(L)}}))=α}})

so that

({{({{P(L>(Subscript[VaR, α])(L))=1-α}})}})

Typically α=0.95, 0.99 &c., so that the probability in the above formula is small.

Parametric VaR (Parametrická hodnota v riziku)

Nonparametric VaR (Neparametrická hodnota v riziku)

Conditional VaR (CVaR, podmíněná hodnota v riziku)

Expected shortfall (očekávaná extrémní ztráta), Tailed VaR

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

Nonparametric estimate of CVaR

Similar risk measures (příbuzné míry rizika)

Average VaR

Weighted Average VaR

Median VaR

Quantile VaR

Spectral measure of risk

Expectiles (expektily)