From: Florian on
Dear all,
I would like to make surf and contour plots of bivariate copulas and have some problems with it since I do not know what the correct input data for these functions is. I have financial returns data of different assets, each with more than 1000 data points and have already estimated the copula parameters that fit the data. I am using the copulapdf and copulacdf functions provided in the statistics toolbox. For example, the description of copulapdf in the help browser is as follows:

Y = copulapdf('Gaussian',U,rho) returns the probability density of the Gaussian copula with linear correlation parameters rho, evaluated at the points in U. U is an n-by-p matrix of values in [0,1], representing n points in the p-dimensional unit hypercube. rho is a p-by-p correlation matrix. If U is an n-by-2 matrix, rho may also be a scalar correlation coefficient.

Nevertheless, I do not know what to put in for U. I thought it was the empirical cdf of my data but with more than 1000 data points, the graphs that result seem quite unreasonable to me.

Any help is appreciated,
Flo
From: Peter Perkins on
On 5/18/2010 1:15 PM, Florian wrote:
> I have financial returns data of different
> assets, each with more than 1000 data points and have already estimated
> the copula parameters that fit the data. I am using the copulapdf and
> copulacdf functions provided in the statistics toolbox.

> Nevertheless, I do not know what to put in for U. I thought it was the
> empirical cdf of my data but with more than 1000 data points, the graphs
> that result seem quite unreasonable to me.

Flo, there is such a thing as an empirical CDF for bivariate data, and
HIST3 is something like an empirical pdf, but it sounds more like you're
asking for the cdf and pdf of the fitted copula. There are examples of
this in the Statistics Toolbox User Guide on this page:

<http://www.mathworks.com/access/helpdesk/help/toolbox/stats/brklrj3.html#bqttfgl-1>

In short, you need to create a grid of points over the unit square,
compute the pdf/cdf at those points for your fitted copula, and pass all
that to SURF. Of course, this is on the copula scale, not on the scale
of your original data. To get the latter, you'd have to transform the
pdf and cdf values.

Hope this helps.

From: Florian on
Peter Perkins <Peter.Perkins(a)MathRemoveThisWorks.com> wrote in message <hsuivl$63$1(a)fred.mathworks.com>...
> On 5/18/2010 1:15 PM, Florian wrote:
> > I have financial returns data of different
> > assets, each with more than 1000 data points and have already estimated
> > the copula parameters that fit the data. I am using the copulapdf and
> > copulacdf functions provided in the statistics toolbox.
>
> > Nevertheless, I do not know what to put in for U. I thought it was the
> > empirical cdf of my data but with more than 1000 data points, the graphs
> > that result seem quite unreasonable to me.
>
> Flo, there is such a thing as an empirical CDF for bivariate data, and
> HIST3 is something like an empirical pdf, but it sounds more like you're
> asking for the cdf and pdf of the fitted copula. There are examples of
> this in the Statistics Toolbox User Guide on this page:
>
> <http://www.mathworks.com/access/helpdesk/help/toolbox/stats/brklrj3.html#bqttfgl-1>
>
> In short, you need to create a grid of points over the unit square,
> compute the pdf/cdf at those points for your fitted copula, and pass all
> that to SURF. Of course, this is on the copula scale, not on the scale
> of your original data. To get the latter, you'd have to transform the
> pdf and cdf values.
>
> Hope this helps.


Thank you very much for the answer. Nevertheless, the more points I grid over the unit square, the higher get the values of the copulapdf on the z axis. So I am wondering if there is a correct number of points the grid should have. Or is the interpretation of the copula the same, regardless of the absolute values on the z axis?
From: Peter Perkins on
On 5/18/2010 3:25 PM, Florian wrote:
> Thank you very much for the answer. Nevertheless, the more points I grid
> over the unit square, the higher get the values of the copulapdf on the
> z axis.

That seems unlikely, but perhaps I am just misunderstanding what you are
saying. I can only direct you to that code in the documentation. If
that doesn't do what you need, you are going to have to be more specific
about what you're doing.

The code I am referring to is this:

u1 = linspace(1e-3,1-1e-3,50);
u2 = linspace(1e-3,1-1e-3,50);
[U1,U2] = meshgrid(u1,u2);
Rho = [1 .8; .8 1];
f = copulapdf('t',[U1(:) U2(:)],Rho,5);
f = reshape(f,size(U1));

surf(u1,u2,log(f),'FaceColor','interp','EdgeColor','none')
view([-15,20])
xlabel('U1')
ylabel('U2')
zlabel('Probability Density')


and a similar chunk for the CDF.
From: p8poulomi on
On May 19, 5:52 pm, Peter Perkins
<Peter.Perk...(a)MathRemoveThisWorks.com> wrote:
> On 5/18/2010 3:25 PM, Florian wrote:
>
> > Thank you very much for the answer. Nevertheless, the more points I grid
> > over the unit square, the higher get the values of the copulapdf on the
> > z axis.
>
> That seems unlikely, but perhaps I am just misunderstanding what you are
> saying.  I can only direct you to that code in the documentation.  If
> that doesn't do what you need, you are going to have to be more specific
> about what you're doing.
>
> The code I am referring to is this:
>
> u1 = linspace(1e-3,1-1e-3,50);
> u2 = linspace(1e-3,1-1e-3,50);
> [U1,U2] = meshgrid(u1,u2);
> Rho = [1 .8; .8 1];
> f = copulapdf('t',[U1(:) U2(:)],Rho,5);
> f = reshape(f,size(U1));
>
> surf(u1,u2,log(f),'FaceColor','interp','EdgeColor','none')
> view([-15,20])
> xlabel('U1')
> ylabel('U2')
> zlabel('Probability Density')
>
> and a similar chunk for the CDF.

Dear all,

I need to plot bivariate copula density contour at 0.05 probability
level increment for Clayton, Gumbel, and Frank copula. Then I need to
superimpose these contour plot with scatter plot of original data,
i.e., u1 and u2. Can anybody pls. guide me in what way I can do it? I
went through the code given in Patton's toolbox for contour plotting
but they did it for normal marginals. but in my case both the
marginals are non-parametric Gaussian kernel. Hoping to get reply soon.