RSAVS_Mu_to_Mat: Generate the intercept term matrix according to mu_vec.

View source: R/pre_define_functions.r

RSAVS_Mu_to_MatR Documentation

Generate the intercept term matrix according to mu_vec.

Description

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

Usage

RSAVS_Mu_to_Mat(mu_vec)

Arguments

mu_vec

a length-n vector of the subgroup effect.

Details

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

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

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.

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)

fenguoerbian/RSAVS documentation built on Oct. 25, 2024, 3:16 p.m.