3
$\begingroup$

So I have got a data set with 3 variables. Using the function C.n(u,pobs(data)), where u is a matrix containing uniform distributed random variables of dimension 3 and the same length as the data set.

However, C.n returns a list of numbers in [0,1] of only one dimension. How can I use this list to generate new data, in three dimensions?

$\endgroup$

2 Answers 2

3
$\begingroup$

Looking at the copula package's documentation, there doesn't seem to be a way to generate samples from empirical copulas. The R function that is used typically for this purpose is rCopula(), which requires a copula object datatype.

The following paper describes how to generate random samples from empirical copulas: http://www.informs-sim.org/wsc07papers/058.pdf, and this in-fact requires the empirical copula density.

If you want to stick w/ R, then I suppose you have two options:

  1. Create an empirical copula object and follow the API that the copula package requires.
  2. Implement this method described in the linked paper above, and use the built-in functionality of R to generate empirical copula densities.

If you are open to using other software packages, I have written some tools in Matlab to do this (they might work in Octave also, but I haven't tested that functionality). All the code lives in this toolbox here: Copula Matlab Toolbox

Specifically, the function you will need to call to generate random pseudo-observations from an empirical copula is empcopularnd. This function implements the method described in the paper above, and requires an empirical copula density as it's input. To generate empirical copula densities, you can use the function empcopulapdf. An example of how to put all of this together (generate empirical density and draw pseudo-samples from the density) is in the test-script test_empcopularnd.

The functions written above should work for any dimensionality, but obviously as your data grows in dimensionality the code will be slower. To speed it up, you may consider compiling the mex file empcopulapdf_c. If you do end up using this code, please PM me if you have any questions!

$\endgroup$
3
$\begingroup$

This functionality is available in the latest version on R-Forge and will be available on CRAN when 0.999-20 is released to CRAN. You can install the latest version via from R-forge via install.packages("copula", repos = "http://R-Forge.R-project.org"). It provides the rCopula method for objects of class empCopula which you should work with. I won't post code here as you find that on the help page of empCopula, so ?empCopula. Note that sampling from an empirical distribution function such as an empirical copula is merely just randomly picking from the observations on which your empirical distribution is built (this can also be shown mathematically).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.