36 Reputation

2 Badges

17 years, 302 days

MaplePrimes Activity

These are answers submitted by gcarlson

(Sorry for previous misformatted post.)

I'm running Maple 12. I don't see what could be wrong with the specified initial values for this nonlinear fit problem. Note error when initial values are specified, and no error without initial values.

> XY := Matrix([[1, 5],[2, 7],[3,10],[4,17],[5,24],[6,37]], datatype=float):

>initxy := Vector([1,2,3], datatype=float):

> Z := Vector([2.2, 3, 4.8, 10.2, 24.5, 75.0], datatype=float):

>NonlinearFit(exp(a+b*x+c*y), XY, Z, [x,y],initialvalues=initxy);

Error, (in Statistics:-NonlinearFit) invalid input: no implementation of NonlinearFit matches the arguments in call, NonlinearFit(exp(a+b*x+c*y),op(w),[x, y],initialvalues = (Vector(3, [...], datatype = float[8])))

>NonlinearFit(exp(a+b*x+c*y), XY, Z, [x,y]);

exp(-0.209656785380510162 + 0.413711750400883371 x + 0.0552760194520834567 y)

Is there something wrong with how I specified the vector of initial values?

"Help" tells me that "initialvalues = ... Vector(realcons) -- Provide initial values for the parameters."  Not shown here is that the initxy vector works fine in the matrix form of NonlinearFit.

Thanks for any assistance.


Like a charm!

Thanks for the good tips.  After just a few hours, IMO --

fdiff:  The coefficients are exploding!  Even if the complete (infinite?) converges, the radius of convergence is tiny or a large number of terms must is required.  My guess is that fdiff has a numerics problem.  I'd stay away from fdiff.

piecewise:  Reasonable coefficients.  Wide convergence interval (for the problem I'm working on).  I only seem to get terms through 4-th power -- limitation of rkf45 method?  Better than fdiff.

dsolve/series:  Solution to any order (set Order environment variable).  Extra work to solve ODEs for each point that I want power series at.  Can't seem to extract functional form of solutions from listprocedure.  Usual way is with f:=eval(p(x),sol), but "order" term (O(x^12) for example) seems to prevent this from working.  If I or someone else can figure out how to do this, my vote is for dsolve/series.

Again, thanks for the good tips.



Apparently the "t=" in the avoid option is also necessary (for single variable solutions?). Even with the initial guess, fsolve will fail if this is omitted. This may have been part of my problem, because I'm certain I tried specifying an initial guess. Thanks.
Page 1 of 1