roiztnb | R Documentation |
Simulates count data from a one-inflated, zero-truncated negative binomial (OIZTNB) process using specified parameters for the rate, one-inflation, and dispersion components.
roiztnb(b, g, alpha, X, Z)
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. |
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 on Z \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.
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)
alpha <- 1.5
simulated_data <- roiztnb(b, g, alpha, X, Z)
print(simulated_data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.