Re: [R] aplpy recursive function on a list

2012-01-26 Thread Brian Diggs
On 1/25/2012 10:09 AM, patzoul wrote: I have 2 series of data a,b and I would like to calculate a new series which is z[t] = z[t-1]*a[t] + b[t] , z[1] = b[1]. How can I do that without using a loop? A combination of Reduce and Map will work. Map to stitch together the a and b vectors, Reduce

Re: [R] aplpy recursive function on a list

2012-01-26 Thread Berend Hasselman
On 26-01-2012, at 17:58, Brian Diggs wrote: On 1/25/2012 10:09 AM, patzoul wrote: I have 2 series of data a,b and I would like to calculate a new series which is z[t] = z[t-1]*a[t] + b[t] , z[1] = b[1]. How can I do that without using a loop? A combination of Reduce and Map will work.

Re: [R] aplpy recursive function on a list

2012-01-26 Thread Berend Hasselman
On 26-01-2012, at 19:10, Berend Hasselman wrote: On 26-01-2012, at 17:58, Brian Diggs wrote: On 1/25/2012 10:09 AM, patzoul wrote: I have 2 series of data a,b and I would like to calculate a new series which is z[t] = z[t-1]*a[t] + b[t] , z[1] = b[1]. How can I do that without using a

Re: [R] aplpy recursive function on a list

2012-01-26 Thread Brian Diggs
On 1/26/2012 10:33 AM, Berend Hasselman wrote: On 26-01-2012, at 19:10, Berend Hasselman wrote: On 26-01-2012, at 17:58, Brian Diggs wrote: On 1/25/2012 10:09 AM, patzoul wrote: I have 2 series of data a,b and I would like to calculate a new series which is z[t] = z[t-1]*a[t] + b[t] ,

[R] aplpy recursive function on a list

2012-01-25 Thread patzoul
I have 2 series of data a,b and I would like to calculate a new series which is z[t] = z[t-1]*a[t] + b[t] , z[1] = b[1]. How can I do that without using a loop? -- View this message in context: http://r.789695.n4.nabble.com/aplpy-recursive-function-on-a-list-tp4328017p4328017.html Sent from the

Re: [R] aplpy recursive function on a list

2012-01-25 Thread Berend Hasselman
On 25-01-2012, at 19:09, patzoul wrote: I have 2 series of data a,b and I would like to calculate a new series which is z[t] = z[t-1]*a[t] + b[t] , z[1] = b[1]. How can I do that without using a loop? ?filter Berend __ R-help@r-project.org

Re: [R] aplpy recursive function on a list

2012-01-25 Thread Berend Hasselman
On 25-01-2012, at 21:00, Berend Hasselman wrote: On 25-01-2012, at 19:09, patzoul wrote: I have 2 series of data a,b and I would like to calculate a new series which is z[t] = z[t-1]*a[t] + b[t] , z[1] = b[1]. How can I do that without using a loop? ?filter Oops. filter only works

Re: [R] aplpy recursive function on a list

2012-01-25 Thread Mark Leeds
that's an AR(1) with a constant added each time so you could use arima.sim and add the constant in afterwards. but I don't know how that fast that is. I started to check if there was a relation cumprod wise but I didn't get far. z[4] = a[4]*a[3]*a[2] + a[4]*a[3] + a[4]*b[3] + b[4] for z[5] you

Re: [R] aplpy recursive function on a list

2012-01-25 Thread Mark Leeds
Hi: I thought about it some more and arima.sim will not work because it will add noise. so sorry for my noise. On Wed, Jan 25, 2012 at 3:46 PM, Mark Leeds marklee...@gmail.com wrote: that's an AR(1) with a constant added each time so you could use arima.sim and add the constant in afterwards.