Multivariate fitting not on a grid

Hi,

I do a lot of 1D fitting to resonance peaks, but recently switched to a new fitting function and discovered that one of the fitting parameters (call it K) is something called "sloppy" which means that if I fit to a single resonance (voltage vs field in my case) the dependence of resonance on K is so much weaker than on the other parameters that I get an uncertainty in K which is much larger than the value of K. The fit works great, it's just that dependence on K is very weak. However, K does scale differently with frequency than the other parameters, so if I can fit simultaneously to peaks at several different frequencies I should be able to get a good value for K.

My data looks something like the attached plot. I have three one-dimensional waves of the same length called vmix, field and frequency. In this example I plotted vmix vs field and colored the trace by frequency. (In every case I have only a few different values of the frequency, but lots of different values of the field). If I use my normal 1-dimensional fit on a subset of vmix (the one that corresponds to the red frequency here) the fit works fine. What I would like to do is fit to all three resonances simultaneously using a multivariate fit, and hopefully plot the result (fit_vmix) for the values of field and frequency I have here.

However, when I go to make the multivariate fit which includes both field and frequency independent variables, I always get a "There may be no dependence on these parameters:" error for several of my parameters. This is even true if I select a subrange of the data which includes only a single frequency, and use as the initial guesses the values I got fitting it with the usual univariate function. Is there any reason I shouldn't be able to do a multivariate fit like this?

Thanks for any suggestions you can provide,

Alex

For reference here's the univariate and multivariate versions of the same fit. (In the first case it takes the frequency from a global variable, in the second from a wave which for the subregion of the middle peak, is constant).

Function NewResFitDCUni(w,B) : FitFunc
    Wave w
    Variable B
    //variable f

    //CurveFitDialog/ These comments were created by the Curve Fitting dialog. Altering them will
    //CurveFitDialog/ make the function less convenient to work with in the Curve Fitting dialog.
    //CurveFitDialog/ Equation:
    //CurveFitDialog/ Variable f=4E9
    //CurveFitDialog/
    //CurveFitDialog/
    //CurveFitDialog/ f(B,f) = Offset + (gyr*om^2*alpha*(2*abs(B)+muM)*Cx+(gyr^3*abs(B)*(abs(B)+muM)^2-gyr*om^2*(abs(B)+muM))*Cz)/((om^2-gyr^2*abs(B)*(abs(B)+muM))^2+alpha^2*gyr^2*om^2*(2*abs(B)+muM)^2+4*alpha*om^2*gyr*(2*abs(B)+muM)*sin(pi/4)*kJsdc)
    //CurveFitDialog/ End of Equation
    //CurveFitDialog/ Independent Variables 1
    //CurveFitDialog/ B
    //CurveFitDialog/ Coefficients 6
    //CurveFitDialog/ w[0] = muM
    //CurveFitDialog/ w[1] = alpha
    //CurveFitDialog/ w[2] = Cz
    //CurveFitDialog/ w[3] = Cx
    //CurveFitDialog/ w[4] = Offset
    //CurveFitDialog/ w[5] = kJsdc

    Variable/G f
    variable om = 2*pi*f
    variable u0=1.256E-6,gyr=1.76E11, q=1.602E-19, hbar=1.05457E-34
    variable muM = w[0]
    variable alpha = w[1]
    variable Cz = w[2]
    variable Cx = w[3]
    variable Offset = w[4]
    variable kJsdc = w[5]
    return Offset + (gyr*om^2*alpha*(2*abs(B)+muM)*Cx+(gyr^3*abs(B)*(abs(B)+muM)^2-gyr*om^2*(abs(B)+muM))*Cz)/((om^2-gyr^2*abs(B)*(abs(B)+muM))^2+alpha^2*gyr^2*om^2*(2*abs(B)+muM)^2+4*alpha*om^2*gyr*(2*abs(B)+muM)*sin(pi/4)*kJsdc)
End

