This function computes the Rand Index(RI) of an estimated mu vector(mu_est) against the target mu vector(mu_target).

RSAVS_RI(mu_est, mu_target, detail = FALSE)

Arguments

mu_est

numerical vector of the estimated subgroup effect. n = length(mu_est).

mu_target

numerical vector of the target(real) subgroup effect. n = length(mu_target).

detail

whether or not should the function computes the details(TP, TN, FP, FN) of these 2 identifications(mu_est and mu_target). Default value is FALSE.

Value

numerical value of Rand Index if detail = FALSE. Otherwise a list containing RI, TP, TN, FP, FN.

Note

mu_est and mu_target must have the same length.

Details

For a subgroup identification of n observations, there are \(n * (n - 1) / 2\) pairs of different observations. The Rand Index describes how these two subgroup identifications are based on these observation pairs and it is given by $$RI = (#TP + #TN) / (#TP + #TN + #FP + #FN),$$ where for any two observation i and j,

  • TP(True Positive): these two observations belong to the same subgroup in both these two identification.

  • TN(True Negative): these two observations belong to different subgroups in both these two identification.

  • FP(False Positive): these two observations belong to the same subgropu in mu_est. But they belong to different subgroups in mu_target.

  • FN(False Negative): these two observations belong to different subgroups in mu_est. But they belong to the same subgroup in mu_target.

Therefore RI ranges from 0 to 1 and RI = 1 if and only if these two identifications are identical.

Note: if detail = TRUE, the function also returns the number of TP, TN, FP and FN.

Examples

n <- 50    # number of observations
k <- 2    # k subgroup effect, centered at 0
group_center <- seq(from = 0, to = 2 * (k - 1), by = 2) - (k - 1)
# subgroup effect vector    
alpha1 <- sample(group_center, size = n, replace = TRUE) 
# another subgroup effect vector
alpha2 <- sample(group_center, size = n, replace = TRUE)
RSAVS_RI(alpha1, alpha2)
#> [1] 0.5102041
RSAVS_RI(alpha1, alpha2, detail = TRUE)
#> $RI
#> [1] 0.5102041
#> 
#> $TP
#> [1] 325
#> 
#> $TN
#> [1] 300
#> 
#> $FP
#> [1] 276
#> 
#> $FN
#> [1] 324
#>