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 <bearmarketsr...@inbox.com> wrote: > 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)), xlab = "Year") > # not defined for Date objects > > and if I do something like > > plot(predict(s,as.numeric(index(d.zoo))), xlab = "Year") > # one straight line, no matter the value of spar > > What am I doing wrong? (The unsmoothed series plots just fine - a noisy > upward trend) > > Thanks in advance. > > P.S. I would really just like to keep varying the penalty parameter 'lambda' > of a Hodrick-Prescott filter until I get a 'smooth enough' series, but an > archive search suggests that if I ask for this, some smarty pants will reply > saying that the HP filter is just the smooth.spline function applied with a > particular choice of lambda and equally spaced observations. > > ____________________________________________________________ > Receive Notifications of Incoming Messages > Easily monitor multiple email accounts & access them with a click. > Visit http://www.inbox.com/notifier and check it out! > > ______________________________________________ > R-help@r-project.org 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. > ______________________________________________ R-help@r-project.org 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.