Question

I'm trying to add a lowess smoothing line to a zoo time series but can't get the lowess line to show.

I'm sure it has to do with the index not matching but I can't figure out how to get around it...

x.Date <- as.Date(paste(2003, 02, c(1, 3, 7, 9, 14,19,24,29), sep = "-"))
x <- zoo(rnorm(8), x.Date)
lo = lowess(x)
plot(x, type='p')
lines(lo,col='purple')

New to time series and any advice is appreciated.

Was it helpful?

Solution

This should work:

lines(index(x), lo$y,col='purple')

index just takes the time index from the zoo object, and I did lo$y to only use the y value from the lowess.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top