View source: R/generate_data.R
generate_data | R Documentation |
This function generates count data from the mixture of logistic-normal multinomial model. It assume the specication of the mean and variance parameter for the latent variable, generate Gaussian latent variable data first, then transform back to compositional data, and then count data.
generate_data(
num_grp,
num_observation,
K,
true_mu,
true_Sig,
seed.no,
M,
truelab = TRUE
)
num_grp |
Number of groups that you want to generate the data from. |
num_observation |
A vector with length as num_grp, specifying the number of observations inside each group. |
K |
Dimension of the latent variable. Number of "taxa" - 1. For example, if you want to generate counts from 4 taxa, specify K=3. |
true_mu |
True means of the latent variable. A list contains num_grp vectors. Each vector is of length K+1, with the last element equals 0. |
true_Sig |
True covariance matrices of the latent variable. A list contains num_grp matrices. Each matrix is a K*K positive definite matrix attached by one row of 0 and one column of 0. |
seed.no |
set.seed() argument. Setting a seed for retriving the data. |
M |
A number to generate total observed counts. The total counts are generated as a uniform random numbers in the interval from M/2 to M. |
truelab |
Logical variable, if is TRUE, the true label of each observation will be returned. Default is TRUE. |
A list cotains both counts data (W) and the latent variable (Y). If truelab is TRUE, true class labels are returned (true_lab).
# generate a two-component 3-dimentional data
generate_data(G = 2, num_observation = c(50,50), K = 2, true_mu = list(c(0,1,0),c(-2,-5,0)),true_Sig=list(rbind(cbind(diag(1,2),0),0),rbind(cbind(diag(1,2),0),0)), seed.no = 1234, M = 10000, truelab = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.