Hi all,
I have this data set:
## Empirical copula
## dt1 = ranking
## dt2 = observed uniform data associated with the ranking
 
Sample data, 
> dt1
        S_i   R_i
 [1,]   7.0  10.0
 [2,] 232.5 440.5
 [3,] 143.0 141.5
 [4,] 272.5 222.0
 [5,]  46.0  34.0
 [6,] 527.0 483.0
 [7,] 420.5 563.5
 [8,]  23.5  16.5
 [9,]  56.5  68.5
[10,] 341.5 382.5
 
> dt2
      unisk1 unisk2
 [1,]  0.008  0.010
 [2,]  0.298  0.615
 [3,]  0.194  0.187
 [4,]  0.357  0.297
 [5,]  0.067  0.048
 [6,]  0.767  0.687
 [7,]  0.573  0.805
 [8,]  0.032  0.025
 [9,]  0.082  0.094
[10,]  0.452  0.516
 
 
for S_i data below, I have divided by 691:
 
> cbind(dt1/(691+1),dt2)
             S_i        R_i unisk1 unisk2
 [1,] 0.01011561 0.01445087  0.008  0.010
 [2,] 0.33598266 0.63656069  0.298  0.615
 [3,] 0.20664740 0.20447977  0.194  0.187
 [4,] 0.39378613 0.32080925  0.357  0.297
 [5,] 0.06647399 0.04913295  0.067  0.048
 [6,] 0.76156069 0.69797688  0.767  0.687
 [7,] 0.60765896 0.81430636  0.573  0.805
 [8,] 0.03395954 0.02384393  0.032  0.025
 [9,] 0.08164740 0.09898844  0.082  0.094
[10,] 0.49349711 0.55274566  0.452  0.516
 
My code is
 
n <- 691
Cn_u1.u2 <- function(dt1,dt2,n)
 
{    cn  <- vector(length=n, mode="numeric")
    
    for (i in 1:n)
    { A     <- as.numeric(dt1[i,1]/(n+1) <= dt2[1,1] & dt1[i,2]/(n+1) <= dt2[1,2])
      cn[i] <- sum(A)/n
   }
  cn
}
 
What I want to do is to compare all ranking value with each uni data at a time using logical and if the it is true=1 and else =0.  I use as.numeric() as what you suggested before.
 
For example: calculate all where ( S_i <= unisk1[1] and R_i <= unisk2[1]) and continue the process for all unisk1 and unisk2.  If n=691, I will have cn=691.
 
Thank you so much for your help.




      
	[[alternative HTML version deleted]]

