Simulate a count table from the ZI-MLN generative model
Source:R/simulate_zimln.R
simulate_zimln.RdDraws a synthetic OTU count matrix (and, optionally, covariates) directly from
the zero-inflated multivariate rounded log-normal model, together with the
true parameter values used to generate it. Useful for examples, unit tests and
checking parameter recovery with ZI_MLN().
Usage
simulate_zimln(
n = 20,
J = 150,
K = 5,
zero.rate = 0.8,
sig2 = 1,
vs2 = 1,
p = 0,
M = n,
m = NULL,
seed = 1
)Arguments
- n
Number of samples.
- J
Number of OTUs (features).
- K
Number of latent factors used to build the true covariance.
- zero.rate
Proportion of entries in each column of the true loading matrix
Lambdaset to zero (controls covariance sparsity). Default 0.8.- sig2
True idiosyncratic variance \(\sigma^2\) (default 1).
- vs2
True subject random-effect variance \(u_s^2\) (default 1).
- p
Number of continuous covariates to generate.
0(default) produces a no-covariate data set (XisNULL).- M
Number of subjects/groups (default
n, i.e. one sample per subject).- m
Optional length-
nsubject index. Defaults to a balanced assignment of thensamples to theMsubjects.- seed
Random seed (default 1).
Value
A list with the simulated data and the ground truth:
YnbyJinteger count matrix (the model input).Xnbypcovariate matrix, orNULLwhenp = 0.m,Msubject index and subject count.
Lambda,sig2,vs2true covariance components.
Omega,true.cortrue covariance
Lambda Lambda' + sig2 Iand the true marginal correlation matrixcov2cor(Omega + vs2 I).ri,thetaj,smjtrue sample-size / OTU-size factors and subject random effects.
betatrue
Jbypregression coefficients (NULLwhenp = 0).kappatrue
Jbyp + 1probit zero-inflation coefficients.epsnbyJtrue absence probabilities \(\epsilon_{ij}\).deltanbyJtrue presence indicators (1= present).