## How to get prior values for mixed logit design

This forum is for posts that specifically focus on Ngene.

Moderators: Andrew Collins, Michiel Bliemer, johnr

### How to get prior values for mixed logit design

Dear Prof. Michiel Bliemer,

I'm working on DCE and conducting research about farmers' selection of insurance using a discrete choice experiment. In my DCE research, I have three alternatives – insurance type1, insurance type2, and “nothing to choose” (opt out). I have 4 attributes, 2 attributes with 3 levels, 1 attribute with 4 levels and 1 attribute with 2 levels.

My orthogonal design for pilot survey was:
Design
;alts = alt1*, alt2*, alt3
;rows = 12
;orth = seq
;block = 3
;model:
U(alt1) = b1 * A[0,1,2] + b2 * B[0,1,2] +b3.effects* C[0,1]+ b4 *D [0,1,2,3] /
U(alt2) = b1 * A[0,1,2] + b2 * B[0,1,2] +b3.effects* C[0,1]+ b4 *D [0,1,2,3] /
U(alt3) = b5
\$

I conducted and collected data (total for 3 blocks - 47 respondents) to get prior values for mixed logit design.
I have a few questions if you can help me.
My questions are following:
1) I conducted my pilot survey and I have a problem with coding data for further analysis. I'm not sure if one attribute needs to be coded as one variable, or every level of attribute needs to be coded as one variable? So, I would kindly ask you if you can take a look at the attached link https://drive.google.com/file/d/1sN5MuX ... sp=sharing to see does any of this 2 tables is correct for coding data from choice.
Additionally, how can I code 3rd alternatives if it represents “nothing to choose”, and it is not defined with any attribute?
2) How to get prior values from my orthogonal design to design an efficient mixed logit model? To analyse the results of my pilot study do I need to use a mixed logit command to find the prior values? I don't understand how to proceed to get prior values for mixed logit design.

Best regards,
Tajana
tajana

Posts: 2
Joined: Wed Jan 15, 2020 9:26 pm

### Re: How to get prior values for mixed logit design

Hi Tajana,

1.
This is not an Ngene related question but rather a question regarding model estimation. It depends on what levels 0,1,2,... stand for. You have effects-coded only attribute C, but not A, B, and D. If A is a qualitative variable, you will need to use dummy or effects coding. If A is a continuous variable, such as price, you need to use exact price levels shown in your survey, e.g. 5 and 10 for \$5 and \$10.

If you are applying effects coding for A, then you will need to use separate parameters for each level, except for reference level.
So for example choosing level 2 as the reference level, you will estimate a parameter for level 0 and level 1. In your data, you could create 2 variables, A0 and A1, for which you set the following:

if level is 0, then A0 = 1 and A1 = 0
if level is 1, then A0 = 0 and A1 = 1
if level is 2, then A0 = -1 and A1 = -1

If you would use dummy coding, the last line would become A0 = 0 and A1 = 1. You can find a lot of information about dummy and effects coding online.

For the opt-out alternative you only add a constant, i.e. it is typically a fixed value of 1 for each choice task. Please refer to the manual of your estimation software how to code your data as this may vary across different software packages. Not all software requires you to explicitly create a column with ones for constants in your data.

2. You would need to estimate a mixed logit model using your pilot data and you would use the parameter estimates to inform your priors. It is almost impossible to create an efficient design for a mixed logit model, so I strongly recommend creating an efficient design for a multinomial logit model. In this case, you would estimate parameters b1, b2, b3, etc (and if you use effects coding or dummy coding, there are a few parameters per attribute) and you would obtain standard errors se1, se2, se3, etc. I again will need to refer you to the manual of your estimation software, obtaining parameter estimates needs to be done outside Ngene. Then you would use Bayesian priors such as b1[(n,b1,se1)] in Ngene.

Michiel
Michiel Bliemer

Posts: 800
Joined: Tue Mar 31, 2009 4:13 pm

### Re: How to get prior values for mixed logit design

Dear, prof. Bliemer

