roiztnb {oneinfl} | R Documentation |
Generate Random Counts from a One-Inflated Zero-Truncated Negative Binomial Process
Description
Simulates count data from a one-inflated, zero-truncated negative binomial (OIZTNB) process using specified parameters for the rate, one-inflation, and dispersion components.
Usage
roiztnb(b, g, alpha, X, Z)
Arguments
b |
A numeric vector of coefficients for the rate component. |
g |
A numeric vector of coefficients for the one-inflation component. |
alpha |
A numeric value representing the dispersion parameter for the negative binomial distribution. |
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, zero-truncated negative binomial process. The process combines:
A negative binomial 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
.Computes the negative binomial dispersion parameter (
\theta = \lambda / \alpha
).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, zero-truncated negative binomial 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)
alpha <- 1.5
simulated_data <- roiztnb(b, g, alpha, X, Z)
print(simulated_data)