views:

230

answers:

1

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(intepolated.values$x,intepolated.values$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?

A: 

Aniko is right on this. You are not plotting the actual data in the second case.

dan