Generic prediction method for the model classes produced by poissonGLM(),
negbinGLM(), quasiPoissonGLM(), tweedieGLM(), zeroinflPoissonGLM(),
zeroinflNegbinGLM(), zeroinflTweedieGLM(), and countGLM(). The call is
forwarded to the backend's own predict() method (stats::predict.glm,
glmmTMB:::predict.glmmTMB, or pscl:::predict.zeroinfl) so the full set
of supported type values is available. Defaults to type = "response".
Arguments
- object
A fitted model returned by any of the package fitters, or a
countGLMcomparison object.- newdata
Optional data frame to predict on. When omitted, predictions on the training data are returned.
- type
Backend-dependent prediction type. Common values:
"response"(default; mean on the response scale),"link"(linear predictor), and for zero-inflated models"count","zero", or"prob". See?stats::predict.glm,?glmmTMB::predict.glmmTMB, and?pscl::predict.zeroinflfor the full list per backend.- ...
Additional arguments forwarded to the backend predict method.
Details
For a countGLM() object the prediction comes from whichever model was
selected by decide.
Examples
df <- data.frame(
y = c(0L, 1L, 2L, 3L, 5L, 0L, 2L, 4L, 1L, 3L),
x1 = c(1.2, -0.4, 0.8, -1.1, 2.0, 0.3, -0.9, 1.5, -0.2, 0.7)
)
fit <- poissonGLM(y ~ x1, data = df)
#> Warning: Count component: 8 events (y > 0) for 1 predictor(s) (8.0 per predictor). At least 10 events per predictor is recommended.
predict(fit, newdata = data.frame(x1 = c(0, 1, 2)))
#> 1 2 3
#> 1.798861 2.409767 3.228141