predict.zerotrunc: Methods for zerotrunc Objects

View source: R/zerotrunc.R

predict.zerotruncR Documentation

Methods for zerotrunc Objects

Description

Methods for extracting information from fitted zero-truncated count regression model objects of class "zerotrunc".

Usage

## S3 method for class 'zerotrunc'
predict(object, newdata,
  type = c("response", "prob", "count", "zero"), na.action = na.pass, ...)
## S3 method for class 'zerotrunc'
residuals(object, type = c("deviance", "pearson", "response"), ...)

Arguments

object

an object of class "zerotrunc" as returned by zerotrunc.

newdata

optionally, a data frame in which to look for variables with which to predict. If omitted, the original observations are used.

type

character specifying the type of predictions or residuals, respectively. For details see below.

na.action

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

...

currently not used.

Details

A set of standard extractor functions for fitted model objects is available for objects of class "zerotrunc", including methods to the generic functions print and summary which print the estimated coefficients along with some further information. The summary in particular supplies partial Wald tests based on the coefficients and the covariance matrix (estimated from the Hessian in the numerical optimization of the log-likelihood). As usual, the summary method returns an object of class "summary.zerotrunc" containing the relevant summary statistics which can subsequently be printed using the associated print method.

Both the fitted and predict methods can compute fitted responses. The latter additionally provides the predicted density (i.e., probabilities for the observed counts), the predicted mean from the count component (without zero truncation) and the predicted probability for observing a non-zero count (in the un-truncated model). The residuals method can compute raw residuals (observed - fitted), Pearson residuals (raw residuals scaled by square root of variance function), and deviance residuals (contributions to the centered log-likelihood).

A logLik method is provided, hence AIC can be called to compute information criteria.

See Also

zerotrunc

Examples

data("CrabSatellites", package = "countreg")
fm <- zerotrunc(satellites ~ width + color, data = CrabSatellites, subset = satellites > 0)

plot(residuals(fm, type = "deviance") ~ fitted(fm))
plot(residuals(fm, type = "pearson") ~ fitted(fm))

coef(fm)
summary(fm)
logLik(fm)
AIC(fm)

countreg documentation built on Dec. 4, 2023, 3:09 a.m.