Learn R Programming

VGAM (version 0.7-5)

model.framevlm: Construct the Model Frame of a VLM Object

Description

This function returns a data.frame with the variables. It is applied to an object which inherits from class "vlm" (e.g., a fitted model of class "vglm").

Usage

model.framevlm(object, ...)

Arguments

object
a model object from the VGAM Rpackage that inherits from a vector linear model (VLM), e.g., a model of class "vglm".
...
further arguments such as data, na.action, subset. See model.frame for more information on these.

Value

  • A data.frame containing the variables used in the object plus those specified in ....

Details

Since object is an object which inherits from class "vlm" (e.g., a fitted model of class "vglm"), the method will either returned the saved model frame used when fitting the model (if any, selected by argument model = TRUE) or pass the call used when fitting on to the default method.

This code implements smart prediction (see smartpred).

References

Chambers, J. M. (1992) Data for models. Chapter 3 of Statistical Models in S eds J. M. Chambers and T. J. Hastie, Wadsworth & Brooks/Cole.

See Also

model.frame, model.matrixvlm, predict.vglm, smartpred.

Examples

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

check1 = model.frame(fit)[1:3,]
check1
check2 = model.frame(fit, data=pneumo[1:3,])
check2
all.equal(unlist(check1), unlist(check2)) # Should be TRUE

q0 = predict(fit)[1:3,]
q1 = predict(fit, newdata=pneumo)[1:3,]
q2 = predict(fit, newdata=pneumo[1:3,])
all.equal(q0, q1)   # Should be TRUE
all.equal(q1, q2)   # Should be TRUE

Run the code above in your browser using DataLab