This function generate the group id matrix according to the subgroup effect vector mu_vec.

RSAVS_Mu_to_Mat(mu_vec)

Arguments

mu_vec

a length-n vector of the subgroup effect.

Value

res: a (n * p) matrix. Each row is for one observation and res[i, j] = 1 if i \(\in\) group_j and res[i, j] = 0 o.w.

Details

  • n = length(mu_vec) is the number of observations.

  • p = length(unique(mu_vec)) is the number of subgroups.

Note

In the result, 1st observation of mu_vec will always be in the 1st subgroup.

Examples

set.seed(1024)
mu_vec <- sample(c(0.5, 0, -0.5), size = 10, replace = TRUE)
group_id_mat <- RSAVS:::RSAVS_Mu_to_Mat(mu_vec)