Announcement

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

  • Calculating marginal effects from a fixed effects regression

    Hi,
    I have a panel data set and I have run the following model
    Code:
    xtreg lnYearRanking l.lnYearRanking lnRelativewagespend l.lnRelativewagespend i.LeagueNumber l.ib3.PR LeagueNumber#c.lnRelativewagespend
    with an example of my dataset being
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int TeamNumbers double(lnYearRanking lnRelativewagespend) byte LeagueNumber long PR
    1  -2.867898941040039                   . 4 3
    1 -2.3632097244262695                   . 4 3
    1 -2.2335922718048096                   . 4 3
    1  -2.116255521774292                   . 4 3
    1 -1.2947272062301636                   . 4 3
    1  -2.008823871612549                   . 4 3
    1  -2.508437156677246                   . 4 3
    1  -2.116255521774292                   . 4 3
    1 -2.3632097244262695                   . 4 3
    2   -.597836971282959                   . 3 3
    2  -.2814124524593353                   . 3 3
    2 -.19415602087974548                   . 3 3
    2   -.597836971282959                   . 3 3
    2 -.19415602087974548                   . 3 3
    2  -.8421827554702759                   . 3 2
    2 -1.2321436405181885                   . 4 1
    2  -.2814124524593353                   . 3 3
    2  -.2376716583967209                   . 3 3
    2  -.6451379656791687                   . 3 3
    2  -.7419373393058777                   . 3 3
    2  -.8421827554702759                   . 3 2
    2  -3.102341890335083                   . 4 3
    2 -1.1130009889602661                   . 4 1
    2 -.15082289278507233                   . 3 3
    2 -.36974701285362244 -1.9844415187835693 3 3
    2 .021506205201148987 -1.0167139768600464 3 1
    2   .7419373393058777  -.7612044811248779 2 3
    2  1.2321436405181885  -.3074471652507782 2 1
    3 -2.2335922718048096  -2.930802822113037 4 3
    3  -2.867898941040039 -2.9393718242645264 4 3
    3  -2.867898941040039 -2.7565817832946777 4 3
    3  -2.116255521774292  -2.871849536895752 4 3
    4  -2.116255521774292                   . 4 3
    4  -1.359626054763794                   . 4 3
    4  -2.008823871612549                   . 4 3
    4 -1.7303905487060547                   . 4 3
    4  -4.521788597106934                   . 4 2
    5  3.4011974334716797  1.1270431280136108 1 3
    5   4.521788597106934  1.1688859462738037 1 3
    5  3.8177123069763184  1.2113429307937622 1 3
    5  3.8177123069763184  1.2744776010513306 1 3
    5  3.8177123069763184  1.1761025190353394 1 3
    5   4.521788597106934  1.5614136457443237 1 3
    5  3.8177123069763184  1.4554295539855957 1 3
    5   4.521788597106934   1.541187047958374 1 3
    5  3.8177123069763184   1.432999610900879 1 3
    5   3.102341890335083   1.574578046798706 1 3
    5   3.102341890335083  1.5737515687942505 1 3
    5  3.4011974334716797  1.4782519340515137 1 3
    5   3.102341890335083  1.3774480819702148 1 3
    5  3.4011974334716797  1.3763655424118042 1 3
    5   3.102341890335083   1.359984278678894 1 3
    5  3.4011974334716797  1.4343746900558472 1 3
    5   3.102341890335083   1.474872350692749 1 3
    5   3.102341890335083  1.5022573471069336 1 3
    5  3.4011974334716797  1.5203529596328735 1 3
    6   2.867898941040039   .7058887481689453 1 3
    6   2.508437156677246   .5919342637062073 1 3
    6  2.6741485595703125     .72902512550354 1 3
    6  2.6741485595703125   .8134595155715942 1 3
    6  2.3632097244262695   .8039206862449646 1 3
    6  2.3632097244262695   .8804538249969482 1 3
    6  1.5712167024612427   .8463802337646484 1 3
    6  2.6741485595703125     .80721515417099 1 3
    6   2.116255521774292    .772148609161377 1 3
    6  1.5712167024612427    .853588879108429 1 3
    6   2.008823871612549  .18860290944576263 1 3
    6  2.6741485595703125   .8779451847076416 1 3
    6  2.6741485595703125  1.0405687093734741 1 3
    6  2.6741485595703125  1.0909303426742554 1 3
    6  2.2335922718048096   .9887481927871704 1 3
    6  1.5712167024612427   .7545763850212097 1 3
    6  1.6486586332321167   .7239120602607727 1 3
    6  1.6486586332321167   .6410467624664307 1 3
    6  1.4975199699401855   .7181633114814758 1 3
    7  -2.116255521774292                   . 4 3
    7 -1.4271163940429688                   . 4 3
    7 -2.2335922718048096                   . 4 3
    7  -1.359626054763794                   . 4 3
    7  -4.521788597106934                   . 4 2
    7  -2.508437156677246                   . 4 3
    7  -2.008823871612549                   . 4 3
    7 -1.8170772790908813                   . 4 3
    7 -2.3632097244262695                   . 4 3
    7  -3.102341890335083                   . 4 3
    7 -3.4011974334716797                   . 4 3
    7 -3.4011974334716797                   . 4 3
    7 -3.8177123069763184                   . 4 2
    8  1.1716374158859253                   . 2 1
    8   1.359626054763794                   . 1 2
    8    .597836971282959                   . 2 3
    8  1.0560526847839355                   . 2 3
    8  .45953232049942017                   . 2 3
    8  .15082289278507233                   . 2 2
    8  -.7419373393058777                   . 3 3
    8  -.4144337773323059                   . 3 3
    8 -.45953232049942017                   . 3 3
    8  -.1076306626200676                   . 3 1
    8   .2814124524593353 -1.5244444608688354 2 3
    8  .36974701285362244 -1.1675177812576294 2 3
    end
    label values PR PR
    label def PR 1 "Promotion", modify
    label def PR 2 "Relegation", modify
    label def PR 3 "ɴone", modify
    And the data is set as
    Code:
    xtset Teamnumbers SeasonStart
    I get my results as follows
    Click image for larger version

