iprlma178
/opt/cluster/R/3.0.2/bin:/opt/cluster/openmpi/gcc/64/1.4.2/bin:/opt/cluster/gcc/4.6.0/bin:/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/opt/cluster/bin

R version 3.0.2 (2013-09-25) -- "Frisbee Sailing"
Copyright (C) 2013 The R Foundation for Statistical Computing
Platform: x86_64-unknown-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(copula)
> data(loss)
> myLoss <- subset(loss, censored==0, select=c("loss", "alae"))
> 
> n <- nrow(myLoss)
> 
> ## values of the marginal empirical c.d.f.s at observations times n
> mr.loss <- rank(myLoss[,1], ties.method="max")
> mr.alae <- rank(sort(myLoss[,2]), ties.method="max")
> 
> tau <- cor(myLoss[,1], myLoss[,2], method="kendall")
> theta <- iTau(gumbelCopula(), tau)
> 
> test.func <- function(x) evTestC(x)$p.value
> 
> ## one replication
> do1 <- function()
+ {
+     x <- rCopula(n, gumbelCopula(theta))
+     y <- x[order(x[,1]),] ## sort according to first coordinate
+     y[,1] <- y[mr.loss,1] ## match ties structure in LOSS
+     # stopifnot(all(mr.loss == rank(y[,1], ties.method="max")))
+     y <- y[order(y[,2]),] ## sort according to second coordinate
+     y[,2] <- y[mr.alae,2] ## match ties structure in ALAE
+     # stopifnot(all(mr.alae == rank(y[,2], ties.method="max")))
+     z <- apply(y, 2, rank, ties.method="random")
+     ## apply test on continuous, tied and randomized sample
+     c(test.func(x), test.func(y), test.func(z))
+ }
> 
> res <- t(replicate(100,do1()))
> write.table(res,"pvalsC.csv")
> summary(res[,1] - res[,3])
      Min.    1st Qu.     Median       Mean    3rd Qu.       Max. 
-0.1039000 -0.0142400 -0.0014990 -0.0004995  0.0164800  0.0869100 
> summary(res[,1] - res[,2])
    Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
-0.01898  0.26970  0.48150  0.45360  0.65960  0.87310 
> apply(res,2, function(x) mean(x <= 0.05))
[1] 0.05 0.45 0.05
> 
