powered by
Simulates count data from a zero-truncated Poisson process using specified parameters for the rate component.
rpp(b, X)
A numeric vector of simulated count data.
A numeric vector of coefficients for the rate component.
A matrix or data frame of predictor variables for the rate component.
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.
truncreg for fitting zero-truncated models.
truncreg
# 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