我使用multinom函数计算了一个多项逻辑回归,其代码如下:
ns()
现在,我想创建一个分类表,我可以从中确定实际与数据一致的预测概率的百分比。因变量(####multinomial regression analysis####
MyData <- read.csv(file="Data.csv", header=TRUE, sep=";")
### changes DV to a factor variable####
MyData2 <- transform(MyData,Y = factor(Y) )
###sets the base for the regression###
MyData3 <- within(MyData2, Y <- relevel(Y, ref= 3))
###the regression equation###
REG=multinom(Y~ a + b + c + d + e + f + g, data=MyData3)
summary (REG)
###predicted probabilities###
prob=fitted(REG)
prob
)表示有四个值1,2,3,4。
如果有人建议可以帮助解决这个问题的代码,我将非常感激。