add_quantile.negbin: Quantiles for the Response of a Negative Binomial Regression

Description Usage Arguments Details Value See Also Examples

View source: R/add_quantile_negbin.R

Description

This function is one of the methods of add_quantile.

Usage

1
2
## S3 method for class 'negbin'
add_quantile(df, fit, p, name = NULL, yhatName = "pred", nSims = 2000, ...)

Arguments

df

A data frame of new data.

fit

An object of class negbin. Predictions are made with this object.

p

A real number between 0 and 1. Sets the probability level of the quantiles.

name

NULL or a string. If NULL, quantiles automatically will be named by add_quantile, otherwise, they will be named name.

yhatName

A string. Name of the vector of predictions.

nSims

A positive integer. Set the number of simulated draws to use.

...

Additional arguments.

Details

Quantiles of Negative Binomial linear models are determined by add_quantile through a simulation using arm::sim.

Value

A dataframe, df, with predicted values and level p quantiles attached.

See Also

add_ci.negbin for confidence intervals for negbin objects, add_pi.negbin for prediction intervals of negbin objects, and add_probs.negbin for response probabilities of negbin objects.

Examples

1
2
3
4
5
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_quantile(df, fit, p = 0.3)

ciTools documentation built on Jan. 13, 2021, 7 a.m.