Page 1 of 1

Code evaluation for implementing Bayesian Prior

PostPosted: Fri Apr 29, 2022 4:40 pm
by jonnyK123
Dear all,

I want to conduct a labeled SCE and already performed a pilot study. Now I want to use the estimation results based on MNL to create my design for the final survey using bayesian priors. However, I am not very experienced with writing codes in Ngene. That is why I would really appreciate if someone with more experience can have look at the code.


Code: Select all
design
;alts = alt1, alt2, alt3, alt4
;rows = 30
;block = 5
;eff = (mnl,d)
;alg = mfederov
;model:
U(alt1) = asc1[0]
        + b1[(n,  -.0870758 , .0303124)]   * A1[2,7,14]
        + b2[(n, -.1342338, .1347078)]   * B1[0]
        + b3[(n, -.0155826, .0070892)]   * C1[10,20,60]
        + b4[(n, -.0512281, .070547)]   * D1[0]
        + b5[(n, -.0222957,  .0063588)]   * E1[30]
        /
U(alt2) = asc2[0]
        + b1      * A2[0]
        + b2      * B2[2,4]
        + b3      * C2[0]
        + b4      * D2[2,3,5]
        + b5      * E2[16,24,32]
        /
U(alt3) = asc3[0]
        + b1      * A3[0,1,2]
        + b2      * B3[0]
        + b3      * C3[0]
        + b4      * D3[1,2,3]
        + b5      * E3[50,75,100]
        /
U(alt4) = b1      * A4[0]
        + b2      * B4[0]
        + b3      * C4[0]
        + b4      * D4[1,2,3]
        + b5      * E4[50,75,100,125,150]
$



Another concers I have with the code is that I do not really know how to hadle the respective asc. My parameter estimates are base on including the alternative specific constants. So, should I include those estimates in the brackets of the respective asc or is it better to estimate another MNL with excluding the constants and use those estimated coefficients / stdd instead?

Re: Code evaluation for implementing Bayesian Prior

PostPosted: Fri Apr 29, 2022 6:01 pm
by Michiel Bliemer
This looks quite good.

A few suggestions:

1. You need to include priors for your ASCs. In the model that you estimated using pilot data, I assume that you also included and estimated ASCs. So you must not only use the parameter estimates for the priors of the attributes, but also use the parameter estimates for the priors of the ASCs, all from the same model that you estimated.

2. I would remove ;alg = mfederov, since the modified Federov algorithm would not be able to guarantee attribute level balance. Since you have no constraints, there is not really a reason for using the modified Federov algorithm. Further, for a Bayesian efficient design you need to select "mean" or "median" and specify the Bayesian draws. See script below.

Code: Select all
design
;alts = alt1, alt2, alt3, alt4
;rows = 30
;block = 5
;eff = (mnl,d,mean)
;bdraws = sobol(500)
;model:
U(alt1) = asc1[0]
        + b1[(n,  -.0870758 , .0303124)]   * A1[2,7,14]
        + b2[(n, -.1342338, .1347078)]   * B1[0]
        + b3[(n, -.0155826, .0070892)]   * C1[10,20,60]
        + b4[(n, -.0512281, .070547)]   * D1[0]
        + b5[(n, -.0222957,  .0063588)]   * E1[30]
        /
U(alt2) = asc2[0]
        + b1      * A2[0]
        + b2      * B2[2,4]
        + b3      * C2[0]
        + b4      * D2[2,3,5]
        + b5      * E2[16,24,32]
        /
U(alt3) = asc3[0]
        + b1      * A3[0,1,2]
        + b2      * B3[0]
        + b3      * C3[0]
        + b4      * D3[1,2,3]
        + b5      * E3[50,75,100]
        /
U(alt4) = b1      * A4[0]
        + b2      * B4[0]
        + b3      * C4[0]
        + b4      * D4[1,2,3]
        + b5      * E4[50,75,100,125,150]
$


3. When you check the choice tasks and if you observe some dominance of certain attributes, then you can consider imposing dominance checks. In that case, you will need the modified Federov algorithm, see script below.

Code: Select all
design
;alts = alt1*, alt2*, alt3*, alt4*
;rows = 30
;block = 5
;eff = (mnl,d,mean)
;bdraws = sobol(500)
;alg = mfederov(candidates = 2000)
;model:
U(alt1) = asc1[0]
        + b1[(n,  -.0870758 , .0303124)]   * A1[2,7,14]
        + b2[(n, -.1342338, .1347078)]   * B1[0]
        + b3[(n, -.0155826, .0070892)]   * C1[10,20,60]
        + b4[(n, -.0512281, .070547)]   * D1[0]
        + b5[(n, -.0222957,  .0063588)]   * E1[30]
        /
U(alt2) = asc2[0]
        + b1      * A2[0]
        + b2      * B2[2,4]
        + b3      * C2[0]
        + b4      * D2[2,3,5]
        + b5      * E2[16,24,32]
        /
U(alt3) = asc3[0]
        + b1      * A3[0,1,2]
        + b2      * B3[0]
        + b3      * C3[0]
        + b4      * D3[1,2,3]
        + b5      * E3[50,75,100]
        /
U(alt4) = b1      * A4[0]
        + b2      * B4[0]
        + b3      * C4[0]
        + b4      * D4[1,2,3]
        + b5      * E4[50,75,100,125,150]
$


Michiel

Re: Code evaluation for implementing Bayesian Prior

PostPosted: Fri Apr 29, 2022 7:03 pm
by jonnyK123
Thank you for help, Michiel.

I have one follow up question:

If I include the paramter estimates for the ASCs in the code in 2., do I include them as follwed:

1. U(alt2) = asc2[-.5062053]

or

2. U(alt2) = asc2[(n, -.5062053, .5740263)]

kind regards,

Jonas

Re: Code evaluation for implementing Bayesian Prior

PostPosted: Sun May 01, 2022 10:55 am
by Michiel Bliemer
Since you are using bayesian priors for the other parameters, I would also used bayesian priors for the constants, so I would do option 2.

Michiel