Learn R Programming

VGAM (version 1.1-14)

predictvglm: Predict Method for a VGLM fit

Description

Predicted values based on a vector generalized linear model (VGLM) object.

Usage

predictvglm(object, newdata = NULL,
            type = c("link", "response", "terms"),
            se.fit = FALSE, deriv = 0, dispersion = NULL,
            untransform = FALSE,
            type.fitted = NULL, percentiles = NULL, ...)

Arguments

Value

If se.fit = FALSE, a vector or matrix of predictions. If se.fit = TRUE, a list with components

fitted.values

Predictions

se.fit

Estimated standard errors

df

Degrees of freedom

sigma

The square root of the dispersion parameter (but these are being phased out in the package)

Details

Obtains predictions and optionally estimates standard errors of those predictions from a fitted vglm object. By default, each row of the matrix returned can be written as \(\eta_i^T\), comprising of \(M\) components or linear predictors. If there are any offsets, these are included.

This code implements smart prediction (see smartpred).

References

Yee, T. W. (2015). Vector Generalized Linear and Additive Models: With an Implementation in R. New York, USA: Springer.

Yee, T. W. and Hastie, T. J. (2003). Reduced-rank vector generalized linear models. Statistical Modelling, 3, 15--41.

See Also

predict, vglm, predictvlm, smartpred, calibrate.

Examples

Run this code
# Illustrates smart prediction
pneumo <- transform(pneumo, let = log(exposure.time))
fit <- vglm(cbind(normal, mild, severe) ~ poly(c(scale(let)), 2),
            propodds, pneumo, trace = TRUE, x.arg = FALSE)
class(fit)

(q0 <- head(predict(fit)))
(q1 <- predict(fit, newdata = head(pneumo)))
(q2 <- predict(fit, newdata = head(pneumo)))
all.equal(q0, q1)  # Should be TRUE
all.equal(q1, q2)  # Should be TRUE

head(predict(fit))
head(predict(fit, untransform = TRUE))

p0 <- head(predict(fit, type = "response"))
p1 <- head(predict(fit, type = "response", newdata = pneumo))
p2 <- head(predict(fit, type = "response", newdata = pneumo))
p3 <- head(fitted(fit))
all.equal(p0, p1)  # Should be TRUE
all.equal(p1, p2)  # Should be TRUE
all.equal(p2, p3)  # Should be TRUE

predict(fit, type = "terms", se = TRUE)

Run the code above in your browser using DataLab