For equally spaced observations this is quite simple and available in
various packages
but I like Gabor Grothendieck's version (which didn't come up
immediately in my Rseek search:
hpfilter <- function(y,lambda=1600)
eye <- diag(length(y))
solve(eye+lambda*crossprod(diff(eye,d=2)),y)}
ur
Try this:
library(zoo)
library(lattice)
z <- as.zoo(EuStockMarkets)
xyplot(z) # original
xyplot(z, type = "smooth") # smooth
In zoo see ?xyplot.zoo and in lattice see ?panel.xyplot
On Sat, Apr 4, 2009 at 3:19 PM, Rob Denniker wrote:
> Can someone please show me how to smooth time series data t
Can someone please show me how to smooth time series data that I have in the
form of a zoo object?
I have a monthly economies series and all I really need is to see a less jagged
line when I plot it.
If I do something like
s <- smooth.spline(d.zoo$Y, spar = 0.2)
plot(predict(s,index(d.zoo)),
3 matches
Mail list logo