From: Adrian Trapletti (adrian.trapletti@lmttrading.com)
Date: Mon 17 Jun 2002 - 17:53:58 EST
Message-id: <3D0D9596.88FB16A4@lmttrading.com>
> Date: Fri, 14 Jun 2002 13:21:23 +0200
> From: Xavier.Abulker@fimat.com
> Subject: [R] exponential smoothing
>
> could someone help me to write a fonction doing an exponential smoothing in
> case of a multivariate time serie?
> I tried
> ewma <- function (x, lambda = 1, init = 0)
> {
> if (is.ts(x))
> filter(lambda*x, filter=1-lambda, method="recursive", init=init)
> else
> stop(message="first argument should be a time serie")
> }
> but I can't apply that to multivariate
> Thanks
>
> xavier
>
For example:
apply(x,FUN=ewma,2,lambda=0.1)
should work. You maybe need to set the default of init in ewma() to x[1].
best
Adrian
-- Dr. Adrian Trapletti Phone: +41 (0)1 994 56 31 Wildsbergstrasse 31 Fax : +41 (0)1 994 56 33 CH-8610 Uster Email: a.trapletti@bluewin.ch Switzerland-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
This archive was generated by hypermail 2.1.3 : Wed 16 Oct 2002 - 11:57:29 EST