[R] EWMA in fMultivar

Leeds, Mark (IED) Mark.Leeds at morganstanley.com
Tue Jul 3 17:34:05 CEST 2007


there is an ewma example in ?filter I think that might be more useful
because then you can see better
What's happening in terms of the smoothing. Actually, I just looked and
it's not there. It must have been in S+.

I include my ewma below but you have to modify it because it assumes a
zoo object. Of coure,  The other
option you have is to look at the source code for the ewma function in
fMultvar.

ewma<-function(x,lambda = 1, init = (1-lambda)*.raw[good.ind][1]) {

   # work with 'non-zoo' data for speed and then recombine
   .raw <- unclass(coredata(x))

   good.ind <- !is.na(.raw)  # determine good values

   .raw[good.ind] <- filter(lambda * .raw[good.ind], filter=(1-lambda),
       method='recursive', init=coredata(init))
   zoo(.raw, index(x)) # create zoo object for return



-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of livia
Sent: Tuesday, July 03, 2007 10:59 AM
To: r-help at stat.math.ethz.ch
Subject: [R] EWMA in fMultivar


Hello, I would like to use the function EWMA() in the fMultivar Package
and I have a series of data x, which is the returns series. Basically, I
would like to get the variance estimation using EWMA.

I am trying something like EWMA(x, lambda) and I have a couple of
questions:

 
Should x be the returns series or price series in my case?

When I get the result, there are the same numbers of data points as in
the returns series. I was expecting there would be one less data points
than the original data series, or are they one period lagged data?

Could anyone give me some advice? Many thanks

--
View this message in context:
http://www.nabble.com/EWMA-in-fMultivar-tf4018921.html#a11414114
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
--------------------------------------------------------

This is not an offer (or solicitation of an offer) to buy/se...{{dropped}}



More information about the R-help mailing list