| simulate_dynamic_poisson | R Documentation |
Generates a latent log-rate process (random walk or AR(1)) and Poisson counts, optionally with zero inflation.
simulate_dynamic_poisson(
n,
sigma,
log_rate0 = 1,
zero_inflation = 0,
rho = 1,
mu = 0,
offset = 0,
seed = NULL
)
n |
Number of observations. |
sigma |
Standard deviation of the latent increments (Gaussian). |
log_rate0 |
Initial log-rate |
zero_inflation |
Probability that the gate is closed (i.e. the
probability of a structural zero) at each time point. |
rho |
AR(1) coefficient of the latent process
|
mu |
Drift (random walk) / intercept (AR(1)) of the latent process.
Default |
offset |
Known log-exposure offset (length 1 or |
seed |
Optional random seed. The previous state of the global random number generator is restored afterwards. |
A list with components y (observed counts), log_rate (the latent
log-rate path z_t), rate (the mean exp(offset + log_rate)),
offset, and structural (logical, TRUE where a structural zero was
forced).
sim <- simulate_dynamic_poisson(n = 50, sigma = 0.2, log_rate0 = 2,
zero_inflation = 0.2, seed = 1)
table(sim$y == 0, sim$structural)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.