cornode: Build a Rank Correlation Using the Iman and Conover Method

View source: R/cornode.R

cornodeR Documentation

Build a Rank Correlation Using the Iman and Conover Method

Description

Builds a rank correlation structure between columns of a matrix or between ‘⁠mcnode⁠’ objects using the Iman and Conover (1982) method.

Usage

cornode(..., target, outrank = FALSE, result = FALSE, seed = NULL)

Arguments

...

a matrix (each of its ‘⁠n⁠’ columns but the first one will be reordered) or ‘⁠n⁠’ ‘⁠mcnode⁠’ objects (each element but the first will be reordered). Arguments should be named.

target

a scalar (only if ‘⁠n=2⁠’) or a ‘⁠(n x n)⁠’ matrix of correlations.

outrank

should the order be returned?

result

should the correlation eventually obtained be printed?

seed

the random seed for building the correlation. If ‘⁠NULL⁠’ the seed is unchanged.

Details

The function accepts for ‘⁠data⁠’:

  • some ‘⁠"V" mcnode⁠’ objects separated by a comma;

  • some ‘⁠"U" mcnode⁠’ objects separated by a comma;

  • some ‘⁠"VU" mcnode⁠’ objects, building the structure column by column;

  • one ‘⁠"V" mcnode⁠’ as first element and some ‘⁠"VU" mcnode⁠’ objects.

‘⁠target⁠’ should be a scalar (two columns only) or a real symmetric positive-definite square matrix. Only the upper triangular part is used (see chol).

The final correlation structure should be checked, as it is not always possible to achieve the target exactly. The order of values within each ‘⁠mcnode⁠’ (except the first) will be changed by this function. The ‘⁠outrank⁠’ option may help to rebuild prior links.

Value

If ‘⁠outrank=FALSE⁠’: the matrix or a list of rearranged ‘⁠mcnode⁠’s. If ‘⁠outrank=TRUE⁠’: the order to be used to rearrange to build the desired correlation.

References

Iman, R. L., & Conover, W. J. (1982). A distribution-free approach to inducing rank correlation among input variables. Communication in Statistics - Simulation and Computation, 11(3), 311-334.

Examples

x1 <- rnorm(1000)
x2 <- rnorm(1000)
x3 <- rnorm(1000)
mat <- cbind(x1, x2, x3)
(corr <- matrix(c(1,0.5,0.2, 0.5,1,0.2, 0.2,0.2,1), ncol=3))
cor(mat, method="spearman")
matc <- cornode(mat, target=corr, result=TRUE)
all(matc[,1] == mat[,1])

mc2d documentation built on Oct. 23, 2026, 1:06 a.m.