Code check

This forum is for posts that specifically focus on Ngene.

Moderators: Andrew Collins, Michiel Bliemer, johnr

Code check

Postby MirtheN » Thu Sep 21, 2023 7:21 pm

Hi,

I am creating an orthogonal fractional factorial design with five alternatives, using the following code:

Code: Select all
?
Simultaneous orthogonal fractional factorial design
Design
;alts = location1, location2, route1, route2, none
;rows = 20
;orth = sim
;block = 2
;con
;model:
U(location1) = a_location + b1 * x1[0,1] + b2 * x2[0,1] + b3 * x3[0,1] + b4 * x4[0,1] + b5 * x5[0,1] /
U(location2) = a_location + b1 * x1      + b2 * x2      + b3 * x3      + b4 * x4      + b5 * x5      /
U(route1)    = a_route    + b6 * x6[0,1] + b7 * x7[0,1] + b8 * x8[0,1] + b9 * x9[0,1]                /
U(route2)    = a_route    + b6 * x6      + b7 * x7      + b8 * x8      + b9 * x9                     
$


I have some questions about this design:
1. Is my code correct?
2. Is there a way to improve my code? The current design results in a D-error of 0.54 and an A-error of 0.71.
3. The constants a_location and a_route are of importance, and therefore I added ;con to the code. Is this correct?

Also, I know that b1-b9 should have positive values. So I could also use an efficient design. The manual states that the sign of a parameter can be indicated in an efficient design. I cannot, however, figure out how to specify a lower bound only for b1-b9 in the code below.

Code: Select all
? Efficient design
Design
;alts = location1, location2, route1, route2, none
;rows = 20
;eff = (mnl, d)
;block = 2
;con
;model:
U(location1) = a_location + b1 * x1[0,1] + b2 * x2[0,1] + b3 * x3[0,1] + b4 * x4[0,1] + b5 * x5[0,1] /
U(location2) = a_location + b1 * x1      + b2 * x2      + b3 * x3      + b4 * x4      + b5 * x5      /
U(route1)    = a_route    + b6 * x6[0,1] + b7 * x7[0,1] + b8 * x8[0,1] + b9 * x9[0,1]                /
U(route2)    = a_route    + b6 * x6      + b7 * x7      + b8 * x8      + b9 * x9                     
$


Could you please help me with this?

Thank you in advance!
MirtheN
 
Posts: 8
Joined: Thu Sep 21, 2023 6:04 am

Re: Code check

Postby Michiel Bliemer » Thu Sep 21, 2023 9:39 pm

Your scripts look okay and your constants and the ;con property are fine.

You can set small positive or negative priors using b[-0.01] or b[0.01], however this is only useful when trying to avoid dominant alternatives as this indicates the preference order of the attributes while the priors essentially remain zero.

You would usually use an asterisk in Ngene to indicate unlabelled alternatives like route1*, route2*, but in your case you have two sets of unlabelled alternatives. To avoid dominant alternatives, you could use the modified Federov algorithm and include several reject constraints as below. With these constraints, it is no longer necessary to use small positive priors. I nevertheless added an asterisk to route1 and route 2 because this also removes duplicates where the levels of the attributes are merely swapped between route1 and route 2. This is less likely to occur for location1 and location2 because they have more attributes.

The script below will generate a design with a D-error of around 0.46.

Once you have done a pilot study and estimated the model, you can use these as informative priors to generate a more efficient design.


Code: Select all
? Efficient design
Design
;alts = location1, location2, route1*, route2*, none
;rows = 20
;eff = (mnl, d)
;block = 2
;alg = mfederov
;reject:
location1.x1 >= location2.x1 and location1.x2 >= location2.x2 and location1.x3 >= location2.x3 and location1.x4 >= location2.x4 and location1.x5 >= location2.x5,
location1.x1 <= location2.x1 and location1.x2 <= location2.x2 and location1.x3 <= location2.x3 and location1.x4 <= location2.x4 and location1.x5 <= location2.x5,
route1.x6 >= route2.x6 and route1.x7 >= route2.x7 and route1.x8 >= route2.x8 and route1.x9 >= route2.x9,
route1.x6 <= route2.x6 and route1.x7 <= route2.x7 and route1.x8 <= route2.x8 and route1.x9 <= route2.x9
;con
;model:
U(location1) = a_location + b1[0.01] * x1[0,1] + b2[0.01] * x2[0,1] + b3[0.01] * x3[0,1] + b4[0.01] * x4[0,1] + b5[0.01] * x5[0,1] /
U(location2) = a_location + b1       * x1      + b2       * x2      + b3       * x3      + b4       * x4      + b5       * x5      /
U(route1)    = a_route    + b6[0.01] * x6[0,1] + b7[0.01] * x7[0,1] + b8[0.01] * x8[0,1] + b9[0.01] * x9[0,1]                      /
U(route2)    = a_route    + b6       * x6      + b7       * x7      + b8       * x8      + b9       * x9                   
$


