3

I'm having trouble estimating a multinomial probit model in R. I've found two packages, but I haven't gotten either to give satisfactory results. Is there a bug in my code? Am I using the packages incorrectly?

A little example:

A consumer faces 3 choices, plus the outside option of not taking any of the choices. The utility of the outside option is normalized to zero:

u_i0 = 0
u_i1 = -20 + 1*age_i + epsilon_i1
u_i2 = 0             + epsilon_i2
u_i3 =  15 - 1*age_i + epsilon_i3

(Here i indexes consumers.)

Code where (assuming no bug) age is uniform on 11:50 and the epsilons are iid Normal(0, 1), independently of age:

library(MNP)  # Multinomial probit
library(mlogit)  # Has a probit option

n <- 1000
df <- data.frame(age=sample(11:50, replace=TRUE, size=n))
constant <- c(-20, 0, 15)
coefficients <- rbind(c(1, 0, -1))
epsilon <- matrix(rnorm(n*3), nrow=n, ncol=3)
utility <- (matrix(rep(constant, n), nrow=1000, ncol=3, byrow=TRUE) +
            as.matrix(df) %*% coefficients + epsilon)
isTRUE(all.equal(utility[1, ], as.vector(constant + coefficients * df$age[1] +
                                         epsilon[1, ])))  # True as expected
df$choice <- max.col(utility)
max.utility <- apply(utility, 1, max)
df$choice[max.utility < 0] <- 0  # Take outside option when all product utilities < 0
df$choice <- factor(df$choice)
table(df$choice)

model.mnp <- mnp(choice ~ age, data=df, burnin=100)
summary(model.mnp)  # Many of the 95% intervals don't contain the true value

model.mlogit <- mlogit(choice ~ 0 | age, data=df,
                       varying=NULL, shape="wide", probit=TRUE)
summary(model.mlogit)

I'd like the models to recover the coefficients, but mnp's estimates seem to be off (or are they just very noisy?), and mlogit gives me an error saying the system is computationally singular.

What should I try?

Edit: this does work (probit=FALSE):

model.mlogit <- mlogit(choice ~ 0 | age, data=df, varying=NULL, shape="wide", probit=FALSE)
summary(model.mlogit)

It gives constants of roughly -30, 0, 22 and age coefficients of 1.5, 0, -1.4. The code runs and it gives reasonable estimates -- but they aren't exactly correct, because the data are generated with normal errors, whereas for the logit to be correctly specified the errors would have to be extreme value (see http://en.wikipedia.org/wiki/Logistic_regression#As_a_latent-variable_model)

Adrian
  • 3,138
  • 2
  • 28
  • 39
  • Take a look at the examples for ?mlogit. In particular the shape of those data head(Fishing), and head(Fish). Look at how these data are generated vs. those data that you are providing to mlogit (head(df)). – Brandon Bertelsen Nov 14 '12 at 03:21
  • @BrandonBertelsen these two commands give the same output: `mlogit(mode ~ 0 | income, data=Fishing, shape='wide', varying = NULL)` and `mlogit(mode ~ 0 | income, data=Fish)` – Adrian Nov 14 '12 at 12:44
  • Yes, but in particular I'm trying to direct you to the shape of the data and the call to mlogit.data() in the example. Looking at what they start with head(Fish), and after mlogit.data look at what they are actually using in the model head(Fishing). – Brandon Bertelsen Nov 14 '12 at 17:11
  • @BrandonBertelsen I'm getting errors even if I use the mlogit.data function and call mlogit on the reshaped data. For example, from some code similar to the mini example I posted above: `model <- mlogit(choice ~ 0 | age + I(age.squared/100) + schooling, data=reshaped.df, probit=TRUE, print.level=2)` where reshaped.df was created with mlogit.data gives `Error in if (is.null(initial.value) || lnl <= initial.value) break : missing value where TRUE/FALSE needed` after running for 2 iterations – Adrian Nov 16 '12 at 13:24
  • @adrian Did you end up solving this issue? I have a similar problem. Could you please help in case you solved it? Thanks. http://stackoverflow.com/questions/23712119/mlogit-multinomial-probit-model-missing-value-where-true-false-needed – dreamer May 17 '14 at 14:41
  • @BrandonBertelsen I have a similar issue, could you please help me? Thanks in advance. http://stackoverflow.com/questions/23712119/mlogit-multinomial-probit-model-missing-value-where-true-false-needed – dreamer May 17 '14 at 18:17
  • @Dreamer recommend opening a new question. – Brandon Bertelsen May 19 '14 at 04:13
  • @BrandonBertelsen I did. Its in the link that I included in my previous comment ;) – dreamer May 19 '14 at 07:21

0 Answers0