feepred {fee} | R Documentation |
Predicted Counts from One-Inflated or Truncated Count Models
Description
Computes the predicted count distribution from a fitted model of class "oneinflmodel"
,
"truncmodel"
, or "basicPoisson"
. The function returns the expected frequency
for each count value from 1 up to maxpred
, based on the model's parameters.
Usage
feepred(model, data, maxpred)
Arguments
model |
A fitted model object of class |
data |
A data frame containing the covariates used to fit the model. |
maxpred |
Optional integer specifying the maximum count value for which to compute predicted frequencies. If not supplied, defaults to the maximum observed count in the data. |
Details
The function determines the model type based on its class and the dist
attribute, and applies the appropriate
density function:
For
oneinflmodel
(Poisson): one-inflated positive Poisson distribution.For
oneinflmodel
(negbin): one-inflated zero-truncated negative binomial.For
truncmodel
(Poisson): truncated positive Poisson.For
truncmodel
(negbin): zero-truncated negative binomial.
Value
A numeric vector of length maxpred
, giving the predicted expected frequency of each count from 1 to maxpred
.
See Also
Examples
df <- data.frame(x = runif(10,0,10), d = sample(c(0,1), 10, replace=TRUE), y = rpois(10, 3) + 1)
model <- oneinfl::oneinfl(formula = y ~ x + d | x + d, df = df, dist = "Poisson")
feepred(model, data = df)