[R] Re: R-help Digest V2 #377
Adrian Trapletti
adrian at olsen.ch
Wed Mar 28 09:36:45 CEST 2001
> Date: Tue, 27 Mar 2001 22:46:37 +0200
> From: "Karl Christoph Keller" <K.Christoph.Keller at web.de>
> Subject: [R] Exponential smoothing
>
> Dear all,
>
> is there any function to do exponential smoothing of data in R?
>
> I have searched all documentation (at least I hope I did) and found
> nothing.
>
> I know exp. smoothing is a somewhat old method and better ones exist,
> but I want it for the reason of comparing results.
>
> Greetings
>
> Christoph
>
A simple exponential weighted moving average procedure would be
ewma <- function (x, lambda = 1, init = 0)
{
y <- filter(lambda*x, filter=1-lambda, method="recursive", init=init)
return (y)
}
Using ewma as a forecast function is known as exponential smoothing.
Try, e.g.:
x <- ts(diffinv(rnorm(100)))
y <- ewma(x,lambda=0.2,init=x[1])
plot(x)
lines(y,col="red")
best
Adrian
--
Dr. Adrian Trapletti, Olsen & Associates Ltd.
Seefeldstrasse 233, CH-8008 Zürich, Switzerland
Phone: +41 (1) 386 48 47 Fax: +41 (1) 422 22 82
E-mail: adrian at olsen.ch WWW: http://www.olsen.ch
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list