Multipeak fit with user baseline

Hello,

I am trying to fit a user baseline within multipeak fit 2, but Igor doesn't seem to be able to converge on a decent fit, despite the starting parameters being close to acceptable. The function is a modified boatsman step function.

I have used the baseline function below, which seems to compile successfully, and works within multipeak fit. When I try to `Do fit' I get the error: 'Multi-peak Fit failed: singular matrix or other numerical error'. I find that this happens even with most variables constrained, or some held. If I hold all of the user defined baseline parameters, the program is able to proceed. Can someone help me with this? I have attached a simple example .pxp file.

Function/S Boltz_BLFuncInfo(InfoDesired)
    Variable InfoDesired

    String info=""

    switch(InfoDesired)
        case BLFuncInfo_ParamNames:
            info = "a1;a2;x0;dx;m1;"
            break;
        case BLFuncInfo_BaselineFName:
            info = "Boltz_BLFunc"
            break;
    endswitch

    return info
end

Function Boltz_BLFunc(s)
    STRUCT MPF2_BLFitStruct &s
    s.cWave[0]=-0.47054
    s.cWave[1]=0.54243
    s.cWave[2]=225
    s.cWave[3]=14.9
    s.cWave[4]=-0.00037
       
    return s.cWave[1] + s.cWave[4]*s.x + ((s.cWave[0])/( 1 + exp ( (s.x-s.cWave[2])/s.cWave[3])))
end

working_example.pxp
johnweeks wrote:
You are setting the values of the coefficient wave to fixed values before evaluating your fit expression. Remove all those assignments.


Thanks John - is there some way I can give the parameters an initial value I know to be good? I'd like to be able to preload these rather than type them in each time.
You would enter them as initial guesses. If you view them as constants (that is, they shouldn't be varied during the fit) then enter them as initial guesses and hold them.

Maybe you are trying to do something you haven't told us?

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
johnweeks wrote:

Maybe you are trying to do something you haven't told us?


I was hoping to have preset values each time I load multipeak. I found I can do this saving each fit as a `checkpoint', which means each fit can start with the same preset parameters. Thanks for your help. Problem solved.