Learn R Programming

oneinfl (version 1.0.2)

rpp: Generate Random Counts from a Zero-Truncated Poisson Process

Description

Simulates count data from a zero-truncated Poisson process using specified parameters for the rate component.

Usage

rpp(b, X)

Value

A numeric vector of simulated count data.

Arguments

b

A numeric vector of coefficients for the rate component.

X

A matrix or data frame of predictor variables for the rate component.

Details

This function generates count data from a zero-truncated Poisson process, which models count data without zeros. The process involves:

  • Calculating the rate parameter (\(\lambda\)) as \(\exp(X \cdot b)\).

  • Iteratively computing probabilities for counts starting from 1 and adding to the cumulative probability until a randomly drawn value is matched.

This function is useful for generating synthetic data for testing or simulation studies involving zero-truncated Poisson models.

See Also

truncreg for fitting zero-truncated models.

Examples

Run this code
# Example usage
set.seed(123)
X <- matrix(rnorm(100), ncol = 2)
b <- c(0.5, -0.2)
simulated_data <- rpp(b, X)
print(simulated_data)

Run the code above in your browser using DataLab