simdata: Generate Poisson, negative binomial (NB), and zero-inflated...

View source: R/datasim.R

simdataR Documentation

Generate Poisson, negative binomial (NB), and zero-inflated NB (ZINB) data

Description

This function generates a data matrix (n \times p) under Poisson, NB, or ZINB assumptions, based on Karlis (or LPGM. 2013) with adjancency matrix B.

Usage

simdata(
  n,
  p,
  B,
  family = c("Poisson", "NB", "ZINB"),
  mu,
  mu_noise,
  theta = NA,
  pi = NA
)

Arguments

n

number of samples

p

number of variables (nodes)

B

adjacency matrix

family

the distribution from which to simulate (Poisson, NB, ZINB)

mu

mean of the non-zero component

mu_noise

mean of noise

theta

dispersion parameter of the non-zero component, where var=\mu+\mu^2/theta

pi

probability of zero inflation

Examples

p <- 4
B <- matrix(c(0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0), nrow=p)
n <- 10
simdata(n, p, B, mu = 5, mu_noise=1)
simdata(n, p, B, mu = 5, mu_noise=1, family="NB", theta=1)
simdata(n, p, B, mu = 5, mu_noise=1, family="ZINB", theta=1, pi=0.2)

drisso/learn2count documentation built on March 25, 2023, 4:21 p.m.