Michiel
Michiel Bliemer
 
Posts: 1888
Joined: Tue Mar 31, 2009 4:13 pm

Re: Code check

Postby MirtheN » Thu Sep 21, 2023 10:22 pm

Hi Michiel,

Thank you very much for your quick reply.

I have some more questions, which I hope you can answer.
1. In the first choice situation resulting from the orthogonal design, location1 and location2, and route1 and route2 are identical. Is there any way to avoid this?

Choice situation location1.x1 location1.x2 location1.x3 location1.x4 location1.x5 location2.x1 location2.x2 location2.x3 location2.x4 location2.x5 route1.x6 route1.x7 route1.x8 route1.x9 route2.x6 route2.x7 route2.x8 route2.x9
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

2. Would you recommend using the orthogonal design or the efficient design?
3. Could you explain how the reject constraints in the efficient design help avoid dominant alternatives?
MirtheN
 
Posts: 8
Joined: Thu Sep 21, 2023 6:04 am

Re: Code check

Postby Michiel Bliemer » Thu Sep 21, 2023 10:39 pm

1. You need to create a sequential or optimal orthogonal design. In the script below, I am tricking Ngene and put location1 and route1 together, and then it creates location2 and route2 such that there is no overlap across attribute levels.

Code: Select all
Design
;alts = alt1, alt2
;rows = 20
;orth = ood
;block = 2
;con
;model:
U(alt1) = b1*loc1[0,1] + b2*loc2[0,1] + b3*loc3[0,1] + b4*loc4[0,1] + b5*loc5[0,1] + b6*r1[0,1] + b7*r2[0,1] + b8*r3[0,1] + b9*r4[0,1] /
U(alt2) = b1*loc1[0,1] + b2*loc2[0,1] + b3*loc3[0,1] + b4*loc4[0,1] + b5*loc5[0,1] + b6*r1[0,1] + b7*r2[0,1] + b8*r3[0,1] + b9*r4[0,1]
$


2. If you think that dominant alternatives are not an issue, then I would use the script above to generate an optimal orthogonal design. If dominant alternatives could be an issue, then I would use the efficient design.

3. The first row in the reject constraint states that if location1 is better than (or equal to) location2 in all attributes, then it is dominant and such a choice task should be rejected. The second row checks for dominance of location 2. Similarly, the third and fourth rows check for dominance of route1 and route2, respectively.

Michiel
Michiel Bliemer
 
Posts: 1888
Joined: Tue Mar 31, 2009 4:13 pm

Re: Code check

Postby MirtheN » Thu Sep 21, 2023 11:24 pm

Michiel Bliemer wrote:
Code: Select all
Design
;alts = alt1, alt2
;rows = 20
;orth = ood
;block = 2
;con
;model:
U(alt1) = b1*loc1[0,1] + b2*loc2[0,1] + b3*loc3[0,1] + b4*loc4[0,1] + b5*loc5[0,1] + b6*r1[0,1] + b7*r2[0,1] + b8*r3[0,1] + b9*r4[0,1] /
U(alt2) = b1*loc1[0,1] + b2*loc2[0,1] + b3*loc3[0,1] + b4*loc4[0,1] + b5*loc5[0,1] + b6*r1[0,1] + b7*r2[0,1] + b8*r3[0,1] + b9*r4[0,1]
$



Is it also possible to include a_location and a_route in this design?
MirtheN
 
Posts: 8
Joined: Thu Sep 21, 2023 6:04 am

Re: Code check

Postby Michiel Bliemer » Thu Sep 21, 2023 11:29 pm

Adding constants in the utility function has no effect on an orthogonal design, they are ignored. Orthogonal designs are not aware of the utility functions, they are merely a mathematical construct whereby each attribute level combination appears equally. Constants are not attributes and not part of the design. Only for efficient designs you need to formulate the design exactly as how you would estimate it.

Michiel
Michiel Bliemer
 
Posts: 1888
Joined: Tue Mar 31, 2009 4:13 pm

Re: Code check

Postby MirtheN » Fri Sep 22, 2023 1:10 am

