In statistics, the real relation among random variables can only be captured by their joint distribution thoroughly. Other methods like person’s correlation \(\rho\), spearman’s rank \(\rho\),or even kendall’s \(\tau\), all just provide the numerical value to measure,to percieve by our mind, the real relationship lies in joint distribution.
\[F(x_1,x_2,...,x_n)\]
In finance,multiple assets are assumed to have correaltions,strong or weak, they always exhibit correlation as they are in a some system of man’s economical activities.But how to detect these correlation and measure they so we can harness them in the prediction of price and value movement is a big question.
Every single asset can be assumed to have a return follows normal distribution \(N(\mu,\sigma)\),or student t distribution \(t(n)\).However,when it comes to investment,diversification is always prefered and people would hold portfolios consisted of several different instruments.What is the distribution of the portofolio now? One can use weighted average and variance to estimate the parameter. But the joint distribution remains unknown. Or one could use the known marginal distribution of single assets and produce a joint distribtion. That how copula comes in.
For any Joint Distribution \(H(x_1,x_2,...,x_d)=P(X_1<=x1,X_2<=x_2,....X_d<=x_d)\),
and their marginal distribution \(F_i(x_i)=P(X_i<=x_i)\),
their exist a unique copula function C that \(C(F_1(x_1),F_2(x_2),..,F_n(x_n))=H(x_1,x_2,...,x_d)\),
which exactly is the multivariate distribution. As is the same with all cumulative distributions,the following conditions are always true:
1. \(C(1,1,...,u_i,1,...1)=u_i\)
2. \(C(u_1,u_2,...,0,..u_n)=0\)
The most commonly used copula is the elliptical copula,which includes Gaussian copula and t copula.During the financial crisis in 2008,most of the MBS products are bundled together and use a simple Gaussian copula to estimate the distribution and calculating Value at Risk,which is totally wrong.
-Gaussian copula
\(C(\Phi_1(x_1),\Phi_2(x_2),...,\Phi_n(x_n);\Sigma)=\Phi_{\Sigma}(x_1,x_2,...,x_n)\)
-Student copula
\(C_t(u_1,u_2,..,u_n;\Sigma;d.f.)=T(T^{-1}(u_1),T^{-1}(u_2),..,T^{-1}(u_n))\)
use R is convinient since the package is already available
R “copula” package can be used to model copulas. It create two objects, copula object and the multivarite normal object.
library("copula")
library("scatterplot3d")
2-D copula and bivariate normal object.
mycop<-normalCopula(c(0.77),dim=2,dispstr="ex")
mymvd<-mvdc(copula=mycop,margins =c("norm","norm"),paramMargins=list(list(mean=0,sd=1),list(mean=1,2)))
0.77 is the correlation between the two variable,dispstr is the type of correlation matirx,“ex” is the simplest one that is only the power of 0.77 inresponce to the distance of index of \(x_i\) and \(x_j\),which is \(|i-j|\).
Generating 1000 random number from the multivariate distribution.
r<-rMvdc(1000,mymvd)
calculate the density and cumulative distribution.
dens<-dMvdc(r,mymvd)
dist<-pMvdc(r,mymvd)
visulize them.
x<-r[,1]
y<-r[,2]
scatterplot3d(x,y,dens,highlight.3d = T)
scatterplot3d(x,y,dist,highlight.3d = T)
The copula function can also be visualized,it will be this look.
u<-rCopula(1000,mycop)
a<-u[,1]
b<-u[,2]
copdens<-dCopula(u,mycop)
copdist<-pCopula(u,mycop)
scatterplot3d(a,b,copdens,highlight.3d = T)
scatterplot3d(a,b,copdist,highlight.3d = T)
Looks magnificant, aren’t they? :)
So copula can be used to form a joint distribution and calculate VaR , because it is a distribution. That all for my log here.The rest of the material is huge and can not be covered here,you can try some here at CRAN[https://cran.r-project.org/web/packages/copula/copula.pdf]