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 negbin. Predictions are made with this object.

q

A double. A quantile of the response distribution.

name

NULL or a string. If NULL, probabilities automatically will be named by add_probs(), otherwise, the probabilities will be named name in the returned data frame.

yhatName

A string. Name of the vector of predictions.

comparison

A character vector of length one. Permitted arguments are "=", "<", "<=", ">", or ">=". The default value is "<".

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)


[Package ciTools version 0.6.1 Index]