[R] Help using smooth.spline with zoo object

Rob Denniker bearmarketsrule at inbox.com
Sat Apr 4 21:19:38 CEST 2009


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!




More information about the R-help mailing list