mboost
mboost copied to clipboard
predict for Multinomial models with type = "class"
library(mboost)
myiris <- as.list(iris)
myiris$class <- factor(levels(iris$Species)[-nlevels(iris$Species)])
## Now fit the linear array model
mlm <- mboost(Species ~ bols(Sepal.Length, df = 2) %O%
bols(class, df = 2, contrasts.arg = "contr.dummy"),
data = myiris,
family = Multinomial())
# works
predict(mlm)
# gives weird error message
predict(mlm, type = "class")
If type = "class" is something we won't be able to fix, we should at least return a meaningful error message.
(Quick) fix:
apply(predict(mlm, type = "response"),1,which.max)