Error: A logical expression has an incompatible element

This forum is for posts that specifically focus on Ngene.

Moderators: Andrew Collins, Michiel Bliemer, johnr

Error: A logical expression has an incompatible element

Postby Pramisha » Wed Oct 27, 2021 9:35 am

Hi Prof Bliemer and all,

I am trying to generate a design through D Efficient MNL model but it keeps showing error.
• I am generating three alternatives, Opt. A, Opt. B and Neither
• I am generating 30 choice sets in five blocks and I need to use the reject constraints.
• For the prior values, I used mean and standard deviation of attributes looking into previous studies.
• Using a design with 30 rows, I hoped that I will be able to estimate all possible interaction effects after data collection.

My attributes and levels:


Tillage Practice Change

Conventional till to no-till
Conventional till to conservation till
Conservation till to no-till
No change in tillage practice

Cover Crops Practice Change

No cover crops to cover crops
No cover crops

Contract Length

5 years contract
10 years contract
No contract

Governance

Government (USDA)
Private (for-profit)
Not-for-profit
None

Carbon Payment ($/acre)

$0/acre
$5/acre
$10/acre
$15/acre
$20/acre

NGene Design (D-error: )
Syntax
Design

;alts= optA*, optB*, Neither

;rows=30

;eff=(mnl,d, mean)

;block=5

;alg= mfederov

;reject:

optA.Tillage_Practice_Change =0 and optA.Cover_Crops_Practice_Change =0 and optA.Carbon_Payment =5,

optA.Tillage_Practice_Change =0 and optA.Cover_Crops_Practice_Change =0 and optA.Carbon_Payment =10,

optA.Tillage_Practice_Change =0 and optA.Cover_Crops_Practice_Change =0 and optA.Carbon_Payment =15,

optA.Tillage_Practice_Change =0 and optA.Cover_Crops_Practice_Change =0 and optA.Carbon_Payment =20,

optA.Tillage_Practice_Change =0 and optA.Cover_Crops_Practice_Change =0 and optA.Governance =3,

optA.Tillage_Practice_Change =0 and optA.Cover_Crops_Practice_Change =0 and optA.Governance =2,

optA.Tillage_Practice_Change =0 and optA.Cover_Crops_Practice_Change =0 and optA.Governance =1,
optA.Tillage_Practice_Change =0 and optA.Cover_Crops_Practice_Change =0 and optA.Contract_Length =2,

optA.Tillage_Practice_Change =0 and optA.Cover_Crops_Practice_Change =0 and optA.Contract_Length =1,

optA.Carbon_Payment =0 and optA.Governance =3,

optA.Carbon_Payment =0 and optA.Governance =2,

optA.Carbon_Payment =0 and optA.Governance =1,

optA.Carbon_Payment =0 and optA.Contract_Length =2,

optA.Carbon_Payment =0 and optA.Contract_Length =1,

optA.Carbon_Payment =5 and optA.Governance =0,

optA.Carbon_Payment =10 and optA.Governance =0,

optA.Carbon_Payment =15 and optA.Governance =0,

optA.Carbon_Payment =20 and optA.Governance =0,

optB.Tillage_Practice_Change =0 and optB.Cover_Crops_Practice_Change =0 and optB.Carbon_Payment =5,

optB.Tillage_Practice_Change =0 and optB.Cover_Crops_Practice_Change =0 and optB.Carbon_Payment =10,

optB.Tillage_Practice_Change =0 and optB.Cover_Crops_Practice_Change =0 and optB.Carbon_Payment =15,

optB.Tillage_Practice_Change =0 and optB.Cover_Crops_Practice_Change =0 and optB.Carbon_Payment =20,

optB.Tillage_Practice_Change =0 and optB.Cover_Crops_Practice_Change =0 and optB.Governance =3,

optB.Tillage_Practice_Change =0 and optB.Cover_Crops_Practice_Change =0 and optB.Governance =2,

