0

I'm working on a discrete choice experiment with the following characteristics: 3 alternatives which includes 1 opt-out. Each of the 2 alternatives has 3 attributes, with each attribute having 3 factor levels. Each respondent has 6 choice tasks to complete. All 3 parameters (alternatives) have been effects type coded.

I would like to create a random parameter error components model with no buy / opt-out as the intercept. However, this gives a singularity error when using the "mlogit" package. Can anyone give advice on how to deal with this?

Random parameter model creation:

rpm1 <- mlogit(choice ~ 0 + Prot + Carb + Price, data=ce,
               rpar = c(Prot = "n", Carb = "n", Price = "n"), panel = TRUE,
               correlation = TRUE, R = 10, Halton = TRUE)

Example of data (in long format):

    id ques choice alti     Prot Carb Price NoBuy
1  26    1  FALSE    1     Meat    B    20     0
2  26    1  FALSE    2      Veg    A    20     0
3  26    1   TRUE    3 NoBurger    0     0     1
4  26    2  FALSE    1     Meat    C    10     0
5  26    2  FALSE    2  Poultry    A    10     0
6  26    2   TRUE    3 NoBurger    0     0     1
7  26    3  FALSE    1  Poultry    C     5     0
8  26    3   TRUE    2     Meat    B    20     0
9  26    3  FALSE    3 NoBurger    0     0     1
10 26    4  FALSE    1  Poultry    A    20     0
11 26    4  FALSE    2      Veg    B     5     0
12 26    4   TRUE    3 NoBurger    0     0     1
13 26    5  FALSE    1      Veg    B    10     0
14 26    5  FALSE    2     Meat    C    10     0
15 26    5   TRUE    3 NoBurger    0     0     1
16 26    6  FALSE    1      Veg    A     5     0
17 26    6  FALSE    2  Poultry    B     5     0
18 26    6   TRUE    3 NoBurger    0     0     1
19 30    1   TRUE    1     Meat    B    20     0
20 30    1  FALSE    2      Veg    A    20     0
David Buck
  • 3,752
  • 35
  • 31
  • 35
Ieben
  • 1

2 Answers2

0

It is a little tricky to diagnose the problem based on what you said, however, there are a couple of things you could try.

The singularity error means that your hessian matrix cannot be inverted, i.e. you cannot obtain your standard errors. Most likely this is caused by your model being over-specified or you don't have enough variation in your data.

You could try this model call:

rpm1 <- mlogit(choice ~ Price + Prot + Carb + NoBuy |-1, data=ce,
               rpar = c(Prot = "n", Carb = "n", Price = "n"), panel = TRUE,
               correlation = TRUE, R = 10, Halton = TRUE)

I have added NoBuy in your utility function and it will calculate and work as an intercept. I have also added |-1, which will remove any other intercepts. You can only estimate a maximum of J-1 where J is equal to the number of alternatives. If you try to estimate all J, your model will fail.

A few other things to note. The number of draws is very very low. You will struggle to make the model converge and your results will not be very meaningful. correlation = TRUE is a fully specified mixed logit with all off-diagonal elements of the lower Cholesky matrix being estimated. This is a very complicated model and can be difficult to estimate if your data is poor. Lastly, I would think carefully about using a normally distributed price parameter given that you cannot estimate welfare measures from such a model.

edsandorf
  • 757
  • 7
  • 17
  • I have tried your recommendation to add `+NoBuy | -1`, but I still get a singularity error. Is it possible that the Hessian cannot be inverted as a result of correlation between several parameters? As I get this singularity error when the `correlation = TRUE` argument is included or omitted. If so, can any improvements to the coding be made to remove correlations? As for the amount of draws, I agree with you. This was just to get a quick estimation to see if the model specification etc works. Same for price distribution, this should indeed not be normally distributed. – Ieben Dec 01 '19 at 12:12
  • Does your MNL model with this specification converge? You should always test your models with the full number of draws. You are trying to approximate the multidimensional integral that is the mixed logit probability. Using only 10 draws will give you a very poor approximation. – edsandorf Dec 01 '19 at 22:04
  • Yes, my MNL model does converge. It is specified as following: `mnl1 <- mlogit(choice ~ 0 + Prot + Carb + Price + NoBuy, data=ce)` . – Ieben Dec 03 '19 at 07:56
  • Ok, so we know that the specification will converge. To keep testing, I would do the following: 1) use the `mlogit` syntax to be sure certain that the constants are not in there, i.e. `choice ~ Price + Prot + Carb + NoBuy | - 1`. 2) Have the `Price` first in your utility function. It improves stability especially when you have `correlation = TRUE`. 3) Start with `correlation = FALSE` and only one random variable using more draws, e.g. `R = 1000`. 4) If step 3 is successful, add another random variable. This should allow you to identify when your model fails. – edsandorf Dec 03 '19 at 08:37
0

I believe that I'm facing the same problem as mentioned here: Including opt-out as alternative specific constant in R Mlogit

When I code my dummy variable for the NoBuy as in the example I still get a singularity related issue. The dummy for the opt-out NoBuy is 1 if this alternative is chosen, while it takes the value -1 if option A or B are chosen. (If I assign the value of 0 to the opt-out dummy when option A or B are chosen as in the dataframe above, I get the same issue.) Namely, Warning message: In sqrt(diag(vcov(object))) : NaNs produced

Is my effects type coding for the attributes and the NoBuy dummy correct?

Here's an example of my effectscoding (always using the opt-out attribute level as a reference):

contrasts(ce_long$Prot) Meat Poultry Veg Meat 1 0 0 Poultry 0 1 0 Veg 0 0 1 NoBurger -1 -1 -1

contrasts(ce_long$Carb) A B C A 1 0 0 B 0 1 0 C 0 0 1 0 -1 -1 -1

contrasts(ce_long$Price) 10 20 5 10 1 0 0 20 0 1 0 5 0 0 1 0 -1 -1 -1

Ieben
  • 1