Simulate a counts matrix X
such that
X[i,j]
is Poisson with rate (mean) Y[i,j]
, where
Y = tcrossprod(L,F)
, L
is an n x k loadings
(“activations”) matrix, and F
is an m x k factors
(“basis vectors”) matrix. The entries of matrix L
are
drawn uniformly at random between zero and lmax
, and the
entries of matrix F
are drawn uniformly at random between 0
and fmax
.
simulate_count_data(n, m, k, fmax = 1, lmax = 1, sparse = FALSE)
Number of rows in simulated count matrix. The number of rows should be at least 2.
Number of columns in simulated count matrix. The number of columns should be at least 2.
Number of factors, or “topics”, used to determine Poisson rates. The number of topics should be 1 or more.
Factors are drawn uniformly at random between zero and
fmax
.
Loadings are drawn uniformly at random between zero and
lmax
.
If sparse = TRUE
, convert the counts matrix to
a sparse matrix in compressed, column-oriented format; see
sparseMatrix
.
The return value is a list containing the counts matrix
X
and the factorization, F
and L
, used to
generate the counts.
Note that only minimal argument checking is performed. This function is mainly used to simulate small data sets for the examples and package tests.