Announcement

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

  • nested logit - all constraints invalid message

    Hi

    I am reposting this because i did not get any replies before.

    I am trying to model migration within Sweden using a nested logit model and I have divided Sweden into 28 different regions. In the first step, I am modeling the choice to either stay in the region where individuals are currently residing or to move from the region as a function of indivudual characterists. In the second step, I am trying to model the choice of destination for those who moved as a function of characteristics at the destination areas.

    When trying to run the model I get the "All constraints invalid message" and the program stops.

    Because the stay-option is degenerate I use the constraint: constraint 1 [stay_tau]_cons=1

    I have managed to make the nested logit model converge in other settings, so I am pretty sure that there is nothing wrong with how I enter the commands. I also employ the nlogitgen command before trying to run the model.


    I am wondering whether this problem has anything to do with the fact that the sets of alternatives differs between indiviudals who move from different regions. For example, those who move from region number 2 can not chose to move to region 2 in the setup of destinations choices (because they are moving from region 2). And those who move from region number 3, can choose to move to region 2 (and to other regions) but not to region nr 3 (because thats where they are moving from.) Could this be the explanation?


    Any input would be of great help!

    Thanks!
    Peter

  • #2
    You didn't get a quick response. You'll increase your chances of a useful answer by following the FAQ on asking questions - provide Stata code in code delimiters, readable Stata output, and sample data using dataex. With what you've posted, we can't replicate the problem and don't even know exactly what you ran.

    I'm afraid that I can't help you with the substance of your problem.

    Comment


    • #3
      Hi Peter,

      I am having the exact same issue, but in my case I am modeling the decision to stay or to move to one of 50 US states. I believe the problem has to do with the most recent update of Stata. Are you by chance using Stata 16? Here is how I solved the problem:

      constraint 1 [/move]stay_tau = 1

      where move defines the tree as specified in the nlogitgen command.

      I hope this helps.

      -Austin



      Comment


      • #4
        Hi Austin,

        I am confused about how to set up the data and the hierarchy. I would appreciate it a lot for your reply! Below is an example of my data. The variables orgin and destination are the previous province and the current province where the individuals reside. I've changed the value of alternative to be 0 if it is the previous province. I set up the hierarchy in this way: nlogitgen move = alternative(stay:0, move=1|2|3|4|5|6|7|8|9|10). Is this correct? Thank you so much!

        -Junni


        Comment


        • #5
          Hi Junni,

          What you've done looks correct. Here is a sample of my code:

          qui replace state=0 if state==state_previous

          nlogitgen move=state(stay: 0, leave: 1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20 |21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|3 7|38|39|40|41|42|43|44|45|46|47|48|49|50|51)

          constraint 1 [/move]stay_tau = 1

          nlogit chosen xvars ///
          || move: altspecvars ///
          || state: , noconstant case(id) constraints(1) vce(cluster id)

          Comment


          • #6
            Hi Austin,

            Thank you so much for your detailed reply! I appreciate it a lot!

            -Junni

            Comment

            Working...
            X