5
$\begingroup$

I have managed to fit different kinds of copulas to my data in R (mostly Archimedean copulas) using the copula package.

I have no problem simulating pseudo observations (u and v), my questions are:

1) how can I convert these simulated data into values of the random variables I am trying to model? From what I get from Sklar's theorem I should use the inverse of the cdf, is it correct?

2) Assuming I am right in 1), another problem is I do not know which is the right inverse cdf to use, as a first approximation I can assume x and y are normally distributed (which is not entirely true due to fat tails), can't I?

Here is my code:

library(copula)

x <- read.table("x.txt")
y <- read.table("y.txt")

mat <- matrix(nrow=100,ncol=2)

for(i in 1:100)
{
    mat[i,1] <- x[,1][i]
    mat[i,2] <- y[,1][i]
}

#Actual observations
plot(mat[,1],mat[,2],main="Returns",xlab="x",ylab="y",col="blue")

#Copula fitting
normal.cop <- normalCopula(dim=2)
fit.cop<- fitCopula(normal.cop,pobs(mat),method="ml")

#Coefficients
rho <- coef(fit.cop)
print(rho)

#Simulate data
u1 = rCopula(500,normalCopula(coef(fit.cop),dim=2))
points(u1[,1],u1[,2],col="red")

EDIT: Here you can find the data for x and y should you need them to run the code. https://www.dropbox.com/s/unxj0wgd7t2b0cc/dataset.zip?dl=0

x and y are returns from two stocks

$\endgroup$
1
  • $\begingroup$ To be clearer, the code above works perfectly, however once I simulated the pseudo observations I am not sure on how to proceed to gather the "real" observations (x and y simulated returns) from the u1 vector of pseudo observations $\endgroup$
    – mickkk
    Feb 10, 2015 at 11:47

1 Answer 1

3
$\begingroup$

From what I understand of your code, essentially all that comes from the underlying stock return data is the value of Rho, aka the correlation between the two returns.

Then you use that to generate a bunch of correlated observations using the normal copula.

The output from that is indeed values from [0,1] with the same dependence structure as initially specified, rho.

To get back to actual values of X and Y I think you need to make some distributional assumptions about X and Y. Then input u1 into each of their inverse marginal distribution functions to get back to the actual return values.

As to what distribution to use, maybe try and fit a student-t visually to the returns data for each stock you already have by varying degrees of freedom used.

$\endgroup$
7
  • 1
    $\begingroup$ Ok! Then, for instance, assuming returns are normally distributed, in order to get back X and Y I should use the inverse of the cumulative normal distribution right? $\endgroup$
    – mickkk
    Feb 10, 2015 at 17:05
  • $\begingroup$ Yes. In R for each new vector of u1[,1] and u1[,2] you can use qnorm() or qt( ,df=degreesOfFreedom), the quantile / inverse function of the normal and student-t respectively. $\endgroup$
    – Henry E
    Feb 11, 2015 at 6:53
  • 1
    $\begingroup$ Thanks now I thing I,ve got it, somehow this part is not always very clear in the documentation $\endgroup$
    – mickkk
    Feb 11, 2015 at 8:22
  • $\begingroup$ I've come up with another doubt: when using qnorm, for instance, my understanding of the process would told me to feed into qnorm the mean and standard deviation of the data to be fitted: qnorm(u1[,1],mu_x,std_x) and of course the same with y right?.. However the simulated data seems to fit the original data when qnorm is used with default mean and stdv.. I should try this with other data different from stock returns since they're anyway near the (-1,1) interval... $\endgroup$
    – mickkk
    Feb 12, 2015 at 14:02
  • 1
    $\begingroup$ Maybe try and ask another more general question on stats exchange about fitting distributions to existing data. The methodology for the copula is right I think but beyond that I don't really know what else to say. $\endgroup$
    – Henry E
    Feb 12, 2015 at 19:11

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.