interactions and dummy variables

This forum is for posts that specifically focus on Ngene.

Moderators: Andrew Collins, Michiel Bliemer, johnr

interactions and dummy variables

Postby mpburton » Tue Dec 12, 2023 9:38 pm

There may be a very short answer to this, but....

I am running a design with an interaction between a dummy variable and a continuous variable, and i get

Error: An interaction term is associated with a dummy or effects coded parameter. Interactions of dummy or effects coded attributes are not currently supported. 'mb.dummy[-1|-0.75|-0.5|-0.25]*m[1,0.75,0.5,0.25,0]*time[1,2,3]'

I am hoping there might be a beta version where this is supported, but as I said....

Michael
mpburton
 
Posts: 2
Joined: Mon Jul 15, 2019 11:16 am

Re: interactions and dummy variables

Postby Michiel Bliemer » Wed Dec 13, 2023 9:13 am

Yes this can be done with the right syntax.

Instead of writing

mb.dummy[-1|-0.75|-0.5|-0.25]*m[1,0.75,0.5,0.25,0]*time[1,2,3]

you need to write

mb1[-1] * m.dummy[1] * time[1,2,3] +
mb2[-0.75] * m.dummy[0.75] * time[1,2,3] +
mb3[-0.5] * m.dummy[-0.5] * time[1,2,3] +
mb4[-0.25] * m.dummy[-0.25] * time[1,2,3]

This syntax assumes that you are using m[1,0.75,0.5,0.25,0] as a main effect as well in the utility function, such that the levels are already defined.

Ngene also supports interactions of dummy variables with dummy variables, for example

mb1[-1] * m.dummy[1] * time.dummy[1] +
mb2[-0.75] * m.dummy[0.75] * time.dummy[1] +
mb3[-0.5] * m.dummy[-0.5] * time.dummy[1] +
mb4[-0.25] * m.dummy[-0.25] * time.dummy[1] +
mb5[-1] * m.dummy[1] * time.dummy[2] +
mb6[-0.75] * m.dummy[0.75] * time.dummy[2] +
mb7[-0.5] * m.dummy[-0.5] * time.dummy[2] +
mb8[-0.25] * m.dummy[-0.25] * time.dummy[2]

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

Re: interactions and dummy variables

Postby Michiel Bliemer » Mon Dec 18, 2023 7:44 pm

This is not an issue or problem, the Ngene syntax is designed this way to make clear what the prior values belong to. If you use b.dummy[...]*x*y then it is unclear whether x is dummy coded, y is dummy coded, or both are dummy coded. There will be no 'fix' because it is not broken :)

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 28 guests