Dear Stata users,
I have an unbalanced panel dataset with 4329 observations and about 400 variables. Time periods range from 2003 to 2010 with gaps.
I would to run a time-series regression to estimate beta coefficients and store them in a variable for each mfiid and its time period, taking into account the panel structure (gaps). _roe is the dependent, _sp500 the independent variable. The dependent variable varies by mfiid each year and the independent variable is the same for each mfiid each year.
Sorted by year and mfiid:
Sorted by year the data looks as follows:
Help is highly appreciated. Thanks a lot in advance!
Kind regards,
Rafael
I have an unbalanced panel dataset with 4329 observations and about 400 variables. Time periods range from 2003 to 2010 with gaps.
I would to run a time-series regression to estimate beta coefficients and store them in a variable for each mfiid and its time period, taking into account the panel structure (gaps). _roe is the dependent, _sp500 the independent variable. The dependent variable varies by mfiid each year and the independent variable is the same for each mfiid each year.
Sorted by year and mfiid:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long mfiid int year float(_roe _sp500) 100000 2007 .2913083 -.010829791 100000 2008 .17713334 -.4216229 100000 2009 .14123334 .201956 100001 2004 .04955833 .0472585 100001 2005 -.008699998 -.01277183 100001 2006 .02328333 .08855005 100001 2007 .21060835 -.010829791 100001 2009 .015933335 .201956 100001 2010 .017058332 .09580792 100004 2008 .20683333 -.4216229 100008 2006 -.4828166 .08855005 100008 2007 -.4197917 -.010829791 100008 2008 -2.9300666 -.4216229 100008 2009 9.721633 .201956 100012 2005 .3659 -.01277183 100012 2006 -.4431167 .08855005 100012 2007 1.6969082 -.010829791 100012 2008 1.2119334 -.4216229 100012 2009 .9820334 .201956 100012 2010 .16185834 .09580792 100013 2009 -.10906667 .201956 100013 2010 -.13484167 .09580792 100016 2005 -.0101 -.01277183 100016 2006 .0035833344 .08855005 100016 2007 .016408335 -.010829791 100016 2008 .05173333 -.4216229 100016 2009 .07153333 .201956 100016 2010 .08925833 .09580792 100017 2003 .17895 .2237602 100017 2004 .16935833 .0472585 100017 2006 .09988333 .08855005 100020 2007 .003608331 -.010829791 100020 2008 .010133334 -.4216229 100020 2009 .09823333 .201956 100020 2010 .016058333 .09580792 100021 2005 -.0768 -.01277183 100021 2006 -.05961667 .08855005 100021 2007 -.017191667 -.010829791 100021 2008 -.04696666 -.4216229 100021 2009 -.023466665 .201956 100021 2010 -.014741667 .09580792 100024 2006 .9799833 .08855005 100024 2009 .51533335 .201956 100024 2010 .014058333 .09580792 100026 2004 17.870058 .0472585 100026 2005 -5.09 -.01277183 100026 2006 9.523084 .08855005 100026 2007 -2.4865916 -.010829791 100026 2008 .54033333 -.4216229 100026 2009 1.4377333 .201956 100026 2010 .4943583 .09580792 100027 2003 1.0200499 .2237602 100027 2004 .8740584 .0472585 100027 2005 .7555 -.01277183 100027 2006 .16448334 .08855005 100029 2006 -.16821668 .08855005 100029 2007 .27910832 -.010829791 100029 2008 .07793334 -.4216229 100029 2009 .005633332 .201956 100030 2005 -.0131 -.01277183 100030 2006 .024183333 .08855005 100030 2007 .02750833 -.010829791 100030 2008 .05113334 -.4216229 100031 2005 -.02 -.01277183 100031 2006 -.03771666 .08855005 100031 2007 -.033691667 -.010829791 100031 2009 .14953333 .201956 100031 2010 .19615833 .09580792 100032 2004 .06425834 .0472585 100032 2005 -.0216 -.01277183 100032 2008 .17953333 -.4216229 100032 2010 .17735833 .09580792 100033 2005 .9403999 -.01277183 100033 2006 .7986833 .08855005 100033 2007 .07110833 -.010829791 100033 2008 .05233334 -.4216229 100033 2009 .03813333 .201956 100033 2010 .23085834 .09580792 100036 2003 1.58285 .2237602 100036 2004 16.50846 .0472585 100036 2005 .0053 -.01277183 100036 2006 .6539834 .08855005 100036 2007 .11130834 -.010829791 end
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long mfiid int year float(_roe _sp500) 100324 2003 .13935 .2237602 100118 2003 -.05345 .2237602 100296 2003 .18615 .2237602 100092 2003 -.05935 .2237602 100720 2003 .14455 .2237602 100104 2003 -.02805 .2237602 101107 2003 .015449997 .2237602 100648 2003 .08945 .2237602 100302 2003 .16415 .2237602 100467 2003 .40555 .2237602 100303 2003 .14535 .2237602 100281 2003 .23025 .2237602 100523 2003 .08065 .2237602 100326 2003 .10955 .2237602 100673 2003 .71915 .2237602 100211 2003 -.066250004 .2237602 100096 2003 -.11025 .2237602 100492 2003 -.22445 .2237602 100312 2003 .06345 .2237602 100431 2003 .02765 .2237602 100565 2003 .55315 .2237602 100477 2003 .08275 .2237602 100713 2003 -.04965 .2237602 100547 2003 -.036650002 .2237602 100684 2003 .07855 .2237602 100556 2003 .05095 .2237602 100404 2003 .07495 .2237602 100280 2003 .25795 .2237602 100080 2003 .19575 .2237602 100288 2003 .04715 .2237602 100309 2003 .01885 .2237602 100253 2003 -2.49875 .2237602 100127 2003 -.46735 .2237602 100749 2003 -.012650002 .2237602 100357 2003 .09915 .2237602 100617 2003 -.18485 .2237602 100027 2003 1.0200499 .2237602 100255 2003 .011749998 .2237602 100346 2003 .22665 .2237602 100233 2003 .007949997 .2237602 100348 2003 .08205 .2237602 100350 2003 .05175 .2237602 100813 2003 .14445 .2237602 100741 2003 .14795 .2237602 100155 2003 -.02585 .2237602 100243 2003 .09685 .2237602 100173 2003 -.05955 .2237602 100733 2003 -.011250002 .2237602 100664 2003 .31375 .2237602 100705 2003 .16505 .2237602 100678 2003 -.02375 .2237602 100590 2003 -.22435 .2237602 100378 2003 -.01945 .2237602 100188 2003 -.0014500022 .2237602 100700 2003 .36955 .2237602 100420 2003 .05695 .2237602 100500 2003 .04465 .2237602 100402 2003 .23905 .2237602 100298 2003 .19165 .2237602 100716 2003 .19895 .2237602 100542 2003 .26064998 .2237602 100339 2003 .39035 .2237602 100641 2003 -.02645 .2237602 100168 2003 -.072850004 .2237602 100158 2003 -.27875 .2237602 100097 2003 .39195 .2237602 100611 2003 -.28904998 .2237602 100512 2003 .46595 .2237602 100299 2003 .50835 .2237602 100225 2003 .50175 .2237602 100036 2003 1.58285 .2237602 100386 2003 .15465 .2237602 100329 2003 .01035 .2237602 100017 2003 .17895 .2237602 100576 2003 -.29035002 .2237602 100442 2003 .12485 .2237602 100831 2003 .06045 .2237602 100089 2003 -.37675 .2237602 100601 2003 .27354997 .2237602 100769 2003 -.16215 .2237602 100747 2003 .11985 .2237602 100515 2003 .08925 .2237602 100222 2003 -.06445 .2237602 100765 2003 -.02665 .2237602 100681 2003 -.03485 .2237602 100217 2003 .005849998 .2237602 100098 2003 -.08055 .2237602 100540 2003 .018349998 .2237602 100464 2003 .01055 .2237602 100660 2003 -.005450003 .2237602 100574 2003 -.02425 .2237602 100236 2003 .17965 .2237602 100205 2003 -.018150002 .2237602 100369 2003 -.02675 .2237602 100714 2003 .33685 .2237602 100497 2003 -.05555 .2237602 100376 2003 .11915 .2237602 100325 2003 .00925 .2237602 100666 2003 .009949997 .2237602 100242 2003 .11325 .2237602 end
Help is highly appreciated. Thanks a lot in advance!
Kind regards,
Rafael
Comment