Closed hofnerb closed 7 years ago
The following piece of code may not be exactly what you are looking for (and what the title says), and I'm not sure if this will eliminate all possible crashes. However, ?Family
has the following note about Multinomial()
:
Note that this family does not work with tree-based base-learners at the moment.
To me, it seems useful to check for this combination in mboost_fit()
:
diff --git a/R/mboost.R b/R/mboost.R
index 6d97af3..45039da 100644
--- a/R/mboost.R
+++ b/R/mboost.R
@@ -52,6 +52,10 @@ mboost_fit <- function(blg, response, weights = rep(1, NROW(response)),
### set up the fitting functions
bl <- lapply(blg, dpp, weights = weights)
+ if (identical("Negative Multinomial Likelihood", family@name) &&
+ any(vapply(bl, inherits, FALSE, what = "bl_tree"))) {
+ stop("Multinomial() does not work with tree-based base-learners")
+ }
blfit <- lapply(bl, function(x) x$fit)
fit1 <- blfit[[1]]
This will stop execution in the previously crashing examples of #44.
see #44