Include conmtratints on one level of a given attribute

This forum is for posts that specifically focus on the Windows desktop version of Ngene (i.e. all version 1.x releases).

Moderators: Andrew Collins, Michiel Bliemer, johnr

Post Reply
NormaB
Posts: 7
Joined: Fri Jul 23, 2021 9:16 pm

Include conmtratints on one level of a given attribute

Post by NormaB »

Hi, I need help with my utility specification, to create constraints on just one level of a given attribute.
This is my syntax
design
;alts = alt1*, alt2*
;rows = 36
;eff =(mnl,d)
;block = 4
;model:
U(alt1)= b1.dummy[0|0|0]*test[1,2,3,4] + b2.dummy[0|0|0]*risk[1,5,20,50] + b3*cost[0,50,200] + b4.dummy[0|0]*time[1,2,3] + b5*dist[1,2,3] /
U(alt2)= b1.dummy[0|0|0]*test[1,2,3,4] + b2.dummy[0|0|0]*risk[1,5,20,50] + b3*cost[0,50,200] + b4.dummy[0|0]*time[1,2,3] + b5*dist[1,2,3]

$

But for test 1, the risk level should be set to 1,5, 20 only. All other attributes are the same for all four tests.
How do I do that?
Thank you.
Michiel Bliemer
Posts: 2055
Joined: Tue Mar 31, 2009 4:13 pm

Re: Include conmtratints on one level of a given attribute

Post by Michiel Bliemer »

You can use the ;cond property, see script below.

Code: Select all

design
;alts = alt1*, alt2*
;rows = 36
;eff =(mnl,d)
;block = 4
;cond:
if(alt1.test = 1, alt1.risk = [1,5,20]),
if(alt2.test = 1, alt2.risk = [1,5,20])
;model:
U(alt1)= b1.dummy[0|0|0]*test[1,2,3,4] + b2.dummy[0|0|0]*risk[1,5,20,50] + b3*cost[0,50,200] + b4.dummy[0|0]*time[1,2,3] + b5*dist[1,2,3] /
U(alt2)= b1.dummy[0|0|0]*test[1,2,3,4] + b2.dummy[0|0|0]*risk[1,5,20,50] + b3*cost[0,50,200] + b4.dummy[0|0]*time[1,2,3] + b5*dist[1,2,3]
$
Michiel
NormaB
Posts: 7
Joined: Fri Jul 23, 2021 9:16 pm

Re: Include constraints on one level of a given attribute

Post by NormaB »

Hi Michiel,
thank you very much.
Kind regards
Norma
NormaB
Posts: 7
Joined: Fri Jul 23, 2021 9:16 pm

Re: Include conmtratints on one level of a given attribute

Post by NormaB »

Hi Michiel,
I have included the following constraints in my model but I keep getting scenarios comparing the same test, although with different levels of the remaining attributes.
What could be wrong in my syntax? I have run it over three days but get the same challenge.

design
;alts = alt1*, alt2*
;rows = 36
;eff =(mnl,d)
;block = 4
;cond:
if(alt1.test = 1, alt1.risk = [1,5,20]),
if(alt2.test = 1, alt2.risk = [1,5,20]),
if(alt1.test = 1, alt1.time = [3]),
if(alt2.test = 1, alt2.time = [3]),
if(alt1.test = 2, alt1.time = [2,3]),
if(alt2.test = 2, alt2.time = [2,3]),
if(alt1.test = 4, alt1.time = [2]),
if(alt2.test = 4, alt2.time = [2]),
if(alt1.test = 3, alt1.time = [1,2]),
if(alt2.test = 3, alt2.time = [1,2])
;model:
U(alt1)= b1.dummy[0|0|0]*test[1,2,3,4] + b2.dummy[0|0|0]*risk[1,5,20,50] + b3*cost[0,50,200] + b4.dummy[0|0]*time[1,2,3] + b5*dist[1,2,3] /
U(alt2)= b1.dummy[0|0|0]*test[1,2,3,4] + b2.dummy[0|0|0]*risk[1,5,20,50] + b3*cost[0,50,200] + b4.dummy[0|0]*time[1,2,3] + b5*dist[1,2,3]
$
Michiel Bliemer
Posts: 2055
Joined: Tue Mar 31, 2009 4:13 pm

Re: Include conmtratints on one level of a given attribute

Post by Michiel Bliemer »

Hi Norma,

I do not see anything wrong with your script or with your design. Could you please clarify what you mean with "I keep getting scenarios comparing the same test"?

Below is the design that I got after a few minutes running the script.

https://www.dropbox.com/scl/fi/fmyxzkwl ... 3g252&dl=0

Michiel
NormaB
Posts: 7
Joined: Fri Jul 23, 2021 9:16 pm

Re: Include conmtratints on one level of a given attribute

Post by NormaB »

Hi Michiel,
this is the same kind of output am getting, but for scenario 1 and 34,
atl1.test =3 and alt2.test = 3.
This means I would be comparing the same type of test.
The type of tests are 1, 2, 3 and 4.
In this case the respondent would just choose one with better attribute level yet the aim is to compare the different tests.
That is what I do not understand.
Post Reply