Interpolation of time series data in R

Posted by Pierreten on Stack Overflow See other posts from Stack Overflow or by Pierreten
Published on 2010-06-16T17:30:53Z Indexed on 2010/06/16 17:32 UTC
Read the original article Hit count: 333

Filed under:
|
|

I'm not sure what i'm missing here, but i'm basically trying to compute interpolated values for a time series; when I directly plot the series, constraining the interpolation points with "interpolation.date.vector", the plot is correct:

plot(date.vector,fact.vector,ylab='Quantity')
lines(spline(date.vector,fact.vector,xout=interpolation.date.vector))

When I compute the interpolation, store it in an intermediate variable, and then plot the results; I get a radically incorrect result:

intepolated.values <- spline(date.vector,fact.vector,xout=interpolation.date.vector)

plot(intepolated.values$x,intepolated.values$y)
lines(testinterp$x,testinterp$y)

Doesn't the lines() function have to execute the spline() function to retrieve the interpolated points in the same way i'm doing it?

© Stack Overflow or respective owner

Related posts about r

    Related posts about plot