Announcement

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

  • Marginsplots with panel data

    Hi there,
    I am estimating panel models containing interaction effects between income and demographic characteristics but I am having problems obtaining the marginal effects of these variables. I have been able to obtain marginal effects for fixed-effects panel models but as soon as I add time-varying predictors, the marginsplots command ceases to work as the marginal effects are not estimated.
    I would be very grateful if anyone could suggest any ways around this problem or alternative way of plotting marginal effects.
    Thank you!


  • #2
    You do not provide a lot of details (e.g. code you used, output you get etc.), but does this help you?

    Best
    Daniel

    Comment


    • #3
      Dear Daniel,
      Thank you so much, and sorry for not providing more detail. The post you referred to is very helpful but I do have some unanswered questions.
      The code you linked to shows that the marginal effects of interactions between time-varying and time-invariant variables in fixed-effects panel models can be obtained as long as a main effect is not requested for time-invariant covariates. This makes sense and had worked with my data.

      My problem is now with models that estimate interactions between two time-varying predictors but also contain time-invariant predictors - whose presence seems to be making it impossible to calculate marginal effects of the interactions.

      For example, if my model is estimated with no main effect of sex (or of any time-invariant covariates), the marginal effects are estimated:

      xtreg logSDQ c.inc_logN##c.region_rankN gm_age Cgm_age CLLTI priR socR otherR lone recon oneW noW college school otherQ noneQ,fe

      Fixed-effects (within) regression Number of obs = 53619
      Group variable: urn Number of groups = 16791

      R-sq: within = 0.0770 Obs per group: min = 1
      between = 0.0840 avg = 3.2
      overall = 0.0744 max = 4

      F(17,36811) = 180.57
      corr(u_i, Xb) = 0.0886 Prob > F = 0.0000

      -------------------------------------------------------------------------------------------
      logSDQ | Coef. Std. Err. t P>|t| [95% Conf. Interval]
      --------------------------+----------------------------------------------------------------
      inc_logN | -1.035205 .0449175 -23.05 0.000 -1.123245 -.9471659
      region_rankN | 1.288132 .0607861 21.19 0.000 1.16899 1.407274
      |
      c.inc_logN#c.region_rankN | -.8907807 .0690488 -12.90 0.000 -1.026118 -.7554431
      |
      gm_age | .0007359 .002892 0.25 0.799 -.0049325 .0064043
      Cgm_age | -.0037604 .0002508 -14.99 0.000 -.004252 -.0032687
      CLLTI | .0679488 .0076601 8.87 0.000 .0529347 .0829628
      priR | .0414581 .0145666 2.85 0.004 .012907 .0700091
      socR | .0104922 .0159612 0.66 0.511 -.0207921 .0417765
      otherR | .0276343 .0212137 1.30 0.193 -.0139451 .0692136
      lone | .0581372 .0124438 4.67 0.000 .033747 .0825274
      recon | .1262525 .016084 7.85 0.000 .0947275 .1577775
      oneW | .0281145 .0077884 3.61 0.000 .012849 .0433801
      noW | .0482886 .0137101 3.52 0.000 .0214163 .0751609
      college | .0284135 .0194728 1.46 0.145 -.0097537 .0665808
      school | .014246 .0204818 0.70 0.487 -.025899 .054391
      otherQ | -.0724801 .1482477 -0.49 0.625 -.3630498 .2180896
      noneQ | .1290886 .0458559 2.82 0.005 .0392098 .2189675
      _cons | 2.549456 .0569948 44.73 0.000 2.437745 2.661168
      --------------------------+----------------------------------------------------------------
      sigma_u | .56055843
      sigma_e | .44627803
      rho | .61206073 (fraction of variance due to u_i)
      -------------------------------------------------------------------------------------------
      F test that all u_i=0: F(16790, 36811) = 4.43 Prob > F = 0.0000

      . margins, dydx(region_rankN) at(inc_logN=(0(0.2)1)) vsquish

      Average marginal effects Number of obs = 53619
      Model VCE : Conventional

      Expression : Linear prediction, predict()
      dy/dx w.r.t. : region_rankN
      1._at : inc_logN = 0
      2._at : inc_logN = .2
      3._at : inc_logN = .4
      4._at : inc_logN = .6
      5._at : inc_logN = .8
      6._at : inc_logN = 1

      ------------------------------------------------------------------------------
      | Delta-method
      | dy/dx Std. Err. z P>|z| [95% Conf. Interval]
      -------------+----------------------------------------------------------------
      region_rankN |
      _at |
      1 | 1.288132 .0607861 21.19 0.000 1.168994 1.40727
      2 | 1.109976 .0487172 22.78 0.000 1.014492 1.20546
      3 | .9318197 .0378576 24.61 0.000 .8576202 1.006019
      4 | .7536636 .0295711 25.49 0.000 .6957052 .8116219
      5 | .5755074 .0264031 21.80 0.000 .5237583 .6272566
      6 | .3973513 .0300203 13.24 0.000 .3385126 .45619
      ------------------------------------------------------------------------------


      In this case, the marginal effects of ranked income at different levels of absolute income are estimated.
      However, as soon as I control for sex, the marginal effects are unable to be estimated:

      xtreg logSDQ c.inc_logN##c.region_rankN Csex gm_age Cgm_age CLLTI priR socR otherR lone recon oneW noW college school otherQ noneQ,fe
      note: Csex omitted because of collinearity

      Fixed-effects (within) regression Number of obs = 53619
      Group variable: urn Number of groups = 16791

      R-sq: within = 0.0770 Obs per group: min = 1
      between = 0.0840 avg = 3.2
      overall = 0.0744 max = 4

      F(17,36811) = 180.57
      corr(u_i, Xb) = 0.0886 Prob > F = 0.0000

      -------------------------------------------------------------------------------------------
      logSDQ | Coef. Std. Err. t P>|t| [95% Conf. Interval]
      --------------------------+----------------------------------------------------------------
      inc_logN | -1.035205 .0449175 -23.05 0.000 -1.123245 -.9471659
      region_rankN | 1.288132 .0607861 21.19 0.000 1.16899 1.407274
      |
      c.inc_logN#c.region_rankN | -.8907807 .0690488 -12.90 0.000 -1.026118 -.7554431
      |
      Csex | 0 (omitted)
      gm_age | .0007359 .002892 0.25 0.799 -.0049325 .0064043
      Cgm_age | -.0037604 .0002508 -14.99 0.000 -.004252 -.0032687
      CLLTI | .0679488 .0076601 8.87 0.000 .0529347 .0829628
      priR | .0414581 .0145666 2.85 0.004 .012907 .0700091
      socR | .0104922 .0159612 0.66 0.511 -.0207921 .0417765
      otherR | .0276343 .0212137 1.30 0.193 -.0139451 .0692136
      lone | .0581372 .0124438 4.67 0.000 .033747 .0825274
      recon | .1262525 .016084 7.85 0.000 .0947275 .1577775
      oneW | .0281145 .0077884 3.61 0.000 .012849 .0433801
      noW | .0482886 .0137101 3.52 0.000 .0214163 .0751609
      college | .0284135 .0194728 1.46 0.145 -.0097537 .0665808
      school | .014246 .0204818 0.70 0.487 -.025899 .054391
      otherQ | -.0724801 .1482477 -0.49 0.625 -.3630498 .2180896
      noneQ | .1290886 .0458559 2.82 0.005 .0392098 .2189675
      _cons | 2.549456 .0569948 44.73 0.000 2.437745 2.661168
      --------------------------+----------------------------------------------------------------
      sigma_u | .56055843
      sigma_e | .44627803
      rho | .61206073 (fraction of variance due to u_i)
      -------------------------------------------------------------------------------------------
      F test that all u_i=0: F(16790, 36811) = 4.43 Prob > F = 0.0000

      . margins, dydx(region_rankN) at(inc_logN=(0(0.2)1)) vsquish

      Average marginal effects Number of obs = 53619
      Model VCE : Conventional

      Expression : Linear prediction, predict()
      dy/dx w.r.t. : region_rankN
      1._at : inc_logN = 0
      2._at : inc_logN = .2
      3._at : inc_logN = .4
      4._at : inc_logN = .6
      5._at : inc_logN = .8
      6._at : inc_logN = 1

      ------------------------------------------------------------------------------
      | Delta-method
      | dy/dx Std. Err. z P>|z| [95% Conf. Interval]
      -------------+----------------------------------------------------------------
      region_rankN |
      _at |
      1 | . (not estimable)
      2 | . (not estimable)
      3 | . (not estimable)
      4 | . (not estimable)
      5 | . (not estimable)
      6 | . (not estimable)
      ------------------------------------------------------------------------------
      Are you aware of any way of estimating the marginal effects of variables in fixed-effects panel models that contain time-invariant covariates? I am reluctant to remove sex from my models.

      Many thanks in advance

      Comment


      • #4
        I am a bit confused. You cannot estimate "effects" of time-invariant predictors in fixed-effects (within) regression model. The ability to control for such measured and unmeasured predictors is the very strength of such models. So I am not quite sure what you are trying to do here. If sex is constant within a panel-unit - and since Stata omits it due to collinearity, which implies it is - this is already controlled for.

        I guess Jeff's answer (in the cited post) concerning the stability of the H matrix applies here, too.

        Best
        Daniel

        Comment


        • #5
          Hi Daniel,
          I'm sorry not to have been clearer - hopefully I can explain things a little better. In the above example I want to examine the marginal effect of ranked income at different levels of absolute income. Both these variables are time-varying so can be estimated in a fixed-effects regression model. The difficulty I am encountering is that while these marginal effects are estimated in fixed-effects panel models that contain no time-invariant predictors (ie: that don't include sex), the marginal effects cannot be estimated once time-invariant predictors are added. So in the example above, I'm not interested in estimating the effect of sex (which I'm aware not possible) but I do still wish to control for sex when examining the effects of other predictors. It's not clear to me why marginal effects of other variables cannot be estimated when time-invariant covariates are added.
          Any help or suggestions would be gratefully received!

          Comment


          • #6
            So in the example above, I'm not interested in estimating the effect of sex (which I'm aware not possible) but I do still wish to control for sex when examining the effects of other predictors.
            Elisabeth,

            the reason you cannot estimate the "effect" of time-invariant predictors is that they are already controlled for! This is why Stata drops sex when you try to include it in your model. This is why all other coefficients do not change. You can review the algebra of the fixed-effects estimator in the Methods and Formulas section of xtreg to gain further insights into how this estimator controls for such predictors.

            Best
            Daniel

            Comment


            • #7
              Thank you so much, Daniel, I was clearly very confused. I appreciate your help.

              Comment

              Working...
              X