How to define a new copula distribution family

The function CopulaDistribution can be used with the most well known kernels. I was wondering how I can add a new family of kernels in a way that it works in the same way as the current function. For example as the documentation explains:

CopulaDistribution can be used with such functions as Mean, PDF, and RandomVariate, etc.

Do I need to define all these functions myself or is there a smart way of using the functions which are already defined in Mathematica?

I wonder if anyone has done something similar and would like to share his/her experience on this.

-
@Szabolcs. Thanks for editing my question. I guess I need to read this page (mathematica.stackexchange.com/editing-help#comment-formatting)? –  Mikael Anderson Feb 12 '12 at 13:26
You can read the guide here, but I myself prefer using the editor toolbar when I can, or keyboard shortcuts (the shortcuts are shown in button tooltips, e.g. selecting a piece of text then pressing ctrl-k to format as code is what I use most often) –  Szabolcs Feb 12 '12 at 14:03
Could you maybe give a concrete example of what you want to do? –  Ｊ. Ｍ. Feb 12 '12 at 14:38

2 Answers

The function ProbabilityDistribution allows you to define your own distribution functions that can be used with all distribution-related functions. The following example is from the documentation.

Define a custom probability distribution giving its pdf:

  dD = ProbabilityDistribution[ Piecewise[{{x^2/9, 0 < x <= 3}}], {x, -\[Infinity], \[Infinity]}];


Then you can use the built-in functions CDF, Mean etc with it just like any other built-in distribution function. For example:

  CDF[dD,x]


gives:

Documentation also contains examples of how construct your own multivariate distributions. There are no specific examples of custom copulas in the documentation but the same principle should apply: you need to use ProbabilityDistribution to define such things in order to be able to use built-in function like CDF, PDF, RandomVariate... with them.

-
thanks I appreciate your point that I can use ProbabilityDistribution to define a new multivariate distribution. However, as far as I can see now, it would not be straightforward to construct new multivariate distributions by changing the marginals (as one can do with CopulaDistribution) for that distribution unless one use functions like TransformedDistribution or alike. Is that right? –  Mikael Anderson Feb 12 '12 at 13:13
@Mikael, you are right; and that's the essential "beauty" of the copula approach/representation. The built-in CopulaDistribution function works with built-in kernels listed in the More Information section; there is not documented mechanism to cosntruct your own kernel and use it as the first argument of the CopulaDistribution function. If these standard copulas are not sufficient for your needs, then you need to use ProbabilityDistribution. Regarding TransformedDistribution I am not sure it allows you to specify the marginal distributions and the copula kernel separately. –  kguler Feb 12 '12 at 13:48
@Mikael, bumped into two related questions in SO: this and this ; and Sasha's answers to both might apply for the case of defining custom copula kernels too. –  kguler Feb 12 '12 at 16:03
... also in response to a different question in SO, Sjoerd mentions that RandomVariate does not work with custom multivariate distributions created via ProbabilityDistribution. –  kguler Feb 12 '12 at 16:13
Many thanks @kguler indeed for very useful links. Regarding TransformedDistributionI should clarify that I was thinking one could transform the marginal distribution of say X from uniform to an arbitrary distribution, say G, by considering the distribution of G(X) using TransformedDistribution. –  Mikael Anderson Feb 12 '12 at 16:36

The following page contains some tips on enabling custom distributions (i.e. written from scratch without TransformedDisribution or ProbabilityDistribution) for use in CopulaDistribution, RandomVariate, etc: Efficient Generation of Random Variates from a Copula Distribution

-