mboost icon indicating copy to clipboard operation
mboost copied to clipboard

predict for Multinomial models with type = "class"

Open davidruegamer opened this issue 6 years ago • 0 comments

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)

davidruegamer avatar Apr 26 '19 17:04 davidruegamer