roipp | R Documentation |
Simulates count data from a one-inflated Poisson process using specified parameters for the rate and one-inflation components.
roipp(b, g, X, Z)
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. |
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 on Z \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.
A numeric vector of simulated count data.
oneinfl
for fitting one-inflated models.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.