var1<-sample(c('A', 'B', 'C'), replace = T, size=100)
var2<-sample(c(0,1), size=100, replace=T)
var3<-rnorm(100, mean=10, sd=2)
df<-data.frame(var1, var2, var3)
library(nnet)
m1<-multinom(var1~var2, data=df)
m2<-multinom(var1~var3, data=df)
m3<-multinom(var1~var2+var3, data=df)
#install.packages('DescTools')
library(DescTools)
PseudoR2(m1, which='all')
I get this error code:
Error in as.data.frame.default(data, optional = TRUE) : cannot coerce class ‘"function"’ to a data.frame In addition: Warning message: In PseudoR2(m1, which = "all") : Could not find model or data element of multinom object for evaluating PseudoR2 null model. Will fit null model with new evaluation of 'df'. Ensure object has not changed since initial call, or try running multinom with 'model = TRUE'
However, m1
is a multinom
object and I think it's all well formatted, no?
You need to set
model=T
: