labelled designs - consistently specified levels

This forum is for posts that specifically focus on Ngene.

Moderators: Andrew Collins, Michiel Bliemer, johnr

labelled designs - consistently specified levels

Postby twickr07 » Tue Oct 24, 2023 11:49 pm

Hi Michiel,

I'm attempting a labelled designs and have come across this error message: "Error: Two identically named attributes do not have consistently specified levels: 'bloodtest.wait', 'endoscopy.wait'"
Ideally, i would like to have the same coefficient for waiting time in both endoscopy and blood test. Is there a way to do this?

Code: Select all
design
;alts = endoscopy*, bloodtest*
;rows=12
;eff=(mnl,d)
;con
;model:
U(endoscopy) = endoscopy[0]                                          ?ASC for endoscopy relative to bloodtest
             + b1.dummy [-0.00001|-0.00002]* missed[1,2,0]           ?Risk of missed diagnosis (0=none, 1=1 in 50, 2=1 in 10)
             + b2 [-0.00001]               * wait[12,24]             ?Waiting time to start treatment (weeks)
             + b3.dummy [0]                * complication [1,0]      ?Complications (0=bleeding 1=perforation)
             + b4.dummy [-0.00001|-0.0002] * discomfort [1,2,0]      ?Discomfort (2=high, 1=moderate, 0=minimal)
             /
U(bloodtest) = b5.dummy [-0.00001|-0.00002]* wrong[1,2,0]            ?Risk of wrong diagnosis (%)(0=1 in 50, 1=1 in 20, 2=1 in 3)
             + b2 [-0.00001]               * wait[2,4]               ?Waiting time to start treatment (weeks)
             + b4.dummy [-0.00001]         * discomfort[1,0]         ?Discomfort (1=moderate, 0=minimal)
$


Any thoughts greatly appreciated!

Tara
twickr07
 
Posts: 15
Joined: Mon Nov 25, 2019 9:51 pm

Re: labelled designs - consistently specified levels

Postby Michiel Bliemer » Wed Oct 25, 2023 8:23 pm

Yes that can be easily done. You simply need to give the wait variables a different name, so for example

b2[-0.00001] * wait[12,24]
for the first alternative, and

b2 * wait2[2,4]
for the second alternative.

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

Re: labelled designs - consistently specified levels

Postby twickr07 » Wed Oct 25, 2023 11:32 pm

Thanks Michiel!! That worked for wait but have a follow-up question about discomfort which is dummy coded.

I get an error message: "Error: An attribute has the wrong number of levels for dummy or effects coding. 'discomfort2'."
Is the solution to include all three levels (minimal, moderate, high) in the blood test alternative and introduce a restriction to stop the level discomfort='high' from appearing in the blood test alternative? or is there a simpler approach?

Code: Select all
design
;alts = endoscopy*, bloodtest*
;rows=12
;eff=(mnl,d)
;con
;model:
U(endoscopy) = endoscopy[0]                                          ?ASC for endoscopy relative to bloodtest
             + b1.dummy [-0.00001|-0.00002]* missed[1,2,0]           ?Risk of missed diagnosis (0=none, 1=1 in 50, 2=1 in 10)
             + b2 [-0.00001]               * wait[12,24]             ?Waiting time to start treatment (weeks)
             + b3.dummy [0]                * complication [1,0]      ?Complications (0=bleeding 1=perforation)
             + b4.dummy [-0.00001|-0.0002] * discomfort [1,2,0]      ?Discomfort (2=high, 1=moderate, 0=minimal)
             /
U(bloodtest) = b5.dummy [-0.00001|-0.00002]* wrong[1,2,0]            ?Risk of wrong diagnosis (%)(0=1 in 50, 1=1 in 20, 2=1 in 3)
             + b2 [-0.00001]               * wait2[2,4]              ?Waiting time to start treatment (weeks)
             + b4.dummy [-0.00001]         * discomfort2[1,0]        ?Discomfort (1=moderate, 0=minimal)
$


Thank you so much!
Tara
twickr07
 
Posts: 15
Joined: Mon Nov 25, 2019 9:51 pm

Re: labelled designs - consistently specified levels

Postby Michiel Bliemer » Wed Oct 25, 2023 11:56 pm

Indeed, you specify the attribute with all levels and then you impose constraints.

Code: Select all
design
;alts = endoscopy, bloodtest
;rows=12
;eff=(mnl,d)
;alg=mfederov
;reject:
bloodtest.discomfort < 2
;con
;model:
U(endoscopy) = endoscopy[0]                                          ?ASC for endoscopy relative to bloodtest
             + b1.dummy [-0.00001|-0.00002]* missed[1,2,0]           ?Risk of missed diagnosis (0=none, 1=1 in 50, 2=1 in 10)
             + b2 [-0.00001]               * wait[12,24]             ?Waiting time to start treatment (weeks)
             + b3.dummy [0]                * complication [1,0]      ?Complications (0=bleeding 1=perforation)
             + b4.dummy [-0.00001|-0.0002] * discomfort [1,2,0]      ?Discomfort (2=high, 1=moderate, 0=minimal)
             /
U(bloodtest) = b5.dummy [-0.00001|-0.00002]* wrong[1,2,0]            ?Risk of wrong diagnosis (%)(0=1 in 50, 1=1 in 20, 2=1 in 3)
             + b2                          * wait2[2,4]              ?Waiting time to start treatment (weeks)
             + b4.dummy                    * discomfort
