2
$\begingroup$

what are best ways to interpolate time series? I have three data points(1980, 1990 and 2001) and I need to interpolate them. Using R na.approx doesn't seem to be what I need since the data I need to interpolate is population and it is very unlikely for it to move linearly.

$\endgroup$
1

3 Answers 3

4
$\begingroup$

As suggested by @forecaster, you can use spline interpolation. For example, in R:

set.seed(123)
y <- rnorm(3)
ylong <- spline(y = y, x = seq_along(y), xout = seq(1, 3, 0.5))$y
plot(y, type = "n")
lines(seq(1, 3, 0.5), ylong, col = "gray")
points(seq_along(y), y, pch = 16, col = "blue")
points(c(1.5, 2.5), ylong[c(2,4)], pch = 16, col = "red")
legend("topleft", legend = c("observed values", "imputed values"), 
  col = c("blue", "red"), pch = c(16, 16), bty = "n")

spline interpolation

See ?spline for details and the available types of splines.

$\endgroup$
0
1
$\begingroup$

There is surely no definite answer on the basis of the given information. The number of data points is extremely small, which is why your underlying model must be very close to reality in order to give a tiny impression of a reasonable result.

The underlying model, in turn, depends heavily on the kind of population you want to consider. A very basic model for population dynamics is logistic growth: you could fit that in a way that mathematically uneducated people might be convinced -- although I wouldn't because the data is to sparse. Therefore, you could try to fit a quadratic function and hope for the same effect. Finally, and even better, forget all this stuff and take the straight line going through the three (almost collinear) points. All other is nonsense.

EDIT: I read your question again and now think that the numbers you provided, (1980, 1990 and 2001), denote years. I thought they'd denote population size on an equidistant grid -- so they seem to be at least not collinear. Then, fitting a cubic splines corresponds to fitting a simple cubic function ... although I'd rather use a quadratic function. But I think you're satisfied...

$\endgroup$
0
0
$\begingroup$

This paper reviews several methods for time series interpolation, and concludes that:

na.interp from the forecast package and na.StructTS from the zoo package showed the best overall results.

These functions are also very easy to use, just one line if your data is already stored as a time series. They're likely to outperform standard spline interpolation, as they can both detect and apply seasonal patterns.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.