Michiel Bliemer wrote:
Code: Select all
? Efficient design
Design
;alts = location1, location2, route1*, route2*, none
;rows = 20
;eff = (mnl, d)
;block = 2
;alg = mfederov
;reject:
location1.x1 >= location2.x1 and location1.x2 >= location2.x2 and location1.x3 >= location2.x3 and location1.x4 >= location2.x4 and location1.x5 >= location2.x5,
location1.x1 <= location2.x1 and location1.x2 <= location2.x2 and location1.x3 <= location2.x3 and location1.x4 <= location2.x4 and location1.x5 <= location2.x5,
route1.x6 >= route2.x6 and route1.x7 >= route2.x7 and route1.x8 >= route2.x8 and route1.x9 >= route2.x9,
route1.x6 <= route2.x6 and route1.x7 <= route2.x7 and route1.x8 <= route2.x8 and route1.x9 <= route2.x9
;con
;model:
U(location1) = a_location + b1[0.01] * x1[0,1] + b2[0.01] * x2[0,1] + b3[0.01] * x3[0,1] + b4[0.01] * x4[0,1] + b5[0.01] * x5[0,1] /
U(location2) = a_location + b1       * x1      + b2       * x2      + b3       * x3      + b4       * x4      + b5       * x5      /
U(route1)    = a_route    + b6[0.01] * x6[0,1] + b7[0.01] * x7[0,1] + b8[0.01] * x8[0,1] + b9[0.01] * x9[0,1]                      /
U(route2)    = a_route    + b6       * x6      + b7       * x7      + b8       * x8      + b9       * x9                   
$



I still have one question. What does the asterisk added to route1 and route2 exactly do? Can it also be left out?
MirtheN
 
Posts: 8
Joined: Thu Sep 21, 2023 6:04 am

Re: Code check

Postby Michiel Bliemer » Fri Sep 22, 2023 11:02 am

The asterisk tells Ngene that the alternatives are unlabelled. This allows Ngene to check for publication choice tasks and dominant alternatives (the latter only if non-zero priors are specified).

For example,
route1 = (1, 0, 1, 0) and route2 = (0, 1, 0, 1)
is the same as
route1 = (0, 1, 0, 1) and route2 = (1, 0, 1, 0)

Ngene detects the above and avoids such duplications.

You do not need the asterisk, it is an option.

Michiel
Michiel Bliemer
 
Posts: 1888
Joined: Tue Mar 31, 2009 4:13 pm

Re: Code check

Postby MirtheN » Fri Sep 22, 2023 11:34 pm

Thank you very much for your help Michiel!

I have one last question.

Code: Select all
? Efficient design
Design
;alts = location1, location2, route1*, route2*, none
;rows = 20
;eff = (mnl, d)
;block = 2
;alg = mfederov
;reject:
location1.x1 >= location2.x1 and location1.x2 >= location2.x2 and location1.x3 >= location2.x3 and location1.x4 >= location2.x4 and location1.x5 >= location2.x5,
location1.x1 <= location2.x1 and location1.x2 <= location2.x2 and location1.x3 <= location2.x3 and location1.x4 <= location2.x4 and location1.x5 <= location2.x5,
route1.x6 >= route2.x6 and route1.x7 >= route2.x7 and route1.x8 >= route2.x8 and route1.x9 >= route2.x9,
route1.x6 <= route2.x6 and route1.x7 <= route2.x7 and route1.x8 <= route2.x8 and route1.x9 <= route2.x9
;con
;model:
U(location1) = a_location + b1[0.01] * x1[0,1] + b2[0.01] * x2[0,1] + b3[0.01] * x3[0,1] + b4[0.01] * x4[0,1] + b5[0.01] * x5[0,1] /
U(location2) = a_location + b1       * x1      + b2       * x2      + b3       * x3      + b4       * x4      + b5       * x5      /
U(route1)    = a_route    + b6[0.0125] * x6[0,1] + b7[0.0125] * x7[0,1] + b8[0.0125] * x8[0,1] + b9[0.0125] * x9[0,1]                      /
U(route2)    = a_route    + b6       * x6      + b7       * x7      + b8       * x8      + b9       * x9                   
$


I want the route and location alternatives to have an equal weight in the design. I, therefore, changed the priors of the route alternatives to 0.0125. Is this correct? Or is this unnecessary?
MirtheN
 
Posts: 8
Joined: Thu Sep 21, 2023 6:04 am

Re: Code check

Postby Michiel Bliemer » Sat Sep 23, 2023 8:04 am

That is unnecessary, just use a near-zero value for all priors at this stage since you have no information on the true values.
Priors reflect actual behaviour, they should not be used to indicate weight of choice alternatives.
Michiel Bliemer
 
Posts: 1888
Joined: Tue Mar 31, 2009 4:13 pm


Return to Choice experiments - Ngene

Who is online

Users browsing this forum: No registered users and 2 guests