# Combining trend estimation and constrained Marquart fit

This title certainly needs some clarification: I need to compute parameters $a_i$ for a helper function $f(\vec{a};k)$ (for grid interpolation) which is fitted to a number of values $y_k$ which are subject to evolution dictated by a system of ODE's $d y_k/d t = F_k(t,\vec{y})$. The Levenberg-Marquardt fit of the values $y_k$ to the function $f(\vec{a};k)$ is repeated in each time step $t_j$. The precise values found for the parameters $a_{i,j}$, which are varied in this fit, does not matter, but I found that in the presence of adaptive step-size control for the ODE this simple algorithm can lead to instabilities as it influences the value of the rhs-functions $F_k(t,\vec{y})$ at higher order. For the present purpose I can assume that the evolution of the parameters is smooth plus some noise $a_{i,j} = A_i(t_j)+\delta_{i,j}$ and the model for the interpolating functions $f(\vec{a};k)$ does not matter. My idea to fix the stability issues is therefore to make the parameters $a_i$ subject to some smoothening procedure.

The concept for this procedure in turn is to estimate the new values $a_{i,J}$ based on the previous ones $a_{i,j}$, $j<J$ and the new $\chi^2$ fit by adding to the function to be minimized in the fit a contribution proportional to $\sum_l \sigma_l (A_l(t_J)-a_{l,J})^2$. Here $\sigma_l$ are positive constant coefficients and $A_l(t_J)$ are the values suggested by the trend of the previous ones (only loosely related to $A_l(t_J)$ above). The obtained $a_{l,J}$ would automatically be consistent with constraints in the fit. (Note that this could be different if I first fit and later smooth) The question is which method to use to predict (to extrapolate) the values $A_l(t_J)$. I wanted to avoid using a simple polynomial or spline fit, because I definitely need to avoid overshooting. On the other hand a second $\chi^2$ fit of a model function seems to overdo it. Also due to the fact that the previous values, $a_{i,j}$, $j<J$, where themselves found based on the combined fit and I am not sure that this does not introduce any bias. What do you think? I also wondered if I could miss use a Sawatzki-Golay smoothing filter (assuming as an approximation that $t_{i+1}-t_i=const$ to avoid the overhead of a full $\chi^2$ fit. But, can it be used for extrapolation?