Error with attribute not existing

This forum is for posts covering broader stated choice experimental design issues.

Moderators: Andrew Collins, Michiel Bliemer, johnr

Post Reply
Cindy Verberkt
Posts: 2
Joined: Thu May 15, 2025 11:35 pm

Error with attribute not existing

Post by Cindy Verberkt »

I have ran this script:
Design
;alts = Persoon_A, Persoon_B
;rows = 30
;block = 2
;eff = (rp, d)
;rdraws = mlhs(100)
;rep = 100

;model:

U(Persoon_A) =
b1[n, 0, 1] * risico.a[1,2,3]
+ b2[n, 0.2, 0.3] * ziekenhuisbezoek.a[1,2,3,4]
+ b3[n, 0.15, 0.3] * test.a[1,2,3]
+ b4[n, 0.1, 0.25] * klachten.a[1,2]
+ b5[n, 0.1, 0.2] * hulp.a[1,2]
/
U(Persoon_B) =
b1[n] * risico.b[1,2,3]
+ b2[n] * ziekenhuisbezoek.b[1,2,3,4]
+ b3[n] * test.b[1,2,3]
+ b4[n] * klachten.b[1,2]
+ b5[n] * hulp.b[1,2]

;rand
;require: Persoon_A.risico.a = Persoon_B.risico.b
$


And received this "Error: The ';require' property contains an attribute that does not exist in the design. 'persoon_a.risico.a"
I would like the output for risico.a and risico.b to be the same --> risico.a = 1 and risico.b = 1.

I do not know how to change the script that it does recognise the attributes as it was able to run before adding the require function!
Michiel Bliemer
Posts: 2039
Joined: Tue Mar 31, 2009 4:13 pm

Re: Error with attribute not existing

Post by Michiel Bliemer »

There are a lot of issues with your script.

- I suggest you use mnl as model type.
- You need to use dummy or effects coding for categorical attributes.
- You cannot use a period (.) in an attribute name.
- Require constraints only work in combination with the modified Federov algorithm.
- Assuming that your alternatives are unlabelled, you cannot add a scenario variable such as risico as a main effect, you need to make interaction effects (as otherwise the model is not identified and you cannot estimate the model). I am assuming that risico is a scenario variable since you are setting it to the same value across both alternatives. Adding a categorical attribute only as an interaction effect in the utility functions is a bit tricky in Ngene and requires specifying an auxiliary (aux) model where you define the scenario variable, while the main model describes the actual model that you will estimate.

Below is a starting script. I added ziekenhuisbezoek in interaction with risico, but you can also add interaction effects between risico and all other attributes. Note that for dummy or effects coded attributes you need to interact with individual levels, as I have done below (avoid interacting with a reference level).

Code: Select all

Design
;alts(aux)  = Persoon_A*, Persoon_B*
;alts(main) = Persoon_A*, Persoon_B*
;rows = 30
;block = 2
;eff = main(mnl, d)

;alg = mfederov

;require: Persoon_A.risico = Persoon_B.risico

;model(aux):
U(Persoon_A) = b1.dummy[0|0]   * risico[1,2,3]             ? 3=reference level
             + b2.dummy[0|0|0] * ziekenhuisbezoek[1,2,3,4] ? 4=reference level
             + b3.dummy[0|0]   * test[1,2,3]               ? 3=reference level
             + b4.dummy[0]     * klachten[1,2]             ? 2=reference level
             + b5.dummy[0]     * hulp[1,2]                 ? 2=reference level
/
U(Persoon_B) = b1.dummy        * risico
             + b2.dummy        * ziekenhuisbezoek
             + b3.dummy        * test
             + b4.dummy        * klachten
             + b5.dummy        * hulp

;model(main):
U(Persoon_A) = b2.dummy[0|0|0] * ziekenhuisbezoek[1,2,3,4] ? 4=reference level
             + b3.dummy[0|0]   * test[1,2,3]               ? 3=reference level
             + b4.dummy[0]     * klachten[1,2]             ? 2=reference level
             + b5.dummy[0]     * hulp[1,2]                 ? 2=reference level
             + bz1_1           * ziekenhuisbezoek.dummy[1] * risico.dummy[1]
             + bz2_1           * ziekenhuisbezoek.dummy[2] * risico.dummy[1]       
             + bz3_1           * ziekenhuisbezoek.dummy[3] * risico.dummy[1] 
             + bz1_2           * ziekenhuisbezoek.dummy[1] * risico.dummy[2]
             + bz2_2           * ziekenhuisbezoek.dummy[2] * risico.dummy[2]       
             + bz3_2           * ziekenhuisbezoek.dummy[3] * risico.dummy[2] 
/
U(Persoon_B) = b2.dummy        * ziekenhuisbezoek
             + b3.dummy        * test
             + b4.dummy        * klachten
             + b5.dummy        * hulp
             + bz1_1           * ziekenhuisbezoek.dummy[1] * risico.dummy[1]
             + bz2_1           * ziekenhuisbezoek.dummy[2] * risico.dummy[1]       
             + bz3_1           * ziekenhuisbezoek.dummy[3] * risico.dummy[1] 
             + bz1_2           * ziekenhuisbezoek.dummy[1] * risico.dummy[2]
             + bz2_2           * ziekenhuisbezoek.dummy[2] * risico.dummy[2]       
             + bz3_2           * ziekenhuisbezoek.dummy[3] * risico.dummy[2] 
$
Michiel
Post Reply