Page 1 of 1

Dummy coded 7 attributes, 3 alt including status quo

PostPosted: Mon Nov 06, 2017 1:53 am
by jaein.seo
Hello,

I'm writing to ask for advice regarding Ngene codes. This is my first time using Ngene. While this is a challenging task to me, it may be quite dull to most of experts.
The design consists of 3 alternatives (standard of care, treatment A, treatment B) with 7 attributes (bm, aff, hypocalc, mvf, osteonerc, admin, cost). The standard of care (std) is presented with 7 attributes with a reference level each. An error message keeps appearing that the attributes have a wrong number of levels. The codes I've tries are shown below:

Code: Select all
Design
;alt=std, trtA, trtB
;rows=24
;block=2
;eff=(mnl, d, mean)
;alg=swap(stop=total(600mins))
 
;model:
U(std)=b1.d[0.3|0.2|0.1]*bm[3]
         +b2.d[0.2|0.1]*aff[0]
         +b3.d[n,0.0,0.1]*hypocalc[0]
         +b4.d[0.3|0.2|0.1]*mvf[0]
         +b5.d[0.3|0.2|0.1]*osteonecr[0]
         +b6.d[n,0.0,0.1]*admin[0]
         +b7.d[0.3|0.2|0.1]*cost[0] /
 
U(trtA)=b1*bm1[3,2,1,0]
          +b2*aff1[2,1,0]
          +b3*hypocalc1[1,0]
          +b4*mvf1[3,2,1,0]
          +b5*osteonecr1[3,2,1,0]
          +b6*admin1[2,1]
          +b7*cost1[3,2,1,0] /
 
U(trtB)=b1*bm1
          +b2*aff1
          +b3*hypocalc1
          +b4*mvf1
          +b5*osteonecr1
          +b6*admin1
          +b7*cost1

? all the attribute levels are dummy coded
? b1(bm), b4(mvf), b5(osteonecr), b7(cost) have 4 levels each (ordinal)
? b2(aff) has 3 levels (ordinal)
? b3(hypocalc) has 2 levels (categorical - yes/no)
? b6(admin) have 3 levels (categorical - infusion, injection, NA)
? b1, b2, b4, b5, b7 are random parameters with Beyesian priors
? b1, b2, b4, b5, b7: the first attribute level has been assigned a prior parameter value of 0.3, the second 0.2, the third 0.3, and the final omitted level, a value of zero
? b3, b6: random parameters following a normal distribution with mean 0.0 and SD 0.1
$


The codes above did not run, so I referred to pg160 in Ngene manual and tried different strategies including as follows.

U(std)=b1[0.1]*bm.ref[3]+…/
U(trtA)=b1*bm.piv[0,-1,-2,-3]+…/
U(trtB)=b1*bm.piv+…$


I am stuck and would like some guidance. Please review. Any feedback would be greatly appreciated.

Thank you,
Jaein

Re: Dummy coded 7 attributes, 3 alt including status quo

PostPosted: Mon Nov 06, 2017 1:16 pm
by Michiel Bliemer
There are several issues with your syntax. You need to state alts instead of alt, you need to use .dummy instead of .d, you have 3 levels for admin but you only provide 2 levels and 2 priors, and several other little things.

The code below will work. Note that you are asking to do a cross-sectional mixed logit model, but a panel mixed logit model is more appropriate. Since it is difficult to optimise for the latter model, it is best to just optimise for an MNL model without random parameters (but possibly use Bayesian priors to account for uncertainty about the priors).

Note that the ;require command needs the modified Federov algorithm.