Name:	Results screenshot.PNG
Views:	1
Size:	39.8 KB
ID:	1377269
    I then want to obtain the marginal effects of all the variables especially the lagged value of lnRelativewagespend , however when I attempt this STATA returns the error message ' default prediction is a function of possibly stochastic quantities other than e(b)'

    I dont understand why it is doing this would anyone be able to help?

    Many thanks

  • #2
    Well, your example data doesn't enable anyone to try to reproduce your problem because it does not contain the variable SeasonStart which is needed in your -xtset- command. And, of course, without that, we can't run -xtreg- with lagged variables.

    You will have a better chance of getting useful advice if your posted data and code all work together and reproduce the problem you are encountering.

    Comment


    • #3
      Apologies, a correct example of the dataset is
      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input int(TeamNumbers SeasonStart) byte LeagueNumber double(lnYearRanking lnRelativewagespend) long PR
      1 2006 4  -2.867898941040039                   . 3
      1 2007 4 -2.3632097244262695                   . 3
      1 2008 4 -2.2335922718048096                   . 3
      1 2009 4  -2.116255521774292                   . 3
      1 2010 4 -1.2947272062301636                   . 3
      1 2011 4  -2.008823871612549                   . 3
      1 2012 4  -2.508437156677246                   . 3
      1 2013 4  -2.116255521774292                   . 3
      1 2014 4 -2.3632097244262695                   . 3
      2 1996 3   -.597836971282959                   . 3
      2 1997 3  -.2814124524593353                   . 3
      2 1998 3 -.19415602087974548                   . 3
      2 1999 3   -.597836971282959                   . 3
      2 2000 3 -.19415602087974548                   . 3
      2 2001 3  -.8421827554702759                   . 2
      2 2002 4 -1.2321436405181885                   . 1
      2 2003 3  -.2814124524593353                   . 3
      2 2004 3  -.2376716583967209                   . 3
      2 2005 3  -.6451379656791687                   . 3
      2 2006 3  -.7419373393058777                   . 3
      2 2007 3  -.8421827554702759                   . 2
      2 2008 4  -3.102341890335083                   . 3
      2 2009 4 -1.1130009889602661                   . 1
      2 2010 3 -.15082289278507233                   . 3
      2 2011 3 -.36974701285362244 -1.9844415187835693 3
      2 2012 3 .021506205201148987 -1.0167139768600464 1
      2 2013 2   .7419373393058777  -.7612044811248779 3
      2 2014 2  1.2321436405181885  -.3074471652507782 1
      3 2011 4 -2.2335922718048096  -2.930802822113037 3
      3 2012 4  -2.867898941040039 -2.9393718242645264 3
      3 2013 4  -2.867898941040039 -2.7565817832946777 3
      3 2014 4  -2.116255521774292  -2.871849536895752 3
      4 2008 4  -2.116255521774292                   . 3
      4 2009 4  -1.359626054763794                   . 3
      4 2010 4  -2.008823871612549                   . 3
      4 2011 4 -1.7303905487060547                   . 3
      4 2012 4  -4.521788597106934                   . 2
      5 1996 1  3.4011974334716797  1.1270431280136108 3
      5 1997 1   4.521788597106934  1.1688859462738037 3
      5 1998 1  3.8177123069763184  1.2113429307937622 3
      5 1999 1  3.8177123069763184  1.2744776010513306 3
      5 2000 1  3.8177123069763184  1.1761025190353394 3
      5 2001 1   4.521788597106934  1.5614136457443237 3
      5 2002 1  3.8177123069763184  1.4554295539855957 3
      5 2003 1   4.521788597106934   1.541187047958374 3
      5 2004 1  3.8177123069763184   1.432999610900879 3
      5 2005 1   3.102341890335083   1.574578046798706 3
      5 2006 1   3.102341890335083  1.5737515687942505 3
      5 2007 1  3.4011974334716797  1.4782519340515137 3
      5 2008 1   3.102341890335083  1.3774480819702148 3
      5 2009 1  3.4011974334716797  1.3763655424118042 3
      5 2010 1   3.102341890335083   1.359984278678894 3
      5 2011 1  3.4011974334716797  1.4343746900558472 3
      5 2012 1   3.102341890335083   1.474872350692749 3
      5 2013 1   3.102341890335083  1.5022573471069336 3
      5 2014 1  3.4011974334716797  1.5203529596328735 3
      6 1996 1   2.867898941040039   .7058887481689453 3
      6 1997 1   2.508437156677246   .5919342637062073 3
      6 1998 1  2.6741485595703125     .72902512550354 3
      6 1999 1  2.6741485595703125   .8134595155715942 3
      6 2000 1  2.3632097244262695   .8039206862449646 3
      6 2001 1  2.3632097244262695   .8804538249969482 3
      6 2002 1  1.5712167024612427   .8463802337646484 3
      6 2003 1  2.6741485595703125     .80721515417099 3
      6 2004 1   2.116255521774292    .772148609161377 3
      6 2005 1  1.5712167024612427    .853588879108429 3
      6 2006 1   2.008823871612549  .18860290944576263 3
      6 2007 1  2.6741485595703125   .8779451847076416 3
      6 2008 1  2.6741485595703125  1.0405687093734741 3
      6 2009 1  2.6741485595703125  1.0909303426742554 3
      6 2010 1  2.2335922718048096   .9887481927871704 3
      6 2011 1  1.5712167024612427   .7545763850212097 3
      6 2012 1  1.6486586332321167   .7239120602607727 3
      6 2013 1  1.6486586332321167   .6410467624664307 3
      6 2014 1  1.4975199699401855   .7181633114814758 3
      7 1996 4  -2.116255521774292                   . 3
      7 1997 4 -1.4271163940429688                   . 3
      7 1998 4 -2.2335922718048096                   . 3
      7 1999 4  -1.359626054763794                   . 3
      7 2000 4  -4.521788597106934                   . 2
      7 2005 4  -2.508437156677246                   . 3
      7 2006 4  -2.008823871612549                   . 3
      7 2007 4 -1.8170772790908813                   . 3
      7 2008 4 -2.3632097244262695                   . 3
      7 2009 4  -3.102341890335083                   . 3
      7 2010 4 -3.4011974334716797                   . 3
      7 2011 4 -3.4011974334716797                   . 3
      7 2012 4 -3.8177123069763184                   . 2
      8 1996 2  1.1716374158859253                   . 1
      8 1997 1   1.359626054763794                   . 2
      8 1998 2    .597836971282959                   . 3
      8 1999 2  1.0560526847839355                   . 3
      8 2000 2  .45953232049942017                   . 3
      8 2001 2  .15082289278507233                   . 2
      8 2002 3  -.7419373393058777                   . 3
      8 2003 3  -.4144337773323059                   . 3
      8 2004 3 -.45953232049942017                   . 3
      8 2005 3  -.1076306626200676                   . 1
      8 2006 2   .2814124524593353 -1.5244444608688354 3
      8 2007 2  .36974701285362244 -1.1675177812576294 3
      end
      label values PR PR
      label def PR 1 "Promotion", modify
      label def PR 2 "Relegation", modify
      label def PR 3 "ɴone", modify
      With the data being declared as
      Code:
      xtset TeamNumbers SeasonStart
      I then run the regression
      Code:
      xtreg lnYearRanking l.lnYearRanking lnRelativewagespend l.lnRelativewagespend i.LeagueNumber l.ib3.PR LeagueNumber#c.lnRelativewagespend, fe robust
      I then receive my results after this I then want to calculate the marginal effects of each variable, in particular the lagged value of lnRelativewagespend

      I use the command
      Code:
      margins, dydx(*)
      but i receive the following error message in red
      Click image for larger version

