0
votes

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
2

2 Answers

0
votes

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.

0
votes

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