optB.Tillage_Practice_Change =0 and optB.Cover_Crops_Practice_Change =0 and optB.Governance =1,

optB.Tillage_Practice_Change =0 and optB.Cover_Crops_Practice_Change =0 and optB.Contract_Length =2,

optB.Tillage_Practice_Change =0 and optB.Cover_Crops_Practice_Change =0 and optB.Contract_Length =1,

optB.Carbon_Payment =0 and optB.Governance =3,

optB.Carbon_Payment =0 and optB.Governance =2,

optB.Carbon_Payment =0 and optB.Governance =1,

optB.Carbon_Payment =0 and optB.Contract_Length =2,

optB.Carbon_Payment =0 and optB.Contract_Length =1,

optB.Carbon_Payment =5 and optB.Governance =0,

optB.Carbon_Payment =10 and optB.Governance =0,

optB.Carbon_Payment =15 and optB.Governance =0,

optB.Carbon_Payment =20 and optB.Governance =0,

;model:

U(optA) = b1 [(n, 0.2, 0.04)] * Carbon_Payment[0, 5, 10, 15, 20]

+ b2.dummy[(n, 0.6, 0.08)|(n, 0.55, 0.33)|(n, 0.26093, 0.05064)] * Tillage_Practice_Change[3, 2, 1,0]

+ b3.dummy[(n, 0.8, 0.2)] * Cover_Crops_Practice_Change[1,0]

+ b4.dummy[(n, -0.86152, 0.05450)|(n, -0.9, 0.09)]* Contract_Length[2,1,0]

+ b5.dummy[(n, -0.20278, 0.04824)|(n, -1.04265, 0.06913) |(n, 0.445, 0.095)] * Governance[3,2, 1, 0] /

U(optB) = b1 * Carbon_Payment

+ b2 * Tillage_Practice_Change

+ b3 * Cover_Crops_Practice_Change

+ b4 * Contract_Length

+ b5 * Governance /

U(Neither) = b0 [(n, 0.1, 0.01)]

$


Can you please check where did I do wrong? Is it in the reject code?

Thank you!
Pramisha
 
Posts: 11
Joined: Mon Apr 19, 2021 7:21 am

Re: Error: A logical expression has an incompatible element

Postby Michiel Bliemer » Wed Oct 27, 2021 10:20 am

There is a comma after the last reject constraint:

optB.Carbon_Payment =20 and optB.Governance =0,

Because of this comma, Ngene is expecting another constraint (logical expression) but none is provided. Removing this comma will do the trick.

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

Re: Error: A logical expression has an incompatible element

Postby Pramisha » Wed Oct 27, 2021 11:39 am

It did magic. Thank you Dr. Bliemer. I have been trying to do both Optimal orthogonal and D-efficient design and compare. I had used D-efficient before but this is my first time for Orthogonal design. Can you please check if my syntax is correct or not, for Optimal Orthogonal Design? Thank you in advance :)

NGene Design (OOD/ Optimal Orthogonal Design )
Syntax
Design

;alts= optA*, optB*, Neither

;rows=30

;orth=ood

;block=5

;reject:

optA.Tillage_Practice_Change =0 and optA.Cover_Crops_Practice_Change =0 and optA.Carbon_Payment =5,

optA.Tillage_Practice_Change =0 and optA.Cover_Crops_Practice_Change =0 and optA.Carbon_Payment =10,

optA.Tillage_Practice_Change =0 and optA.Cover_Crops_Practice_Change =0 and optA.Carbon_Payment =15,

optA.Tillage_Practice_Change =0 and optA.Cover_Crops_Practice_Change =0 and optA.Carbon_Payment =20,

optA.Tillage_Practice_Change =0 and optA.Cover_Crops_Practice_Change =0 and optA.Governance =3,

optA.Tillage_Practice_Change =0 and optA.Cover_Crops_Practice_Change =0 and optA.Governance =2,