Code: Select all
    Design
    ;alts = trtA, trtB, std
    ;rows = 24
    ;block = 2
    ;eff = (mnl,d)
    ;alg = mfederov(candidates = 1000)
    ;rdraws = gauss(5)
    ;require:
     std.bm = 3,
     std.aff = 0,
     std.hypocalc = 0,
     std.mvf = 0,
     std.osteonecr = 0,
     std.admin = 0,
     std.cost = 0
     
    ;model:

        U(trtA)=b1.dummy[0.3|0.2|0.1]*bm[3,2,1,0]
             +b2.dummy[0.2|0.1]*aff[2,1,0]
             +b3.dummy[0.0]*hypocalc[1,0]
             +b4.dummy[0.3|0.2|0.1]*mvf[3,2,1,0]
             +b5.dummy[0.3|0.2|0.1]*osteonecr[3,2,1,0]
             +b6.dummy[0.0|0.0]*admin[2,1,0]
             +b7.dummy[0.3|0.2|0.1]*cost[3,2,1,0] /
 
    U(trtB)=b1*bm
              +b2*aff
              +b3*hypocalc
              +b4*mvf
              +b5*osteonecr
              +b6*admin
              +b7*cost /
     
    U(std)=b1*bm
              +b2*aff
              +b3*hypocalc
              +b4*mvf
              +b5*osteonecr
              +b6*admin
              +b7*cost


    ? all the attribute levels are dummy coded
    ? b1(bm), b4(mvf), b5(osteonecr), b7(cost) have 4 levels each (ordinal)
    ? b2(aff) has 3 levels (ordinal)
    ? b3(hypocalc) has 2 levels (categorical - yes/no)
    ? b6(admin) have 3 levels (categorical - infusion, injection, NA)
    ? b1, b2, b4, b5, b7 are random parameters with Beyesian priors
    ? b1, b2, b4, b5, b7: the first attribute level has been assigned a prior parameter value of 0.3, the second 0.2, the third 0.3, and the final omitted level, a value of zero
    ? b3, b6: random parameters following a normal distribution with mean 0.0 and SD 0.1
    $

Re: Dummy coded 7 attributes, 3 alt including status quo

PostPosted: Tue Nov 07, 2017 11:05 pm
by jaein.seo
Thank you very much for your help, Michiel. Ngene is running the design now. While it runs, an error message appears that
Warning: The ':rdraws' property was specified, but no random priors were specified in the models. Defaulting to assigning blocks with the 'minsum' method.
Could this be ignored?

I noticed that the Trt A and Trt B have ‘not applicable’ as their levels but only Std is intent to include NA as its level. I am thinking to incorporate trtA.admin<>0 and trtB.admin<>0 under ;require:
Would it affect the design?

Re: Dummy coded 7 attributes, 3 alt including status quo

PostPosted: Wed Nov 08, 2017 11:24 am
by Michiel Bliemer
You can remove ;rdraws since I removed the randomly distributed parameters that you put in the syntax. You will need ;rdraws if you put the distributions back again.

Note that you cannot have a reference level of a dummy coded variable only appear in the status quo alternative, there are several posts here on the forum that discuss that issue. You can try adding these constraints but if Ngene is not able to find a design that this is because it is not possible to estimate the model because of identification issues. This is a model specification issue, not a design problem.

Michiel

Re: Dummy coded 7 attributes, 3 alt including status quo

PostPosted: Wed Nov 15, 2017 6:52 am
by jaein.seo
Hello,

I'm writing to ask if I have to re-run the design when I change a level of one of attributes from the design posted on Nov 5.
For the attribute 'MVF,' initially the alternatives trtA and trtB included four levels including the reference level (0 in 1000) while the Standard of Care only included the lowest level (0 in 1000). Now, I'd like to replace the lowest level with the highest level (62 in 1000). I wonder if I could just change the wordings of the level when I put the choice questions in the survey because it's just the reversed order.

The levels of the attribute MVF were initially:

- Standard of care: 0 in 1000
- Treatment A: 0 in 1000, 15 in 1000, 20 in 1000, 25 in 1000
- Treatment B: 0 in 1000, 15 in 1000, 20 in 1000, 25 in 1000

It'd be changed to:

- Standard of care: 62 in 1000
- Treatment A: 15 in 1000, 20 in 1000, 25 in 1000, 62 in 1000
- Treatment B: 15 in 1000, 20 in 1000, 25 in 1000, 62 in 1000

My question is: Do I have to re-run the code taking this change into account?

Re: Dummy coded 7 attributes, 3 alt including status quo

