4
$\begingroup$

I am using the mlogit package in R to estimate a choice model, I started with the famous Yogurt dataset.

library(mlogit)

data(Yogurt)
names(Yogurt)

Yogdata <- mlogit.data(Yogurt, choice = "choice", shape = "wide", varying = c(2:9), 
                       sep=".")

Yog1 <- mlogit(choice ~ feat+price , data = Yogdata)

summary(Yog1)
phat      <- Yog1$probabilities
Yname     <-colnames(phat)
Y1hat     <- max.col(phat)
Y1hatname <- Yname[Y1hat]

preds = predict(Yog1,newdata=Yogdata)
preds[100:120,]
Yogurt[100:120,c('choice')]

The output preds includes probabilities that sum up to 1 for each row.

         dannon     hiland    weight   yoplait
 [1,] 0.3881972 0.03053851 0.2200040 0.3612603
 [2,] 0.6834572 0.01580043 0.1138286 0.1869137
 [3,] 0.4136804 0.03137184 0.2344462 0.3205015
 [4,] 0.4136804 0.03137184 0.2344462 0.3205015
 [5,] 0.4136804 0.03137184 0.2344462 0.3205015
 [6,] 0.4136804 0.03137184 0.2344462 0.3205015
 [7,] 0.4136804 0.03137184 0.2344462 0.3205015
 [8,] 0.4136804 0.03137184 0.2344462 0.3205015

 [1] dannon  dannon  yoplait yoplait dannon  dannon  dannon  yoplait dannon 
[10] dannon  yoplait yoplait dannon  dannon  dannon  dannon  dannon  dannon 
[19] dannon  dannon  dannon 

The choice would be the highest probability in each row. Would this be correct? When I compare this choice against real choices coming from Yogurt, for the same rows, I see matches are not too great. Is there a way to improve this model? Is this the right way to judge the success of this model?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.