optA.Tillage_Practice_Change =0 and optA.Cover_Crops_Practice_Change =0 and optA.Governance =1,


optA.Tillage_Practice_Change =0 and optA.Cover_Crops_Practice_Change =0 and optA.Contract_Length =2,

optA.Tillage_Practice_Change =0 and optA.Cover_Crops_Practice_Change =0 and optA.Contract_Length =1,

optA.Carbon_Payment =0 and optA.Governance =3,

optA.Carbon_Payment =0 and optA.Governance =2,

optA.Carbon_Payment =0 and optA.Governance =1,

optA.Carbon_Payment =0 and optA.Contract_Length =2,

optA.Carbon_Payment =0 and optA.Contract_Length =1,

optA.Carbon_Payment =5 and optA.Governance =0,

optA.Carbon_Payment =10 and optA.Governance =0,

optA.Carbon_Payment =15 and optA.Governance =0,

optA.Carbon_Payment =20 and optA.Governance =0,

optB.Tillage_Practice_Change =0 and optB.Cover_Crops_Practice_Change =0 and optB.Carbon_Payment =5,

optB.Tillage_Practice_Change =0 and optB.Cover_Crops_Practice_Change =0 and optB.Carbon_Payment =10,

optB.Tillage_Practice_Change =0 and optB.Cover_Crops_Practice_Change =0 and optB.Carbon_Payment =15,

optB.Tillage_Practice_Change =0 and optB.Cover_Crops_Practice_Change =0 and optB.Carbon_Payment =20,

optB.Tillage_Practice_Change =0 and optB.Cover_Crops_Practice_Change =0 and optB.Governance =3,

optB.Tillage_Practice_Change =0 and optB.Cover_Crops_Practice_Change =0 and optB.Governance =2,

optB.Tillage_Practice_Change =0 and optB.Cover_Crops_Practice_Change =0 and optB.Governance =1,

optB.Tillage_Practice_Change =0 and optB.Cover_Crops_Practice_Change =0 and optB.Contract_Length =2,

optB.Tillage_Practice_Change =0 and optB.Cover_Crops_Practice_Change =0 and optB.Contract_Length =1,

optB.Carbon_Payment =0 and optB.Governance =3,

optB.Carbon_Payment =0 and optB.Governance =2,

optB.Carbon_Payment =0 and optB.Governance =1,

optB.Carbon_Payment =0 and optB.Contract_Length =2,

optB.Carbon_Payment =0 and optB.Contract_Length =1,

optB.Carbon_Payment =5 and optB.Governance =0,

optB.Carbon_Payment =10 and optB.Governance =0,

optB.Carbon_Payment =15 and optB.Governance =0,

optB.Carbon_Payment =20 and optB.Governance =0

;model:

U(optA) = b1 [ 0 ] * Carbon_Payment[0, 5, 10, 15, 20]

+ b2.dummy[ 0 ] * Tillage_Practice_Change[3, 2, 1,0]

+ b3.dummy[ 0 ] * Cover_Crops_Practice_Change[1,0]

+ b4.dummy[ 0 ]* Contract_Length[2,1,0]

+ b5.dummy[ 0 ] * Governance[3,2, 1, 0] /

U(optB) = b1 * Carbon_Payment

+ b2 * Tillage_Practice_Change

+ b3 * Cover_Crops_Practice_Change

+ b4 * Contract_Length

+ b5 * Governance /

$
Pramisha
 
Posts: 11
Joined: Mon Apr 19, 2021 7:21 am

Re: Error: A logical expression has an incompatible element

Postby Michiel Bliemer » Wed Oct 27, 2021 11:50 am

No this syntax is not correct. Optimal orthogonal designs cannot handle constraints such as reject constraints or check for dominance. Further, your attribute levels need to be consistent with the number of rows to ensure attribute level balance. It cannot be guaranteed that an orthogonal design exists.

So you need to remove * from the alternatives and you need to remove the reject constraints, then run the syntax and see if Ngene can find such a design.

