Announcement

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

  • Rolling window estimation panel data

    Dear All,

    I have the following data (those are just a sample of my dataset, actually):

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(id year lnint lndep lnlab lncap lnequity lnloans lnta)
     1 2005         . -3.5450916  -5.384714  -5.944329  1.255616  -3.1717405  8.429235
     1 2006  9.836766  -2.942683  -5.380128  -5.542646  1.378766   -3.909952   8.37586
     1 2007 10.290488   -2.76569  -5.731722  -5.671097 1.2383742   -5.070323  8.504311
     1 2008  10.45436 -2.8110676  -5.810579  -5.692796  .6729445  -3.5462155  8.583168
     1 2009  9.063528 -2.8913634 -4.7505684  -4.913087 1.8099267   -3.635427  7.746301
     2 2012         .  -3.433987 -3.1401834 -3.5322256 3.9174085   -1.478102  7.444249
     2 2013  7.231605 -3.6971784 -3.1393394  -3.616967  3.846951  -1.5349776  7.508787
     3 2005         .  -3.652647 -4.5738516  -4.023805  1.510722  -.03410915  8.668196
     3 2006 10.767858  -3.412363 -4.6960588 -4.1619763  1.510722   -.0570557  8.915566
     3 2007 11.033508  -3.001456  -4.854148 -4.2663617  1.528228  -.06665684  9.102644
     3 2008 11.224381 -3.3871984  -5.503325  -5.449979 2.1234584  -.12589249  9.793784
     3 2009 11.778563  -3.194117  -5.197103  -4.929899 2.1198635   -.1536192  9.906632
     3 2010  11.80485  -3.451947  -5.230482  -4.631745 2.1529243  -.14516848  9.940012
     3 2011 11.841537  -3.421317  -5.269543 -4.6745133 2.0869136  -.17007537  9.942371
     3 2012  11.81761  -3.331901  -5.186319  -4.780854  1.894617   -.2100239  9.886799
     3 2013 11.785814  -3.360389  -5.090207  -5.020613 2.1016922  -.22107954  9.799737
     3 2014 11.725443  -3.329965   -5.02324  -6.113041 2.2170272    -.247767  9.750628
     4 2012         .  -3.763136  -5.173321   -5.79236  1.912501  -.11023907  8.431417
     4 2013  9.366841 -4.1785207  -4.947873   -5.64102 2.0906289  -.12306535  8.413609
     5 2005         .  -3.913287  -5.654703  -5.442142   .751416   -3.661077  9.292289
     5 2006 10.551073 -3.5629494  -5.836577  -5.627485  .6830968   -3.277009  9.597777
     5 2007  11.19384  -3.512593   -6.19798  -5.919777  .5007753   -2.509101 10.168272
     5 2008 11.972282  -2.937308  -6.099257  -5.811574 .53062826   -2.526024 10.142307
     5 2009  11.35302  -2.887062  -5.288267  -5.087596 1.7191888   -2.206527  9.277251
     5 2010 10.782118 -3.8829076   -5.23403  -5.215338  1.757858  -1.8844573  9.204322
     5 2011  9.774672 -4.1868367  -5.534035  -5.455563 1.5644406   -2.168852  9.425855
     5 2012  9.860596  -3.931265  -5.780675  -5.617045 1.5769148   -2.020509  9.587337
     5 2013 10.148788  -3.935172   -5.55197  -4.504277 1.8293763    -1.89333  9.402117
     5 2014 10.075677 -4.6758857  -5.866054  -5.667603 1.7544037  -3.7159944  9.579625
     5 2015 10.102294  -5.129348  -5.776425  -5.776425  1.693779   -3.544181  9.746716
     6 2005         .  -3.525915  -4.468251   -3.67794 1.4655675   -1.736006  8.360071
     6 2006  9.396995  -3.456478 -4.3112617 -3.7177446  1.541159   -1.981464  8.371705
     6 2007  9.475355 -3.7411144 -4.5610094  -3.790901 1.5303947  -1.8731618  8.473032
     6 2008  9.637098  -3.654276 -4.5321107 -3.8389635 1.6014057  -2.3124132    8.3163
     6 2009  8.748976   -4.85852 -4.3769608 -3.7272985  1.667707   -2.553785  8.227108
     6 2010  8.281567  -5.602119    -4.0976 -3.6635616 1.8961195    -2.46241  7.926241
     6 2011  8.817624  -5.174736 -4.3233967  -3.971176  1.474763  -2.2807343  8.130059
     6 2012  9.028998  -6.053853  -4.509638  -3.972495 1.5851452  -1.9847984    8.3163
     6 2013  8.212058  -7.044905  -4.498359 -4.1526136  1.583094   -1.691054  8.327001
     6 2014  8.274561  -6.729525 -4.4265914 -3.9803045  1.667707  -1.4745065  8.297792
     7 2004         .          . -2.6741486 -2.6741486  3.672242           .  4.060443
     7 2005 4.1018167          .  -2.415914 -2.2335923  4.198855           . 4.0253515
     7 2006 4.6145263          . -2.2900064 -2.2900064 4.1538706           . 4.3694477
     7 2007  3.682861          .  -2.545531 -2.2270775 3.9130225           .  4.624973
     7 2008  3.008155          .  -1.704748 -1.5505974 4.0303392  -1.5505974  4.189655
     7 2009 2.3035846 -4.0073333 -2.0177972 -2.0177972  3.962716   -1.346629  5.153292
     7 2010         .          . -2.0253744  -1.878771  3.930648  -1.7917595  4.969813
     8 2003         .  -5.267858  -3.170449 -2.6239054 3.0435696           .  5.568345
     8 2004  7.414133  -5.036952 -2.9400434    -2.7169  3.267666           .   5.42495
     8 2005  7.484543  -5.068904  -2.932219  -2.858111  3.343215           .  5.497168
     9 2013         .  -4.351872  -5.040017  -5.050721  2.741485 -.017694352 12.147442
     9 2014 13.336335  -4.532281  -5.148026  -5.112075 2.7226105  -.01915705  12.23977
    10 2008         .  -2.467017  -6.378426  -6.378426  3.010128  -.07032777  7.071573
    10 2009  8.588211    -2.6112  -6.244167  -5.838702  3.135494  -.12057817  6.937314
    10 2010  8.213951  -2.804482  -6.049734  -5.644269  3.239071   -.1918003  6.742881
    10 2011  8.000349  -2.666624  -4.980176  -4.980176 3.5490425  -.16596127   6.36647
    11 2003         .  -3.864232  -5.067855  -5.250177 1.0647107  -3.1707354  6.859615
    11 2004  7.063596  -3.158933  -4.189655 -4.3719764  1.927164  -1.7473078  5.981414
    12 1999         .  -3.465736 -3.9186676 -4.3241324  4.323868  -1.8817856   5.01728
    12 2000  6.769872  -3.555348  -4.356709  -4.356709 4.3046055   -5.049856  5.049856
    12 2001  7.041044 -3.0910425 -4.2696977  -4.962845  4.357862   -4.962845  4.962845
    12 2002  4.695742          . -4.0253515 -4.7184987  4.399007  -4.7184987 4.7184987
    13 2011         .  -6.464346 -1.9692392  -1.668598 4.1394773  -1.5470804 12.026563
    13 2012 12.330278  -5.756114 -3.1639054 -2.2005951 3.9094195  -1.7207496 12.407293
    13 2013 12.034214 -4.5251446  -2.953835  -2.387065 4.0210567   -1.783521 12.524992
    13 2014   9.99297   -3.17009  -2.955658   -2.30237 4.1003265   -1.497763 12.603156
    14 1998         . -4.4426513  -4.016383 -2.9177706   2.22029  -1.5314764 4.7095304
    14 1999  6.548276          . -4.2243977  -2.838103 2.7363136  -1.4728624   5.32301
    14 2000  7.132705  -5.087596  -3.705409  -2.361674  2.667228  -1.2630618  5.497168
    14 2001  7.128159  -5.153292  -3.563478  -2.108191  2.689207  -1.1026691  5.509388
    14 2002  6.805988  -5.099866 -3.7256935  -2.150157  2.944439   -.6891392  5.517453
    15 2009         .  -5.617901  -2.541714 -2.9962614 1.5390154   -8.844197 12.140035
    15 2010 11.086693   -6.21006  -2.316232  -2.942934 1.7681496   -10.06311  11.85487
    15 2011 11.242453   -5.81533  -2.220285 -2.8556316    1.7492   -8.835716 11.780155
    15 2012 10.470854  -6.257257  -2.423266  -2.777811  1.735189  -1.1082493 11.703133
    15 2013 10.260577  -5.955041 -2.3597496  -2.729535  2.107786  -1.4253113  11.59527
    15 2014 10.043815  -6.130628 -2.3613153  -2.689455 2.2565413  -1.7590805 11.577936
    16 1996         .          .          .  -2.564949  4.425924           .  2.564949
    16 1997  4.137404          .          . -2.6390574  4.403666           . 2.6390574
    16 1998  3.657389          .          .   -2.70805  4.415945           .   2.70805
    16 1999 3.4108176          .          . -2.6390574 4.4475803           . 2.6390574
    16 2000 2.2905126          .          .   -2.70805 4.4418273           .   2.70805
    16 2001         .          .          .   -2.70805  4.103139           .   2.70805
    16 2002  2.329227          .          .  -2.772589 4.0903363           .  2.772589
    16 2003         .          .  -2.833213  -2.833213 4.0785537           .  2.833213
    16 2004         .          .  -2.890372  -2.890372 4.0590625           .  2.890372
    16 2005  2.985682          .  -2.944439  -2.944439  4.048126           .  2.944439
    16 2006  3.376905          .  -2.995732  -2.995732 4.0418224           .  2.995732
    16 2007 3.8910036          .  -3.135494  -3.135494  3.999851           .  3.135494
    17 2001         . -3.6357484  -4.295924 -4.3298254  2.607124   -.9228975  7.697121
    17 2002  9.381776  -3.699617  -4.258113  -4.258113 2.5832424   -.9133819  7.784473
    18 2004         . -2.1231165  -3.690349 -3.3455086  3.194173           .  6.523562
    18 2005  4.481306   -2.75457  -4.122284  -3.429137  2.841998           .  7.118016
    18 2006  5.621777 -1.9694406  -4.087176 -3.3763294  2.839663           .  7.419381
    18 2007  6.242496 -1.4816045 -4.1854033 -2.8824906   2.98366           .  7.404279
    18 2008  5.811021 -2.9177706  -3.877591 -2.0667832  2.861629           .  7.135687
    18 2009  4.959061   -2.75457  -4.057565  -2.490687  3.185112           .  7.235619
    18 2010  5.550048 -2.5839975 -4.0572453 -2.6526015  3.224858           .  7.353082
    18 2011  6.138893  -2.852631  -4.100097  -2.743073 3.3054204           .  7.358194
    18 2012  6.855409 -3.5115454 -4.2444053 -3.8485096  3.186766   -3.907933  7.799753
    18 2013  6.811949  -3.564827  -4.601743 -4.0496745  2.903617  -4.0496745  8.239329
    18 2014  6.485169 -2.0301704 -4.6736073 -4.1753607  2.528126  -4.3401155  8.544808
    18 2015  5.127173 -2.1768157 -4.7187867 -4.1545734  2.348514  -4.6264133 8.8459215
    19 2005         .  -3.659892 -4.2282925 -4.5384474 2.5120354   -.2331546  6.936343
    19 2006  8.612758  -3.446808 -4.3870144  -4.610158  2.435366  -.27069068  7.095064
    19 2007  8.907484  -2.956747  -4.513055   -4.91852  2.412336  -.21531604  7.221105
    19 2008  9.114793 -2.6993165 -4.5525603 -4.6860914  2.373975  -.19345044  7.325149
    19 2009   8.87387  -3.178054 -4.5873656  -4.781522 2.3075726   -.2382268  7.420579
    19 2010  8.748533 -3.4859626 -4.5826974   -4.90812 2.2407095     -.28844  7.473069
    19 2011  8.767827  -3.314186 -4.5591264  -4.884549 2.1294215   -.2320546  7.449498
    19 2012  8.818311  -3.517074  -4.564348  -4.889771 2.1882958  -.29077324   7.45472
    19 2013  8.749935  -3.756538 -4.6671014  -5.072566  1.993339  -.49871475  7.557473
    19 2014  8.612445 -3.8983586 -4.6826453   -5.08811 1.9444805    -.605108  7.573017
    20 2005  8.656983 -2.0037298   -6.16804  -4.781746 1.4906543  -.04062559  7.554335
    20 2006  9.258633 -1.5206816  -6.320408  -4.934114 1.4327008  -.02625013  7.929846
    20 2007  9.891869   -1.94591  -6.343221  -5.164566 1.7281095 -.032394204  8.422663
    20 2008 10.748727  -2.586268  -6.618842  -6.048297 1.0986123  -.11662847  9.183791
    20 2009 10.888193  -3.093425   -6.91702   -5.89845  .9745597  -.18958816  9.481969
    20 2010 10.895258   -3.14621  -6.904519  -5.805907  .9707789  -.14401548  9.469469
    21 2007         .  -3.005161 -4.6244826 -4.7580137 2.2772672  -.36568335  8.313362
    21 2008 10.085193   -2.71294  -4.609628  -5.058578 2.1016922   -.4567472  8.459776
    21 2009  9.653011  -3.451347 -4.5560675  -4.993281 2.1701958   -.4414438  8.427268
    21 2012  9.296322  -5.202174  -5.944111  -6.300786 1.9558605   -.4075643 8.2466955
    21 2013  9.236258 -4.1425467 -4.5839953  -5.186171  1.943049   -.4920344  8.321665
    21 2014 9.1775675  -4.371915  -4.491628  -5.040194 1.9257075    -.497718   8.29829
    21 2015  8.943213 -4.6608334  -4.373748  -4.928059  1.853168   -.4858431  8.223895
    22 2005         .  -3.871201  -3.650658 -4.3438053 2.2502387   -.7328875 4.3438053
    22 2006  5.800546  -3.850148  -4.356709  -4.356709 2.2470725   -.6678293  4.356709
    22 2007  5.888518 -3.8066626 -4.3694477 -4.3694477  2.298577   -.6558757 4.3694477
    22 2008  6.178773  -3.713572 -3.7256935 -4.4188404 2.3311725   -.6576405 4.4188404
    22 2009   5.99844 -3.8066626  -3.749504 -4.4426513  2.339881   -.6359887 4.4426513
    22 2010  5.772935 -3.8286414  -3.701302  -4.394449 2.3145137   -.5877866  4.394449
    22 2011  5.942484   -3.78419  -3.650658 -4.3438053 2.2925348   -.4317824 4.3438053
    22 2012  5.966762  -3.970292  -3.701302  -4.394449  2.396986   -.3690975  4.394449
    22 2013  5.962293  -4.204693 -3.7256935 -4.4188404 2.3702438   -.3757893 4.4188404
    22 2014  5.964145 -4.0775375   -3.78419  -4.477337  2.270062   -.4342856  4.477337
    23 2005         .  -3.735115  -5.750984  -5.057837  1.449269  -.05725191  7.137279
    23 2006  8.772294  -3.465736  -5.703115  -5.009968 1.2919837  -.07118721  7.312553
    23 2008         .  -2.891553  -5.892197  -6.403022  1.088562  -.04402518  7.501635
    23 2009  8.945062  -3.589958  -5.814727  -6.037871 1.1631508 -.029672153  7.424165
    23 2010  8.742545  -3.803695  -5.678123  -6.594413  1.211941  -.04547828   7.28756
    23 2011  8.584475 -3.5653815  -5.566817  -6.483107  1.329724  -.06148507  7.176255
    23 2012  8.423902  -3.787027  -5.445875    -5.9567 1.4374627  -.06967106  7.055313
    24 2005         .  -3.529031  -4.398146  -4.754821 1.8000582 -.035047386  6.700731
    24 2006  8.433072  -3.555348   -4.36136 -4.2743487  1.667707  -.03062664  6.759255
    24 2007  10.61696  -2.993062     -5.358  -4.867377  1.398717  -.05254189  8.759198
    24 2008 10.697454  -2.716817  -5.199334          . 1.3962446  -.04271962  8.695842
    24 2009 10.001897  -3.506489  -5.155601          . 1.6351057 -.022748124  8.556798
    24 2010  9.805542 -4.0194435  -5.080541          .  1.543298 -.028373165  8.664061
    24 2011  9.964502  -3.785091  -5.134116          . 1.6311995  -.07387489  8.689465
    24 2012  9.741357  -3.890419  -5.178219          . 1.6311995  -.05564506  8.579416
    24 2013    9.5749  -4.150401  -5.115996  -8.517193 1.6034198  -.05699374  8.517193
    25 2005         . -3.8527496  -5.327472  -5.509793 1.7029282  -.09814704  7.812378
    25 2006  9.471843  -3.587029  -5.363302  -5.363302 1.2178757  -.04904122  8.002359
    25 2007  9.855424  -3.230625  -5.446737  -5.264416  1.141033  -.05462611  8.154788
    26 2005         .  -3.006056  -4.832479 -4.5022373   1.60543    -.331221  7.967973
    26 2006 9.5268135 -2.6844404   -4.99132  -4.543295 1.6428727   -.2532159  8.126814
    26 2007  9.899924  -2.397206  -4.978801  -4.618798 1.5062972  -.25377542  8.379998
    26 2008  10.10425 -2.4577205  -4.973168  -4.880795 1.4678744   -.2299202  8.407155
    26 2009   9.81773  -2.900009  -4.869117  -4.840129 1.4951488   -.2719196  8.395477
    26 2010  9.857513  -3.199291  -4.572475  -4.539685 1.9473377  -.26011094   8.66682
    26 2011  9.946911 -3.1951094 -4.5342665 -4.5171723 1.9329696   -.2197715  8.594709
    26 2012  9.935578  -3.262893 -4.5970674  -4.708293 1.8718022   -.3356237  8.640119
    26 2013  9.798433    -3.3732  -4.539107  -4.803258  1.930071   -.3047414  8.564459
    26 2014  9.704051 -3.6004126  -4.641302  -4.850394 1.4793292   -.4039195  8.611594
    27 1988         . -2.7751894   -3.87582 -3.9329784 1.3083328   -.9490806  6.766191
    27 1989   9.38299 -2.7996805  -4.006542  -4.050994  1.713798   -.9808292  7.142036
    27 1990  9.471232  -2.643073  -3.779972  -3.779972 1.7850705   -.7266698  7.075809
    27 1991  9.534749  -2.672804  -3.745321  -3.745321 1.8515995   -.6780183  7.179308
    27 1992  9.777981  -2.562728 -3.8086214 -3.8086214 1.7387103   -.8366998  7.334982
    27 1993  9.933344  -2.455863 -3.8013854  -3.750092 1.6956155   -.7990957  7.438972
    27 1994  9.736729  -2.816853  -3.674238  -3.721866 2.0541236   -.8034362  7.435438
    27 1995 10.107428 -2.6911244  -3.876904  -3.980088  1.729884   -.8811714  7.808729
    27 1996 10.364308  -2.667781 -3.8740904 -3.9918735 1.6752257   -.9699252  8.150757
    27 1997 10.249393  -2.928305  -3.996854  -4.094835 1.5260563  -1.1206565 8.3143425
    27 1998 10.068673  -2.763676 -3.8990824  -3.728737 1.7387103   -.9404589  8.147577
    27 1999  9.886471  -3.791927 -4.0484514  -3.770072 1.7263316   -.6609274  8.442901
    27 2000 10.175846  -3.184788  -3.953468  -3.745171  1.752672  -1.1947913  8.507345
    27 2001 10.019074   -3.22142 -4.2784204  -3.707376 1.5195132   -1.329756 8.7443285
    28 1993         .  -2.571167  -3.741065 -3.6720724 2.2955606   -1.107123  6.380123
    28 1994   8.54107  -2.795473   -3.55915  -3.702251  2.415914   -.4560596    6.2672
    28 1995  8.838015  -2.597385  -3.791737   -3.86073 2.2115657  -1.0275164  6.499787
    28 1996  9.005561  -2.502381 -3.8286414 -4.0362806 2.1162555    -.973609   6.60123
    28 1997  8.727519  -3.013751   -3.87769 -4.0853295 2.0756845   -.8913773  6.650279
    29 2008         .          .  -2.890372  -2.890372  3.683364   -.4924765  2.890372
    29 2009 4.4958014          .  -3.637586  -3.637586  3.388787   -.5930638  3.637586
    29 2010  5.084381 -3.5263605 -3.9512436 -3.9512436 3.0051875  -.36772475 3.9512436
    29 2011  5.441205 -3.8286414  -4.158883  -4.158883  2.754934   -.3302417  4.158883
    29 2012  5.835892  -3.496508  -4.454347  -4.454347  2.749832   -.3112126  4.454347
    29 2013  6.193405 -3.6720724  -4.919981  -4.226834 2.2955606   -.5761755  4.919981
    29 2014   6.42959 -3.6699514 -4.5485997 -4.1431346  2.248129    -.667036  5.241747
    30 2005         .  -3.486355   -4.26268  -3.974998 2.2823825   -.3178671  5.361292
    30 2006  7.030822  -3.323236 -4.0690265 -4.7621737  2.296567   -.2848371  5.455321
    30 2007  7.270737  -3.036554 -4.1934357 -4.4811177  2.296567  -.27146214   5.57973
    30 2008   7.46577   -2.74084  -4.046554          . 2.3075726  -.23545684  5.655992
    30 2009  7.216239  -3.075775  -4.130355 -4.6411805 2.2554934  -.24673146  5.739793
    30 2010  7.139811  -3.310543 -4.1526136 -4.6634393 2.1667652  -.19370686  5.762052
    30 2011  7.271877 -3.6480575  -4.162003 -4.3851466  1.822935   -.2262637  5.771441
    30 2012  7.230273 -3.2708356 -4.1206617 -4.3438053  .8329091  -.35482135    5.7301
    31 2007         .  -3.152736   -4.52396 -4.7471037 2.7625384   -.4163704  6.133398
    31 2008  7.952977 -2.8247745 -4.4228487  -4.828314  2.709383   -.3974969  6.214608
    31 2009  7.649793  -3.488903  -4.518159  -4.923624 2.6789646   -.3964153  6.309918
    31 2010  7.478757 -3.6888795 -4.5626106  -4.968076 2.5997224   -.3933647   6.35437
    31 2011  7.654661  -3.953645 -4.6459923  -5.051457  2.444085   -.4664898  6.437752
    31 2012  7.887535  -3.886705  -4.829646  -4.829646  2.409644   -.6604003  6.621406
    31 2013  8.254008  -3.874485  -4.703204  -5.059879 2.1114247   -.6583999  7.005789
    31 2014  8.200859 -4.0543394  -4.786658  -5.009801 2.0967903   -.7902939  7.089243
    32 1993         .  -2.929287  -4.276666  -4.564348  1.508512   -1.152101  5.662961
    32 1996         .   -3.42589  -3.925268 -4.3307333  2.503074  -1.0726368   5.02388
    32 1997  7.020155 -3.2027464 -3.6699514 -3.6699514  2.524127    -.866591  5.056246
    32 1998   6.85294  -3.680511  -3.657131  -3.657131 2.6181254   -.7529657  5.043425
    32 1999  6.698884  -3.745575 -3.7316995 -3.7316995  2.621039   -.7112746  5.117994
    33 2005         .  -3.745477 -4.1460247  -4.202858 2.0464017  -.20599943 9.3445215
    33 2006   10.8698  -3.570812  -4.157587  -4.471517 1.9865035  -.17892267  9.420277
    33 2007 11.176022 -3.1512556 -4.1765614  -4.609222   1.94591  -.15811493  9.499571
    34 1993         .  -2.638469 -4.0009375  -4.250398 2.4680996  -.55033153  8.344743
    34 1994    10.742  -2.809493  -3.991599 -4.2172713 2.3194423   -.5833562 8.5867195
    34 1995 10.929094  -2.782264 -4.0473485 -4.2704916 2.2082744  -.57736003 8.7478285
    34 1996 11.264855 -2.6630955  -3.863716 -4.1821694 2.0781908   -.6069311    9.0342
    34 1997 11.129635  -2.858389  -3.927282 -4.4345303 1.9558605  -.58780783  9.153029
    34 1998 10.983998 -3.1090915  -3.982451 -4.3661757 2.1234584   -.5076558  9.186458
    34 1999 10.724107  -3.625149 -4.0072384   -4.18956  1.918392  -.50146216  9.264734
    34 2000 10.857387 -3.2526076  -4.019676  -4.225216 1.9878744   -.4084627  9.229162
    34 2001 10.936323  -3.240719 -4.1462317   -4.32168  2.070653   -.4096572  9.305286
    34 2002 10.881625  -3.277374  -4.119863 -4.3403363 2.0464017   -.3591603  9.350971
    35 1987         .  -3.014495  -3.853895 -4.5470424  2.320425  -1.0001333  7.380256
    35 1988  9.548982 -3.0245974  -3.865397 -4.4043937 2.2905126   -.8978357  7.448916
    35 1989  9.705086 -2.8990355  -3.819359  -4.330185  2.222459   -.7964984  7.508239
    35 1990  9.805491 -2.7997696 -3.7682064   -4.27131 2.2544446   -.7006944  7.529407
    35 1991   9.82747  -2.778431  -3.627536 -4.1383615  2.340844   -.6459025  7.539559
    35 1992  9.973666 -2.6719716 -3.6160045 -4.1205606 2.3184583   -.6146277  7.586296
    35 1993  9.943103 -2.6760626  -3.567225  -4.078051 2.3561258  -.56605333  7.574558
    35 1994  9.819783  -2.884862 -3.5754054  -4.181541 2.3608541   -.5474699  7.582738
    35 1995  9.973357  -2.847663  -3.608018 -4.1368623  2.399712   -.5177875  7.633369
    35 1996  9.999545 -2.7744434  -3.552534 -4.0524898 2.3570733   -.5800198  7.663408
    36 2005         .  -4.342413  -4.171872  -4.537332  2.796061   -.5445427  8.063693
    36 2006  9.636607 -4.1726274  -4.135759  -4.487157   2.83615   -.4533821  8.124743
    36 2007   9.88096  -3.837975 -4.2052455 -4.4565597  2.829087   -.4068473  8.194229
    36 2008 10.026784  -3.637199 -4.1291804  -4.905019  2.802754   -.3168901  8.272315
    36 2009  9.720295  -4.286486  -4.198514  -5.009444  2.823163  -.29445907  8.341649
    36 2010  9.677963 -4.6933846  -4.243494  -4.985431  2.841998    -.266635  8.386629
    36 2011  9.804049  -4.487231  -4.232293  -4.989979  2.851862  -.21562873  8.391176
    36 2012  9.786824 -4.1610117  -4.277327  -5.019265  2.841415  -.23539054  8.420462
    36 2013  9.781035   -4.03356   -4.35307  -5.151577   2.77944   -.3179446  8.447414
    36 2014  9.812491  -4.138162 -4.3313804  -5.041057   2.77944   -.3644966  8.442254
    37 1988         .  -2.552046 -4.2812853 -4.2812853  1.893112    -.679417  5.379897
    37 1989  7.670671  -2.633548 -4.1972017 -4.4848843  1.879465   -.8128117  5.583496
    37 1990   7.85475  -2.550421  -4.347047  -4.634729 2.0476928   -.7916989  5.733341
    37 1991  8.077817 -2.4402745 -4.1053944 -4.5108595  2.008214   -.6660453  5.897154
    37 1992   8.33547  -2.432987 -4.3351097 -4.5174313 1.8000582   -.5739096  6.126869
    37 1993  8.391372  -2.507635  -4.117875 -4.2720256 2.3427668    -.330444  6.063785
    37 1994  8.345589  -2.715713  -4.163337  -4.317488 2.1961129    -.316234  6.109248
    37 1995  8.487658   -2.76587   -4.26469 -4.4188404  1.740466   -.3787176    6.2106
    37 1996  8.602035  -2.626372  -4.208417  -4.496099 1.6956155  -.48876595  6.287858
    37 1997  8.432156  -2.661757 -4.1858597 -4.4735417 1.7369512   -.4304905  6.265301
    37 1998  8.163417 -2.8716795  -4.304065 -4.4582157  1.678964   -.4006505  6.249975
    37 1999  7.839415  -3.314186 -4.3250785 -4.6615505  2.368373   -.3683551  6.270988
    37 2000  7.947891  -3.426515   -4.49024  -5.049856 1.8870696  -.50125617  6.436151
    37 2001  8.034139  -3.115223 -4.1839566 -4.4716387 2.2278614   -.2819841  6.263398
    38 2005         .  -3.678324 -4.4063497 -4.6839814 1.1085626   -3.123734  7.902857
    38 2006  8.876158  -3.655323 -4.4090877  -4.814553  1.166271   -2.756165  7.992607
    38 2007  9.976254  -3.381464 -4.6754217  -5.080887  1.211941   -2.525599  8.258941
    38 2008 10.027878 -2.7979586 -4.4046264   -4.82448 1.6409365  -2.3578558  7.959975
    38 2009  9.863009  -3.888792 -4.0398564 -4.4918413 1.9344158  -1.7790407  7.824046
    38 2010  9.390782  -4.064184  -4.164448 -4.5348215 1.8656293  -2.0556788  7.902118
    38 2011  8.666963  -3.570237 -4.6731405  -4.816241   1.60543    -2.51751  8.074338
    38 2012  8.337999  -4.288265  -4.717711  -4.911867 1.5581446    -2.78875  8.244071
    38 2013 8.3649435  -4.073764  -4.671216 -4.7426753 1.7900914  -2.2363937  8.038512
    38 2014  8.250725  -4.392764  -4.868358  -4.981687  1.697449  -2.4353716 8.2005625
    38 2015  8.408895  -4.572835  -4.921602  -4.959342  1.704748   -1.957857  8.217439
    39 2005         .          . -2.2437446 -2.8033605 3.0530574           .  4.189655
    39 2006  5.436339          .  -2.628801  -2.965273  2.775709           .  4.574711
    39 2007  5.732661          .   -1.99243 -2.8033605  3.188004           .  4.189655
    39 2008  5.249127          . -2.9177706  -3.610918 2.0386195           .  5.220356
    39 2009  5.249337          . -3.1696856  -4.085976  1.993339    -5.47227   5.47227
    39 2010  4.795377          . -2.7135904  -3.589059 2.2955606           .  5.198497
    39 2011  5.072671          . -2.4054425  -3.280911 2.5718486           .  4.890349
    39 2012 4.0986686          .   -2.70805  -3.719651  2.408745           .  5.105946
    39 2013  5.191122          .  -3.155064  -4.166665 2.0412202   -4.454347  5.552959
    39 2014  4.791234          .  -3.004031 -4.1026435  2.252344   -4.795791  5.488938
    40 2005         .  -3.388619 -4.1108737 -4.3621883  2.390596    -.470368  6.308098
    40 2006  7.764984  -3.303217 -4.1554046  -3.713572 1.9837563   -.5148989  6.352629
    40 2007  7.979284 -2.9813435  -4.158883  -4.276666 2.0307763   -.5242252  6.356108
    40 2008  8.143474 -2.8576794  -4.348125   -4.75359 1.8325815   -.4294575   6.54535
    40 2009  7.856014 -3.5101876  -4.479859  -4.885324  1.796747   -.3671652  6.677083
    40 2010  7.897445 -4.0036902  -4.738146  -5.143611 1.5789787   -.3547313   6.93537
    40 2011  8.301938  -3.888413   -4.83556  -5.154014  1.211941   -.4707259  7.233455
    40 2012  8.723165  -3.913272  -5.174093  -5.626078 1.3376292   -.7585438  7.571989
    40 2013  8.706962 -4.0357146  -5.294979    -5.4773 1.2919837   -.9808292  7.779885
    40 2014  8.632395  -4.020379  -5.284472  -5.689937  1.449269   -.9309734  7.769379
    end
    Panel is unbalanced. I would like to run the following model:

    Code:
    xtreg lnint lndep lnlab lncap lnequity lnloans lnta i.year, fe r
    I am particularly interested in saving the estimated parameters in a new
    dta file. In addition, I would like to adopt a rolling window, such that I estimate the model for each a 5-years period, s
    pecifying that the window should advance by 1 year each time the estimation is done.

    I tried the following:

    Code:
    xtset id year
    rolling _b, window(5) saving (betas, replace) stepsize (1) start (1987) end (2014): xtreg lnint lndep lnlab lncap lnequity lnloans lnta i.year, fe r


    Stata saves the _b coefficients but it makes a rolling window over each id. So it seems that the estimation is carried out for each id over a period of 5 year with 1 year rolling window, i.e. the estimation is carried out over 5 observations only (is that possible?). Instead, I would like to save the _b, which are estimated for a 5-year panel data. In other words, I would need the _b for the panel 1987-1991, 1988-1992, 1989-1993 and so on.

    I tried rangerun using the following code:

    Code:
    program mypanel
    xtset id year
    xtreg lnint lndep lnlab lncap lnequity lnloans lnta, fe r
    end
    
    cd "mydir"
    
    use mydata.dta, clear
    rangerun mypanel, interval (year -3 0) use (lnint lndep lnlab lncap lnequity lnloans lnta)
    But nothing happens and on top I do not know how to save the _b coefficients from each estimation. Any hint? Thanks in advace.

    Dario


  • #2
    I'm not really good with rangestat or rolling. You can always program this using a loop over time and saving the output.

    Comment


    • #3
      I agree with Phil that you might as well loop over each year but here's how to do the same with rangerun (from SSC). You only want to run the program once per year so it will be more efficient to pick a representative observation and define a valid upper interval bound only for those observations. Your program must also handle cases where there is not enough observations by prefixing the command with capture. I also added the verbose option to show the output of each program run. Finally, I added code to spot check results for 2014.

      Code:
      * choose 1 observation per year to calculate the regression
      bysort year (id): gen pick = _n == 1
      gen high = cond(pick, year, -99)
      
      program drop _all
      program mypanel
          xtset id year
          gen year1 = r(tmin)
          cap noi xtreg lnint lndep lnlab lncap lnequity lnloans lnta, fe r
          if _rc exit
          gen obs = e(N)
          foreach v in lndep lnlab lncap lnequity lnloans lnta _cons {
              gen b_`v' = _b[`v']
          }
      end
      
      rangerun mypanel, interval (year -4 high) verbose
      
      * spot check results for 2014
      list year1 year obs b_* if pick & year == 2014
      xtset id year
      xtreg lnint lndep lnlab lncap lnequity lnloans lnta if inrange(year, 2014-4, 2014), fe r
      If you run the code with the data example from #1 you get the following spot check results:
      Code:
      . list year1 year obs b_* if pick & year == 2014
      
           +---------------------------------------------------------------------------------------------------+
           | year1   year   obs     b_lndep    b_lnlab    b_lncap   b_lneq~y   b_lnloans     b_lnta    b__cons |
           |---------------------------------------------------------------------------------------------------|
      270. |  2010   2014    82   -.3048032   .2232576   .1167689   -.244353   -.0882232   .5213642   5.398532 |
           +---------------------------------------------------------------------------------------------------+
      
      . xtset id year
             panel variable:  id (unbalanced)
              time variable:  year, 1987 to 2015, but with gaps
                      delta:  1 unit
      
      . xtreg lnint lndep lnlab lncap lnequity lnloans lnta if inrange(year, 2014-4, 2014), fe r
      
      Fixed-effects (within) regression               Number of obs     =         82
      Group variable: id                              Number of groups  =         23
      
      R-sq:                                           Obs per group:
           within  = 0.2944                                         min =          1
           between = 0.5381                                         avg =        3.6
           overall = 0.5411                                         max =          5
      
                                                      F(6,22)           =      24.75
      corr(u_i, Xb)  = -0.0863                        Prob > F          =     0.0000
      
                                          (Std. Err. adjusted for 23 clusters in id)
      ------------------------------------------------------------------------------
                   |               Robust
             lnint |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
             lndep |  -.3048032   .2992704    -1.02   0.320    -.9254519    .3158456
             lnlab |   .2232576   .2746309     0.81   0.425    -.3462919    .7928072
             lncap |   .1167689   .0990557     1.18   0.251    -.0886602    .3221979
          lnequity |   -.244353   .2224701    -1.10   0.284    -.7057277    .2170217
           lnloans |  -.0882232   .0160562    -5.49   0.000    -.1215217   -.0549247
              lnta |   .5213642   .3120662     1.67   0.109    -.1258214     1.16855
             _cons |   5.398532   2.905404     1.86   0.077    -.6269075    11.42397
      -------------+----------------------------------------------------------------
           sigma_u |   1.264474
           sigma_e |  .34269379
               rho |  .93157563   (fraction of variance due to u_i)
      ------------------------------------------------------------------------------
      
      .

      Comment


      • #4
        Phil Bromiley and Robert Picard Thank you very much both for your suggestions

        Comment

        Working...
        X