rmnegcorr: Remove negative correlations from a correlation matrix

Description Usage Arguments Value Examples

Description

rmnegcorr removes "negative correlations" from a correlation matrix. A negative correlation is defined as a relation between to variables/objects, that have a high correlation value due to NOT frequently appearing together. This function can be applied for correlation matrizes created for variable or object relations.

Usage

1
rmnegcorr(corrmatrix, matrix, dim, niv = 0.1)

Arguments

corrmatrix

correlation matrix (as produced by varnastats::corrmat())

matrix

underlying data.frame

dim

switch to define if the correlation matrix should be created for columns or rows.

1: table is created for column (variables) relations.

2: table is created for row (objects) relations.

niv

decision niveau. The smaller niv the weaker the overlap of two variables/objects can be, to still be recognised as the cause for a positiv relation.

default: 0.1 -> 10%

Value

correlation matrix without negative relations

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
testmatrixrand <- data.frame(
   matrix(base::sample(0:1,400,replace=TRUE), nrow=20, ncol=20)
)

testmatrixrand[,1] <- c(1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0)
testmatrixrand[,2] <- c(0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1)

testcorr <- corrmat(testmatrixrand, "chi2", chi2limit = 0.1, dim = 1)

rmnegcorr(testcorr, testmatrixrand, dim = 1)

nevrome/varnastats documentation built on May 9, 2019, 10:43 a.m.