[R] Again question about filter()

Gabor Grothendieck ggrothendieck at gmail.com
Sun Aug 10 20:23:47 CEST 2008


The first three values are:

> filter <- c(0.1, 0.5, 1, 0.5)
> init <- 1:4
> filter %*% init + 1
     [,1]
[1,]  7.1
> filter %*% c(7.1, init[1:3]) + 2
     [,1]
[1,] 6.71
> filter %*% c(6.71, 7.1, init[1:2]) + 3
      [,1]
[1,] 9.221


On Sun, Aug 10, 2008 at 12:47 PM, Sergey Goriatchev <sergeyg at gmail.com> wrote:
> Hello,
>
> I thought I understood filter() with the help from Prof. Grothendieck,
> but I guess I did not.
> For example, how does this work:
>
>  filter(1:10, c(0.1, 0.5, 1, 0.5), "recursive", init=c(1,2,3,4))
> Time Series:
> Start = 1
> End = 10
> Frequency = 1
>  [1]   7.10000   6.71000   9.22100  15.87710  21.45821  28.66037
> 41.08274  55.83522  74.51437 100.78197
>
> If I understand it correctly, the time series, together with initial
> values, looks like
> 1,2,3,4,1,2,3,4,5,6,7,8,9,10
>
> The first value is calculated as 1*0.1+2*0.5+3*1+4*0.5+1=7.1,
> where the first four arguments are initial values times coefficients,
> and the last argument is the first value
> of the timeseries, that is 1.
> But how are the consecutive values calculated?
> Totally at a loss. Please, help.
>
> /Sergey
>
> --
> I'm not young enough to know everything. /Oscar Wilde
> Experience is one thing you can't get for nothing. /Oscar Wilde
> When you are finished changing, you're finished. /Benjamin Franklin
> Tell me and I forget, teach me and I remember, involve me and I learn.
> /Benjamin Franklin
> Luck is where preparation meets opportunity. /George Patten
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list