# Re: st: multiple rolling regressions

 From "Erasmo Giambona" To statalist Subject Re: st: multiple rolling regressions Date Thu, 8 May 2008 11:50:08 +0200

```Dear Statalisters,

Few days ago I posted an email on rolling regressions. I have not
received any reactions yet. I hope this is because my question was not
clear enough. So I am giving it another try. I truly hope to receive
some help.

Here is my problem:

I have a panel dataset that looks as follows:

firm year y x
1 1980 20 23
1 1981 22 34
1 1982 20 19
1 198320 23
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
.............
etc.

Assume also that "trend" is a trend variables ranging from 1 to 5.

I need to implement a two-step procedure. In the first step, I run for
each "firm" a regression of y on the trend variable and an intercept
and a regression of x on the trend variable and an intercept, using in
both cases 5 years of data: 1) y = intercept +b*trend + errory;
2) x = intercept + c*trend + errorx. After the first step, I output
the errors from regression 1) and regression 2). Now I regress the
errors
from 1) on the errors from 2) (again for each firm): 3) errory =
d*errorx+error. I repeat the two steps for each year in the sample.

I hope you have some suggestions on how I could handle this issue.

Best regards,
Erasmo

On Mon, May 5, 2008 at 5:16 PM, Erasmo Giambona <e.giambona@gmail.com> wrote:
> Dear Statalisters,
>
> I have a panel dataset that looks as follows:
>
> firm year y x
> 1 1980 20 23
> 1 1981 22 34
> 1 1982 20 19
> 1 198320 23
> 1 1984 22 34
> 1 1985 20 19
> ...........
> 2 1980 15 23
> 2 1981 55 34
> 2 1982 29 19
> 2 1983 15 23
> 2 1984 55 34
> 2 198529 19
> .............
> etc.
>
> I need to run the following 3 5-year window rolling regressions: 1) y
> = intercept +b*trend + erroy;
> 2) x = intercept + c*trend + errorx; 3) errory = d*errorx+error.
>
> I can easily run the first two regressions using "rolling" or
> "rollreg", except that I don't know how to set the trend variable
> to range from 1 to 5 for each regression. I have no idea however on
> how to save the residuals after each run of 1) and 2) to run
> regression 3).
>
> I would truly appreciate any suggestions on how I could resolve this issue.
>
> Best regards,
> 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/
>
*
*   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/
```