# Fitting a copula with Poisson marginals to data in R

First off, I know this is a question which requires an thorough answer, so I am coming here with a very humble attitude. I have limited knowledge about both copulas and R, so I will try to explain what I know and what my thoughts are:

I have a data set of n observations of $(X,Y)$, two correlated Poisson random variables, which comes in "set" - that is - I observe $(X_1,Y_1), (X_2,Y_2),...,(X_n,Y_n)$. I have read about using discrete marginals with copulas in:

http://www.actuaries.org/LIBRARY/ASTIN/vol37no2/475.pdf

and I realize it can be troublesome using Poisson marginals. I have to admit that I did not understand too much of the above article, but nevertheless I hope I am able to describe the joint distribution of $(X,Y)$ using some copula.

I understand that different copulas model different type of dependence, such as tail dependence and such. But this is not what I am looking for. For my data, it seems that X follows Y, and vice verca - so it seems like we have strong dependence on the "straight line".

I found the following about fitting copulas to data:

    library(copula)

## Toy example for gumbel copula with log-normal distribution
## (Taken from the documentation of copula::fitMvdc)

## Specify the copula
gumbel.cop <- gumbelCopula(3, dim=2)
myMvd <- mvdc(gumbel.cop, c("lnorm","lnorm"), list(list(meanlog = 1.17),
list(meanlog = 0.76)))
## Generate some random sample to test
x <- rmvdc(myMvd, 1000)

## Fit the random sample
fit <- fitMvdc(x, myMvd, c(1,1,2))
fit


Now, first of all this uses a gumbel copula. Could there be some other copula better fitting what I am looking for? I am curious to how 'the experts' choose which copula to work with. For example, if we are looking at financial data with strong tail dependence, it seems obvious, but for other 'types' of dependence, I am not sure if I understand the copula choice.

From the above code in R, could I just replace "lnorm" with "name of poisson distribution", and what would this name be? I cannot seem to find a list of names of the marginals.

Also, the above code generated data. I have my own data.

I know I am asking a lot here, but this is all a bit overwhelming to me...

## 1 Answer

There are already many different copulas implemented in the R-package copula, but you will find more in other packages as well (e.g. VineCopula or spcopula (r-forge)). In several published papers you will find even more. Thus, there might be a better choice for your data at hand. However, without knowing your specific data set it is impossible to give a general advise. Using the above R packages, I composed a small shiny application that allows to interactively explore different copula families: copulatheque. This tool might be helpful to get an idea of the variety of copulas available in the above packages.

The choice of the family could be a model driven one based on for instance the need of being able to include upper or lower tail dependence or symmetry properties. To decide which family fits your data best, one can in general rely on well known tools such as log-likelihood, AIC, BIC, ... . A visual entry point is to look at scatterplots of the rank transformed data or smoothed versions thereof. Unfortunately, the discrete case is a bit harder to handle than the continuous one. I find the paper you quoted above a good entry point in the discrete world (and references therein), but you might want to backup your knowledge by some more background reading on copulas (see e.g. this thread). Copulas are a very powerful tool, but they are as well very easy to mess around with.

In terms of R-code, I would suggest to use the "rCopula" method (of the copula package) to generate samples on the copula scale and then provide these to your favourite inverse cumulative distribution function of the margins. The VineCopula package offers a function "BiCopSelect" that walks through a list of copula families, fits a copula for each family and compares the AIC or BIC. Once you made a sensitive choice of appropriate copula family candidates, this is a very helpful tool.