regression2(f,x,y,z,ic)
Performs a non linear regression of function f(x, a1, a2, ..., ak). Arrays x and y contains the data points and array ic contains the initial values of the unknown parameters.
See also regression linearreg_ana
Example
To fit function f(x,y)=a*x^b*y^c to a set of pairs (x,y,z) we first create a function:
f(x,y,a,b,c)=a*x^b*y^c
f(x,y,a,b,c)=a*x^b*y^c
The set of pairs is given by these three arrays:
x = ( 3.017 2.822 2.632 2.287 2.207 2.048 1.963 1.784 1.712 2.972 2.719 2.495 2.07 1.969 1.768 1.677 1.479 1.387 2.843 2.485 2.163 1.687 1.408 1.279 1.016 0.742 0.607 )
( 3.017 2.822 2.632 2.287 2.207 2.048 1.963 1.784 1.712 2.972 2.719 2.495 2.07 1.969 1.768 1.677 1.479 1.387 2.843 2.485 2.163 1.687 1.408 1.279 1.016 0.742 0.607 )
y = ( 2.175 2.624 2.839 3.03 3.057 3.098 3.115 3.144 3.153 2.106 2.542 2.721 2.878 2.899 2.929 2.939 2.957 2.963 1.984 2.32 2.444 2.525 2.547 2.554 2.564 2.568 2.571 )
( 2.175 2.624 2.839 3.03 3.057 3.098 3.115 3.144 3.153 2.106 2.542 2.721 2.878 2.899 2.929 2.939 2.957 2.963 1.984 2.32 2.444 2.525 2.547 2.554 2.564 2.568 2.571 )
z = ( 0.32 0.629 0.95 1.574 1.725 2.035 2.204 2.57 2.721 0.313 0.643 0.956 1.597 1.758 2.088 2.24 2.583 2.744 0.315 0.639 0.954 1.459 1.775 1.927 2.243 2.581 2.753 )
( 0.32 0.629 0.95 1.574 1.725 2.035 2.204 2.57 2.721 0.313 0.643 0.956 1.597 1.758 2.088 2.24 2.583 2.744 0.315 0.639 0.954 1.459 1.775 1.927 2.243 2.581 2.753 )
Making use of function regression2() we get:
regression2(f,x,y,z)
Nonlinear Regression
Statistics:
+-----------------------+------------------+
| R squared | 0.94715 |
| R squared adjusted | 0.94275 |
| Df1 (regression) | 2 |
| Df2 (error) | 24 |
| F statistic | 215.06912 |
| P | 0.00000 |
| SSQ | 0.92741 |
| Log-likelihood | 7.19975 |
| AIC | -0.31109 |
| BIC | -0.16711 |
+-----------------------+------------------+
Computed parameters
+----+------------------+------------------+------------------+
| | Value | Std. Error | P |
+----+------------------+------------------+------------------+
| a | 0.06917 | 0.02102 | 0.00308 |
| b | -0.86733 | 0.05967 | 2.00000 |
| c | 3.58329 | 0.30173 | 0.00000 |
+----+------------------+------------------+------------------+
Covariance matrix
+----+------------------+------------------+------------------+
| | a | b | c |
+----+------------------+------------------+------------------+
| a | 0.00044 | 0.00069 | -0.00632 |
| b | 0.00069 | 0.00356 | -0.01076 |
| c | -0.00632 | -0.01076 | 0.09104 |
+----+------------------+------------------+------------------+