Here is the PowerPoint presentation

advertisement
Copulas and their Applications
Outline
Introduction
Application of Gaussian copula
Simulation techniques
Application in Finance
Fitting with real life data
Introduction
Motivation
Normal distributions are not normal!!!
Linear correlation is not suitable
Multinormal distribution is inappropriate.
Empirical evidence in Finance :
Marginal distributions are skewed and heavy-tailed (Mandelbrot (1963),
Fama (1965), Bouchaud, Sornette, and Potters (1997), Danielsson and de
Vries (1997)).
B.B. Mandelbrot. The variation of certain speculative prices. Journal Of Business, 36:392{417, 1963
E.F. Fama. The behavior of stock market prices. Journal of Business, 38(1):34{105, 1965.
Bouchaud,J. P., D. Sornette, and M. Potters (1997): Option Pricing in the Presence of Extreme Fluctuations, in Mathematics of Derivative Securities , eds. M. A. H.
Dempster and S. Pliska. New York: Cambridge University Press.
Danielsson , J. , and C. G. De Vries (1997): Tail Index and Quantile Estimation with Very High Frequency Data, Working paper, Tinbergen Insitute, Rotterdam, The
Netherlands.
Introduction
Why copula?
Separation of dependence from marginal distributions (Sklar’s
Theorem, 1959)
Scale-free measure of dependence vs. traditional linear
dependence (Fisher, 1997)
Total dependence vs. pairwise dependence
Useful for joint outcomes
Fisher, N. I. 1997. Copulas. Encyclopedia of Statistical Sciences. 2.
Sklar, A. (1959), Fonctions de répartition à n dimensions et leurs marges, Publ. Inst. Statist. Univ. Paris 8: 229–231
Introduction
What is copula?
MV to 1-d marginal DF. (Nelsen,1999))
MV DF on [0,1]n , with uniformly distributed marginals
(Embrechts, Lindskog, & McNeil, 2003).
Embrechts, P., Lindskog, F., & McNeil, A. 2003. Modelling dependence with copulas and applications to risk management. Handbook of heavy tailed
distributions in finance, 8(1), 329-384.
Nelsen, R. B. (1999). An introduction to copulas. Springer.
Introduction
What is Copula?
Graphical Demonstration*

F2(y)
(1,1)
(x, y)
H(x, y)
(0,0)
F1(x)
* This concept is taken from: A Brief Introduction to Copulas, Speaker: Hua, Lei, February 24, 2009, Department of Statistics, University of British Columbia.
Introduction
What is Copula?
Graphical Demonstration*
F2(y)
(1,1)
Copula
(x, y)
(0,0)
H(x, y)
F1(x)
Copula: Mapping (assigns value) of joint distribution
function to each pair (x,y).
* This concept is taken from: A Brief Introduction to Copulas, Speaker: Hua, Lei, February 24, 2009, Department of Statistics, University of British Columbia.
Application of Gaussian Copula
1. Two correlated random variables
2. Easy way: generate MV Gaussian distribution
Problem: Normally distributed
3. Marginal distributions with correlation
4. Possible way:
A. Generate variables from correlated Gaussian distribution
B. Transform into uniform distributions
C. Transform again into desired marginal distributions
Application of Gaussian Copula
A. Generate variables from correlated Gaussian distribution
require(mvtnorm)
S <- matrix(c(1,.8,.8,1),2,2)
#Correlation matrix
A <- rmvnorm(mean=c(0,0), sig=S,
n=1000) #Our Gaussian variables
R –code for this part has been taken from http://www.r-bloggers.com/copulas-made-easy/
with a little modification
Application of Gaussian Copula
B. Transform into uniform distributions
require(mvtnorm)
S <- matrix(c(1,.8,.8,1),2,2)
#Correlation matrix
A <- rmvnorm(mean=c(0,0), sig=S,
n=1000) #Our gaussian variables
U <- pnorm(A) #Now U is uniform
hist(U[,1])
R –code for this part has been taken from http://www.r-bloggers.com/copulas-made-easy/
with a little modification
Application of Gaussian Copula
B. Transform into uniform distributions
require(mvtnorm)
S <- matrix(c(1,.8,.8,1),2,2)
#Correlation matrix
A <- rmvnorm(mean=c(0,0), sig=S,
n=1000) #Our gaussian variables
U <- pnorm(A) #Now U is uniform
hist(U[,2])
R –code for this part has been taken from http://www.r-bloggers.com/copulas-made-easy/
with a little modification
Application of Gaussian Copula
C. Transform again into desired marginal distributions
 require(mvtnorm)
 S <- matrix(c(1,.8,.8,1),2,2) #Correlation
matrix
 A <- rmvnorm(mean=c(0,0),sig=S,n=1000)
#Our gaussian variables
 U <- pnorm(A) #Now U is uniform
 x <- qchisq(U[,1],10) #x is chi-sq distributed
 y <- qbeta(U[,2],1,2) #y is beta distributed
 plot(x,y) #They correlate!
R –code for this part has been taken from http://www.r-bloggers.com/copulas-made-easy/
with a little modification
Simulation Technique
Gaussian Copula
2 variables
 P = matrix(c(1, 0.5, 0.5, 1), nrow = 2) ## Correlation
matrix
 d = nrow(P)
# Dimension
 n = 300
# Number of samples
 ## Simulation
 A = t(chol(P))
 U = matrix(nrow = n, ncol = d)
 for (i in 1:n){

Z
= rnorm(d)

X
= A%*%Z

U[i, ] = pnorm(X)}
 plot(U)
# Graph
Code source: http://stats.stackexchange.com/questions/37424/how-to-simulate-from-agaussian-copula
Simulation Technique
Gaussian Copula
3 variables











P = matrix(c(1, 0.1, 0.9, 0.1, 1, 0.5, 0.9, 0.5, 1), nrow = 3)
d = nrow(P)
# Dimension
n = 300
# Number of samples
## Simulation
A = t(chol(P))
U = matrix(nrow = n, ncol = d)
for (i in 1:n){
Z
= rnorm(d)
X
= A%*%Z
U[i, ] = pnorm(X)}
pairs(U)
# Graph
Code source: http://stats.stackexchange.com/questions/37424/how-to-simulate-from-agaussian-copula
Application in Finance
VaR calculations
Consider individual asset return’s dependence structure
Linear correlation is no longer meaningful
Mostly measured by tail dependence (Schmidt, 2004).
Tail dependence coefficients calculation is easy for Gaussian
copulas
Schmidt, R. (2004). Tail dependence, in P. Cizek, W. Härdle, R. Weron (eds.) Statistical Tools for Finance and Insurance, Springer.
Application in Finance
VaR Calculation using MC: Conventional vs. Copula
Creating MV normal and fat-tailed distributions
 require(copula)
 require(mvtnorm)
 ## Creating Mulativariate normal distributions
 set.seed(3)
 sigma = matrix(c(1,0.1,0.1,1), ncol=2)
 ret = rmvnorm(n=10000, mean=c(0,0), sigma=sigma)
 ## Creating non-normal fat-tailed distributions
 U = pnorm(ret) #Now U is uniform
 m = qcauchy(U[,1]) #x is Cauchy distributed
 n = qcauchy(U[,2]) #y is Cauchy distributed
 nret=cbind(m,n)
Application in Finance
VaR Calculation using MC: Conventional vs. Copula
Conventional VaR calculation for MVN Distribution
 mu1=apply(ret,2,mean)
 sigma1=cov(ret)
 rep1=list("vector",1)
5% VaR = -1.43
 for (i in 1:1)
 {rep1[[i]]=rmvnorm(10000,mu1,sigma1)}
 rep1 <- rep1[[1]]
 p_ret1<- apply(rep1, 1, function(x) return(sum(x * c(0.5, 0.5)))) #
simulated portfolio return
 quantile(p_ret1, 0.05) #, type = 3) # your Portfolio VaR (95%)
A basic structure of Copula simulation can be found at: http://r.789695.n4.nabble.com/Monte-Carlo-simulation-for-VaR-estimation-td4082611.html
Application in Finance
VaR Calculation using MC: Conventional vs. Copula
Copula VaR calculation for MVN Distribution
 cdata1=pobs(ret)
5% VaR = -1.39
 fg1 = fitCopula(copula=normalCopula(), data=cdata1)
 rcop1 = rCopula(copula=normalCopula(fg1@estimate), n=10000)
 fcop1 = qnorm(rcop1)
 p_ret3= apply(fcop1, 1, function(x) return(sum(x * c(0.5, 0.5)))) #
simulated portfolio return
 quantile(p_ret3, 0.05) # Portfolio VaR (95%)
Application in Finance
VaR Calculation using MC: Conventional vs. Copula
Conventional VaR calculation for Non-normal Distribution
 mu2=apply(nret,2,mean)
 sigma2=cov(nret)
 rep2=list("vector",1)
5% VaR = -466.59
 for (i in 1:1)
 {rep2[[i]]<-rmvnorm(10000,mu2,sigma2)}
 rep2 = rep2[[1]]
 p_ret2= apply(rep2, 1, function(x) return(sum(x * c(0.5, 0.5)))) #
simulated portfolio return
 quantile(p_ret2, 0.05) # Portfolio VaR (95%)
Application in Finance
VaR Calculation using MC: Conventional vs. Copula
Copula VaR calculation for Non-normal Distribution
 cdata2=pobs(nret)
5% VaR = -1.41
 fg2 = fitCopula(copula=normalCopula(), data=cdata2)
 rcop2 = rCopula(copula=normalCopula(fg2@estimate),
n=10000)
 fcop2 = qnorm(rcop2)
 p_ret4= apply(fcop2, 1, function(x) return(sum(x * c(0.5, 0.5))))
# simulated portfolio return
 quantile(p_ret4, 0.05) # Portfolio VaR (95%)
Fitting with Real Life Data
The forecast errors data set
Gumbel Distribution
 Extreme value type I
 Smallest extreme and largest extreme.
Source: Wikipedia
Fitting with Real Life Data
The forecast errors data set
 library(mvnmle)
 library(copula)
 error=read.csv("http://courses.ttu.edu/isqs6348westfall/CSV/errors.csv")
 er=as.matrix(error[,2:3])
 #Fitting with Gumbel Copula*
 mu1=mean(er[,1]); mu2=mean(er[,2])
 sd1=sd(er[,1]); sd2=sd(er[,2])
 gmb=gumbelCopula(4,dim=2)
 myCDF = mvdc(gmb, margins=c("norm","norm"),
 paramMargins=list(list(mean=mu1,sd=sd1),list(mea
n=mu2,sd=sd2)))
 fit <- fitMvdc(er, myCDF, start= c(4,1,2,3,4))
 fit
* Craighead , Steve.(2010) R CORNER: A TOY COPULA ERM MODEL IN R. Society
for Actuaries. July 2010. Issue 36.







# Get the parameter value
b1hat=2.00032*sqrt(6)/pi
b2hat=1.9795*sqrt(6)/pi
mu1hat=0.06469-b1hat*0.5772
mu2hat=0.4219-b2hat*0.5772
E<-pobs(er)
sigma=cor(qnorm(E))




## Creating Mulativariate normal distributions
Z = rmvnorm(n=1000, mean=c(0,0), sigma=sigma)
# Creating uniform distribution
U = pnorm(Z)







# Transforming to Gumbel distribution
Y1=qgumbel(U[,1], mu=mu1hat, sigma=b1hat)
Y2=qgumbel(U[,2], mu=mu2hat, sigma=b2hat)
Y=cbind(Y1, Y2)
cor(Y); cor(er)
summary(Y); summary(er)
plot(Y); plot(er)
Fitting with Real Life Data: Comparison
The forecast errors data set
Gumbel Copula Estimation vs. Regular Statistics
Gumbel Copula
Regular
Mean of E1
0.03166
0.0107
Mean of E2
0.38944
0.3994
Correlation
0.9880363
0.9870216
Covariance Matrix:
Gumbel
Y1
Y2
Y1
Y2
3.947473 3.875008
3.875008 3.896550
Regular
E1
E2
E1
E2
3.142011 3.149591
3.149591 3.240764
Fitting with Real Life Data: Comparison
The forecast errors data set
Plot of Regular vs. Gumbel Copula
Download