Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Nick Cox <njcoxstata@gmail.com> |
To | "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |
Subject | Re: st: Plot coefficients and confidence intervals for rolling regressions |
Date | Sat, 1 Oct 2011 12:58:18 +0100 |
A detail is that 1.96 doesn't quite square with a window of 10. NickOn 30 Sep 2011, at 22:52, Richard Herron <richard.c.herron@gmail.com> wrote:
I found that I can plot fitted values with confidence intervals from -regress- with -lfitci-. Is there a similar functionality that I can combine with -rolling- regressions (i.e., -rolling: regress-) to do similar plots of regression coefficients and confidence intervals? * ----- begin code ----- * plot of fitted values and confidence intervals sysuse auto, clear twoway lfitci mpg weight * but can I plot confidence intervals from -rolling: regress- ? My manual solution seems hackish. clear set obs 200 generate t = _n generate y = 1 replace y = 0.5*y[_n - 1] + rnormal() if t > 1 tsset t rolling _b _se, window(10) recursive clear keep(t): regress y l.y * generate plot "manually" tsset date generate lower = _stat_1 - 1.96*_stat_3 generate upper = _stat_1 + 1.96*_stat_3 tsline _stat_1 lower upper * ----- end code ----- Is there a more Stata way to do this? Thanks!
* * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/