[R-sig-finance] tips and tricks for rolling regressions?
Achim Zeileis
Achim.Zeileis at wu-wien.ac.at
Wed Aug 25 14:45:03 CEST 2004
On Wed, 25 Aug 2004 13:34:46 +0100 Patrick Burns wrote:
>
> Using something like "apply" rather than a for loop is unlikely
> to be significantly more efficient (it might even be less) and it
> is going to be much less clear what the code is doing.
>
> If a loop is not sufficiently fast for you, there are techniques of
> updating the matrix decomposition with each new observation.
> I don't know of any such code for R, but I wouldn't be surprised
> if there is an implementation or two floating around.
For recursive (rather than rolling) regression, there is an
implementation of the recursive updating technique of Brown, Durbin,
Evans (1975, JRSS B) in recresid() in package strucchange. However, I
only return the recursive residuals, not the recursive estimates.
In efp() (with type set to "RE" or "ME") I do recursive and rolling
regresseion (recursive/moving estimates) but also only in a simple for()
loop. But I just call lm.fit() instead of lm() which saves a lot of
computation time when done repeatedly.
best,
Z
> Patrick Burns
>
> Burns Statistics
> patrick at burns-stat.com
> +44 (0)20 8525 0696
> http://www.burns-stat.com
> (home of S Poetry and "A Guide for the Unwilling S User")
>
> Taher Khan wrote:
>
> >Greetings!
> >
> >I want to find out if there is a clever way to do a one-step-ahead
> >moving window rolling regression using a vectorized operation like
> >with apply, rather than a for loop.
> >
> >Does anyone have a code snippet they would like to share for how they
> >do rolling regressions?!?!
> >
> >Thanks in advance!
> >
> >_______________________________________________
> >R-sig-finance at stat.math.ethz.ch mailing list
> >https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> >
> >
> >
>
> _______________________________________________
> R-sig-finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>
More information about the R-sig-finance
mailing list