I'm finding it hard to understand your code.
The first line, recasts revenu as a factor variable, ok.
the line after would seem to want to predict something using a model that is not yet declared (because there seems to be a declaration the line below.), but also dc doesnt seem to be referenced elsewhere. so can this simply be removed?
Then you fit a model (you implicitly cast fac.num as factor, in contrast to your more explicit approach for revenu, I personally would prefer a consistent approach, though its not an issue technically.)
However pred.probs, would only contain the predictions, so when you ggplot you fail to have any data aside from the predictions. revenu is not a name of a prediction level. you can add/bind revenu back in so that its there.
However then your ggplot also tries to plot other things that are not present (and its not clear where they would come from) i.e 'mean' and 'level'.
Perhaps there is a relevant different between your use of predict and the tutorials use of glm.predicts predicts functions.
Here is a version of your code that gets you up to where plot creation might begin, but I would pause thinking about what to plot before addressing the model's apparent strategy of always predicting class 2 for fac.num.
library(nnet)
library(haven)
library(tidyverse)
voxit_destill_1996<-haven::read_spss("voxit_destill_1996.sav")
input_data <- data.frame(
revenu=as.factor(voxit_destill_1996$revenu),
fac.num=as.factor(voxit_destill_1996$fac.num)
)
input_data_no_na <- na.omit(input_data)
# dc = predicts(mod.fak_diff_1996.7,"F", position = 1 )
mod.fak_diff_1996.7 <- multinom(fac.num ~ revenu, data=input_data_no_na)
pred.probs <- predict(mod.fak_diff_1996.7, type = "probs")
pred.probs <-as.data.frame(pred.probs)
pred.probs$prediction <- apply(pred.probs, 1, which.is.max)
table(pred.probs$prediction) ## unfortunately your model only predicts '2' so probably isnt a great model...
(pred.probs <- bind_cols(pred.probs,input_data_no_na))