gcamdata icon indicating copy to clipboard operation
gcamdata copied to clipboard

Should we allow for spline interpolation?

Open pkyle opened this issue 8 years ago • 0 comments

The data system currently has dozens of places where exogenous data (whether assumptions or from other sources) is provided for some number of selected years, and we interpolate to either construct a time series with more years, or to construct the model inputs. This issue may be pertinent for ongoing studies using annual timesteps. For monotonically increasing values linear interpolation may work fine, but for bouncy time series with only a few observations, the spline might be worth trying out. The default spline() method in R is fmm: "Forsythe, Malcolm and Moler (an exact cubic is fitted through the four points at each end of the data, and this is used to determine the end conditions)". It definitely shouldn't be used for extrapolation, and in the little testing I've done I've seen it put curves near the end points that aren't supported by the data, but it does avoid the abrupt change in direction at each observation with linear interpolation. The plot below shows the two methods' interpolation of municipal water demand in Spain, for which 6 data points are available between 1986 and 2012. Anyway, implementation would be easy; either make a spline_fun()--same as approx_fun() but with the function approx() replaced with spline(), and no "rule" argument--or put a "method" argument into the existing approx_fun(). example_plot

pkyle avatar Nov 16 '17 16:11 pkyle