## Consider the following example taken from
## Genest and Remillard (2004), p 352:
x <- matrix(rnorm(500),100,5)
x[,1] <- abs(x[,1]) * sign(x[,2] * x[,3])
x[,5] <- x[,4]/2 + sqrt(3) * x[,5]/2
## In order to test for independence "within" x, the first step consists
## in simulating the distribution of the test statistics under
## independence for the same sample size and dimension,
## i.e. n=100 and p=5. As we are going to consider all the subsets of
## {1,...,5} whose cardinality is between 2 and 5, we set p=m=5.
## This may take a while...
if(copula:::doExtras()) { ## not run, typically:% ------------------------------
print(system.time(
d <- indepTestSim(100,5)
))
## The next step consists of performing the test itself:
test <- indepTest(x,d)
## Let us see the results:
print(test)
## Display the dependogram with the details:
dependogram(test, print=TRUE)
}# (not in CRAN checks)% ------------------ not on CRAN ------------------------
## We could have tested for a weaker form of independence, for instance,
## by only computing statistics for subsets whose cardinality is between 2
## and 3. Consider for instance the following data:
y <- matrix(runif(500),100,5)
## and perform the test:
d <- indepTestSim(100,5,3)
test <- indepTest(y,d)
test
dependogram(test,print=TRUE)
## NB: In order to save d for future use, the save function can be used.
Run the code above in your browser using DataLab