Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • No interactions allowed in mixed logit regression (Stata 14 -mixlogit- and -gmnl- packages)

    Hello,
    This is my first post here, please pardon me for any mistake or obvious errors, but I haven't found an answer to my problem in the forum.
    I am working on Stata 14 on the analysis of a discrete choice experiment. I am using a mixed logit regression (-mixlogit- package) and am trying to include interaction terms between a factor variable (a characteristic of the respondent, named -know_water-) and one of the attributes of the choice experiment -inf_100-.
    My code looks like so
    Code:
    global randvars "inf_50 inf_100 heat_20 heat_40 heat_60 red_car dist_0 dist_100 dist_500 sq"
    mixlogit choice inf_100#i.know_water, group(chid) id(id) nrep(500) rand($randvars payment) ln(1)
    I systematically get the error "interactions not allowed" however I change the code. I also tried it with the gmnl package, and it did not work (code below):
    Code:
    gmnl choice, group(chid) id(id) nrep(500) rand($randvars mpayment )ln(1) mixl
    However, I have performed the same interactions with a multinomial conditional logit regression without problem, like so:
    Code:
    clogit choice $randvars payment inf_100##know_water, group(chid)
    My -know_water- variable was encoded from string to a factorial variable successfully, since it worked with the conditional logit regression
    Code:
    encode know_origin_water, gen(know_water)
    Is my code wrong ? Or is it the whole -mixlogit- package that does not allow for interactions ? In this case, would you have any recommendations for other packages on Stata14 ?

    Thank you in advance

    Georges Farina

  • #2
    Georges Farina Many community-contributed packages including -mixlogit- and -gmnl- do not recognise Stata's factor variable short-cuts. You can generate the interaction terms directly as new variables, and include them in your model specification. For example:

    HTML Code:
    generate double inf_100Xknow_water = inf_100 * know_water  
    mixlogit choice inf_100Xknow_water, group(chid) id(id) nrep(500) rand($randvars payment) ln(1)

    Comment

    Working...
    X