Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: multiple rolling regressions


From   "Austin Nichols" <[email protected]>
To   [email protected]
Subject   Re: st: multiple rolling regressions
Date   Thu, 8 May 2008 13:33:19 -0400

clear
input firm year y x
1 1980 20 23
1 1981 22 34
1 1982 20 19
1 1984 22 34
1 1985 20 19
1 1986 28 34
1 1987 30 19
2 1980 15 23
2 1981 55 34
2 1982 29 19
2 1983 15 23
2 1984 55 34
2 1985 29 19
2 1986 28 34
2 1987 30 19
end
fillin firm year
tsset firm year
sort firm year
g double d=.
qui forv i=3/`=_N-2' {
 loc f=`i'-2
 loc l=`i'+2
 if firm[`f']==firm[`i'] & firm[`l']==firm[`i'] {
 reg y year in `f'/`l' if firm==firm[`i']
 predict double ye if e(sample), resid
 reg x year in `f'/`l' if firm==firm[`i']
 predict double xe if e(sample), resid
 reg ye xe
 replace d=_b[xe] in `l'
 drop ye xe
 }
 }
li, noo sepby(firm)


On Thu, May 8, 2008 at 1:21 PM, Erasmo Giambona <[email protected]> wrote:
> Hi Austin,
>
> Thanks very much. Your code really gets me very very close to what I
> want to achieve.
>
> Here are some additional clarifications that you required. Yes, I am
> only interested in saving the estimated coefs d of reg ye xe. If there
> are missing data in the 5 year window, I would still like to get the
> estimates with whatever data is available. If there are gaps, for
> instance for a company I have data for the window 1980-1984 and
> 1990-1994, then I would like to get estimates for the first window and
> independently for the second window.
>
> I noticed that you code calculates d based on observations from -2 to +2.
> For instance, d=.15129763 for 1982 is based on data from 1980-1984.
> What I would really like to achieve is for instance that d for 1984 is
> based on the data from 1980-1984.
>
> Hope you can provide some additional hints on how I could obtain what I need.
> Thanks very much,
> Erasmo
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index