roipp {oneinfl} | R Documentation |
Generate Random Counts from a One-Inflated Poisson Process
Description
Simulates count data from a one-inflated Poisson process using specified parameters for the rate and one-inflation components.
Usage
roipp(b, g, X, Z)
Arguments
b |
A numeric vector of coefficients for the rate component. |
g |
A numeric vector of coefficients for the one-inflation component. |
X |
A matrix or data frame of predictor variables for the rate component. |
Z |
A matrix or data frame of predictor variables for the one-inflation component. |
Details
This function generates count data from a one-inflated Poisson process. The process combines:
A Poisson distribution for counts greater than one.
A one-inflation component that adjusts the probability of observing a count of one.
The algorithm:
Calculates the rate parameter (
\lambda
) as\exp(X \cdot b)
.Computes the one-inflation probabilities (
\omega
) based onZ \cdot g
.Simulates counts for each observation:
Draws a random number to determine whether the count is one.
Iteratively calculates probabilities for higher counts until the random number is matched.
This function is useful for generating synthetic data for testing or simulation studies involving one-inflated Poisson models.
Value
A numeric vector of simulated count data.
See Also
oneinfl
for fitting one-inflated models.
Examples
# Example usage
set.seed(123)
X <- matrix(rnorm(100), ncol = 2)
Z <- matrix(rnorm(100), ncol = 2)
b <- c(0.5, -0.2)
g <- c(1.0, 0.3)
simulated_data <- roipp(b, g, X, Z)
print(simulated_data)