[R] Bollinger Bands

Gabor Grothendieck ggrothendieck at myway.com
Mon Nov 24 17:28:35 CET 2003


I assume you are looking to apply some function, f, over the
last k points of your time series for each point in the 
series (except for the first k-1 points).

Let z be a vector that represents your time series.  Then 
the j-th column of 

  zl <- matrix(c(z,NA),length(z),k)[-seq(k-1),]   # ignore warning

is z lagged by j-1.  Now apply f to the rows:

  apply(zl,1,f)

--- 
Date: Mon, 24 Nov 2003 15:19:10 +0000 
From: <Arnaud_Amsellem at ssga.com>
To: <r-help at stat.math.ethz.ch> 
Subject: [R] Bollinger Bands 

 
 
Is there a way to create Bollinger Bands without having to loop on the
observations of a time serie?

Any help appreciated

Thanks




More information about the R-help mailing list