New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multinomial should throw a proper error is not called within gamboost function #46

Closed
hofnerb opened this Issue Aug 11, 2016 · 1 comment

Comments

Projects
None yet
2 participants
@hofnerb
Member

hofnerb commented Aug 11, 2016

see #44

@mvkorpel

This comment has been minimized.

Contributor

mvkorpel commented Aug 12, 2016

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.

@hofnerb hofnerb closed this in d24c494 Feb 9, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment