predict.gnm {gnm} | R Documentation |
Predict Method for Generalized Nonlinear Models
Description
Obtains predictions and optionally estimates standard errors of those predictions from a fitted generalized nonlinear model object.
Usage
## S3 method for class 'gnm'
predict(object, newdata = NULL,
type = c("link", "response", "terms"), se.fit = FALSE, dispersion =
NULL, terms = NULL, na.action = na.exclude, ...)
Arguments
object |
a fitted object of class inheriting from |
newdata |
optionally, a data frame in which to look for variables with which to predict. If omitted, the fitted predictors are used. |
type |
the type of prediction required. The default is on the scale
of the predictors; the alternative The value of this argument can be abbreviated. |
se.fit |
logical switch indicating if standard errors are required. |
dispersion |
the dispersion of the fit to be assumed in computing
the standard errors. If omitted, that returned by |
terms |
with |
na.action |
function determining what should be done with missing values
in |
... |
further arguments passed to or from other methods. |
Details
If newdata
is omitted the predictions are based on the data used
for the fit. In that case how cases with missing values in the
original fit is determined by the na.action
argument of that
fit. If na.action = na.omit
omitted cases will not appear in
the residuals, whereas if na.action = na.exclude
they will
appear (in predictions and standard errors), with residual value
NA
. See also napredict
.
Value
If se = FALSE
, a vector or matrix of predictions. If se =
TRUE
, a list with components
fit |
predictions. |
se.fit |
estimated standard errors. |
residual.scale |
a scalar giving the square root of the dispersion used in computing the standard errors. |
Note
Variables are first looked for in 'newdata' and then searched for in the usual way (which will include the environment of the formula used in the fit). A warning will be given if the variables found are not of the same length as those in 'newdata' if it was supplied.
Author(s)
Heather Turner
References
Chambers, J. M. and Hastie, T. J. (1992) Statistical Models in S
See Also
Examples
set.seed(1)
## Fit an association model with homogeneous row-column effects
RChomog <- gnm(Freq ~ origin + destination + Diag(origin, destination) +
MultHomog(origin, destination), family = poisson,
data = occupationalStatus)
## Fitted values (expected counts)
predict(RChomog, type = "response", se.fit = TRUE)
## Fitted values on log scale
predict(RChomog, type = "link", se.fit = TRUE)