Solved – Extrapolation of Time Series in Python

curve fittingextrapolationnonlinear regressionpythontime series

I have the following plot in time series and would like to extrapolate it to derive a value in X[n+20], for instance. I tried poly fitting it but extrapolation does come out correct that way. Any proposed approaches? enter image description here

The data comes from blood glucose after a meal overtime, it usually starts at some value, say 90mg/dl at mealtime, peaks to 150mg/dl, then decreases down to some value which can be less than the intial 90mg/dl. Since we have several post-meal signals which all start at different values, we aligned them by substracting the offset so that we can derive a general curve fit for them all, of course it will only be an approximation and that is fine. x is time.

\begin{array}{cc}
0 & 0. \\
5 & 4.3 \\
10 & 12.7 \\
15 & 22.1 \\
20 & 32.6 \\
25 & 41. \\
30 & 47.8 \\
35 & 50. \\
40 & 51.9 \\
45 & 52. \\
50 & 51.2 \\
55 & 45.4 \\
60 & 43.4 \\
65 & 39.9 \\
70 & 40.2 \\
75 & 35.4 \\
80 & 30.2 \\
85 & 27.9 \\
90 & 25. \\
95 & 19.6 \\
100 & 15.8 \\
105 & 13.9 \\
110 & 9.1 \\
115 & 4. \\
120 & 1.6 \\
125 & -1.4 \\
130 & -4. \\
135 & -5.6 \\
140 & -6.8 \\
145 & -7.7 \\
150 & -8.6 \\
155 & -10.4 \\
160 & -10.9 \\
165 & -10.9 \\
170 & -10.2 \\
175 & -10.2 \\
180 & -10.3 \\
185 & -10.7 \\
\end{array}

Best Answer

What you are doing is . Judging from what you write in the comments, forecasting this series is not truly a statistical problem, but a biological one. Best to model the dynamics giving rise to this curve and then extrapolate these out.

From a purely statistical/forecasting standpoint, the best you can probably do is the so-called naive or random-walk forecast: project the last observation out in a flat line. If you want to, use the smoothed value.

(And even if you do use a nice complex model, it makes sense to compare its predictions out-of-sample to a simple benchmark like the naive forecast. You find surprisingly often that the simple benchmark outperforms a more complex approach.)