[Math] Recursive curve fitting

regression

I have a few points for which I have to obtain a best fit. (I tried to use the least squares curve fitting method as Robert says, however, since it seems to be fitting rather poorly, any other suitable method would also work for me.)

However, the function is recursive and looks like this –

$$f(x+1)= f(x) + k_1(f(x)-k_2)^3$$

where the starting point $f(1)$ is known and fitting needs to be done only for positive integral values of $x$, from $1$ upto some natural no. $n$

I don't understand how would I apply the matrix method of minimizing the norm $\min(\lVert Ax-B\rVert^2)$ since I would have to consider all possible combinations of powers of $k_1$ and $k_2$ which makes my $x$ matrix terribly complex with every iteration.

This suggests that least square curve fitting is probably not the best way of doing this.
I tried to find other questions related to recursive curve fitting here, but I couldn't find any similar situation. Please help me solve this.

Best Answer

The parameters enter nonlinearly into your equation. However, fortunately you can rewrite your equation in such a way that you have linear parameters:

$$ (f(x+1) - f(x))^{1/3} = a f(x) - b $$ where $k_1 = a^3$ and $k_2 = b/a$.

So you can apply least squares to these linear equations in $a$ and $b$ for $x$ from $1$ to $n$.

EDIT: I tried some data that seem close to what you had in your picture:

$$ y = [237,130,120, 113, 111, 110] $$

Linear least squares for the residuals $(y_{i+1} - y_i)^{1/3} - a y_i + b$, $i = 1 \ldots,5$, in Maple produces $$ a = -.0273525754168209,\ b = -1.67458695987193$$ which corresponds to $$ k_1 = - 0.0000204641953284227606,\ k_2= 61.2222774036158200$$ I then tried nonlinear least squares for the residuals $ y_{i+1} - y_i - k_1 (y_i - k_2)^3$, $i=1 \ldots 5$, using the above as initial values (this is often necessary because the nonlinear least squares algorithms often provide only a local minimum rather than the global minimum). The result was $$ k_1 =- 0.0000166852730695581124, k_2 = 51.1767746591434971 $$

The recursion using initial value $237$ and parameters from the linear least squares produces the values $$ 237, 125.855961638565, 120.330463855443, 116.104385196179, 112.721501867265, 109.926405798693$$ while the recursion using parameters from the nonlinear least squares produces $$ 237, 129.938505804843, 121.786225982822, 115.912389815574, 111.385883230420, 107.744051206183$$

Related Question