Hello everyone,
I'm currently trying to perform a rolling regression in order to estimate coefficients which I want to use to predict company earnings. One way is to use -rollreg- (user written command).
My problem is, that -rollreg- does not accept any gaps in the data. As far as I understand, my data does not have any gaps - at leat when it comes to the panel variable "id" and time variable "Year".
But since changes in the panel are counted as gaps, -rollreg- does not work. Is there a way to work around this?
The expample contains a small portion of my data - the real set has many more variables and observations.
Earnings_w is my dependent variable
L1.DD L1.NegE L1.Earnings_w L1.Dividends_w L1.Accruals_w L1.TotalAssets_w are my independent variables.
thank you!
I'm currently trying to perform a rolling regression in order to estimate coefficients which I want to use to predict company earnings. One way is to use -rollreg- (user written command).
My problem is, that -rollreg- does not accept any gaps in the data. As far as I understand, my data does not have any gaps - at leat when it comes to the panel variable "id" and time variable "Year".
But since changes in the panel are counted as gaps, -rollreg- does not work. Is there a way to work around this?
The expample contains a small portion of my data - the real set has many more variables and observations.
Earnings_w is my dependent variable
L1.DD L1.NegE L1.Earnings_w L1.Dividends_w L1.Accruals_w L1.TotalAssets_w are my independent variables.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int Year float(FFF DD NegE id Earnings_w Dividends_w Accruals_w TotalAssets_w) 2000 . 1 0 1 145000 44140.06 31000 1573000 2001 . 1 0 1 123000 45293.79 -57000 1707000 2002 . 1 0 1 125000 47430.6 -128000 1609000 2003 . 1 0 1 154000 54828.8 -97000 1689000 2004 . 1 0 1 171000 56614.95 -57000 1711000 2005 . 1 0 1 179000 77348.5 -21000 2111000 2006 . 1 0 1 259524 83804 -49206 2251528 2007 1 1 0 1 223976 84408 88431 2363250 2008 1 1 1 1 -23818 35366 -41511 1946498 2009 1 1 0 1 64524 35366 -67391 1661938 2010 1 1 0 1 115907 44207.5 256813 1777113 2011 1 1 0 1 55807 43832.5 -27904 1822692 2012 1 1 0 1 78252 43478.75 -42612 1740368 2013 1 1 0 1 80453 43482.5 -84965 1531712 2014 1 1 0 1 94668 46961.1 -20448 1823535 2015 1 1 0 1 141439 52179 -48960 1921206 2003 . 0 0 2 26184 . -51569 3219480 2004 . 0 0 2 33670 . -70428 3561096 2005 . 0 0 2 49938 . -217817 5040470 2006 . 0 0 2 191351 . -255000 5482955 2007 . 1 0 2 170229 62700 -323760 7647286 2008 . 1 0 2 157020 62700 -532865 9626986 2009 . 1 0 2 161457 57000 -953640 9479606 2010 . 1 0 2 174857 62700 -515560 10167808 2011 . 1 0 2 194995 63135 -306151 10212330 2012 . 1 0 2 60631 20617.6 -208170 9940072 2013 . 1 0 2 113558 46170 -577162 10343502 2014 . 1 0 2 127969 51300 -686644 9997414 2015 . 1 0 2 156286 66690 -1096362 10436940 2008 . 0 0 3 33274 . -38700 1101928 2009 . 0 0 3 31192 . -88094 816687 2010 . 0 0 3 47181 . -28232 808211 2011 . 1 0 3 86020 52896 -18486 850104 2012 0 1 0 3 71312 21158.4 -46111 854304 2013 0 1 0 3 56028 21158.4 -66206 906199 2014 0 1 0 3 59212 42316.8 -35939 1052512 2015 0 1 0 3 42697 42316.8 -67181 1075303 2002 . 0 0 4 9180 . -31458 130478 2003 . 0 0 4 6449 . -31378 272825 2004 . 0 0 4 25049 . -48174 799876 2005 . 0 0 4 33405 . 52249 972413 2006 . 1 0 4 77186 19800 -61921 1512604 2007 . 0 0 4 40376 0 52668 2845265 2008 . 0 1 4 -33881 . -133559 2697420 2009 . 0 0 4 54193 0 111919 2550053 2010 . 0 1 4 -270478 0 -436766 900347 2012 . 0 0 4 303551 0 . 55518 2006 . 0 0 5 7449 . -6872 97212 2007 . 1 0 5 8426 4870 4695 132432 2008 . 1 0 5 11031 5357 1241 135013 2009 . 0 0 5 4597 0 -9990 138868 2010 . 0 1 5 -17257 0 -24016 154887 2011 . 0 1 5 -12377 0 -23183 142687 2012 . 0 1 5 -2491 0 -2698 130689 2013 . 0 1 5 -28297 0 4052 131698 2014 . 0 1 5 -27024 0 -19530 95071 2015 . 0 1 5 -13397 0 -5026 88274 2010 . 0 0 6 27868 . -24196 253603 2011 . 0 0 6 28144 . 13993 283872 2012 . 0 0 6 10630 . -3847 330385 2013 . 0 0 6 21145 . 1729 429410 2014 . 0 0 6 28894 0 -786 547185 2015 . 0 1 6 -9594 0 -6672 718245 2010 . 0 0 7 6617 0 -3534 48338 2011 . 0 0 7 5273 0 -4109 55964 2012 . 1 0 7 5124 2496.55 4482 55453 2013 . 1 0 7 3647 2496.55 -4175 52639 2014 . 1 0 7 3484 2496.55 23 52003 2015 . 1 0 7 4156 3108.6 71 52970 2000 . 1 0 8 73100 43890 -27832 718445 2001 . 1 0 8 66267 39900 -32026 733097 2002 . 1 0 8 70291 42000 -50634 762538 2003 . 1 0 8 70842 42000 -79527 823709 2004 . 1 0 8 71688 42000 -122665 942954 2005 . 1 0 8 74304 42000 -83712 1181687 2006 . 1 0 8 76785 46200 -64777 1479892 2007 . 1 0 8 87678 52500 -76735 1559660 2008 . 1 0 8 91149 54600 -57247 1735284 2009 . 1 0 8 73361 44100 -82113 1860932 2010 . 1 0 8 75718 42000 -94025 1998496 2011 . 1 0 8 31602 21000 -147311 2150158 2012 . 1 0 8 71890 22008 -107781 2061803 2013 . 1 0 8 73291 27300 -131063 1953937 2014 . 1 0 8 82482 34608 -138109 1892223 2015 . 1 0 8 100434 42000 -127979 1909656 2004 . 0 1 9 -8631 0 -7035 18773 2005 . 0 1 9 -28612 0 -4565 75004 2006 . 0 1 9 -57292 0 -9533 107981 2007 . 0 1 9 -24070 0 -3228 143510 2008 . 0 1 9 -61600 0 -20294 111697 2004 . 0 1 10 -4082 . -8714 137814 2005 . 0 0 10 2902 0 -7916 136419 2006 . 0 0 10 3298 0 8069 160097 2007 . 0 0 10 2309 0 17860 224168 2008 . 0 1 10 -27558 0 -29127 229999 2009 . 0 1 10 -36698 0 -31435 127016 2000 . 1 0 11 22544 12025.374 -18069 857314 2001 . 1 0 11 37574 12014.04 -48432 845426 2002 . 1 0 11 44325 19845.834 -16742 855988 2003 . 1 0 11 65382 19845.834 -26614 897086 end
Comment