Function NewResFitDC(w,B,f) : FitFunc
    Wave w
    Variable B
    variable f

    //CurveFitDialog/ These comments were created by the Curve Fitting dialog. Altering them will
    //CurveFitDialog/ make the function less convenient to work with in the Curve Fitting dialog.
    //CurveFitDialog/ Equation:
    //CurveFitDialog/ Variable f=4E9
    //CurveFitDialog/
    //CurveFitDialog/
    //CurveFitDialog/ f(B,f) = Offset + (gyr*om^2*alpha*(2*abs(B)+muM)*Cx+(gyr^3*abs(B)*(abs(B)+muM)^2-gyr*om^2*(abs(B)+muM))*Cz)/((om^2-gyr^2*abs(B)*(abs(B)+muM))^2+alpha^2*gyr^2*om^2*(2*abs(B)+muM)^2+4*alpha*om^2*gyr*(2*abs(B)+muM)*sin(pi/4)*kJsdc)
    //CurveFitDialog/ End of Equation
    //CurveFitDialog/ Independent Variables 2
    //CurveFitDialog/ B
    //CurveFitDialog/ f
    //CurveFitDialog/ Coefficients 6
    //CurveFitDialog/ w[0] = muM
    //CurveFitDialog/ w[1] = alpha
    //CurveFitDialog/ w[2] = Cz
    //CurveFitDialog/ w[3] = Cx
    //CurveFitDialog/ w[4] = Offset
    //CurveFitDialog/ w[5] = kJsdc

    //Variable/G f
    variable om = 2*pi*f
    variable u0=1.256E-6,gyr=1.76E11, q=1.602E-19, hbar=1.05457E-34
    variable muM = w[0]
    variable alpha = w[1]
    variable Cz = w[2]
    variable Cx = w[3]
    variable Offset = w[4]
    variable kJsdc = w[5]
    return Offset + (gyr*om^2*alpha*(2*abs(B)+muM)*Cx+(gyr^3*abs(B)*(abs(B)+muM)^2-gyr*om^2*(abs(B)+muM))*Cz)/((om^2-gyr^2*abs(B)*(abs(B)+muM))^2+alpha^2*gyr^2*om^2*(2*abs(B)+muM)^2+4*alpha*om^2*gyr*(2*abs(B)+muM)*sin(pi/4)*kJsdc)
End
And if you don't want to constantly scroll back and forth because of the wide code block, here's my post from above. Sorry about that. (The attached image is also hidden in the lower right corner of the above post.)

Hi,

I do a lot of 1D fitting to resonance peaks, but recently switched to a new fitting function and discovered that one of the fitting parameters (call it K) is something called "sloppy" which means that if I fit to a single resonance (voltage vs field in my case) the dependence of resonance on K is so much weaker than on the other parameters that I get an uncertainty in K which is much larger than the value of K. The fit works great, it's just that dependence on K is very weak. However, K does scale differently with frequency than the other parameters, so if I can fit simultaneously to peaks at several different frequencies I should be able to get a good value for K.

My data looks something like the attached plot. I have three one-dimensional waves of the same length called vmix, field and frequency. In this example I plotted vmix vs field and colored the trace by frequency. (In every case I have only a few different values of the frequency, but lots of different values of the field). If I use my normal 1-dimensional fit on a subset of vmix (the one that corresponds to the red frequency here) the fit works fine. What I would like to do is fit to all three resonances simultaneously using a multivariate fit, and hopefully plot the result (fit_vmix) for the values of field and frequency I have here.

However, when I go to make the multivariate fit which includes both field and frequency independent variables, I always get a "There may be no dependence on these parameters:" error for several of my parameters. This is even true if I select a subrange of the data which includes only a single frequency, and use as the initial guesses the values I got fitting it with the usual univariate function. Is there any reason I shouldn't be able to do a multivariate fit like this?

Thanks for any suggestions you can provide,

Alex
It's hard to say much without having any idea what the values of coefficients might be, or the frequencies involved. And I'm not very good at reading giant expressions like that and intuiting what the dependence might be like for various parts of the expression.

I did this:

make/n=(100,100) junk
setscale/I x -.14, -.01, junk
setscale/I y 0,1e6,junk
make/D coefs={1, 1, 1, 1, 0, 1}     // Probably not very close to right, eh?
junk = NewResFitDC(coefs, x, y)
display;appendimage junk
ModifyImage junk ctab= {*,*,Rainbow256,0}


In the resulting image, I see no dependence on frequency (y in my attempt). That would be a problem.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Hi John,

Thanks for the quick reply. It turned out that the multivariate version is actually working -- I though I was fitting the exact same data both ways, but it turns out I missed a factor of 10^9 in one of the frequency definitions, which was screwing everything up. I'm also able to plot the results the way I wanted to. Thanks again,

Alex