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)

Arguments

n

Number of rows in simulated count matrix. The number of rows should be at least 2.

m

Number of columns in simulated count matrix. The number of columns should be at least 2.

k

Number of factors, or “topics”, used to determine Poisson rates. The number of topics should be 1 or more.

fmax

Factors are drawn uniformly at random between zero and fmax.

lmax

Loadings are drawn uniformly at random between zero and lmax.

sparse

If sparse = TRUE, convert the counts matrix to a sparse matrix in compressed, column-oriented format; see sparseMatrix.

Value

The return value is a list containing the counts matrix X and the factorization, F and L, used to generate the counts.

Details

Note that only minimal argument checking is performed. This function is mainly used to simulate small data sets for the examples and package tests.