simulation_data: Generate simulation data and parameters

data_genR Documentation

Generate simulation data and parameters

Description

'data_gen( )' generates matrix data (x) and parameters (alpha, Lambda, Sigma) for experimenting with the HBCM model.

Usage

data_gen(n, p, centers, mu, omega, labels, size, hparam_func)

Arguments

n

an integer specifying the number of observations (rows) of data x.

p

an integer specifying the number of variables (columns) of data x.

centers

an integer specifying the number of clusters.

mu

a vector of size 'centers' specifying the mean vector of the multivariate normal distribution of alpha.

omega

a matrix of size 'centers x centers' specifying the covariance matrix of the multivariate normal distribution of alpha.

labels

a vector of size 'p' specifying the cluster labels of the variables.

size

an integer specifying the number of simulation data sets.

hparam_func

a list of size two specifying the function of generating random numbers of parameter Lambda and Sigma.

Value

A list of lists.

x_list

a list of data x.

alpha_list

a list of alpha.

hlambda_list

a list of Lambda.

hsigma_list

a list of Sigma.

Examples

n <- 500
p <- 500
centers <- 3

mu <- rep(0, centers)

off_diag <- 0.5
omega <- diag(rep(1, centers))
for (i in 1:centers) {
 for (j in 1:centers) {
   if (i!=j){
     omega[i,j] = off_diag
   } 
 }
}

ppi <- rep(1/centers, centers)
labels <- sample(c(1:centers), size = p, replace = TRUE, prob = ppi) 

size <- 5
hparam_func <- list(
  lambda_func = function(p) stats::rnorm(p, 0, 1),
  sigma_func = function(p) stats::rchisq(p, 2) + 1
)
data_list <- data_gen(n, p, centers, mu, omega, labels, size, hparam_func)

xiangli2pro/hbcm documentation built on Nov. 15, 2024, 9:15 a.m.