Serving the Quantitative Finance Community

 
User avatar
MissWawrzyniak
Topic Author
Posts: 0
Joined: October 20th, 2005, 11:34 am

COPULA density with MATLAB

November 3rd, 2005, 10:42 am

Hi!Does anyone have a code to generate the density function of bivariate normal copula?????? I know how to generate distribution of normal copula but how to deal with its density ? Thanks a lotM
 
User avatar
MissWawrzyniak
Topic Author
Posts: 0
Joined: October 20th, 2005, 11:34 am

COPULA density with MATLAB

November 30th, 2005, 2:36 pm

anyone ??? someone ??? do u know how to denerate the density of normal copula ???? very important to methx
 
User avatar
AlanS
Posts: 0
Joined: October 24th, 2003, 1:44 pm

COPULA density with MATLAB

November 30th, 2005, 2:53 pm

You should divide the multivariate density (use mvnpdf) by the product of the marginal densities (use normpdf)
 
User avatar
MissWawrzyniak
Topic Author
Posts: 0
Joined: October 20th, 2005, 11:34 am

COPULA density with MATLAB

November 30th, 2005, 3:15 pm

hmmmmmmm thank you very much. ... but what ??? sorry Im being very dump.I have found the following code to generate the plot of normal copula distribution which I understand. n=500;Z = mvnrnd([0 0], [1 .8; .8 1], n);U = normcdf(Z,0,1); plot(U(:,1),U(:,2),'.');So what you saying is to use Z=mvnpdf([0 0], [1 .8; .8 1],n)and divide this by U1*U2, where U1=U2=normpdf(Z,0,1)??????????? and surf(U1,U2,Z/U1*U2) ??? hmmm I wish I had some brain too.
 
User avatar
AlanS
Posts: 0
Joined: October 24th, 2003, 1:44 pm

COPULA density with MATLAB

November 30th, 2005, 3:30 pm

The code you give is to generate a Monte Carlo sample from the copula, which is a bit different to plotting the density. To plot the density of a bivariate copula with correlation 'rho' on the grid (0.01,0.02,...,.99) * (0.01,0.02,...,.99) use the following code% requires the statistics toolbox for the functions norminv.m and mvnpdf.mp=zeros(99,99);u=0.01:0.01:0.99;for i = 1:99 for j = 1:99 x1 = norminv(u(i)); x2 = norminv(u(j)); p(i,j) = mvnpdf([x1 x2],[0 0],[1 rho; rho 1])/normpdf(x1)/normpdf(x2); endendsurf(u,u,p)figure, contour(u,u,p)
 
User avatar
MissWawrzyniak
Topic Author
Posts: 0
Joined: October 20th, 2005, 11:34 am

COPULA density with MATLAB

November 30th, 2005, 3:52 pm

yeahhh it works !!!! THANKS THANKS THANKS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!omg thats fantastic! THANKSSSSSSSSSSSSSSSSSSSSSSSSSSS
 
User avatar
MissWawrzyniak
Topic Author
Posts: 0
Joined: October 20th, 2005, 11:34 am

COPULA density with MATLAB

November 30th, 2005, 3:52 pm

%%double post
Last edited by MissWawrzyniak on November 29th, 2005, 11:00 pm, edited 1 time in total.