Escolar Documentos
Profissional Documentos
Cultura Documentos
guillermo.navas@estudiant.upc.edu
Contents
1 Introduction
5 Conclusions
6 Numerical Software
Introduction Generalized Vasicek Model Fourier Transform Method Haar-based Wavelet Approximation Conclusions Numerical Software
Introduction
Credit risk is the risk of loss resulting from an obligors inability to meet its legal
obligation according to the debt contract.
N √
α − ρxk
π X
E [p(y )] ≈ h wk H √ g (xk ) = p (5)
2 k=1 1−ρ
Newton-Raphson algorithm
N √
α − ρxk
0 ∂f (α, ρ, p) πh X 0
f (α; ρ, p) = = √ wk H √ g (xk ) (8)
∂α 2 1 − ρ k=1 1−ρ
f (αk )
αk+1 = αk − α0 = Bisection(f (α), lb, ub, 1e−01) (9)
f 0 (αk )
Brent’s method
Introduction Generalized Vasicek Model Fourier Transform Method Haar-based Wavelet Approximation Conclusions Numerical Software
Table: Benchmark for computing the threshold α for two discretization schemes and 3 root-finding
algorithms. B+NR = Bisection + Newton-Raphson, B+NRFD = Bisection + Newton-Raphson
with centered finite difference order 2. Tolerance=1e−15. α0 = −1.03125. DE: N = 100,
d = 11. Riemann midpoint: N = 100. Gaussian factor model: Y ∼ N (0, 1) and n ∼ N (0, 1)
where α∗ = Φ−1 (0.15).
1
The value of the parameter h is u 2/3 where u is the unit roundoff typically 10−16 in double-precision.
Introduction Generalized Vasicek Model Fourier Transform Method Haar-based Wavelet Approximation Conclusions Numerical Software
Computation methods:
Double exponential transformation.
Monte Carlo + Median Latin Hypercube sampling.
π/2 √ 0
α − ρ tan(x)
Z
G (tan(x))
P[X = n] = 2 B n, N, H √ dx (12)
−π/2 1 − ρ cos(2x) +1
Necdet Batir (2010) established a new Stirling-type approximation formula for the
factorial function, which so far is one of the most accurate approximations to n!
√
r
1 1 31 139 9871
n! ≈ 2πnn e −n n + +
4
− − + (14)
6 72n 6480n2 155520n3 6531840n4
We make use of (14) to write an expression for the logarithm of the binomial
coefficient,
ln n! ≈ n ln n − n + 21 ln(2π) + 14 ln n + 16 + 72n
1 1
1 + 90n 1
− 31 + 24n − 139 + 9871
42n
(15)
and having written ln n! we can easily write ln kn as follows,
n
ln ≈ n ln n − (n − k) ln(n − k) − k ln k − 12 ln(2π)
k
h
+ 14 ln n + 61 + 72n1
1 + 90n1 1
− 31 + 24n − 139 + 9871
42n
− ln (n − k) + 61 + 72(n−k)1 1
1 + 90(n−k) 1
− 31 + 24(n−k) − 139 + 9871
42(n−k)
i
− ln k + 61 + 72k
1
1 + 90k 1 1
− 31 + 24k − 139 + 9871
42k
(16)
Introduction Generalized Vasicek Model Fourier Transform Method Haar-based Wavelet Approximation Conclusions Numerical Software
Latin hypercube sampling (LHS) is one form of stratified sampling that can yield more
precise estimates of the distribution function.
Theoretical results√for the univariate case show that the sampling error of MC
decreases as O(1/ N), whereas the sampling error for LHS is O(1/N), therefore it is
quadratically faster.
Remark
MC and LHS are both unbiased estimation techniques, therefore computed statistics
approach their theoretical values as N → ∞.
Introduction Generalized Vasicek Model Fourier Transform Method Haar-based Wavelet Approximation Conclusions Numerical Software
9.5%
p
5.0%
4.5%
4.0%
3.5%
3.0%
2.5%
2.0%
1.5%
1.0%
0.5%
0.0%
0.0% 5.0% 10.0% 15.0% 20.0% 25.0% 30.0% 35.0% 40.0% 45.0%
Loss scenario
7.5% 1.0
7.0% Y ∼ NIG(α =2,β =1),² ∼N(0,1) Y ∼ NIG(α =2,β =1)
Y ∼ NIG(α =8,β =7.5),² ∼N(0,1) Y ∼ NIG(α =8,β =7.5)
6.5% Y ∼ NIG(α =8,β = −7)
Y ∼ NIG(α =8,β = −7),² ∼N(0,1)
6.0% 0.8
5.5%
5.0%
fNIG(x,α,β)
4.5% 0.6
Probability
4.0%
3.5%
3.0% 0.4
2.5%
2.0%
1.5% 0.2
1.0%
0.5%
0.0% 0.0
0.0% 5.0% 10.0% 15.0% 20.0% 25.0% 30.0% 35.0% 40.0% 45.0% 4 3 2 1 0 1 2 3 4
Loss scenario x
(a) Probability distribution. (b) Density of some NIG distribution.
The Vasicek distribution implies a strong assumption; the systematic and idiosyncratic
factors are normally and standardized distributed. Schönbucher provided a general
portfolio cumulative distribution function given by
s
α 1 − ρ −1
F (x; α, ρ) = P[X ≤ x] = 1 − G √ − H (x) (17)
ρ ρ
We can derive Equation (17) to obtain the general portfolio loss density function
s s
∂F (x; α, ρ) 1−ρ 0 α 1 − ρ −1 ∂ −1
f (x; α, ρ) = = G √ − H (x) H (x) (18)
∂x ρ ρ ρ ∂x
and the quantile function or inverse cumulative distribution function can be easily
obtained from Equation (17)
√ −1
α− ρG (1 − β)
F −1 (β; α, ρ) = H √ (19)
1−ρ
Introduction Generalized Vasicek Model Fourier Transform Method Haar-based Wavelet Approximation Conclusions Numerical Software
L − L quantile function
√
√ 1−β 3
π α − ρ ln β
−1 1 π
F (β; α, ρ) = 1 + tanh √ √ (22)
2 2 3 1−ρ
Introduction Generalized Vasicek Model Fourier Transform Method Haar-based Wavelet Approximation Conclusions Numerical Software
0.75% 0.075%
p p p p
Probability
0.4% 0.04%
0.35% 0.035%
0.3% 0.03%
0.25% 0.025%
0.2% 0.02%
0.15% 0.015%
0.1% 0.01%
0.05% 0.005%
0.0% 0.0%
0.0% 5.0% 10.0% 15.0% 20.0% 25.0% 30.0% 35.0% 40.0% 45.0% 0.0% 5.0% 10.0% 15.0% 20.0% 25.0% 30.0% 35.0% 40.0% 45.0%
Loss scenario Loss scenario
Ln = En · Λn · Dn = wn · Dn (24)
For a given state of the economy Y = y , the conditional Fourier transform of the
portfolio default distribution (fL (x), 0 < x < 1) is defined as
PN
fˆL|Y =y (t) = E [e −itL | Y = y ] = E [e −it n=1 wn Dn
| Y = y] (26)
Introduction Generalized Vasicek Model Fourier Transform Method Haar-based Wavelet Approximation Conclusions Numerical Software
where
√ 2
αn − ρn y e −x /2
pn (y ) = Φ √ and φ(x) = √
1 − ρn 2π
Introduction Generalized Vasicek Model Fourier Transform Method Haar-based Wavelet Approximation Conclusions Numerical Software
The last function 1 F1 (a; b; z) is the confluent hypergeometric function of the first
kind. Thus, the portfolio Fourier transform with beta distributed LGD is given by
Z ∞ N
Y
fˆL (t) = [1 − pn (y ) + pn (y )1 F1 (αn ; αn + βn ; −itEn )]φ(y ) dy (37)
−∞ n=1
Introduction Generalized Vasicek Model Fourier Transform Method Haar-based Wavelet Approximation Conclusions Numerical Software
Integral representation: Amongst the several methods for computing 1 F1 (a; b; z),
Abramowitz and Stegun give a useful integral form for <(b) > <(a) > 0
Γ(b)
Z 1
1 F1 (a; b; z) = e zt t a−1 (1 − t)b−a−1 dt (38)
Γ(a)Γ(b − a) 0
Taylor series: In practice the simplest method for computing the confluent
hypergeometric function is to truncate the Taylor series defined as follows
N
X (a)j 1 j
1 F1 (a; b; z) ≈ SN = z (39)
j=0
(b) j j!
Introduction Generalized Vasicek Model Fourier Transform Method Haar-based Wavelet Approximation Conclusions Numerical Software
Z 1
Γ(b)
1 F1 (a; b; z) = e zt t a−1 (1 − t)b−a−1 dt (40)
Γ(a)Γ(b − a) 0
Γ(b)
Z 1
1 F1 (a; b; z) = e <(z)t t a−1 (1 − t)b−a−1 e i=(z)t dt (41)
Γ(a)Γ(b − a) 0 | {z } | {z }
r (t) e iωt ,ω==(z)
Table: Results by applying the numerical steepest descent method to compute the confluent
hypergeometric function on the complex plane for large values of a, b and |z|.
Introduction Generalized Vasicek Model Fourier Transform Method Haar-based Wavelet Approximation Conclusions Numerical Software
2 given a Fourier resolution M the inversion is performed using the Discrete Inverse
Fourier Transform (DIFT)
Coefficients cm,k
m
2X −1 m
ML (−2m ln(z)) − z 2
Q(z) ≡ cm,k z k ≈ (49)
k=0
2m/2 (1 − z)
R ∞ QN
−∞ n=1 [1 − pn (y )]f (y ) dy
lim Q(z) = cm,0 = (50)
z→0 2m/2
2
Z π
cm,k = <(Q(re iu )) cos(ku) du (51)
πr k 0
Introduction Generalized Vasicek Model Fourier Transform Method Haar-based Wavelet Approximation Conclusions Numerical Software
Computation of <(Q(re iu ))
m
ML (−2m ln(re iu ) − (re iu )2
Q(re iu ) = (52)
2m/2 (1 − re iu )
<(z1 )<(z2 ) + =(z1 )=(z2 )
<(Q(re iu )) = (53)
(<(z2 ))2 + (=(z2 ))2
where
m
<(z1 ) = <(ML (−2m ln(re iu )) − r 2 cos(2m u), <(z2 ) = 2m/2 (1 − r cos(u)) (54)
and
m
=(z1 ) = =(ML (−2m ln(re iu )) − r 2 sin(2m u), <(z2 ) = −2m/2 r sin(u) (55)
Z ∞ N
m
En Λn i2m En Λn u
Y
ML (−2m ln(re iu )) = [1 − pn (y ) + pn (y )r 2 e ]f (y ) dy (56)
−∞ n=1
N
π X
<(ML (−2m ln(re iu ))) ≈ h wj <(ML (−2m ln(re iu ); xj )) (57)
2 j=1
N
π X
=(ML (−2m ln(re iu ))) ≈ h wj =(ML (−2m ln(re iu ); xj )) (58)
2 j=1
Introduction Generalized Vasicek Model Fourier Transform Method Haar-based Wavelet Approximation Conclusions Numerical Software
15
m =8,k =0
m =8,k =50
<(Q(reiu ))cos(ku)
10 m =8,k =125
m =8,k =250
The extended trapezoidal rule stands as the fastest method with remarkable accuracy
for this kind of integrals.
Portfolio 1. This portfolio has N = 1001 obligors with pn = 0.0033, ρn = 0.2 and
En = 1 for n = 1, . . . , N − 1 and E1001 = 100.
Table: VaR of portfolio 1 for m ∈ {10, 11}. Relative error with respect to Monte Carlo with 5
millions scenarios.
Portfolio 2. This portfolio has N = 1000 obligors with pn = 0.003, ρn = 0.15 and
En = 1/n for n = 1, . . . , N.
Table: VaR of portfolio 2 for m ∈ {8, 9, 10, 11, 12}. Relative error with respect to Monte Carlo
with 5 millions scenarios.
Introduction Generalized Vasicek Model Fourier Transform Method Haar-based Wavelet Approximation Conclusions Numerical Software
Portfolio 3. This portfolio has N = 10000 obligors with pn = 0.01, ρn = 0.15 and
En = 1/n for n = 1, . . . , N.
Table: VaR of portfolio 3 for m ∈ {8, 9, 10}. Relative error with respect to Monte Carlo with 5
millions scenarios.
Portfolio 4. This portfolio has N = 1000 obligors with pn = [0.001, 0.01, 0.1, 0.2],
ρn = [0.02, 0.1, 0.2, 0.5] and En = 1 for n = 1, . . . , N.
Table: VaR value at 99.9% for portfolio 4. Relative error with respect to Monte Carlo using
Median Latin Hypercube Sampling and applying tan transformation.
Introduction Generalized Vasicek Model Fourier Transform Method Haar-based Wavelet Approximation Conclusions Numerical Software
Conclusions
Numerical software
14000
12000
10000
Lines of code
8000
6000
4000
2000
0
C++ C Python R AMPL Total
Figure: Lines of code for each programming language. Total = 12399 lines.
The total project is over 12000 lines of source code. The main code in C++ has been
coded following a software development process called Test-driven development
(TDD).
Introduction Generalized Vasicek Model Fourier Transform Method Haar-based Wavelet Approximation Conclusions Numerical Software
About me
Questions
Questions?
Thank you