PostPosted: Wed Nov 15, 2017 8:00 pm
by Michiel Bliemer
If you change the levels, then your priors are generally no longer appropriate, you will have to change your priors and re-run the syntax. If you think the priors are still OK, even though the reference alternative is different now, then you can simply change the text without re-running the syntax.

Michiel

Re: Dummy coded 7 attributes, 3 alt including status quo

PostPosted: Wed Dec 13, 2017 7:15 am
by jaein.seo
Hi,

I am writing with a query regarding the change made in the design. My team has decided to add interaction terms with a new variable 'bmeta.' We are wondering if the presence of bone metastasis will affect people's choice. This will be a binary, non-directional interaction term on the 'bm' variable with two levels [1,0] which indicates yes for bone metastasis and no for none. 'bmeta' will be introduced in the interaction, without first being specified with a parameter for a main effect. Everything else is the same. The following syntax does not run. Please review and advise. Your feedback would be much appreciated.

Code: Select all
Design
;alts = trtA*, trtB*, std*
;rows = 24
;block = 2
;eff = (mnl,d)
;alg = mfederov(candidates = 1000)
;require:
trtA.admin<>0,
trtB.admin<>0,
std.bm = 2,
std.aff = 0,
std.hypocalc = 0,
std.mvf = 0,
std.osteonecr = 0,
std.admin = 0,
std.cost = 0

;model:

U(trtA)=b1.dummy[0.3|0.2|0.1]*bm[3,2,1,0] +
   b2.dummy[0.3|0.2|0.1]*aff[3,2,1,0] +
   b3.dummy[0.0]*hypocalc[1,0] +
   b4.dummy[0.3|0.2|0.1]*mvf[3,2,1,0] +
   b5.dummy[0.3|0.2|0.1]*osteonecr[3,2,1,0] +
   b6.dummy[0.0|0.0]*admin[2,1,0] +
   b7.dummy[0.3|0.2|0.1]*cost[3,2,1,0] +
   i1[(n, 0.0, 0.1)]*bmeta.dummy[1,0]*bm.dummy[1] +
   i2[(n, 0.0, 0.1)]*bmeta.dummy[1,0]*bm.dummy[2] +
   i3[(n, 0.0, 0.1)]*bmeta.dummy[1,0]*bm.dummy[3] /

U(trtB)=b1*bm +
   b2*aff +
   b3*hypocalc +
   b4*mvf +
   b5*osteonecr +
   b6*admin +
   b7*cost +
   i1*bmeta.dummy[1,0]*bm.dummy[1] +
   i2*bmeta.dummy[1,0]*bm.dummy[2] +
   i3*bmeta.dummy[1,0]*bm.dummy[3] /

U(std)= b1*bm +
   b2*aff +
   b3*hypocalc +
   b4*mvf +
   b5*osteonecr +
   b6*admin +
   b7*cost +
   i1*bmeta.dummy[1,0]*bm.dummy[1] +
   i2*bmeta.dummy[1,0]*bm.dummy[2] +
   i3*bmeta.dummy[1,0]*bm.dummy[3] $


Thank you,
Jaein

Re: Dummy coded 7 attributes, 3 alt including status quo

PostPosted: Wed Dec 13, 2017 9:48 am
by johnr
An interaction cannot occur without all elements first being specified as main effects. Hence the term

bmeta.dummy[1,0]*bm.dummy[1]

where is bmeta.dummy[1,0] first appears in the interaction without being a main effect is the issue.

This syntax should run

Design
;alts = trtA*, trtB*, std*
;rows = 24
;block = 2
;eff = (mnl,d)
;alg = mfederov(candidates = 1000)
;require:
trtA.admin<>0,
trtB.admin<>0,
std.bm = 2,
std.aff = 0,
std.hypocalc = 0,
std.mvf = 0,
std.osteonecr = 0,
std.admin = 0,
std.cost = 0

;model:

