I am trying to run rolling prais regressions with a panel data set,
rolling command seems not to be working well for this purpose (I
already posted with that question and so far no solution was
found).
I wrote a small loop to do the same, the problem is that I have an
unbalanced panel dataset and as soon as missing observation is
encountered, the loop brakes (I tried 'tsfill, full' and replacing
all missing with 99999999, but then prais regression doesn't like
that either and the loop breaks again).
Is there a way to write the loop to skip those missing observations,
put a missing value into the "anwswer" and continue on?
Here is the main code:
forvalues y=1973/1996 {
gen resid`y'=.
gen pred`y'=.
forvalues i=1/3824 {
prais r exp if (year>=`y'-14 & year<=`y') & s==`i'
predict r if e(sample), resid
predict p if e(sample)
replace resid`y'=r if (year>=`y'-4 & year<=`y') & s==`i'
replace pred`y'=p if (year>=`y'-4 & year<=`y') & s==`i'
drop r p
}
}
Olga Gorbachev Melloni
Economics Ph.D. Student
Columbia University
www.columbia.edu/~ocg2001
*
* 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/