Announcement

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

  • Need help with nested logit marginal effects

    Dear scholars, I am having problem estimating the marginal effects after the estimation of my nested logit using nlogit in stata. Please is there any package or short procedure to estimate this marginal effects

  • #2
    I am not familiar with -nlogit-. But I see that it is an official Stata command. So it would be very surprising if you could not get the marginal effects by using the -margins- command, just as you would after any other Stata estimation command. Have you tried that? If you are not familiar with -margins-, I recommend reading the excellent Richard Williams' https://www3.nd.edu/~rwilliam/stats/Margins01.pdf for a very lucid introduction. Further knowledge about the command can then be gained by reading the corresponding chapter in the PDF documentation that is installed with Stata.

    Comment


    • #3
      Thanks so much Prof Clyde Schechter for the swift response. I will try the margin command . however, the stata manual doesn't include the margins as a post estimation command. That's why I'm a little bit concerned if it would work.

      Comment


      • #4
        Interesting. Perhaps it will not. I don't know what to advise you in that case. I'm not familiar with the nlogit model, so if that doesn't work, I hope somebody who is will join in.

        Comment


        • #5
          first, -margins- is not appropriate for use after -nlogit-; here is what I received after trying it:
          Code:
          command margins not appropriate after nlogit
          r(322)
          second, can you explain what marginal effects, in particular what types of marginal effects, you want (and please show the results of the estimation within CODE blocks - see the FAQ if this is not clear); also please explain what variable you want marginal effects for
          Last edited by Rich Goldstein; 19 Dec 2021, 15:03.

          Comment


          • #6
            Thanks so much, marginal effect is a post estimation needed after the estimation of logistics regression to show the effects of each covariates on the dependent variable. Similar estimate was carried out in Cameron and Trivedi ( microeconometrics using stata) example 15.6.5. I tried to use the delta approach to calculating average marginal effect as used by the said author but I kept getting an error type message "mismatch"
            Code:
            Code:
            preserve
            Quietly summarize expendenegy
            Gen delta =r(SD)/1000
            Quietly replace expendenegy = expendenegy + delta if energy_altern== "Biomas_Trad"
            
            
            Error message : type mismatch
            eneegy_altern is an alternative variable that shows the various alternatives available to the user. Its is a string just like the examples giving in nested logit I have encoded it while the expendenegy is my alternative specific variable that changes per each alternatives while Biomas_Trad Is one of the alternative options.
            Last edited by Hamid muili; 23 Dec 2021, 14:23.

            Comment


            • #7
              I'm going to limit myself to commenting that the above cannot be correct because case matters in Stata and the commands you show are not allowed to start with capital letters; I have the book you cite but don't find that "example" - what page is it on?

              Comment


              • #8
                eneegy_altern is an alternative variable that shows the various alternatives available to the user. Its is a string just like the examples giving in nested logit I have encoded it[ [emphasis added]
                If you have encoded it, then it is no longer a string variable. It is now a numeric variable with value labels attached so that, in listings and in the browser, it will look like a string to human eyes. But it is not a string. So it is the -if energy_altern == "Biomas_Trad"- clause that is precipitating the error message.

                Try:
                Code:
                quietly replace expendenegy = expendenegy + deltaif energy_altern == "Biomas_Trad":energy_altern
                Note: This assumes that the name of the value label attached to energy_altern is, itself, energy_altern. If you used -encode- and did not specify anything different from that, that is the name that Stata would use by default.

                If this does not solve the problem, please post back showing an example of your data set using the -dataex- command. If you are running version 17, 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

                Comment

                Working...
                X