View source: R/zero-inflation.R
| structural_zero_prob | R Documentation |
For a zero-inflated fit (Poisson or binomial), returns for every observed zero the posterior probability that it is a structural zero (gate closed) rather than an ordinary sampling zero generated by the observation process. A single gate-open probability governs all observations (it does not vary over time or with covariates), while the gate itself is drawn separately for every observation.
structural_zero_prob(object, zeros_only = TRUE)
object |
A |
zeros_only |
If |
The model introduces a latent gate indicator v_t \in \{0, 1\}: when
the gate is open (v_t = 1) the count comes from the observation model
(Poisson or binomial); when closed (v_t = 0) the count is a structural
zero. The sampler stores v_t for each draw, so the structural-zero
probability is
\Pr(\text{structural} \mid y_t = 0) = 1 - \overline{v_t},
the posterior mean of the gate being closed. Non-zero observations are
always sampling observations and have structural probability 0.
A data frame with columns time, observed, p_structural
(posterior probability the zero is structural) and p_sampling
(1 - p_structural).
sim <- simulate_dynamic_poisson(60, 0.2, 2, zero_inflation = 0.25, seed = 1)
fit <- fit_dynamic_model(sim$y, zero_inflation = TRUE, nsave = 300, nburn = 200,
seed = 1)
structural_zero_prob(fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.