In my orthogonal design, I had b3 named as effects variable.
My variables are:
Th – 10%, 20%, 30% (numeric variable)
Comp – 60%, 70%, 80% (numeric variable)
Time – 3 years, 5 years (discrete numeric variable) - effects variable
Premium – 2,500, 3,000, 3,500, 4,000, 4,500 (numeric continuous variable)

For model estimation, I codded effects variable (time) and get one new variable (time-reference level 5).

When I estimated mixed logit model using pilot data by STATA my output was:
coef. SD
Th -0.051952 -0.053512
Comp 0.072854 0.398857
Time 0.455559 0.464289
time5referencelevel 0.379783 -0.068717

Then I use priors and want to design efficient mix logit design in Ngene.
? Efficient based on an RP model
Design
;alts = alt1*, alt2*, alt3
;rows = 12
;eff = (rp,d)
;rep = 500
;rdraws = halton(250)
;model:
U(alt1) = b1[n, -0.0519521, 0.0535116] * A[0,1,2] + b2[n, 0.0728537, 0.0398857] * B[0,1,2] + b3.effects[(n, 0.4555593, 0.4642886)] * C[0,1] + b4[n, -0.0005366, 0.0011181] * D[0,1,2,3,4] /
U(alt2) = b1 * A + b2 * B + b3.effects * C + b4 * D /
U(alt3) = b5
\$

With this syntax, I get a design with D error 7.282938, and B estimate 81%. But, as you said, for effects coding is obligatory to put two parameters for mean and SD for b3.effects[(n, 0.4555593, 0.4642886)|(n, 0.379783, 0.068717)]. When I put mentioned in Ngene Syntax (b3.effects[(n, 0.4555593, 0.4642886)|(n, 0.379783, 0.068717)]) there occurred an error: “Error: An attribute has the wrong number of levels for dummy or effects coding. 'c'”.
So, my question is, is this proposed efficient design ok or what it needs to be changed? How to properly design mixed logit if I have effects codded variable, and parameters for mixed logit estimation.
What do you suggest on how to proceed.

Thank you!

Tajana
tajana

Posts: 2
Joined: Wed Jan 15, 2020 9:26 pm

### Re: How to get prior values for mixed logit design

There are several issues.

1. You need to use the exact same levels for estimation as for designing. You state that you use 60%, 70%, 80% for Comp but you are using levels 0,1,2 in the design. You typically would have 60,70,80 in your data and use B[60,70,80] in the Ngene syntax. For Premium, I would expect D[2500,3000,3500,4000,4500] instead of D[0,1,2,3,4] unless you are applying scaling to all parameters afterwards.

2. In my advice I recommended using a Bayesian efficient design for the multinomial logit model instead of a fixed efficient design for the mixed logit model. In your syntax you are mixing both up, namely you use Bayesian priors (with brackets around the priors) and random parameters (without brackets around the priors). Please make sure that you understand the difference between Bayesian priors and random parameters.

3. If you have 2 levels in an effects coded variable, you are only estimating 1 parameter, so it is correct to ignore the reference level.

4. I do not understand your STATA output that gives also a parameter for the reference level, since you do not estimate this level. If this is the reference level and you are using effects coding, then the value needs to be -0.455559. I do not know STATA so please make sure you understand the estimation output.

Michiel

? Efficient based on an RP model
Design
;alts = alt1*, alt2*, alt3
;rows = 12
;eff = (rppanel,d)
;rep = 500
;rdraws = halton(250)
;model:
U(alt1) = b1[n, -0.0519521, 0.0535116] * A[0,1,2] + b2[n, 0.0728537, 0.0398857] * B[0,1,2] + b3.effects[(n, 0.4555593, 0.4642886)] * C[0,1] + b4[n, -0.0005366, 0.0011181] * D[0,1,2,3,4] /
U(alt2) = b1 * A + b2 * B + b3.effects * C + b4 * D /
U(alt3) = b5
\$
Michiel Bliemer

Posts: 800
Joined: Tue Mar 31, 2009 4:13 pm