Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: Plot coefficients and confidence intervals for rolling regressions
From
Richard Herron <[email protected]>
To
[email protected]
Subject
st: Plot coefficients and confidence intervals for rolling regressions
Date
Fri, 30 Sep 2011 17:52:13 -0400
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/