Announcement

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

  • cmclogit + margins + interactions

    Hello!

    I'm trying to use a McFadden's choice model using cmclogit with case- and alternative-specific variables. I'm interested in examining how the average marginal effect of an alternative-specific variable varies across alternatives.

    Here's an example for the basic main effects model (with time being the alternative-specific variable, and mode the alternative-id)
    Code:
    use https://www.stata-press.com/data/r16/travel, clear
    
    cmset id mode // setup case-id and alternative-id
    
    gen time=traveltime+termtime
    
    * main effects cmclogit-model
    cmclogit choice time , casevars(income partysize)
    It looks like this model could tell me how the (direct/indirect) average marginal effect of time varies across alternatives, e.g.
    Code:
    margins, dydx(time)
    marginsplot
    But I'm a bit unsure at this point: if I wanted to know how the effect of the alternative-specific variable varies across alternatives, wouldn't I need to interact it with the alternative-ID? Wouldn't the variation of the time effects across alternatives in the main effects model be partly due to the inbuilt interactions of the logit model, rather than necessarily indicating a "real" interaction (or am I completely on the wrong track in my thinking here)?

    In other words, wouldn't I need the following model instead of the main effects model:
    Code:
    cmclogit choice time c.time#i.mode, casevars(income partysize)
    If the latter model would be correct (it runs fine), I still wonder how I would use the margins command in this case: if this was an ordinary logit, I'd use margins dydx(time), over(alternatives) -- but that doesn't work after cmclogit.

    Any help in getting me out of my confusion is greatly appreciated!

    Best,
    Irene
    Last edited by Irene Prix; 18 Sep 2020, 08:54.
Working...
X