# Global fitting with multivariate functions

Hi,

I'm trying to do a global fitting of a series of 2D waves to a 2D gaussian function with Igor 6. It doesn't look like the global analysis GUI will fit with a multivariate function; is there another way to do this?

Thanks!

No, I'm afraid that the complexity of adding multivariate support was a reach too far in a package that is already pretty complex. If you look at the code, you will see that it has quite a lot of complex bookkeeping and very indirect code.

If you have a pretty well-defined situation, you can fake it by concatenating your data sets and doing a single fit. You will need some bookkeeping if you have local fit coefficients.

In reply to by johnweeks

Thanks John! My data consists of a series of 2D waves that each contain three 2D gaussians. The amplitude of the gaussians is random in each frame, however the other parameters should be the same across all frames. The best approach I could come up with was to use global fitting to link all parameters except the amplitudes, but perhaps there's a simpler way to do this.

To do a single fit, like you suggested, I would need to have an amplitude coefficient for each frame, right? I have about 100 frames, so that would work out to 300 amplitude coefficients. is there a limit on the number of coefficients in a single fit?

One simple option, if all parameters really are the same (except amplitude), would be to sum up all your frames, and fit the sum to get all your peak parameters (again except amplitude). Now you hold those parameters constant and fit your frames independently of each other using only the amplitudes as free parameters.

I wouldn't work if the positions of your peaks are moving around for instance.

In reply to by olelytken

Thanks for the suggestion. Unfortunately the three peaks are too close together-- summing them all gives a single "blob", which I dont think I could be confident about the fit to three gaussians. Perhaps only summing select frames would work though.

There is a practical limit on the number of independent variables in that you have to define each one in the function definition. But the only limit on the number of fit coefficients is your patience. More coefficients means more time spent computing derivatives by numerical differences.

You could write a fit function that has the width, etc., for just three Gaussians, but 1000 amplitudes. You would need to concatenate your images into a single huge wave, but not into layers. You need it to be "flat" with each image one after the other in a single layer. The easiest method would be to concatenate such that there are N*1000 rows, and M columns. Then you should be able to use Redimension/N=(N*1000, M) imagestack to flatten the images. Write the fitting function as an all-at-once fit function; it will have to have some detailed knowledge of the layout so that it fits the amplitudes each to the correct frame. Since it is dependent on the layout of the wave, you won't be able to use the /D auto-destination feature.

I'm sure you will have some more questions...

Thank you very much for the explanation. I've never done anything with all-at-once functions before, but I'll try it out!

DisplayHelpTopic "All-At-Once Fitting Functions"

And I'm sure you'll have some questions :)