1 / 25

Copulas and their Applications

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

anne-lott
Télécharger la présentation

Copulas and their Applications

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Copulas and their Applications

  2. Outline • Introduction • Application of Gaussian copula • Simulation techniques • Application in Finance • Fitting with real life data

  3. IntroductionMotivation • 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.

  4. IntroductionWhy 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

  5. IntroductionWhat 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.

  6. IntroductionWhat 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.

  7. IntroductionWhat is Copula? Graphical Demonstration* F2(y) (1,1) • Copula: Mapping (assigns value) of joint distribution function to each pair (x,y). Copula (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.

  8. 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

  9. Application of Gaussian CopulaA. 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

  10. Application of Gaussian CopulaB. 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 gaussianvariables • 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

  11. Application of Gaussian CopulaB. 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 gaussianvariables • 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

  12. Application of Gaussian CopulaC. 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 gaussianvariables • 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

  13. Simulation TechniqueGaussian Copula2 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-a-gaussian-copula

  14. Simulation TechniqueGaussian Copula3 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-a-gaussian-copula

  15. Application in Finance • VaRcalculations • 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.

  16. Application in FinanceVaR Calculation using MC: Conventional vs. CopulaCreating 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)

  17. Application in FinanceVaR Calculation using MC: Conventional vs. CopulaConventional VaRcalculation for MVN Distribution • mu1=apply(ret,2,mean) • sigma1=cov(ret) • rep1=list("vector",1) • 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%) 5% VaR = -1.43 A basic structure of Copula simulation can be found at: http://r.789695.n4.nabble.com/Monte-Carlo-simulation-for-VaR-estimation-td4082611.html

  18. Application in FinanceVaR Calculation using MC: Conventional vs. CopulaCopulaVaRcalculation for MVN Distribution • cdata1=pobs(ret) • 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%) 5% VaR = -1.39

  19. Application in FinanceVaR Calculation using MC: Conventional vs. CopulaConventional VaRcalculation for Non-normal Distribution • mu2=apply(nret,2,mean) • sigma2=cov(nret) • rep2=list("vector",1) • 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%) 5% VaR = -466.59

  20. Application in FinanceVaR Calculation using MC: Conventional vs. CopulaCopulaVaRcalculation for Non-normal Distribution • cdata2=pobs(nret) • 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%) 5% VaR = -1.41

  21. Fitting with Real Life DataThe forecast errors data set

  22. Gumbel Distribution • Extreme value type I • Smallest extreme and largest extreme. Source: Wikipedia

  23. Fitting with Real Life DataThe forecast errors data set • # 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) • library(mvnmle) • library(copula) • error=read.csv("http://courses.ttu.edu/isqs6348-westfall/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(mean=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.

  24. Fitting with Real Life Data: ComparisonThe forecast errors data setGumbel Copula Estimation vs. Regular Statistics Covariance Matrix: Gumbel Regular

  25. Fitting with Real Life Data: ComparisonThe forecast errors data setPlot of Regular vs. Gumbel Copula

More Related