pbreheny / visreg

Visualization of regression functions
http://pbreheny.github.io/visreg/
61 stars 18 forks source link

visreg for multinomial models #18

Closed pbreheny closed 7 years ago

pbreheny commented 8 years ago

David Mouillot (Université Montpellier) writes:

How can use visreg for multinomial regression models? I have to predict an ordinal variable with 3 categories, I compute my multinom function (package nnet) but I cannot then use this result in visreg.

pbreheny commented 8 years ago

visreg cannot currently handle this type of model (one for which the prediction is a vector of class probabilities, rather than just a single number), but certainly, it would be a nice improvement if it could. I hope to get this improvement into the next version.

pbreheny commented 7 years ago

This issue has been fixed by commit 1a526c455c0fc13424ae97cf123a09f9c2f877c4

Long story: This is part of a larger issue: how should visreg handle objects that return matrices as predictors? This also comes up in multiple outcome regression models ("mlm") and quantile regression (#16). The existing infrastructure in visreg is to return a list of visreg objects in this case, one for each outcome. In the case of multinomial regression, we'd also like the ability to overlay them, which means collapsing them from a list into a single visreg object, then plotting.

Short story: This works now, but you'll have to specify collapse=TRUE. See enhances-nnet.R for details and a working, reproducible example.