0

I have calculated a multinomial logistic regression using the multinom function with the following code:

####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

Now, I would like to create a classification table from which I can determine the percentage of the predicted probabilities that actually agree with the data. The dependent variable (leg_pat_mean) represents has four value 1,2,3,4.

I would appreciate it very much if someone suggests code that can help to solve this problem.

mt1022
  • 16,834
  • 5
  • 48
  • 71
Henning
  • 1
  • 1
  • Could you please post some example data that we can work with? https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Marcus Campbell Apr 20 '18 at 17:37
  • I'd try `prob = predict(REG)`, so `table(prob, MyData3$Y)` should work. If you just want the percentage of correct classification, `mean(fitted == MyData3$Y)` would do it. – Yannis Vassiliadis Apr 20 '18 at 18:40

0 Answers0