View source: R/pre_define_functions.r
RSAVS_RI | R Documentation |
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)
mu_est |
numerical vector of the estimated subgroup effect.
|
mu_target |
numerical vector of the target(real) subgroup effect.
|
detail |
whether or not should the function computes the details(TP, TN, FP, FN)
of these 2 identifications( |
numerical value of Rand Index if detail = FALSE
.
Otherwise a list containing RI, TP, TN, FP, FN
.
mu_est
and mu_target
must have the same length.
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.
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)
RSAVS_RI(alpha1, alpha2, detail = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.