Hi everyone,
I want to create plots with predicted values and confidence intervals for my multinomial logistic models (multinom
function, created with the nnet
package). I have numerical predictors on the log scale.
I want to create plots with predicted values and confidence intervals for my multinomial logistic models ( multinom
function, created with the nnet
package). I have numerical predictors on the log scale.
As janix said his post, though ggeffects() should be compatible with multinom, the plot does not display confidence intervals. If I plot the same data with effects(), I do get the CIs.
What I have tried:
I found this very helpful post on RCommunity in which confidence intervals from the effects package were combined with ggeffects to create a plot.
However, (and I'm sure this is my error somewhere) when I run this code I get the following error:
Error in FUN(X[[i]], ...) : object 'L' not found
I have also tried MNLpred
package and its mnl_pred_ova
function as an alternative, but my predictors are in log scale, and it doesn't seem to be able to deal with these - I get the following error:
Error in eval(parse(text = paste0("data$", xvari))) :
attempt to apply non-function
Lastly, I tried using the mnlAveEffPlot
function from the DAMisc
package, which works, but isn't as customisable as I would like.
I am new to using to R and to this community, so my apologies if this question is very basic or is missing something essential. Here is a small example:
library(nnet)
library(plyr)
library(dplyr)
library(ggplot2)
library(tidyr)
library(sjPlot)
library(DAMisc)
library(ggeffects)
library(scales)
library(MNLpred)
library(effects)
df <- data.frame(response = c("1 Better", "1 Better", "1 Better", "2 Medium", "2 Medium", "2 Medium", "3 Worse", "3 Worse", "3 Worse"),
count = c(1000, 2000, 4000, 6000, 10000, 3000, 6000, 5000, 11000))
mod1 <- multinom(response ~ log(count),
data = df)
summary(mod1)
pred <- ggpredict(mod1, terms = "count")
plot(pred)
Thanks for your help!