predictvglm | R Documentation |
Predicted values based on a vector generalized linear model (VGLM) object.
predictvglm(object, newdata = NULL,
type = c("link", "response", "terms"),
se.fit = FALSE, deriv = 0, dispersion = NULL,
untransform = FALSE,
type.fitted = NULL, percentiles = NULL, ...)
object |
Object of class inheriting from |
newdata |
An optional data frame in which to look for variables with which to predict. If omitted, the fitted linear predictors are used. |
type |
The value of this argument can be abbreviated.
The type of prediction required. The default is the first one,
meaning on the scale of the linear predictors.
This should be a The alternative The |
se.fit |
logical: return standard errors? |
deriv |
Non-negative integer. Currently this must be zero. Later, this may be implemented for general values. |
dispersion |
Dispersion parameter. This may be inputted at this stage, but the default is to use the dispersion parameter of the fitted model. |
type.fitted |
Some VGAM family functions have an argument by
the same name. If so, then one can obtain fitted values
by setting |
percentiles |
Used only if |
untransform |
Logical. Reverses any parameter link function.
This argument only works if
|
... |
Arguments passed into |
Obtains predictions and optionally estimates
standard errors of those predictions from a fitted
vglm
object.
This code implements smart prediction (see
smartpred
).
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 |
This function may change in the future.
Setting se.fit = TRUE
and type = "response"
will generate an error.
The arguments type.fitted
and percentiles
are provided in this function to give more convenience than
modifying the extra
slot directly.
Thomas W. Yee
Yee, T. W. and Hastie, T. J. (2003). Reduced-rank vector generalized linear models. Statistical Modelling, 3, 15–41.
predict
,
vglm
,
predictvlm
,
smartpred
,
calibrate
.
# Illustrates smart prediction
pneumo <- transform(pneumo, let = log(exposure.time))
fit <- vglm(cbind(normal, mild, severe) ~ poly(c(scale(let)), 2),
propodds, data = 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.