Name:	results screenshot error message .PNG
Views:	1
Size:	29.7 KB
ID:	1377400


      I don't understand why this is and was wondering how I could obtain the marginal effects?

      Many thanks

      Comment


      • #4
        Using just the sample of data you provided, and your xtset and xtreg commands, I have the same experience. Different regression results, of course, since it's just a subset of the full data, but the same error message.

        By omitting the lagged dependent variable from the model, I avoid the error message. That makes sense - the lagged dependent variable contains a random error.

        Small consolation, though. Perhaps Richard Williams - Statalist's evangelist of, and expert on, the interpretation of margins and their calculation with the margins command - can enlighten us on how to think about this problem.

        Comment


        • #5
          Actually, I was kind of hoping William Lisowski would know the answer. ;-)

          Since you have a lagged independent variable, I wonder if you wouldn't be better off using xtabond or a related command anyway?
          -------------------------------------------
          Richard Williams, Notre Dame Dept of Sociology
          StataNow Version: 19.5 MP (2 processor)

          EMAIL: [email protected]
          WWW: https://www3.nd.edu/~rwilliam

          Comment


          • #6
            If Richard is hoping for me to explain margins, we're doomed!

            A little more work with Duck Duck Go (like Google but without the attitude that it knows the "right" answer) turned up the following from Statalist in 2011.

            Question: I'm trying to use the margins command. I have NO problem when my FE Panel is run without a lagged dependant variable. However, when I introduce my lagged dependant variable and do the same margins command , I get "default prediction is a function of possibly stochastic quantities other than e(b)" What am I doing wrong?

            Reply: For one thing, using the FE estimator in a dynamic panel does not make much sense due to Nickell bias. If you're trying to estimate a dynamic panel model, use xtabond or Roodman's xtabond2 from SSC.
            Please don't ask me what Nickell bias is, we're much deeper into econometrics than I ever hoped to be. But here is a link to a later explanation on Statalist from Clyde Schechter which fleshes out the problem a little further.

            I think the bottom line is that margins is telling you that you've made a wrong turn in your analysis plan.

            Comment


            • #7
              The commentators did not mention that there are good reasons not to estimate a model with a lagged dv using xtreg. There are many appropriate estimators - depending on the situation, xtivreg, xtivreg2, xtabond (and variants including xtabond2), cmp, GSEM, and xtdpdml handle some such models.

              So the first problem isn't margins, it is the estimator.

              Comment


              • #8
                Hi,
                thank you very much for the replies,

                after more research into the bias of including a lagged variable in a fixed effects regression I have decided to drop the lagged value of the independent variable from my model.

                Below shows the initial regression and then the marginal effects.
                Click image for larger version

