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]
Re: st: Plot coefficients and confidence intervals for rolling regressions
From
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: Plot coefficients and confidence intervals for rolling regressions
Date
Sat, 1 Oct 2011 12:58:18 +0100
I don't think there's a canned way of doing this so it would have to
be done as you did it.
A detail is that 1.96 doesn't quite square with a window of 10.
Nick
On 30 Sep 2011, at 22:52, Richard Herron <[email protected]>
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/