
Last chance! 50% off unlimited learning
Sale ends in
The predict()
methods allow to obtain within-sample and
out-of-sample predictions from models
fitted with mclogit()
and mblogit()
.
For models with random effecs fitted using the PQL-method, it is possible to obtain responses that are conditional on the reconstructed random effects.
# S3 method for mblogit
predict(object, newdata=NULL,type=c("link","response"),se.fit=FALSE, ...)
# S3 method for mclogit
predict(object, newdata=NULL,type=c("link","response"),se.fit=FALSE, ...)
# S3 method for mmblogit
predict(object, newdata=NULL,type=c("link","response"),se.fit=FALSE,
conditional=TRUE, ...)
# S3 method for mmclogit
predict(object, newdata=NULL,type=c("link","response"),se.fit=FALSE,
conditional=TRUE, ...)
The predict
methods return either a matrix (unless called with
se.fit=TRUE
) or a list with two matrix-valued elements
"fit"
and "se.fit"
.
an object in class "mblogit", "mmblogit", "mclogit", or "mmclogit"
an optional data frame with new data
a character string specifying the kind of prediction
a logical value; whether predictions should be accompanied with standard errors
a logical value; whether predictions should be made
conditional on the random effects (or whether they are set to zero,
i.e. their expectation). This argument is consequential only if
the "mmblogit" or "mmclogit" object was created with method="PQL"
.
other arguments, ignored.
library(MASS)
(house.mblogit <- mblogit(Sat ~ Infl + Type + Cont,
data = housing,
weights=Freq))
head(pred.house.mblogit <- predict(house.mblogit))
str(pred.house.mblogit <- predict(house.mblogit,se=TRUE))
head(pred.house.mblogit <- predict(house.mblogit,
type="response"))
str(pred.house.mblogit <- predict(house.mblogit,se=TRUE,
type="response"))
# This takes a bit longer.
data(electors)
(mcre <- mclogit(
cbind(Freq,interaction(time,class))~econ.left/class+welfare/class+auth/class,
random=~1|party.time,
data=within(electors,party.time<-interaction(party,time))))
str(predict(mcre))
str(predict(mcre,type="response"))
str(predict(mcre,se.fit=TRUE))
str(predict(mcre,type="response",se.fit=TRUE))
Run the code above in your browser using DataLab