exclude.pairs: Exclude paires from correlation matrix

Usage Arguments Examples

Usage

1
exclude.pairs(Cor.mat, M, th = 0.1, excluded = NULL)

Arguments

Cor.mat
M
th
excluded

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (Cor.mat, M, th = 0.1, excluded = NULL) 
{
    flag <- FALSE
    cor.tmp <- abs(Cor.mat)
    diag(cor.tmp) <- diag(cor.tmp) - diag(Cor.mat)
    if (!is.null(excluded)) 
        cor.tmp[excluded, ] <- 0
    mm <- max(cor.tmp)
    idxtorm <- which(cor.tmp == mm, arr.ind = TRUE)
    if (mm > th) {
        for (i in 1:dim(idxtorm)[1]) {
            M[idxtorm[i, 1], idxtorm[i, 2]] <- M[idxtorm[i, 1], 
                idxtorm[i, 2]] - 1
        }
        dd <- diag(M)[unique(c(idxtorm))]
        diag(M)[unique(c(idxtorm))] <- dd - 1
        excluded <- rbind(excluded, idxtorm)
    }
    else {
        excluded <- excluded
        flag <- TRUE
    }
    return(list(M = M, excluded = excluded, flag = flag))
  }

MPBA/r-sparcc documentation built on May 8, 2019, 3:22 p.m.