[Math] Exponential regression with two terms and constraints

least squaresnonlinear optimizationregression

Corrected equation and one more update.

There was a major mistake in the equation.
The corrected equation should be in the form:
$$f(x) = 1 – c1*exp(-3*x/a1) – c2*exp(-3*x/a2).$$

I would like to find a least squares fit to a bunch of points; the parameters $c1$, $c2$, $a1$ ,and,$a2$ should be optimized. I am particularly interested in finding an analytical solution without iterations and initial guesses.

Now, $c1$, and $c2$ should not necessarily sum up to 1 (instead, the sum should be less than or equal to one and positive); $a1$ and $a2$ should also be positive.

I am not sure if this is realistic…but any help would be appreciated!

If anybody finds it worth his/her time, there are some points:
$$xi=0, 12.08, 24.276, 36.368, 48.21, 59.998,$$
$$yi=0, 0.735, 0.894, 0.999, 1.074, 0.84.$$

I am trying to fit a variogram model. Therefore, I need to use one of the models that are positive-definite; the exponential model happens to be one of them. The variogram models are usually being fit either manually or through some iterative procedure.

Using a semi-automatic fitting algorithm, I obtained the following result.
fitted model

The fitted parameters: $c1=0.975$; $c2=0.025$; $a1=25.741$; $a2=150.0$

I hope everything is correct now. Let me know if you see any inconsistency.

Best Answer

The case of the regression for four parameters $p,q,b,c$ of the function : $$y=be^{px}+ce^{qx}$$ was considered pp.71-74 in the paper https://fr.scribd.com/doc/14674814/Regressions-et-equations-integrales . It involves a 4x4 matrix.

If we add a parameter for the function : $$y=a+be^{px}+ce^{qx}$$ the five parameters $p,q,a,b,c$ regression involves a 5x5 matrix, as shown below.

The first part of calculus is common for various variants, depending if there is or not a relationship between $a,b,c$.

The second part of calculus below is valid if there is no additional condition. Do not apply it if an additional condition is requested on the form of linear relationship between $a,b,c$.

In the case of condition $c_0+c_1+c_2=1$ see the corresponding calculus method below.

enter image description here

enter image description here

UPDATED ANSWER AFTER THE CHANGE OF WORDING OF THE PROBLEM :

Now, the function considered is : (1-f(x)) = c1*exp(-3x/a1) + c2*exp(-3*x/a2) as specified in R.Chuck's comment. Then : $$f(x)=1-c_1e^{-3x/a_1}-c_2e^{-3x/a_2}$$ This corresponds to : $$y(x)=be^{px}+ce^{qx}\qquad \begin{cases} y(x)=f(x)-1\\ p=-3/a_1\\ q=-3/a_2\\ b=-c_1 \\ c=-c_2 \end{cases}$$ So, the method of regression with four parameters $(p,q,b,c)$ can directly be applied. There is no need for the above method with five parameters.

NUMERICAL EXAMPLE (From R.Chuck's original data)

As already pointed out the number of points is too small, which leads to deviation in the numerical integration (not accurate values of $S_k$ and $SS_k$).

As a consequence, the numerical results below are far to be accurate.

The fitting of the equation of the form (1) : $\quad f(x)=a+be^{px}+be^{qx}\quad$ leads to the black curve.

The fitting of the equation of the form (2) : $\quad f(x)=1-c_1e^{px}-c_2e^{qx}\quad$ leads to the blue curve.

Obviously, this example of data is not compatible with a good fit of the form (2) of equation.

enter image description here

enter image description here

COMMENTS ABOUT THE SECOND DATA SET :

Second data set (given by R. Chuck in the comments section) :

x: 0, 6.798406, 10.924855, 15.152776, 19.715873, 25.229183, 29.650875‌​, 34.891332, 40.29349, ‌​44.933608, 50.335293;

y: 0, 0.301604, 0.573718, 0.627697, 0.687598, 0.802262, 0.742347, 0.‌​857322, 0.947088, 0.96‌​6117, 1.093539

This is a very useful example to understand where the difficulty arrises.

In the next figure, the results of two regression calculus are represented :

Black curve : Five parameters regression. The fit is satisfactory.

Blue curve : Four parameters regression, with an imposed condition ($a=1$ instead of free $a$). The fit is very bad. So, what is the snag ?

enter image description here

The function to fit is : $\quad f(x)=1-c_1e^{-2x/a_1}-c_2e^{-2x/a_2}\quad$ with condition $a_1,a_2,c_1,c_2$ all positive.

This is the same as $\quad f(x)=a+be^{px}+ce^{qx}\quad$ with condition $p,q,b,c$ all negative and $a=1$.

$f'(x)=(pbe^{px}+qce^{qx})>0$ any $x$ , so $f(x)$ is an increasing function.

$f''(x)=(p^2be^{px}+q^2ce^{qx})<0$ any $x$ so $f'(x)$ is a decreasing function.

Thus, the function $f(x)$ is increasing more and more slowly.

If the overall shape of the "cloud" of points is of the same kind (increasing more and more slowly), all is for the best : The fitting will probably be good and the condition fulfilled.

If not, the computed coefficients will probably not fulfill the condition.

That is what arrises in the case of the given data : we observe that, for large $x$, the trend is to $y$ increasing more quickly than slowly. The shape of the cloud of points isn't compatible with the chosen function and/or associated condition.

Then, they are two possibilities :

  • Choosing an other kind of function and/or conditions. This is probably not what is wanted.

  • Considering the points which make not compatible the shape of the cloud are outliners and eliminate them. For example in eliminating the three last points, the result is shown below. The result of the four parameters fitting is close to the five parameters fitting. With the four parameters fitting, all conditions of signs of the parameters are fulfilled.

enter image description here

NOTE : It is possible that the points appearing as outliners be not really outliners but be due to a big scatter. This can be overcome with a larger number of points. In case of large scatter it is necessary to have a big number of points so that the overall shape of the cloud of points be representative.

Possibly, if there was much more points, the cloud of points might appear increasing more slowly on the right side. Then the condition would be satisfied. The present appearance can be an artefact due to a too large scatter and the difficulty encountered can be a consequence.

By a number of simulations, if it's confirmed that a large scatter combined with a low number of points is the true cause of the problem, the results cannot be reproducible from a data set to another. No miraculous solution, except reducing the scatter and/or increasing the number of points, of course if possible in practice.

Related Question