Predicting responses or linear parts of the baseline-category and conditional logit models
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 class 'mblogit' predict(object, newdata=NULL,type=c("link","response"),se.fit=FALSE, ...) ## S3 method for class 'mclogit' predict(object, newdata=NULL,type=c("link","response"),se.fit=FALSE, ...) ## S3 method for class 'mmblogit' predict(object, newdata=NULL,type=c("link","response"),se.fit=FALSE, conditional=TRUE, ...) ## S3 method for class 'mmclogit' predict(object, newdata=NULL,type=c("link","response"),se.fit=FALSE, conditional=TRUE, ...)
object |
an object in class "mblogit", "mmblogit", "mclogit", or "mmclogit" |
newdata |
an optional data frame with new data |
type |
a character string specifying the kind of prediction |
se.fit |
a logical value; whether predictions should be accompanied with standard errors |
conditional |
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 |
... |
other arguments, ignored. |
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"
.
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))
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.