Announcement

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

  • First Difference Model

    I have a panel dataset with 102 observations, 51 groups and t=2. I can run both FE and RE, but get the "r(2000) no observations" error when trying to run a First Difference regression. All my variables are numerical and there are no missing values. Would someone be able to tell me why this is happening and how to get round this issue?

    Fixed effects regression code: xtreg pcr realmw propmales propwhites popdensity propyouth propnodiploma realjust, fe
    First difference code: reg d.pcr d.realmw d.propmales d.propwhites d.popdensity d.propyouth d.propnodiploma d.realjust
    Last edited by Savan Shah; 13 Feb 2017, 07:52.

  • #2
    There is nothing obviously wrong with the command you show for your first difference code. I think that in order to get advice you need to show more information. At a minimum:

    1. The -xtset- command and Stata's output in response to that.
    2. A small representative sample of your data. (Use the -dataex- command to do this. Run -ssc install dataex- and read the instructions in -help dataex-.)
    3. The output of the fixed-effects regression command.

    When posting the commands and output, be sure to place them between code delimiters so they will be easily readable. If you do not know about code delimiters, read FAQ #12. If you don't use code delimiters the regression outputs, in particular, will be a jumble.

    Comment


    • #3
      Please see the following information:


      1.
      Code:
      xtset
             panel variable:  stateid (strongly balanced)
              time variable:  year, 2007 to 2012, but with gaps
                      delta:  1 unit
      2.
      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input float(pcr realmw2 propmales propwhites popdensity propyouth propnodiploma realjust2)
      3977.7     5.15  .4792586  .7063107   .08948506 .09664607  .02184466     464.2
      3502.2 6.506917   .483106  .7051417   .09408568 .07743967 .017418677   424.242
      3379.2     7.15 .50986344  .7450683 .0011548417  .0986343  .02124431    978.57
      2739.4 7.078108   .516129  .7237027 .0012494723 .10378682  .02524544  1128.086
      4532.6     6.75 .50247246  .8865848   .05518774 .08741426 .028712714    707.28
      3539.2 6.986778 .50358176  .8777626   .05775829 .09099223 .015698826  638.5732
      3955.5     6.25 .48332125  .7962291    .0530023  .1040609 .023567803    399.84
      3660.1 6.506917  .4895153  .8026813   .05590416 .09487797 .016156755  410.8692
      3043.5      7.5  .4975696  .7789715    .2324315  .1014969 .019774636    962.71
      2758.7 7.306435  .4968645  .7469841    .2415855 .10487857  .01966307  895.4401
      2999.2     6.85  .5067666  .9075578   .04634226  .0841141   .0193629    602.51
      2684.7 6.977645  .4924423  .8922037    .0485132  .0968576 .016109785  626.7186
      2470.6     7.65  .4881571  .8558637    .7149407 .08116695 .011554015    627.27
        2140 7.404309  .4836508   .823429    .7262987  .0975263 .015638327   628.765
      3378.5     6.65  .4895592   .737819    .4423825 .09164733 .023201857    837.82
      3340.9 6.506917  .4839424  .7131783    .4634239 .09302326 .021040974  733.6482
      4088.8     6.67  .4904772  .8086591     .336822  .0868121  .02153693    697.38
      3276.7  6.88387  .4880076  .7863455    .3545377  .0862087 .018462025  628.5952
      3889.6     5.15  .4895689  .6616027    .1625184 .09275703  .02310902     552.2
      3410.6 6.506917  .4838377  .6333781    .1683605 .09160385 .017040173 521.96246
      4119.3     7.25 .49083665 .21513945    .1954028 .08685259  .00876494    613.38
      3075.2 6.621456 .49402985 .20597015    .2086373  .1097015 .015671642 560.65924
      2275.8     5.15 .50305086   .959322  .017847827 .08949152 .025084745    482.07
      1983.5 6.621456   .498094  .9491741   .01904575 .09148666 .018424397  512.8752
      2935.8      6.5  .4890857  .7812401   .22774214 .10811452 .017795002    565.16
      2578.7 7.460131  .4885532  .7832586   .22894894 .09881205 .017071828  572.8024
      3370.8     5.15  .4988165  .8937984   .17688218 .08568723  .02414392    401.24
      3029.2 6.555873 .48292145  .8723438   .17732877 .09648985  .02833307  356.6576
      2648.3     5.15   .490579   .935937   .05225832 .10380267 .019527236    443.77
      2271.8 6.555873  .4952193   .920211   .05429925 .10253874 .020441806  455.1494
        3709     5.15   .494675  .8887257  .033305317 .10209328 .021300036    480.36
      3143.2 6.555873 .49004975  .8656716   .03441835 .09701493 .014570007  478.1447
        2546     5.15  .4824647  .9045299   .10398532 .09498295  .02191914    401.71
      2552.9 6.506917  .4890951  .8858469   .10915167 .10974478 .023201857   395.109
      4204.7     5.15  .4819563  .6728395    .0974912 .11111111 .023979107    646.26
      3540.6 6.506917  .4833555  .6591212   .10429614 .09165557  .01886374  698.5109
      2448.3     6.75 .49125475  .9589354   .04263539 .08973384 .015209125    397.36
      2509.9  6.73119 .49473685  .9496241   .04312173 .09022556 .016541352  359.6161
      3431.5     6.15  .4863709  .6440406    .5782282 .09656155  .01656868    743.44
      2753.5 6.506917 .48468685  .5963524    .5987284 .09532003 .013764624  714.1454
      2399.2      7.5  .4830308  .8601421    .8121732    .08603 .017205998    634.02
        2153 7.179936  .4827533  .8454699    .8362756  .1157443 .018089836 555.47577
      3063.5     6.95  .4905717  .8195587   .17633878 .09167503 .017552657    569.05
      2530.5 6.691512  .4846955  .8024322   .17161636 .09862929 .013913223 523.90015
      3044.8     6.15  .4989318  .8951253   .06466421  .1044863  .01650806    555.16
      2568.3 6.555873  .4936613  .8647115   .06637217  .0885525 .016840113  522.5347
      3113.9     5.15  .4844398  .6033887   .06163253 .10753804 .029391425    411.41
        2811 6.506917  .4826176  .6005453   .06252761  .1002045  .02249489  441.0164
      3829.5      6.5  .4896552  .8489655   .08437404 .08413793  .01448276    448.71
      3314.4 6.555873  .4854188  .8284164   .08579967 .09104782 .016276704  452.0659
      2906.2     6.15  .4973147  .9065521  .006396612 .10418905  .02792696    538.15
      2583.7 6.986778  .4989858  .9087221    .0067745 .09432048 .015212982   599.566
      3142.4     5.15 .50141484  .9043577  .023000574 .11375212 .019241653    470.03
      2754.9 6.555873  .4953425  .8915069  .023755545 .09917808  .01589041  454.4803
      3785.7     6.15  .5088757  .8086785   .02309139 .09585799  .02524655    803.01
      2809.4  7.53476  .4985097  .7406855  .024448635  .0976155 .017883755  749.9324
      2005.9     5.15  .4950344  .9564553   .14621368  .0909091 .012223071    443.37
        2324 6.506817  .4919293  .9508071   .14532009  .0914681 .010760953  438.7749
      2214.4     7.15  .4887991  .7556582   1.1775552 .09076212 .015935335    747.34
      2047.3 6.506817  .4806981  .7587841   1.1764673 .10228848  .01641239  693.7614
      3815.8     5.15    .48842  .8353062  .016018381 .09418425   .0257334    686.63
      3600.7 6.849782  .4860226  .8401177   .01680982 .08680726  .01961746  686.1838
      1987.9     7.15  .4832983  .7306197    .4040198  .1007353 .021638656    860.82
        1922 6.506817  .4844631  .7131999    .4104069 .10133912 .017837754  888.4813
      4082.2     6.15  .4903401  .7320077   .18205225 .08812564  .02011072    484.75
      3369.5 6.506917    .48101  .7099422    .1955041 .09416097  .01946344  507.5754
      2000.3     5.15  .4959481  .8816856  .008941926 .11183144  .02106969    396.39
      2010.1 6.555873 .50222224  .8518519  .009782496 .10518519 .017777778  511.8193
      3468.1     6.85  .4867038   .853874    .2770144   .094708 .018199487    535.91
      3117.4 6.962789  .4834806  .8372791   .27703887 .10220848 .018109541  527.7432
      3558.3     5.15  .4856816  .7402635   .05090756 .10051546  .02176403    465.86
        3401 6.506917  .4948235  .7093177    .0549166  .0945049  .01884789  455.1611
        3543      7.8  .4982503   .879677   .03870275 .08506057 .019919246    625.78
      3224.2 8.037078 .49325725  .8812241   .04017169 .09854772 .009595436   658.392
      2363.5     6.25  .4893479  .8698258   .27591094  .0980154   .0163629    577.73
      2166.3 6.506817  .4905631  .8512111   .28420278 .10616546 .019109784  585.3802
      2606.8      7.4 .48671725  .8842505   1.0195297 .10056926 .020872865     640.5
      2572.3 6.641441  .4836223  .8757225   1.0040529 .09922928  .01734104 581.10815
      4294.8     5.15  .4756271  .6833885   .14058222 .08424041 .015144344    415.89
      3822.2 6.506917  .4815698  .6966609    .1534229 .09648743 .018430183  383.7376
      1736.8     5.15  .4987013  .9246753  .010156837  .1025974 .023376623    426.48
      2060.1 6.555873  .4987685  .8583744  .010710847 .10591133 .022167487  446.7398
      4098.6     5.15  .4782095  .7996622   .14356771 .08868244  .01891892    466.97
      3371.4 6.506917   .484772  .7898059    .1536805 .08332019 .017831782  462.4129
      4122.3     5.15  .4919952  .8303064   .08894785 .10109313  .02556378    505.54
      3361.8 6.506917  .4939434  .8042748   .09796667 .09432635 .021530166  500.9339
      3518.7     5.15  .4958613  .9306267   .03087516 .10721324  .02167915    508.52
      2991.8 6.621456  .4989339  .9168444  .034246236  .1098081 .022743426  490.7915
      2366.5     7.53  .4935484  .9564516   .06726949  .1032258 .016129032    506.89
      2398.7 7.592782  .4902597  .9448052   .06683549 .08441558  .01461039  533.7206
      2486.5     5.15  .4885911  .7336164   .19088334 .08622977 .017113293    573.65
      2162.1 6.506917  .4855818   .719659    .2019747 .09829488  .01429288 529.16943
        4047     7.93  .4924027  .8361824    .0950711 .09338398  .02073441    577.08
      3658.6  8.25627  .4974329  .8095937   .10257988  .0966701  .02097697  534.1369
      2517.6     5.85  .4944873  .9525909   .07546318 .07938258 .017640574    397.01
      2364.9 6.506917   .489863  .9446575    .0759208 .07726027  .01863014  448.9952
      2843.9      6.5 .49342585  .8993791   .10111193  .1018992  .01990504    610.82
      2453.8 6.555873  .4975378  .8809356    .1049895  .1044671  .01582835   623.025
      2879.1     5.15  .5096899  .9554263  .005314485 .09302326 .017441861    835.89
      2293.8 6.621456  .5079929  .9271758  .005798556 .09946714 .014209592  873.9591
      end
      3.
      Code:
      xtreg pcr realmw2 propmales propwhites popdensity propyouth propnodiploma realjust2, fe
      
      Fixed-effects (within) regression               Number of obs      =       102
      Group variable: stateid                         Number of groups   =        51
      
      R-sq:  within  = 0.5275                         Obs per group: min =         2
             between = 0.1683                                        avg =       2.0
             overall = 0.1412                                        max =         2
      
                                                      F(7,44)            =      7.02
      corr(u_i, Xb)  = -0.9880                        Prob > F           =    0.0000
      
      -------------------------------------------------------------------------------
                pcr |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      --------------+----------------------------------------------------------------
            realmw2 |  -117.0064    65.8877    -1.78   0.083    -249.7943    15.78158
          propmales |  -2155.626   9584.563    -0.22   0.823    -21472.04    17160.79
         propwhites |   7316.423   2715.016     2.69   0.010     1844.667    12788.18
         popdensity |  -2631.606   1508.292    -1.74   0.088    -5671.369    408.1571
          propyouth |   -6785.68   5550.815    -1.22   0.228    -17972.61    4401.253
      propnodiploma |    26012.7   12634.82     2.06   0.045     548.9044     51476.5
          realjust2 |   1.573439   1.022336     1.54   0.131    -.4869431    3.633821
              _cons |  -811.6483   4962.123    -0.16   0.871    -10812.15    9188.853
      --------------+----------------------------------------------------------------
            sigma_u |  4163.1048
            sigma_e |  246.08662
                rho |  .99651802   (fraction of variance due to u_i)
      -------------------------------------------------------------------------------
      F test that all u_i=0:     F(50, 44) =     9.47              Prob > F = 0.0000

      Comment


      • #4
        The dataex example data set is incomplete because it does not contain the variables stateid and year that are needed for replication of your results.

        Yet, from your output it is already clear what is happening. You only have data for the two years 2007 and 2012. The data is xtset with a delta of 1 unit. With the D. operator, Stata thus tries to create differences between consecutive years, that is from 2011 to 2012. The following should work:
        Code:
        . xtset stateid year, delta(5)
        . xtreg pcr realmw2 propmales propwhites popdensity propyouth propnodiploma realjust2, fe
        . reg D.(pcr realmw propmales propwhites popdensity propyouth propnodiploma realjust)
        With T=2, the results from the fixed-effects and the first-difference estimation should be identical.
        https://www.kripfganz.de/stata/

        Comment

        Working...
        X