[R] Rolling window linear regression

Achim Zeileis Achim.Zeileis at uibk.ac.at
Thu Aug 19 09:12:13 CEST 2010


The function rollapply() in package "zoo" can be used to run rolling 
regressions. See the examples in the manual page for a worked example.

On Thu, 19 Aug 2010, siddharth.garg85 at gmail.com wrote:

> Thanks, I will try it.
>
> Regards
> Sid
> Sent on my BlackBerry? from Vodafone
>
> -----Original Message-----
> From: Dennis Murphy <djmuser at gmail.com>
> Date: Wed, 18 Aug 2010 08:46:49
> To: <siddharth.garg85 at gmail.com>
> Subject: Re: [R] Rolling window linear regression
>
> This is called kernel-based regression; the most popular version is loess.
> Try
>
> library(sos)
> findFn('loess')
>
> to see some of the various implementations available, including graphics
> functions. The basic function is loess(); the window width is related to the
> span = parameter of that function.
>
> HTH,
> Dennis
>
> On Wed, Aug 18, 2010 at 2:08 AM, <siddharth.garg85 at gmail.com> wrote:
>
>> Hi
>>
>> Does there exists an efficient way of performing linear regression on
>> rolling windows in R.
>>
>> The exact problem is:
>>
>> We have a dataset of length l. The window size is w.
>>
>> Now, I perform linear regression on window i to (i+w) . Using this model
>> can I perform linear regression over window (i+1) to (i+w+1).
>>
>> Thanks
>> Sid
>> Sent on my BlackBerry? from Vodafone
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
> 	[[alternative HTML version deleted]]



More information about the R-help mailing list