predict.negbin1: Predict Method for Negative Binomial 1 Fits

Description Usage Arguments Details Value References Examples

Description

Obtains predictions from a fitted negative binomial 1 model object.

Usage

1
2
3
4
## S3 method for class 'negbin1'
predict(object, newdata = NULL,
                type = c("response", "location", "probability", "quantile"),
                na.action = na.pass, at = 0.5, ...)

Arguments

object

a fitted object of class inheriting from "negbin1".

newdata

optionally, a data frame in which to look for variables with which to predict.

type

the type of prediction required. The default is on the scale of the linear predictors; response and location are equivalent.

na.action

function determining what should be done with missing values in newdata. The default is to predict NA.

at

quantiles or counts.

...

additional arguments to be passed.

Details

newdata must contail all columns used in the estimation. If omitted, the fitted linear predictors are used. For type = "response" (as well as type = "location"), the conditional mean, the inverse link applied to the linear predictor, is calculated. type = "probability" computes the expected probabilities for each count at = 0, 1, 2, 3, ..., whereas type = "quantile" gives the quantile function for probabilities at.

Value

Returns a vector of predictions.

References

Cameron AC & Trivedi PK (1986). Econometric Models Based on Count Data: Comparisons and Applications of Some Estimators and Tests, Journal of Applied Econometrics, 1, 29–53.

Cameron AC & Trivedi PK (2013). “Regression Analysis of Count Data”, Cambridge University Press.

Lawless JF (1987). Negative Binomial and Mixed Poisson Regression, The Canadian Journal of Statistics, 15(3), 209–225.

Winkelmann R & Boes S (2009). “Analysis of Microdata”, Springer, Second Edition.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
## packages
require("Formula") 

## data generating process
dgp <- function(n = 1000, coef = c(0.2, 0.3, 0, 2)) {
  d <- data.frame(
    x1 = runif(n, -1, 1),
    x2 = runif(n, -1, 1)
    )
  d$mu <- exp(coef[1] + coef[2] * d$x1 + coef[3] * d$x2)
  d$y <- rnbinom(n, mu = d$mu, size = d$mu / coef[4])
  return(d)
}

## simulate data
set.seed(2007-05-15)
d <- dgp()

## model
m1 <- negbin1(y ~ x1 + x2, data = d)

## predictions
newd <- data.frame(x1 = c(2, 0, 1, 4), x2 = c(1, 0, -1, 1))
predict(m1, newd, type = "location")
predict(m1, newd, type = "response")
predict(m1, newd, type = "quantile", at = 0.95)
predict(m1, newd, type = "probability", at = 2)    

negbin1 documentation built on May 2, 2019, 6:19 p.m.