U(trtA)=b1.dummy[0.3|0.2|0.1]*bm[3,2,1,0] +
b2.dummy[0.3|0.2|0.1]*aff[3,2,1,0] +
b3.dummy[0.0]*hypocalc[1,0] +
b4.dummy[0.3|0.2|0.1]*mvf[3,2,1,0] +
b5.dummy[0.3|0.2|0.1]*osteonecr[3,2,1,0] +
b6.dummy[0.0|0.0]*admin[2,1,0] +
b7.dummy[0.3|0.2|0.1]*cost[3,2,1,0] +
b8[0]*bmeta[1,0] +
i1[(n, 0.0, 0.1)]*bmeta*bm.dummy[1] +
i2[(n, 0.0, 0.1)]*bmeta*bm.dummy[2] +
i3[(n, 0.0, 0.1)]*bmeta*bm.dummy[3] /

U(trtB)=b1*bm +
b2*aff +
b3*hypocalc +
b4*mvf +
b5*osteonecr +
b6*admin +
b7*cost +
b8*bmeta +
i1*bmeta*bm.dummy[1] +
i2*bmeta*bm.dummy[2] +
i3*bmeta*bm.dummy[3]/

U(std)= b1*bm +
b2*aff +
b3*hypocalc +
b4*mvf +
b5*osteonecr +
b6*admin +
b7*cost +
b8*bmeta +
i1*bmeta*bm.dummy[1] +
i2*bmeta*bm.dummy[2] +
i3*bmeta*bm.dummy[3] $

Re: Dummy coded 7 attributes, 3 alt including status quo

PostPosted: Wed Dec 13, 2017 10:14 pm
by Andrew Collins
We do have some more flexibility and can specify a new attribute in an interaction, without specifying it first as a main effect. However, this does not extend to dummy coded variables (I'll look into implementing this in future). Since bmeta only takes 2 levels, there should be no problem entering it without dummy coding. I have done so in the syntax below.

Two more things. Should the bone metastasis be related to the choice task (the patient I presume) rather than the alternative, and so be essentially a scenario (see section 8.5 of the manual) with the same value for all alternatives? If so, we can enforce this when using the Federov algorithm by adding "trtA.bmeta=trtB.bmeta" to the require list. If not, remove from the syntax below.

Also, since the std alternative has fixed levels, this will probably cause problems if all of the interactions are specified. In the syntax, for std, I have retained the interaction only for bm=2.

Andrew

Code: Select all
Design
;alts = trtA*, trtB*, std*
;rows = 24
;block = 2
;eff = (mnl,d)
;alg = mfederov(candidates = 1000)
;require:
trtA.admin<>0,
trtB.admin<>0,
std.bm = 2,
std.aff = 0,
std.hypocalc = 0,
std.mvf = 0,
std.osteonecr = 0,
std.admin = 0,
std.cost = 0,
trtA.bmeta=trtB.bmeta

;model:

U(trtA)=b1.dummy[0.3|0.2|0.1]*bm[3,2,1,0] +
   b2.dummy[0.3|0.2|0.1]*aff[3,2,1,0] +
   b3.dummy[0.0]*hypocalc[1,0] +
   b4.dummy[0.3|0.2|0.1]*mvf[3,2,1,0] +
   b5.dummy[0.3|0.2|0.1]*osteonecr[3,2,1,0] +
   b6.dummy[0.0|0.0]*admin[2,1,0] +
   b7.dummy[0.3|0.2|0.1]*cost[3,2,1,0] +
   i1[(n, 0.0, 0.1)]*bmeta[1,0]*bm.dummy[1] +
   i2[(n, 0.0, 0.1)]*bmeta*bm.dummy[2] +
   i3[(n, 0.0, 0.1)]*bmeta*bm.dummy[3] /

U(trtB)=b1*bm +
   b2*aff +
   b3*hypocalc +
   b4*mvf +
   b5*osteonecr +
   b6*admin +
   b7*cost +
   i1*bmeta*bm.dummy[1] +
   i2*bmeta*bm.dummy[2] +
   i3*bmeta*bm.dummy[3] /

U(std)= b1*bm +
   b2*aff +
   b3*hypocalc +
   b4*mvf +
   b5*osteonecr +
   b6*admin +
   b7*cost  +
   i2[(n, 0.0, 0.1)]*bmeta*bm.dummy[2]
$