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 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> Date: Fri, 14 Jun 2002 13:21:23 +0200 > From: Xavier.Abulker at 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 at 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 at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._