Re: Problems getting CURVEFIT to work [message #32897 is a reply to message #32857] |
Fri, 15 November 2002 10:35  |
Jonathan Greenberg
Messages: 91 Registered: November 2002
|
Member |
|
|
Hello again Craig:
You MPCURVEFIT function is terrific! I've started using it instead of
CURVEFIT. One quick question, how does it deal with NaN values? I started
including NaN values in my regressions, and I noticed some strange behavior
from the output -- ideally it should just ignore the X,Y that has a NaN for
the X value, but is this actually the case?
--j
On 11/12/02 5:14 PM, in article onk7jiuv7e.fsf@cow.physics.wisc.edu, "Craig
Markwardt" <craigmnet@cow.physics.wisc.edu> wrote:
>
> Jonathan Greenberg <greenberg@ucdavis.edu> writes:
>> Hi there, I'm trying to use CURVEFIT to fit data to a decay function of the
>> form:
>> f(x) = a(1-e^(bx))+c
>
> Problem 1. Your parameters A and C are very highly (anti) correlated
> with each other. It would be better to recast as A*EXP(B*X) + C.
>
>
>> My code is as follows:
>>
>> pro decayfunc, X,A,F,pder
>> bx=EXP(A[1]*X)
>> F=A[0]*(1-bx)+A[2]
>> if N_PARAMS() GE 4 THEN $
>> pder=[[1-bx],[-A[0]*X*bx],[replicate(1.0,N_ELEMENTS(X))]]
>> end
>> X=[30185.0,33897.0,35089.0,35377.0,35665.0]
>> Y=[0.3002,1.3849,1.3004,1.226,1.3118]
>> A=[1.25,-1.0,-0.1]
>
> Problem 2. Your initial value of "B" of -1 is not a good choice.
> When the fitter tries to evaluate EXP(-1.0*30185.) the result is zero.
> A better choice would be about -1./30000.
>
> Problem 3. Your data don't look very exponential to me! There is
> just one low point. You are going to have to live with some very
> large confidence intervals...
>
>> weight=[1.0,1.0,1.0,1.0,1.0]
>> yfit=CURVEFIT[X,Y,weights,A,SIGMA,FUNCTION_NAME='decayfunc', /DOUBLE]
>
> Suggestion. It might be worth trying MPCURVEFIT or MPFITFUN from my
> web page. The fitting routines appear to be much more robust than the
> stock CURVEFIT.
>
> Good luck,
> Craig
>
> http://cow.physics.wisc.edu/~craigm/idl/idl.html (under curve fitting)
|
|
|