fin285a:computer simulations and risk assessment section 7.2...
TRANSCRIPT
![Page 1: Fin285a:Computer Simulations and Risk Assessment Section 7.2 …people.brandeis.edu/~blebaron/classes/fin285a/_downloads/copulas1.pdf · Overview Fall 2016: LeBaron Fin285a: 7.2-5](https://reader036.vdocuments.us/reader036/viewer/2022071008/5fc5a417c6bc244f8261ce60/html5/thumbnails/1.jpg)
Fin285a:Computer Simulations andRisk Assessment
Section 7.2Copulas
Danı́elson, 1.8
![Page 2: Fin285a:Computer Simulations and Risk Assessment Section 7.2 …people.brandeis.edu/~blebaron/classes/fin285a/_downloads/copulas1.pdf · Overview Fall 2016: LeBaron Fin285a: 7.2-5](https://reader036.vdocuments.us/reader036/viewer/2022071008/5fc5a417c6bc244f8261ce60/html5/thumbnails/2.jpg)
Overview
Fall 2016: LeBaron Fin285a: 7.2-5 list – 2 / 27
Copula objectives
Copula lesson 1: Generate a distribution
Copula lesson 2: Generate two random variables
Copula lesson 3: Empirical distributions (data)
Copula details
Matlab functions and fitting copulas
Copula wrap-up
![Page 3: Fin285a:Computer Simulations and Risk Assessment Section 7.2 …people.brandeis.edu/~blebaron/classes/fin285a/_downloads/copulas1.pdf · Overview Fall 2016: LeBaron Fin285a: 7.2-5](https://reader036.vdocuments.us/reader036/viewer/2022071008/5fc5a417c6bc244f8261ce60/html5/thumbnails/3.jpg)
Copula objectives
Copula objectives
Copula lesson 1:Generate adistribution
Copula lesson 2:Generate tworandom variables
Copula lesson 3:Empiricaldistributions (data)
Copula details
Matlab functions andfitting copulas
Copula wrap-up
Fall 2016: LeBaron Fin285a: 7.2-5 list – 3 / 27
![Page 4: Fin285a:Computer Simulations and Risk Assessment Section 7.2 …people.brandeis.edu/~blebaron/classes/fin285a/_downloads/copulas1.pdf · Overview Fall 2016: LeBaron Fin285a: 7.2-5](https://reader036.vdocuments.us/reader036/viewer/2022071008/5fc5a417c6bc244f8261ce60/html5/thumbnails/4.jpg)
Objectives
Fall 2016: LeBaron Fin285a: 7.2-5 list – 4 / 27
⊲ Generate dependence between X and Y⊲ Fix distribution of X alone, and Y alone
(Marginal distributions)⊲ Example
• Fit returns to a student-t• Then adjust dependence between them
![Page 5: Fin285a:Computer Simulations and Risk Assessment Section 7.2 …people.brandeis.edu/~blebaron/classes/fin285a/_downloads/copulas1.pdf · Overview Fall 2016: LeBaron Fin285a: 7.2-5](https://reader036.vdocuments.us/reader036/viewer/2022071008/5fc5a417c6bc244f8261ce60/html5/thumbnails/5.jpg)
Copula lesson 1: Generate adistribution
Copula objectives
Copula lesson 1:Generate adistribution
Copula lesson 2:Generate tworandom variables
Copula lesson 3:Empiricaldistributions (data)
Copula details
Matlab functions andfitting copulas
Copula wrap-up
Fall 2016: LeBaron Fin285a: 7.2-5 list – 5 / 27
![Page 6: Fin285a:Computer Simulations and Risk Assessment Section 7.2 …people.brandeis.edu/~blebaron/classes/fin285a/_downloads/copulas1.pdf · Overview Fall 2016: LeBaron Fin285a: 7.2-5](https://reader036.vdocuments.us/reader036/viewer/2022071008/5fc5a417c6bc244f8261ce60/html5/thumbnails/6.jpg)
Generate a distribution
Fall 2016: LeBaron Fin285a: 7.2-5 list – 6 / 27
⊲ F (x) is cumulative distribution function for some RVX
⊲ Generate a uniform random variablezi ∼ Uniform[0, 1]
⊲ Generate yi = F−1(zi)⊲ yi’s will follow the distribution represented by F ()⊲ matlab: copulaex1.m
![Page 7: Fin285a:Computer Simulations and Risk Assessment Section 7.2 …people.brandeis.edu/~blebaron/classes/fin285a/_downloads/copulas1.pdf · Overview Fall 2016: LeBaron Fin285a: 7.2-5](https://reader036.vdocuments.us/reader036/viewer/2022071008/5fc5a417c6bc244f8261ce60/html5/thumbnails/7.jpg)
Copula example 1
Fall 2016: LeBaron Fin285a: 7.2-5 list – 7 / 27
% Simple motivating example for copula technology
% Convert a uniform random variable into a student-t
nsample = 10000;
z = rand(nsample,1);
y = tinv(z,3);
histfit(y);
![Page 8: Fin285a:Computer Simulations and Risk Assessment Section 7.2 …people.brandeis.edu/~blebaron/classes/fin285a/_downloads/copulas1.pdf · Overview Fall 2016: LeBaron Fin285a: 7.2-5](https://reader036.vdocuments.us/reader036/viewer/2022071008/5fc5a417c6bc244f8261ce60/html5/thumbnails/8.jpg)
Message
Fall 2016: LeBaron Fin285a: 7.2-5 list – 8 / 27
⊲ Can turn a uniform into any distribution you want⊲ This can be useful sometimes in monte-carlo’s
![Page 9: Fin285a:Computer Simulations and Risk Assessment Section 7.2 …people.brandeis.edu/~blebaron/classes/fin285a/_downloads/copulas1.pdf · Overview Fall 2016: LeBaron Fin285a: 7.2-5](https://reader036.vdocuments.us/reader036/viewer/2022071008/5fc5a417c6bc244f8261ce60/html5/thumbnails/9.jpg)
Copula lesson 2: Generatetwo random variables
Copula objectives
Copula lesson 1:Generate adistribution
Copula lesson 2:Generate tworandom variables
Copula lesson 3:Empiricaldistributions (data)
Copula details
Matlab functions andfitting copulas
Copula wrap-up
Fall 2016: LeBaron Fin285a: 7.2-5 list – 9 / 27
![Page 10: Fin285a:Computer Simulations and Risk Assessment Section 7.2 …people.brandeis.edu/~blebaron/classes/fin285a/_downloads/copulas1.pdf · Overview Fall 2016: LeBaron Fin285a: 7.2-5](https://reader036.vdocuments.us/reader036/viewer/2022071008/5fc5a417c6bc244f8261ce60/html5/thumbnails/10.jpg)
Convert two normals to student-t
Fall 2016: LeBaron Fin285a: 7.2-5 list – 10 / 27
⊲ Generate (w1, w2) from a multivariate Normal⊲ Get u = F (w1), v = F (w2) where F (x) is normal
CDF⊲ Generate y = G−1(u), z = G−1(v)
G(x) is the student-t CDF⊲ matlab: copulaex2.m
![Page 11: Fin285a:Computer Simulations and Risk Assessment Section 7.2 …people.brandeis.edu/~blebaron/classes/fin285a/_downloads/copulas1.pdf · Overview Fall 2016: LeBaron Fin285a: 7.2-5](https://reader036.vdocuments.us/reader036/viewer/2022071008/5fc5a417c6bc244f8261ce60/html5/thumbnails/11.jpg)
Copula example 2
Fall 2016: LeBaron Fin285a: 7.2-5 list – 11 / 27
% Basic bivariate copula
% Normal copula, student-t marginals, matlab scatter plot
nsample = 10000;
% build variance/covariance matrix for normals
rho = 0.5; % correlation
omega = [1 rho; rho 1];
mn = [ 0 0];
% draw normals to vector w
w = normal(nsample,mn,omega);
% map to uniforms using the cdf
u = normcdf(w(:,1),0,1);
v = normcdf(w(:,2),0,1);
% map back to student-t (4 degrees of freedom)
y = tinv(u,4);
z = tinv(v,4);
% nice matlab routine for plotting
scatterhist(y,z);
![Page 12: Fin285a:Computer Simulations and Risk Assessment Section 7.2 …people.brandeis.edu/~blebaron/classes/fin285a/_downloads/copulas1.pdf · Overview Fall 2016: LeBaron Fin285a: 7.2-5](https://reader036.vdocuments.us/reader036/viewer/2022071008/5fc5a417c6bc244f8261ce60/html5/thumbnails/12.jpg)
Copula lesson 3: Empiricaldistributions (data)
Copula objectives
Copula lesson 1:Generate adistribution
Copula lesson 2:Generate tworandom variables
Copula lesson 3:Empiricaldistributions (data)
Copula details
Matlab functions andfitting copulas
Copula wrap-up
Fall 2016: LeBaron Fin285a: 7.2-5 list – 12 / 27
![Page 13: Fin285a:Computer Simulations and Risk Assessment Section 7.2 …people.brandeis.edu/~blebaron/classes/fin285a/_downloads/copulas1.pdf · Overview Fall 2016: LeBaron Fin285a: 7.2-5](https://reader036.vdocuments.us/reader036/viewer/2022071008/5fc5a417c6bc244f8261ce60/html5/thumbnails/13.jpg)
Generate desired correlation with empirical marginals
Fall 2016: LeBaron Fin285a: 7.2-5 list – 13 / 27
⊲ Generate (w1, w2) from a multivariate Normal⊲ Get u = F (w1), v = F (w2) where F (x) is normal
CDF⊲ Generate usret1mc = G−1(u), emretmc = G−1(v)
• G(x) is empirical CDF from data• Like bootstrap
⊲ matlab: copulaex3.m
![Page 14: Fin285a:Computer Simulations and Risk Assessment Section 7.2 …people.brandeis.edu/~blebaron/classes/fin285a/_downloads/copulas1.pdf · Overview Fall 2016: LeBaron Fin285a: 7.2-5](https://reader036.vdocuments.us/reader036/viewer/2022071008/5fc5a417c6bc244f8261ce60/html5/thumbnails/14.jpg)
What is an empirical CDF?
Fall 2016: LeBaron Fin285a: 7.2-5 list – 14 / 27
⊲ Rt vector of returns⊲ p = G(x) = fraction(Rt ≤ x)⊲ R̃(p) = G−1(p) = quantile(Rt, p)
![Page 15: Fin285a:Computer Simulations and Risk Assessment Section 7.2 …people.brandeis.edu/~blebaron/classes/fin285a/_downloads/copulas1.pdf · Overview Fall 2016: LeBaron Fin285a: 7.2-5](https://reader036.vdocuments.us/reader036/viewer/2022071008/5fc5a417c6bc244f8261ce60/html5/thumbnails/15.jpg)
Copula details
Copula objectives
Copula lesson 1:Generate adistribution
Copula lesson 2:Generate tworandom variables
Copula lesson 3:Empiricaldistributions (data)
Copula details
Matlab functions andfitting copulas
Copula wrap-up
Fall 2016: LeBaron Fin285a: 7.2-5 list – 15 / 27
![Page 16: Fin285a:Computer Simulations and Risk Assessment Section 7.2 …people.brandeis.edu/~blebaron/classes/fin285a/_downloads/copulas1.pdf · Overview Fall 2016: LeBaron Fin285a: 7.2-5](https://reader036.vdocuments.us/reader036/viewer/2022071008/5fc5a417c6bc244f8261ce60/html5/thumbnails/16.jpg)
The steps to generate X, Y
Fall 2016: LeBaron Fin285a: 7.2-5 list – 16 / 27
⊲ Draw (U, V ) from a joint distribution C(U, V ) wherethe marginal distributions of both U and V areU [0, 1]
⊲ Then send U, V through an inverse CDF,
• X = G−1(U)• Y = F−1(V )
⊲ The distribution C(U, V ) is tricky, this is whatcontrols dependence at the uniform density stage
⊲ C(U, V ) is the copula function
![Page 17: Fin285a:Computer Simulations and Risk Assessment Section 7.2 …people.brandeis.edu/~blebaron/classes/fin285a/_downloads/copulas1.pdf · Overview Fall 2016: LeBaron Fin285a: 7.2-5](https://reader036.vdocuments.us/reader036/viewer/2022071008/5fc5a417c6bc244f8261ce60/html5/thumbnails/17.jpg)
What was the copula?
Fall 2016: LeBaron Fin285a: 7.2-5 list – 17 / 27
F (), G() are marginal CDF’s for X,Y
(U, V ) = (F (X), G(Y )) (7.2.1)
Pr(U ≤ u, V ≤ v) = C(u, v) (7.2.2)
Pr(X ≤ x, Y ≤ y) = C(F (x), G(y)) = H(x, y) (7.2.3)
C() is the copula function and controls the joint distribution.Sklar’s Thm: any multivariate CDF, H(x1, x2, . . . , xd) can be writtenas
H(x1, x2, . . . , xd) = C(F1(x1), F2(x2), . . . , Fd(xd)) (7.2.4)
![Page 18: Fin285a:Computer Simulations and Risk Assessment Section 7.2 …people.brandeis.edu/~blebaron/classes/fin285a/_downloads/copulas1.pdf · Overview Fall 2016: LeBaron Fin285a: 7.2-5](https://reader036.vdocuments.us/reader036/viewer/2022071008/5fc5a417c6bc244f8261ce60/html5/thumbnails/18.jpg)
Picture of the Gaussian Copula
Fall 2016: LeBaron Fin285a: 7.2-5 list – 18 / 27
Uniform World (u, v) (dependence)
Multivariate Normal (Σ)
(w1, w2) → Normal CDF(Φ), u = Φ(w1), v = Φ(w2)
Target Marginal Inverse CDF’s
y = G−1(u)z = F−1(v)
![Page 19: Fin285a:Computer Simulations and Risk Assessment Section 7.2 …people.brandeis.edu/~blebaron/classes/fin285a/_downloads/copulas1.pdf · Overview Fall 2016: LeBaron Fin285a: 7.2-5](https://reader036.vdocuments.us/reader036/viewer/2022071008/5fc5a417c6bc244f8261ce60/html5/thumbnails/19.jpg)
Copula varieties
Fall 2016: LeBaron Fin285a: 7.2-5 list – 19 / 27
⊲ GaussianC(u) = ΦΣ(Φ
−1(u1),Φ−1(u2))
ΦΣ(x) is multivariate Normal CDF, mean zero,,var=1, var/cvar= Σ, Φ(x) is univariate N(0, 1)
⊲ Student-t: Same as Gaussian but student-t CDF⊲ Clayton (Archemedian class)
C(u) = ψ(ψ−1(u1) + ψ−1(u2))ψ(x) = (1 + x)−1/θ
ψ−1(x) = x−θ − 1⊲ Joe⊲ Gumbel
![Page 20: Fin285a:Computer Simulations and Risk Assessment Section 7.2 …people.brandeis.edu/~blebaron/classes/fin285a/_downloads/copulas1.pdf · Overview Fall 2016: LeBaron Fin285a: 7.2-5](https://reader036.vdocuments.us/reader036/viewer/2022071008/5fc5a417c6bc244f8261ce60/html5/thumbnails/20.jpg)
Matlab functions and fittingcopulas
Copula objectives
Copula lesson 1:Generate adistribution
Copula lesson 2:Generate tworandom variables
Copula lesson 3:Empiricaldistributions (data)
Copula details
Matlab functions andfitting copulas
Copula wrap-up
Fall 2016: LeBaron Fin285a: 7.2-5 list – 20 / 27
![Page 21: Fin285a:Computer Simulations and Risk Assessment Section 7.2 …people.brandeis.edu/~blebaron/classes/fin285a/_downloads/copulas1.pdf · Overview Fall 2016: LeBaron Fin285a: 7.2-5](https://reader036.vdocuments.us/reader036/viewer/2022071008/5fc5a417c6bc244f8261ce60/html5/thumbnails/21.jpg)
copulafit and copularnd
Fall 2016: LeBaron Fin285a: 7.2-5 list – 21 / 27
% program = copulaexfit.m
% map returns to uniforms using empirical cdf
eqret = (wldeqp(2:end,2:end)-(wldeqp(1:end-1,2:end)))./...
wldeqp(1:end-1,2:end);
uret(:,1) = empcdf(eqret(:,1),eqret(:,1));
uret(:,2) = empcdf(eqret(:,2),eqret(:,2));
% Fit a gaussian copula
[paramhat] = copulafit(’Gaussian’,uret);
umc = copularnd(’Gaussian’,paramhat,nmc);
% Fit a student-t copula (nu = degrees of freedom)
[paramhat, nu] = copulafit(’t’,uret);
umc = copularnd(’t’,paramhat,nu,nmc);
% Fit a Clayton copula (fatter left tail)
[paramhat] = copulafit(’clayton’,uret);
umc = copularnd(’clayton’,paramhat,nmc);
![Page 22: Fin285a:Computer Simulations and Risk Assessment Section 7.2 …people.brandeis.edu/~blebaron/classes/fin285a/_downloads/copulas1.pdf · Overview Fall 2016: LeBaron Fin285a: 7.2-5](https://reader036.vdocuments.us/reader036/viewer/2022071008/5fc5a417c6bc244f8261ce60/html5/thumbnails/22.jpg)
Matlab implementation
Fall 2016: LeBaron Fin285a: 7.2-5 list – 22 / 27
⊲ matlab: copulaexfit.m⊲ Fit 3 copulas (Clayton, Student-t, Gaussian) to
uniform CDF⊲ Estimate extreme right and left tail probabilities⊲ Estimate VaR (extreme)⊲ Scatter plots
![Page 23: Fin285a:Computer Simulations and Risk Assessment Section 7.2 …people.brandeis.edu/~blebaron/classes/fin285a/_downloads/copulas1.pdf · Overview Fall 2016: LeBaron Fin285a: 7.2-5](https://reader036.vdocuments.us/reader036/viewer/2022071008/5fc5a417c6bc244f8261ce60/html5/thumbnails/23.jpg)
Copula wrap-up
Copula objectives
Copula lesson 1:Generate adistribution
Copula lesson 2:Generate tworandom variables
Copula lesson 3:Empiricaldistributions (data)
Copula details
Matlab functions andfitting copulas
Copula wrap-up
Fall 2016: LeBaron Fin285a: 7.2-5 list – 23 / 27
![Page 24: Fin285a:Computer Simulations and Risk Assessment Section 7.2 …people.brandeis.edu/~blebaron/classes/fin285a/_downloads/copulas1.pdf · Overview Fall 2016: LeBaron Fin285a: 7.2-5](https://reader036.vdocuments.us/reader036/viewer/2022071008/5fc5a417c6bc244f8261ce60/html5/thumbnails/24.jpg)
Advantages
Fall 2016: LeBaron Fin285a: 7.2-5 list – 24 / 27
⊲ Separates problems
• Fitting marginal distribution• Modeling dependence
⊲ May beat the bootstrap for small samples
• Generating joint (x, y) extreme observations• Using actual data as marginals distributions!!
⊲ Key problem: Which copula do you use?
![Page 25: Fin285a:Computer Simulations and Risk Assessment Section 7.2 …people.brandeis.edu/~blebaron/classes/fin285a/_downloads/copulas1.pdf · Overview Fall 2016: LeBaron Fin285a: 7.2-5](https://reader036.vdocuments.us/reader036/viewer/2022071008/5fc5a417c6bc244f8261ce60/html5/thumbnails/25.jpg)
Puzzles in multivariate returns
Fall 2016: LeBaron Fin285a: 7.2-5 list – 25 / 27
⊲ Do correlations change with volatility and risk?⊲ Some think yes
• When volatility is high, correlations are high?• Ability to diversify risk is low
⊲ This gets more complex⊲ Changing copulas⊲ ”Risk on/risk off” behavior
![Page 26: Fin285a:Computer Simulations and Risk Assessment Section 7.2 …people.brandeis.edu/~blebaron/classes/fin285a/_downloads/copulas1.pdf · Overview Fall 2016: LeBaron Fin285a: 7.2-5](https://reader036.vdocuments.us/reader036/viewer/2022071008/5fc5a417c6bc244f8261ce60/html5/thumbnails/26.jpg)
Risk on/risk off
Fall 2016: LeBaron Fin285a: 7.2-5 list – 26 / 27
⊲ Traders appear to correlate in buying and sellingrisky assets
⊲ Statistic: Days where more than 90 percent ofstocks are moving in the same direction
• Up to 2006 this is about 3-5 days per year• 2008-2011 this is above 30 (or about 1/7 (14
percent)trading days)
⊲ Matlab: rollcorr.m
![Page 27: Fin285a:Computer Simulations and Risk Assessment Section 7.2 …people.brandeis.edu/~blebaron/classes/fin285a/_downloads/copulas1.pdf · Overview Fall 2016: LeBaron Fin285a: 7.2-5](https://reader036.vdocuments.us/reader036/viewer/2022071008/5fc5a417c6bc244f8261ce60/html5/thumbnails/27.jpg)
Overview
Fall 2016: LeBaron Fin285a: 7.2-5 list – 27 / 27
Copula objectives
Copula lesson 1: Generate a distribution
Copula lesson 2: Generate two random variables
Copula lesson 3: Empirical distributions (data)
Copula details
Matlab functions and fitting copulas
Copula wrap-up