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.

Était-ce utile?

La 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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top