Name:	Initial regression.PNG
Views:	1
Size:	37.8 KB
ID:	1377604

                Click image for larger version

Name:	Marginal effcects with no lagged dependent variable.PNG
Views:	1
Size:	31.5 KB
ID:	1377603

                Could I please just confirm the interpretation of these marginal effects, in particular the effects of lnrelativewage spend and the lagged value of lnrelativewage spend.
                Does this result mean a 1% increase in wage spend improves league position by 39%?
                And that the lagged value decreases league position by -12%?

                would Richard Williams be able to help with this as an expert on margins?

                Many thanks

                Comment


                • #9
                  As I have said in other recent threads, I find it hard to interpret the AMEs for continuous variables. I prefer to plot predictions across a range of reasonable values. For more, see the handouts (especially the first 3) in the section entitled "Interpreting results: Adjusted Predictions and Marginal effects" at

                  http://www3.nd.edu/~rwilliam/xsoc73994/index.html

                  As noted in the 3rd handout, a nice feature of the MCP command is that you could have a logged independent variable like yours while doing a plot with the unlogged variable.

                  Incidentally, I am not sure that the decision to drop the lagged independent variable is right, but I assume you have your reasons.

                  -------------------------------------------
                  Richard Williams, Notre Dame Dept of Sociology
                  StataNow Version: 19.5 MP (2 processor)

                  EMAIL: [email protected]
                  WWW: https://www3.nd.edu/~rwilliam

                  Comment


                  • #10
                    Richard Williams Thankyou for the advice,

                    I have also run the following probit regression
                    Click image for larger version

Name:	probit regression.PNG
Views:	1
Size:	27.3 KB
ID:	1377626


                    I then calculate the margins from this probit regression as follows

                    Click image for larger version

Name:	Probit regression margins.PNG
Views:	1
Size:	19.3 KB
ID:	1377627


                    Would the advice for interpreting marginal effect of the lagged value of 'residalleagueposition' be as you mentioned above?
                    And with league numbers and itvdummy being dummy variables would the interpretation be that being in league 2 incrases the probability of an insolvency event by 1.8%? and so forth with the other dummy variables?
                    (in my regression if an insolvency event occurred then the dependent variable took a value of 1 and a 0 if not)

                    ​​​​​​​Many thanks

                    Comment

                    Working...
                    X