"vlm"
or one that inherits
from this such as "vglm"
) or a small one
(such as returned if it were of class "lm"
).model.matrixvlm(object, type=c("vlm","lm","lm2","bothlmlm2"), ...)
"vlm"
is the VLM model matrix corresponding
to the formula
argument.
The value "lm"
is the LM model matrix corresponding
to the formu
data
(which
is a data frame created with model.framevlm
),
contrasts.arg
, and xlev
.
type="bothlmlm2"
then a list is returned with components
"X"
and "Xm2"
.object
.
This can be a small LM object or a big VLM object (default).
The latter is constructed from the former and the constraint
matrices.
This code implements smart prediction
(see smartpred
).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.
model.matrix
,
model.framevlm
,
predict.vglm
,
smartpred
.# Illustrates smart prediction
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)
fit@x
model.matrix(fit)
Check1 = head(model.matrix(fit, type="lm"))
Check1
Check2 = model.matrix(fit, data=head(pneumo), type="lm")
Check2
all.equal(c(Check1), c(Check2))
q0 = head(predict(fit))
q1 = head(predict(fit, newdata=pneumo))
q2 = predict(fit, newdata=head(pneumo))
all.equal(q0, q1) # Should be TRUE
all.equal(q1, q2) # Should be TRUE
Run the code above in your browser using DataLab