mari1: Modified Adjusted Rand Index 1

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/mari1.R

Description

mari1 is used to compute the value of the Modified Adjusted Rand Index 1. It considers two partitions U and V', which are usually obtained on two sets of units S and T, where T is a subset of S. Because two vectors U and V do not have the same length, the cluster of units, which are not present in the partition V, need to be added to the partition V (denoted as V'). This can be done manually or with function merge.

Usage

1
mari1(U, V, outgoing.name, k = 500)

Arguments

U

Partition U.

V

Partition V'.

outgoing.name

The label of added cluster (see Description). Do not specify this argument if there is no added values.

k

Number of permutations.

Value

The function returns the value of the Modified Adjusted Rand Index 1. The expected value of the index in the case of two random and independant partitions is 0. The maximum value of the index is 1. Higher value indicates more similar (stable) partitions. The splitting of clusters lowers the value of the index, but the merging of clusters does not affect the value of the index.

Author(s)

Marjan Cugmas

References

Cugmas M. and Ferligoj A. (2015). On comparing partitions. submitted

See Also

Other types of Modified Rand Index: mri21, mri22.

Modified Adjusted Rand Index: mari1, mari21, mari22.

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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# THIS FUNCTION CONVERT THE CONTINGENCY TABLE INTO TWO VECTORS
fromTableToVectors <- function(cont.table){
  dat <- matrix(ncol = 2)
  for (j in 1:dim(cont.table)[2]){
    for (i in 1:dim(cont.table)[1]){
      if (cont.table[i, j] >= 1){
        for (t in 1:cont.table[i,j]){
          imei <- rownames(cont.table)[i]
          imej <- colnames(cont.table)[j]
          dat <- rbind(dat, c(imei, imej))
        }
      }
    }
  }
  dat <- dat[-1,]
  return(dat)
}


# DATA
example.Model <- list(NULL)

# example 1
cont.table <- rbind(c(0, 10, 0, 0, 0),
                c(10, 0, 0, 0, 0),
                c(0, 0, 10, 0, 0),
                c(0, 0,  0, 5, 5))
rownames(cont.table) <- c(1:4)
colnames(cont.table) <- c(1:5)
example.Model[[1]] <- cont.table

# example 2
cont.table <- rbind(c(0, 10, 0, 0, 0),
                c(0, 10, 0, 0, 0),
                c(0, 0, 10, 0, 0),
                c(0, 0,  0, 5, 5))
rownames(cont.table) <- c(1:4)
colnames(cont.table) <- c(1:5)
example.Model[[2]] <- cont.table

# example 3
cont.table <- rbind(c(0,  0, 0, 0, 0),
                c(10, 10, 0, 0, 0),
                c( 0,  0, 10, 0, 0),
                c(0, 0,  0,   5, 5))
rownames(cont.table) <- c(1:4)
colnames(cont.table) <- c(1:5)
example.Model[[3]] <- cont.table

# COMPUTE MRI1
# example 1
U <- fromTableToVectors(example.Model[[1]])[,1]
V <- fromTableToVectors(example.Model[[1]])[,2]
mari1(U = U, V = V, outgoing.name = 4, k = 500)

# example 2
U <- fromTableToVectors(example.Model[[2]])[,1]
V <- fromTableToVectors(example.Model[[2]])[,2]
mari1(U = U, V = V, outgoing.name = 4, k = 500)

# example 3
U <- fromTableToVectors(example.Model[[3]])[,1]
V <- fromTableToVectors(example.Model[[3]])[,2]
mari1(U = U, V = V, outgoing.name = 4, k = 500)

mri documentation built on May 30, 2017, 8:18 a.m.