0

I have 6 classes of outcome variable and 14 predictor variables. I built the model below:

fit <- multinom(y  ~ X1 + X2 + as.factor(X3) + ... + X14, data= Original)

And I want to predict probabilities of each class of outcome for a given new data point.

X1 <- 1.6
X2 <- 4
x3 <- 15
.
.
.
X14 <- 8
dfin <- data.frame( ses = c(100, 200, 300), X1, X2, X3, ..., X14)

Then I run predict:

predict(fit, todaydata = dfin, type = "probs")

The outcome looks like:

          #class1      #class2     #class3      #class4      #class5       #class6
#5541   7.226948e-01 1.498199e-01 8.086624e-02 1.253289e-02 8.799416e-03 2.528670e-02
#5546   6.034188e-01 7.386553e-02 1.908132e-01 1.229962e-01 4.716406e-04 8.434623e-03
#5548   7.266859e-01 1.278779e-01 1.001634e-01 2.032530e-02 7.156766e-03 1.779076e-02
#5562   7.120179e-01 1.471181e-01 9.146071e-02 1.265592e-02 8.189511e-03 2.855781e-02
#5666   6.645056e-01 3.034978e-02 1.687687e-01 1.219601e-01 3.972833e-03 1.044308e-02
#5668   4.875966e-01 3.126855e-02 2.090006e-01 2.430828e-01 3.721631e-03 2.532970e-02
#5670   3.900772e-01 1.305786e-02 1.803779e-01 4.137106e-01 1.314298e-03 1.462155e-03
#5671   4.272971e-01 1.194599e-02 1.748494e-01 3.833422e-01 8.863019e-04 1.678975e-03
#5674   5.477521e-01 2.587478e-02 1.650817e-01 2.487404e-01 3.368726e-03 9.182195e-03
#5677   4.300207e-01 9.532836e-03 1.608679e-01 3.946310e-01 2.626104e-03 2.321351e-03
#5678   4.542981e-01 1.220728e-02 1.410984e-01 3.885146e-01 2.670689e-03 1.210891e-03
#...

Then I change values of new data point by running the lines below:

X1 <- 2.7
X2 <- 5.1
x3 <- 28
.
.
.
X14 <- 2

dfin2 <- data.frame( ses = c(100, 200, 300), X1, X2, X3, ..., X14)
predict(fit, todaydata = dfin2, type = "probs")

again I got exactly the same probabilities.

          #class1      #class2     #class3      #class4      #class5       #class6
#5541   7.226948e-01 1.498199e-01 8.086624e-02 1.253289e-02 8.799416e-03 2.528670e-02
#5546   6.034188e-01 7.386553e-02 1.908132e-01 1.229962e-01 4.716406e-04 8.434623e-03
#5548   7.266859e-01 1.278779e-01 1.001634e-01 2.032530e-02 7.156766e-03 1.779076e-02
#5562   7.120179e-01 1.471181e-01 9.146071e-02 1.265592e-02 8.189511e-03 2.855781e-02
#5666   6.645056e-01 3.034978e-02 1.687687e-01 1.219601e-01 3.972833e-03 1.044308e-02
#5668   4.875966e-01 3.126855e-02 2.090006e-01 2.430828e-01 3.721631e-03 2.532970e-02
#5670   3.900772e-01 1.305786e-02 1.803779e-01 4.137106e-01 1.314298e-03 1.462155e-03
#5671   4.272971e-01 1.194599e-02 1.748494e-01 3.833422e-01 8.863019e-04 1.678975e-03
#5674   5.477521e-01 2.587478e-02 1.650817e-01 2.487404e-01 3.368726e-03 9.182195e-03
#5677   4.300207e-01 9.532836e-03 1.608679e-01 3.946310e-01 2.626104e-03 2.321351e-03
#5678   4.542981e-01 1.220728e-02 1.410984e-01 3.885146e-01 2.670689e-03 1.210891e-03
#...

What am I doing wrong that cause same outcome for 2 different dfin and dfin2 data frames?

My second question is that why for a single data point I get so many rows of outcome?

Thanks a lot for your time!

Zheyuan Li
  • 71,365
  • 17
  • 180
  • 248
  • Has the issue in your previous question been solved? http://stackoverflow.com/questions/23193824/why-multinom-predicts-a-lot-of-rows-of-probabilities-for-each-level-of-outcome If so, please accept the answer as "accepted answer". – Roman Luštrik Apr 22 '14 at 07:42
  • `dfin` and `dfin2` appear to be identical, from the information you've provided, so why would you expect different probabilities for them? – Thomas Apr 22 '14 at 09:43

0 Answers0