I have a panel dataset with countries and years. I am trying to do some overlapping regressions for every country in windows of 5 years. I want these 5 years to be overlapping so for example for United States, I want the first regression to be for 1980-1984, the second 1981-1985, third 1982-1986 and goes on like this. I have used loop within a loop to do this. As you can see from the do file below
i stands for countries and j stands for years
local i=1
while `i'<131 {
local j=1980
while `j'< 2006 {
reg y x1 x2 x3 if cc==`i' & (year==`j'|year ==`j'+1|year ==`j'+2|year==`j'+3|year ==`j'+4)
local j= `j'+1
}
local i= `i'+1
}
However I have missing data for some countries and years, so when the loop starts if it does not find any data for the first country and/or first group of years the do file stops.
I have tried to use capture command, but still was unable to make the loop work.
Could someone help me out here, how should I do these regressions.
I'd really appreciate any help .
Indrit Hoxha
Univesity of Houston