$


Note that the script above works fine, but you will always see wait=24 appear with wait=2, and wait=12 is always combined with wait=4 in the design. This is because all priors are (near) zero and then it becomes most efficient to compare extreme levels (24,2) while all other tasks get (12,4), as this leads to an optimal design. You can always manually swap some of these levels if this is undesirable.

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

Re: labelled designs - consistently specified levels

Postby twickr07 » Thu Oct 26, 2023 12:11 am

Thank you for your helpful suggestions!! I really appreciate your help.

Tara
twickr07
 
Posts: 15
Joined: Mon Nov 25, 2019 9:51 pm

Re: labelled designs - consistently specified levels

Postby twickr07 » Fri Jan 05, 2024 10:49 pm

Hi Michiel,

I estimated a model with some pre-testing data for the Ngene code you helped me with and have a follow up question. When I code the wait time attribute as a categorical variable, the level 24 weeks is omitted because of collinearity. However, the model runs fine when I code the wait time attribute as a linear variable.
I tried to manually swap some of the wait time levels as you suggested but that didn't solve the collinearity issue.
Then I redid the design with the wait time attribute coded in Ngene as a categorical variable, but this also didn't fix the problem.


Code: Select all
design
;alts = endoscopy, bloodtest
;rows=12
;eff=(mnl,d)
;alg=mfederov
;reject:
bloodtest.discomfort =2
;con
;model:
U(endoscopy) = endoscopy[0]                                                   ?ASC for endoscopy relative to bloodtest
             + b1.dummy [-0.00001|-0.00002]         * missed[1,2,0]           ?Risk of missed diagnosis (0=none, 1=2%, 2=10%)
             + b2.dummy [-0.00001]                  * wait[12,24]             ?Waiting time to start treatment (weeks)
             + b3.dummy [-0.00001]                  * complication [1,0]      ?Complications ( 0=bleeding, 1=perforation)
             + b4.dummy [-0.00001|-0.0002]          * discomfort [1,2,0]      ?Discomfort (2=high, 1=moderate, 0=minimal)
             /
U(bloodtest) = b2.dummy                             * wait2[2,4]
             + b4.dummy                             * discomfort
             + b5.dummy [-0.00001|-0.00002]         * wrong[1,2,0]            ?Risk of wrong diagnosis (%)(0=2%, 1=5%, 2=33%)
$


In another attempt, I also increased the size of the wait time prior to a larger value more different from zero, but that was also unsuccessful.

So, I am wondering if I just have to live with a model that I can only specify linearly without the flexibility of modelling wait time as a categorical variable or is there a better way to solve this issue?

Thanks,
Tara
twickr07
 
Posts: 15
Joined: Mon Nov 25, 2019 9:51 pm

Re: labelled designs - consistently specified levels

Postby Michiel Bliemer » Sat Jan 06, 2024 10:28 am

The best way to resolve it is to add an attribute level that appears in both alternatives. For example, adding wait=8 to both endoscopy and bloodtest would allow you to dummy code the wait attribute as in the script below. Note that 12 rows is too little to estimate so many dummy coded parameters in the model, I would increase the number of rows.

Code: Select all
design
;alts = endoscopy, bloodtest
;rows=24
;block=2
;eff=(mnl,d)
;alg=mfederov(candidates=432)
;reject:
bloodtest.discomfort=2,
endoscopy.wait=2, endoscopy.wait=4,
bloodtest.wait=12, bloodtest.wait=24
;con
;model:
U(endoscopy) = endoscopy[0]                                                    ?ASC for endoscopy relative to bloodtest
             + b1.dummy [-0.00001|-0.00002]                   * missed[1,2,0]           ?Risk of missed diagnosis (0=none, 1=2%, 2=10%)
             + b2.dummy [-0.00001|-0.00002|-0.00003|-0.00004] * wait[4,8,12,24,2]       ?Waiting time to start treatment (weeks),
             + b3.dummy [-0.00001]                            * complication [1,0]      ?Complications ( 0=bleeding, 1=perforation)
             + b4.dummy [-0.00001|-0.0002]                    * discomfort [1,2,0]      ?Discomfort (2=high, 1=moderate, 0=minimal)
             /
U(bloodtest) = b2.dummy                                       * wait
             + b4.dummy                                       * discomfort
             + b5.dummy [-0.00001|-0.00002]                   * wrong[1,2,0]            ?Risk of wrong diagnosis (%)(0=2%, 1=5%, 2=33%)
$


Perhaps also carefully look at your attribute levels. For example, endoscopy always has a complication (either bleeding or perforation), while 'no complication' is not a level. Also, is a complication not risky, expressed as a percentage? Or is it certain that either bleeding or perforation will occur?

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

Re: labelled designs - consistently specified levels

Postby twickr07 » Mon Jan 08, 2024 9:30 pm

Thanks Michiel that resolved the collinearity issue - it's great to finally find a solution! Also, thanks for your feedback about the attributes, complications is a compound attribute with corresponding risks, sorry I forgot to include them in the ngene annotations.
twickr07
 
Posts: 15
Joined: Mon Nov 25, 2019 9:51 pm


Return to Choice experiments - Ngene

Who is online

Users browsing this forum: No registered users and 20 guests