Announcement

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

  • nlogit syntax for three-level models

    Hi there, I feel sort of silly asking this but I've been Googling for ages with no luck!

    I'm trying to estimate a model in nlogit with three levels (a "trunk" and two "branches" in the lingo). In other words, the subject chooses between category A and category B, then within category B chooses category B1 or B2. A, B1, and B2 each have options within them.

    I know that nlogit can estimate models like this, since the documentation explicitly mentions it. But it never specifies the syntax for setting up a >2 level model. Nor can I find any examples online.

    Any help would be appreciated, thank you!

  • #2
    Hello Nick,
    Could you precisely write the nlogigitgen command you launched? This is the crucial command for defining the nested structure.
    And if possible paste us what stata sends you back when typing nlogittree?

    Best,
    Charlie




    Comment


    • #3
      Well right now I'm running the command:
      nlogitgen type = education(nodegree: 10 | 12 | 13, degree: 14 | 16 | 19)

      But this only sets up a two-level tree. I'm wondering how I can set up the nlogitgen command to create a three-level tree.

      Comment


      • #4
        I figured it out by going back and looking at the old code for the obsolete nlogitrum. Since it doesn't seem to be anywhere else on the internet (but I did find plenty of examples of people asking how to do it) I'll provide a little example of a three-level nested logit through nlogit in Stata here:

        Five levels of the variable "ed": 12, 13, 14, 16, 19.
        I want the top level to split them into (12,13) and (14, 16, 19)
        I want the middle level to split (14, 16, 19) into 14 and (16, 19)
        I want the bottom level to have (12, 13) in one branch, 14 in a degenerate branch by itself, and (16,19) in the third.

        I also have the choice variable "choice" equal to 1 if the given option was chosen, the alternative-varying variable "price," and the demographic variable "female." "id" identifies individuals.

        *produce the tree's top level
        nlogitgen top = ed(nodeg: 12 | 13, deg: 14 | 16 | 19)
        *Then the second level
        nlogitgen middle = ed(least: 12 | 13, middle: 14, most: 16 | 19)

        *estimate the model
        nlogit choice price || top: || middle: || ed: female, case(id)
        Last edited by Nick Huntington-Klein; 23 Sep 2015, 18:52.

        Comment

        Working...
        X