Hi everybody, I know that a similiar topic has been posted, but as my question differs I am opening a new topic. I am trying to follow how the godness of fit test for copulas in the copula package works. Therefore I wrote a function to caculate the empirical copula, whose results are necessary to derive the test statistics. In a next step I compare the test statistic with the one derived through the copula package. My problem is that the results differ and the only source for the difference can be within the empirical copula function. In the code of the package the empirical copula function is written in C. As I am not familiar with C I can not find out where my possible mistake is. Is there maybe anyone familiar with C who can take a look at these functions and tell me weather I am doing the same or something different? Here is my code: fkt.Cemp = function(U,V){ C.emp = numeric(dim(U)[1]) for(i in 1:dim(U)[1]){ A = numeric(dim(U)[1]) for(j in 1:dim(U)[1]){ A[j] <- as.numeric(U[j,1] <= V[i,1] & U[j,2] <= V[i,2]) } C.emp[i] = sum(A)/(dim(U)[1]) } return(C.emp) } and here is the C code: double empcop(int n, int p, double *U, double *V, int m, int k) { int i,j, ind; double ec = 0.0; for (i=0;i<n;i++) { ind = 1; for (j=0;j<p;j++) ind *= (U[i + n * j] <= V[k + m * j]); ec += (double)ind; } return ec/(double)n; } Thank you! -- View this message in context: http://r.789695.n4.nabble.com/empirical-copula-copula-package-gof-Test-tp4323930p4323930.html Sent from the R help mailing list archive at Nabble.com.