Examples for 'e1071::matchClasses'


Find Similar Classes in Two-way Contingency Tables

Aliases: matchClasses compareMatchedClasses

Keywords: category

### ** Examples

## a stupid example with no class correlations:
g1 <- sample(1:5, size=1000, replace=TRUE)
g2 <- sample(1:5, size=1000, replace=TRUE)
tab <- table(g1, g2)
matchClasses(tab, "exact")
Direct agreement: 0 of 5 pairs
Iterations for permutation matching: 120 
Cases in matched pairs: 23.6 %
1 2 3 4 5 
4 3 5 2 1 
## let pairs (g1=1,g2=4) and (g1=3,g2=1) agree better
k <- sample(1:1000, size=200)
g1[k] <- 1
g2[k] <- 4

k <- sample(1:1000, size=200)
g1[k] <- 3
g2[k] <- 1

tab <- table(g1, g2)
matchClasses(tab, "exact")
Direct agreement: 2 of 5 pairs
Iterations for permutation matching: 6 
Cases in matched pairs: 50.1 %
1 2 3 4 5 
4 5 1 3 2 
## get agreement coefficients:
compareMatchedClasses(g1, g2, method="exact")
$diag
      [,1]
[1,] 0.501

$kappa
          [,1]
[1,] 0.3440554

$rand
          [,1]
[1,] 0.7265385

$crand
         [,1]
[1,] 0.248127

[Package e1071 version 1.7-11 Index]