| simulate_dynamic_binomial | R Documentation |
Generates a latent logit process (random walk or AR(1)) and binomial counts, optionally with structural (zero-inflation) zeros.
simulate_dynamic_binomial(
n,
sigma,
trials,
logit0 = 0,
zero_inflation = 0,
rho = 1,
mu = 0,
offset = 0,
seed = NULL
)
n |
Number of observations. |
sigma |
Standard deviation of the latent increments (Gaussian). |
trials |
Number of trials: a single number (recycled) or a length- |
logit0 |
Initial logit |
zero_inflation |
Structural-zero probability. With probability
|
rho |
AR(1) coefficient of the latent process
|
mu |
Drift (random walk) / intercept (AR(1)) of the latent process.
Default |
offset |
Known offset on the logit scale (length 1 or |
seed |
Optional random seed. The previous state of the global random number generator is restored afterwards. |
A list with components y (successes), trials, logit (latent
path z_t), prob (plogis(offset + logit)), offset, and
structural (logical, TRUE for structural zeros).
sim <- simulate_dynamic_binomial(n = 50, sigma = 0.15, trials = 40, seed = 1)
head(sim$y)
# with structural zeros:
zi <- simulate_dynamic_binomial(50, 0.15, trials = 40, zero_inflation = 0.2, seed = 1)
mean(zi$structural)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.