Several questions on ;require ;cond, and other issues

This forum is for posts that specifically focus on Ngene.

Moderators: Andrew Collins, Michiel Bliemer, johnr

Several questions on ;require ;cond, and other issues

Postby dooglos » Thu Feb 20, 2020 2:24 pm

Hello, I am new to Ngene and am working through some coding issues. Please see my code below - it is well commented to describe the 4 alternatives and 5 attributes. All five attribute are dummy coded.

Most of my questions are about using ;require and ;cond. I want to use both, to restrict the levels of attributes to plausible values. Some of these restrictions are for one alternative. Some apply to all alternatives. I find that the only way to logically express these restrictions is by using BOTH ;require and ;cond, but this poses problems for the algorithm - if using ;require, I need to use an mfederov algorithm, but mfederov doesn't work with ;cond. Does this mean that I can't use ;require and ;cond together? If so, how can I impose these restrictions?

Also, is it possible to impose conditions on all alternatives?

Also, in the below code I am getting the error: "Error: An attribute has the wrong number of levels for dummy or effects coding. 'freq'", and I can't figure out what's wrong with the levels of freq.

Thanks a lot!!

????????????????????????????????????????????????????????????????????????????
?????? 1. Design details
????????????????????????????????????????????????????????????????????????????

Design

? 4 alternatives, in 2 blocks,
;alts = IMIN, SCIN, IMPL, ORAL
;rows = 64
;block = 4

? D-efficient design with multinomial logit
;eff = (mnl, d)

? Algorithm
? if using the require property, I need to use mfederov, but I can't use that with cond
?;alg = mfederov(stop=noimprov(4 secs))
?;alg=all


????????????????????????????????????????????????????????????????????????????
????? 2. Restrict attribute levels
????????????????????????????????????????????????????????????????????????????
? loca: 0 home, 1 pharm, 2 clinic
? freq: numeric in weeks: 0 1, 1 4, 2 8, 3 12, 4 26, 5 52
? pain: 0 none, 1 minimal, 2 mild, 3 moderate
? lead: numeric in months: 0 0, 1 1, 2 3
? buff: numeric in weeks: 0 0, 1 2, 2 4, 3 6, 4 13, 5 26
;require:
IMIN.loca>=1,
IMIN.freq>=1 and IMIN.freq<=3,
IMIN.pain>=2,
IMIN.lead>=1,

SCIN.freq<=3,
SCIN.pain>=1 and SCIN.pain<=2,
SCIN.lead>=1,

IMPL.loca=2,
IMPL.freq>=3,
IMPL.pain>=2,
IMPL.lead>=1,

ORAL.loca=0,
ORAL.freq<=1,
ORAL.pain=0,
ORAL.lead=0

?any way to impose conditions on all alternatives?
;cond:
if(IMIN.freq=1, IMIN.buff=1),
if(IMIN.freq=2, IMIN.buff=2),
if(IMIN.freq=3, IMIN.buff=3),

if(SCIN.freq=0, SCIN.buff=0),
if(SCIN.freq=1, SCIN.buff=1),
if(SCIN.freq=2, SCIN.buff=2),
if(SCIN.freq=3, SCIN.buff=3),

if(IMPL.freq=3, IMPL.buff=3),
if(IMPL.freq=4, IMPL.buff=4),
if(IMPL.freq=5, IMPL.buff=5),

if(SCIN.freq=0, SCIN.loca=0),
if(SCIN.freq=0, SCIN.buff=0),

if(IMIN.loca=[1,2], IMIN.freq>=1),
if(SCIN.loca=[1,2], SCIN.freq>=1)


???????????????????????????????????????????????????????????????????????????
????? 3. Specify attributes and levels for each alternative
???????????????????????????????????????????????????????????????????????????
?Priors
? loca: Home (0) is best. Pharmacy (1) and clinic (2) are equal
? freq: all frequencies equal
? pain: each successive pain level is worse
? lead: less lead in is better
? buff: bigger buffer is better

;model:
? IMIN
U(IMIN) = b1.dummy[0.01|0]*loca[0,1,2]
+ b2.dummy*freq[0,1,2,3,4,5]
+ b3.dummy[0.03|0.02|0.01]*pain[0,1,2,3]
+ b4.dummy[0.02|0.01]*lead[0,1,2]
+ b5.dummy[-0.02|-0.01]*buff[0,1,2,3,4,5]
/

? SCIN
U(SCIN) = b1*loca
+ b2*freq
+ b3*pain
+ b4*lead
+ b5*buff
/

? IMPL:
U(IMPL) = b1*loca
+ b2*freq
+ b3*pain
+ b4*lead
+ b5*buff
/

? ORAL:
U(ORAL) = b1*loca
+ b2*freq
+ b3*pain
+ b4*lead
+ b5*buff
$
dooglos
 
Posts: 1
Joined: Wed Feb 19, 2020 7:48 am

Re: Several questions on ;require ;cond, and other issues

Postby Michiel Bliemer » Sat Feb 22, 2020 11:44 am

1. For dummy coding all priors need to be explicitly stated (Ngene does not automatically default them to zero as a safe-guard so that the user is made aware that L-1 parameters are estimated with L levels). So you will need to use:

b2.dummy[0|0|0|0]*freq[0,1,2,3,4,5]

2. The modified Federov algorithm is a row-based algorithm. This algorithm can handle ;require and ;reject constraints, but not ;cond constraints. It does not automatically satisfy attribute level balance. For a heavily constrained design, the modified Federov algorithm works best. The default swapping algorithm is a column-based algorithm. This algorithm can handle ;cond constraints but not ;require or ;reject constraints and is able to satisfy attribute level balance. Note that one type of constraints can often be rewritten in another type of constraints. In your case, you can rewrite all your ;cond constraints into ;reject constraints such that you can use the mfederov algorithm with both ;require and ;reject constraints.

For example,

;cond:
if(IMIN.freq=1, IMIN.buff=1)

can be replaced by

;reject:
IMIN.freq = 1 and IMIN.buff = 0,
IMIN.freq = 1 and IMIN.buff = 2,
IMIN.freq = 1 and IMIN.buff = 3,
IMIN.freq = 1 and IMIN.buff = 4,
IMIN.freq = 1 and IMIN.buff = 5

I understand that this may seem quite convoluted but it is the only way. Optimising designs with constraints is quite complex and each algorithm only works with certain types of constraints.

3. There is no shortcut in the syntax to apply constraints across alternatives, they need to be specified for each alternative separately (copy & paste is your friend).

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


Return to Choice experiments - Ngene

Who is online

Users browsing this forum: No registered users and 47 guests