Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: rollreg question


From   Cameron Hooper <[email protected]>
To   [email protected]
Subject   st: rollreg question
Date   Thu, 03 Mar 2005 13:14:11 -0500

Hello

My question relates to the 'rollreg' routine available via ssc install.

I have panel data on which I wish to perform rolling regressions. However, for consistency with prior research I want to use standard OLS regressions as produced by "regress" rather than ivreg (or ivreg2). Here is an example of problem.


. use http://www-personal.umich.edu/~chooper/stata/rrtest1, clear
. list

+----------------------------+
| id y x1 x2 year |
|----------------------------|
1. | 1 12 80 100 1980 |
2. | 1 23 90 93 1981 |
3. | 1 45 100 62 1982 |
4. | 1 13 56 120 1983 |
5. | 1 22 65 90 1984 |
|----------------------------|
6. | 1 21 72 80 1985 |
7. | 1 56 120 12 1986 |
8. | 1 43 90 45 1987 |
9. | 1 29 67 67 1988 |
10. | 1 14 42 55 1989 |
|----------------------------|
11. | 2 34 76 87 1985 |
12. | 2 56 123 34 1986 |
13. | 2 32 56 56 1987 |
14. | 2 67 90 98 1988 |
15. | 2 83 54 54 1989 |
|----------------------------|
16. | 2 45 67 76 1990 |
17. | 2 12 43 23 1991 |
18. | 2 45 56 56 1992 |
19. | 2 23 43 67 1993 |
20. | 2 56 56 120 1994 |
+----------------------------+

// First I run a "standard" OLS. I will want to obtain the same results
// when I run rollreg.

. regress y x1 x2 if id == 1 & year < 1985

Source | SS df MS Number of obs = 5
-------------+------------------------------ F( 2, 2) = 5.88
Model | 603.433889 2 301.716944 Prob > F = 0.1453
Residual | 102.566111 2 51.2830556 R-squared = 0.8547
-------------+------------------------------ Adj R-squared = 0.7094
Total | 706 4 176.5 Root MSE = 7.1612

------------------------------------------------------------------------------
y | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
x1 | -.0532435 .3456986 -0.15 0.892 -1.540665 1.434178
x2 | -.6242087 .2963772 -2.11 0.170 -1.899417 .6509993 _cons | 85.21505 52.12469 1.63 0.244 -139.0594 309.4895
------------------------------------------------------------------------------

// Now I try to reproduce this using rollreg

. rollreg y x1 x2 if id == 1, move(5) stub(rr)
time variable not set, use -tsset varname ...-
r(111);

// It seems I must set the time variable.

. tsset id year
panel variable: id, 1 to 2
time variable: year, 1980 to 1994

. rollreg y x1 x2 if id == 1, move(5) stub(rr)
. list id year rr_cons if id == 1 & year == 1985

+----------------------+
| id year rr_cons |
|----------------------|
6. | 1 1985 29.03253 |
+----------------------+

// The constant is 29.03253 which differs from that for the ordinary OLS
// where _cons = 85.21505. What happens if I remove the if clause?

. drop rr*
. rollreg y x1 x2, move(5) stub(rr)
. list id year rr_cons if id == 1 & year == 1985

+----------------------+
| id year rr_cons |
|----------------------|
6. | 1 1985 29.03253 |
+----------------------+

// Same problem.

I am not very familiar with the use of regression in a time series context. I am happy to accept that the results reported by rollreg are "superior" because they take the temporal nature of the data into account. However, is there a way I can force rollreg to generate the same results as those generated by a simple "regress" command?

Thanks for any help you can offer.

Cameron
*
* 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