Announcement

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

  • How can I use the marginal effects after fixed effects and random effects models?

    Dear Statalist,

    I use linear model for panel data


    How can I use the marginal effects after these commands please

    xtreg c.rgdpg c.ihs_inigdppc c.fdx c.fdxsquar c.ihs_infvolatility c.fdx##c.ihs_infvolatility c.fdxsquar##c.ihs_infvolatility c.ihs_inf c.ihs_gov c.ihs_gfcf c.ihs_trd c.ihs_lbor, fe

    xtreg c.rgdpg c.ihs_inigdppc c.fdx c.fdxsquar c.ihs_infvolatility c.fdx##c.ihs_infvolatility c.fdxsquar##c.ihs_infvolatility c.ihs_inf c.ihs_gov c.ihs_gfcf c.ihs_trd c.ihs_lbor, re



    margins, dydx(fdx) at(ihs_infvolatility = (.017071 .4295887 6.00237) fdx = (12.9673 55.90659 93.312)) Is this command correct for both fe and re? If not, could you please support me with the correct commands




    Thank you

    Badiah

  • #2
    Any help!

    Comment


    • #3
      The -margins- command does many things, and as you don't say what specifically you are trying to calculate, nobody can say whether it is correct for your purposes or not.

      Suffice it to say that if you are trying to calculate marginal effects of fdx at the 9 combinations of fdx and ihs_infvolatility listed in your -at()- option, then this is almost the right command for that purpose. The problem is actually in your -xtreg- command where you have included a variable fdxsquar and its interaction with ihs_infvolatility. If, as the name suggests, fdxsquar is fdx2, then -margins- will be unable to give you correct results no matter how you use it. Quadratic terms must be specified using factor variable notation in order to use -margins-. Similarly I worry when I see variables named ihs_something and worry that these may be interactions of some variable ihs with something else. If that is what they are, you have to rewrite them with appropriate factor variable notation. If they are not, however, interactions then those can be left alone. Anyway, assuming those are not interactions, change your code to:
      Code:
      xtreg c.rgdpg c.ihs_inigdppc c.fdx##c.fdx##ihs_infvolatility  c.ihs_inf c.ihs_gov c.ihs_gfcf c.ihs_trd c.ihs_lbor, // EITHER fe OR re GOES AFTER THE COMMA
      margins, dydx(fdx) at(ihs_infvolatility = (.017071 .4295887 6.00237) fdx = (12.9673 55.90659 93.312))
      It should run equally well after -fe- as after -re-. However, if there are colinearities among the variables in the models, then you may get (not estimable) as a result: this is more likely to happen with -fe- than with -re- because the fixed effects provide extra opportunities for colinearity that are not available with -re-. But otherwise, it should work with either model.

      Added: Your post went unanswered for a day. Admittedly, it was a holiday in many of the countries where Statalist is popular. But even so, I think it went unanswered largely because your question just lacked the information to support an answer. As you can see, my answer is conditioned on some guesses that I have made about your data. In general, when you do not get a timely response on Statalist, it is usually not helpful to just add "Any help?" or the like to your thread. It is better to assume that the question was not clearly posed and rephrase it with more and clearer information. In particular, you should, before posting anything, ask yourself: would a person who has no other knowledge of my problem and no knowledge or experience in my discipline be able to fully understand my question based solely on what I have written here. I think you can see, in retrospect, that the answer to that question in the case of #1 is no. When asking for help with code, you should assume as a minimum that a description of all of the relevant variables in your data set will be needed, along with a statement of the research question (avoiding discpline-specific jargon, using terminology that anybody with a college education and basic knowledge of statistics would understand). Nearly always include example data, using the -dataex- command to do so. And if you have tried some code yourself, but it did not produce satisfactory results, show the code, the results you got, and unless it is blatantly obvious, explain how the results differ from what you wanted. The more you help those who try to help you, the more likely you will get useful and timely advice.
      Last edited by Clyde Schechter; 26 Dec 2021, 18:59.

      Comment


      • #4
        Clyde Schechter dear Clyde, Thank you very much for your response, your answer is very helpful, which is exactly what I expect.
        I am sorry for doing like that mistake, due to the stress of studying, I forgot it is holiday. I promise will not repeat that in future.

        Thank you for time and kind help.
        Happy new year

        Best regards

        Badiah

        Comment

        Working...
        X