Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[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 <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

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 <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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index