add_probs.negbin {ciTools} | R Documentation |
Response Probabilities for Negative Binomial Models
Description
This is the method add_probs
uses if the model fit is an
object of class negbin
. Probabilities are determined through
simulation, using the same method as add_pi.negbin
.
Usage
## S3 method for class 'negbin'
add_probs(
df,
fit,
q,
name = NULL,
yhatName = "pred",
comparison = "<",
nSims = 2000,
...
)
Arguments
df |
A data frame of new data. |
fit |
An object of class |
q |
A double. A quantile of the response distribution. |
name |
|
yhatName |
A string. Name of the vector of predictions. |
comparison |
A character vector of length one. Permitted
arguments are |
nSims |
A positive integer. Controls the number of simulated draws. |
... |
Additional arguments. |
Value
A dataframe, df
, with predicted values and
probabilities attached.
See Also
add_ci.negbin
for confidence intervals for
negbin
objects, add_pi.negbin
for prediction
intervals of negbin
objects, and
add_quantile.negbin
for response quantiles of
negbin
objects.
Examples
x1 <- rnorm(100, mean = 1)
y <- MASS::rnegbin(n = 100, mu = exp(1 + x1), theta = 5)
df <- data.frame(x1 = x1, y = y)
fit <- MASS::glm.nb(y ~ x1, data = df)
add_probs(df, fit, q = 50)