add_probs.negbin: Response Probabilities for Negative Binomial Models

Description Usage Arguments Value See Also Examples

View source: R/add_probs_negbin.R

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## 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

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_probs(df, fit, q = 50)

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