(Optimal) orthogonal designs are very restrictive so there is no flexibility in adding any kind of other constraint.

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

Re: Error: A logical expression has an incompatible element

Postby Pramisha » Wed Oct 27, 2021 12:54 pm

Thank you Dr. Bliemer for your prompt response. I used the following syntax but it showed that "Error: An attribute has the wrong number of levels for dummy or effects coding. 'tillage_practice_change' ".

I even reduced the carbon payment levels from 5 to 4 and used rows= 36 and block =4, and checked if it worked but still it yielded the same result.

Design

;alts= optA, optB, Neither

;rows=30

;orth=ood

;block=5

;model:

U(optA) = b1 [ 0 ] * Carbon_Payment[0, 5, 10, 15, 20]

+ b2.dummy[ 0 ] * Tillage_Practice_Change[3, 2, 1, 0]

+ b3.dummy[ 0 ] * Cover_Crops_Practice_Change[1,0]

+ b4.dummy[ 0 ]* Contract_Length[2,1,0]

+ b5.dummy[ 0 ] * Governance[3,2, 1, 0] /

U(optB) = b1 * Carbon_Payment

+ b2 * Tillage_Practice_Change

+ b3 * Cover_Crops_Practice_Change

+ b4 * Contract_Length

+ b5 * Governance /

$
Pramisha
 
Posts: 11
Joined: Mon Apr 19, 2021 7:21 am

Re: Error: A logical expression has an incompatible element

Postby Pramisha » Wed Oct 27, 2021 2:04 pm

I got to realize what you meant by " your attribute levels need to be consistent with the number of rows to ensure attribute level balance." Since It isn't possible to have the same number of rows in all attribute levels in our case, i think it is best to stick to D-efficient model.
Pramisha
 
Posts: 11
Joined: Mon Apr 19, 2021 7:21 am

Re: Error: A logical expression has an incompatible element

Postby Michiel Bliemer » Wed Oct 27, 2021 4:00 pm

You had a few mistakes in the syntax, the following would generate an OOD design.

Code: Select all
Design

;alts= optA, optB, Neither

;rows=30

;orth=ood

;block=5

;model:

U(optA) = b1 [0] * Carbon_Payment[0, 5, 10, 15, 20]

+ b2.dummy[0|0|0] * Tillage_Practice_Change[3, 2, 1, 0]

+ b3.dummy[0] * Cover_Crops_Practice_Change[1,0]

+ b4.dummy[0|0]* Contract_Length[2,1,0]

+ b5.dummy[0|0|0] * Governance[3,2, 1, 0] /

U(optB) = b1 * Carbon_Payment

+ b2 * Tillage_Practice_Change

+ b3 * Cover_Crops_Practice_Change

+ b4 * Contract_Length

+ b5 * Governance

$


Note that an orthogonal design does not exist with 30 rows (because of attribute level balance inconsistencies), so Ngene generates a design with 60 rows.

I generally prefer using a D-efficient design because it does not have all the restrictions of an orthogonal design.

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

Re: Error: A logical expression has an incompatible element

Postby Pramisha » Wed Oct 27, 2021 5:45 pm

Thank you Dr. Bliemer. It worked and didn't take even a full minute to finish. However, it showed 0% D-Optimality, which I think don't need to affect the design it generated since in other post, you told that "We found a bug in the implementation, which only occurs in some cases with 5 or more levels, and only affects the reporting of D-optimality, not the generation of the design itself." I used 60 rows and 10 blocks this time.
Thank you!
Pramisha
 
Posts: 11
Joined: Mon Apr 19, 2021 7:21 am

Re: Error: A logical expression has an incompatible element

Postby Michiel Bliemer » Wed Oct 27, 2021 6:55 pm

Yes the D-efficiency percentage is indeed not correctly reported, we are fixing this in the next release (together with making several other improvements).

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


Return to Choice experiments - Ngene

Who is online

Users browsing this forum: No registered users and 12 guests