## Prediction Intervals for Negative Binomial Linear Models

### Description

This function is one of the methods for add_pi, and is called automatically when add_pi is used on a fit of class negbin.

### Usage

## S3 method for class 'negbin'
df,
fit,
alpha = 0.05,
names = NULL,
yhatName = "pred",
nSims = 2000,
...
)


### Arguments

 df A data frame of new data. fit An object of class negbin. alpha A real number between 0 and 1. Controls the confidence level of the interval estimates. names NULL or character vector of length two. If NULL, prediction bounds automatically will be named by add_pi, otherwise, the lower prediction bound will be named names and the upper prediction bound will be named names. yhatName A string. Name of the predictions vector. nSims A positive integer. Determines the number of simulations to run. ... Additional arguments.

### Details

Prediction intervals for negative binomial fits are formed through a two part simulation scheme:

1. Model coefficients are generated through a parametric bootstrap procedure that simulates the uncertainty in the regression coefficients.

2. Random draws from the negative binomial distribution are taken with a mean that varies based on the model coefficients determined in step (1) and over-dispersion parameter that is taken from the original fitted model.

Quantiles of the simulated responses are taken at the end to produce intervals of the desired level.

### Value

A dataframe, df, with predicted values, upper and lower prediction bounds attached.

add_ci.negbin for confidence intervals for negbin objects, add_probs.negbin for conditional probabilities 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_pi(df, fit, names = c("lpb", "upb"))



[Package ciTools version 0.6.1 Index]