MagicPlot Manual

Plotting and nonlinear fitting software

User Tools

Site Tools


fitting

This is an old revision of the document!


Nonlinear Curve Fitting: Fit Plot

Nonlinear least squares data fitting can be performed using Fit Plot. To create a Fit Plot, select x and y columns in table, then select Table → Create Fit Plot in main menu, or use context menu in table, or use Create Fit Plot button in the toolbar.

'Nonlinear' means here that analytical fitting function depends nonlinearly on varying parameters (fit parameters). Linear fitting is a quite simple method, which is based on solving the system of linear equations. Unlike linear fitting, nonlinear fitting is performed by iterative algorithm which needs the user to set the initial values of fit parameters.

To fit the data, implement these steps:

  1. Create a Fit Plot, specify Y errors in Plot properties, if any
  2. Specify fit function by adding Fit Curves
  3. Specify initial values of fit parameters (drag curves or enter accurate values)
  4. Specify used X data interval
  5. Run fitting

Fit example

Further reading

This manual does not completely cover the complex nonlinear fitting methodology. We recommend you to take a look at this book:

  • H. Motulsky and A. Christopoulos, Fitting Models to Biological Data Using Linear and Nonlinear Regression: A Practical Guide to Curve Fitting. 2003, GraphPad Software Inc., San Diego CA, graphpad.com. PDF is available for free here.

Fit Function is a Sum of Fit Curves

MagicPlot considers fit function as a sum of Fit Curves. Ordinarily in peaks fitting each Fit Curve corresponds to one peak in experimental data. There is a number of predefined Fit Curves (Line, Parabola, Gauss, Lorentz, etc.) You can also specify a custom Fit Curve. Baseline fitting components may be added to the fitting sum, too.

Fit Plot window contains the list of Fit Curves. Each Fit Curve in the list has three checkboxes: Show, Baseline, Sum:

  • Show: Specifies whether to show this Fit Curve on plot. Active only if Baseline checkbox is not set
  • Baseline: Toggles the subtracting of this Fit Curve from experimental data. You also can use Residual button to subtract Fit Sum from data
  • Sum: Specifies whether to use this Fit Curve in sum fit function

Below the Fit Curves list is a parameters table which shows names, values, and descriptions of parameters relating to selected Fit Curve.

Copying and Pasting Fit Curves

You can copy and paste Fit Curves from one Fit Plot to another Fit Plot or Figure. You can also paste the copied Fit Curves to the same Fit Plot to create a copy.

  • The copy of Fit Curves with the same parameters and styles will be created if you paste Fit Curves to a Fit Plot.
  • A link to the source Fit Curves will be inserted if you paste Fit Curves in a Figure.

Setting Initial Values of Parameters

Nonlinear fitting assumes that certain initial values of parameters are set before fitting. This procedure is very easy if you use Fit Curves of predefined types (not custom equation): you can drag curves on plot. Initial parameters values for each Fit Curve can also be set in parameter table.

Moving curves with mouse

Parameter Locking

You can lock parameter(s) to prevent varying this parameter during fit and to prevent its changing due to setting initial values by mouse dragging (for built-in functions). Set the checkbox in Lock column in parameters list.

Fit Intervals

You can set the x intervals of the data. Data points outside these intervals are not used to compute the minimizing residual sum of squares (see below). You can use this feature if some data points (especially in the beginning or the end) are inaccurate, e.g. noisy.

Select Fit Interval tab to set intervals visually or edit accurate borders values:

  • Double click on interval to split it
  • Drag the interval border to move it. If intervals intersect, they will be merged
  • Use context menu on the plot to create, delete and split intervals
Interval context menu Interval context menu

Baseline Fitting and Extraction

Fit Interval is also usable when baseline fitting. Before baseline fitting you can specify the interval which does not contain any signal points and contains baseline only. Set Baseline checkboxes at baseline Fit Curves after baseline fitting to subtract baseline from data. Then specify the whole interval and fit the data.

The most appropriate curve type for baseline fitting is spline.

Note that if you execute one of data processing algorithms (integration, FFT, etc.) on Fit Plot, then the difference between the data and baseline curves (which you do see on the plot) will be processed. You can use this behaviour to exclude baseline from data before integrating, see Integration for more information.

'Data-Baseline' Table Column

The 'Data-Baseline' column is appended to the Table with initial (x, y) fit data when you create Fit Plot. The 'Data-Baseline' column contains the difference between initial y data and baseline approximation (the sum of Fit Curves for which Baseline checkbox is set).

It is 'Data-Baseline' column that is actually plotted on Fit Plot.

Use 'Data-Baseline' column in Table if you want to process the data without baseline. This column is also used as initial data if you use Processing menu when Fit Plot is active.

Viewing the Difference between Data and Fit Sum Function (Residual)

MagicPlot offers two different ways to view the difference between data and Fit Sum function:

  • You can set Baseline checkboxes for all fit function components to subtract them from data and explore the residual plot

or

  • You can press and hold Residual button. The difference between data and Fit Sum function is shown while button is pressed. You can use either mouse or space key (if button is selected) to hold Residual button.

Fit One Curve

You can also use MagicPlot to fit the data with single selected Fit Curve by pressing Fit One Curve button. In this case a specific data interval for each Fit Curve is used and the main fitting data interval (set in Fit Interval tab) is ignored. Select Set Interval checkbox in the bottom of the Fit Plot panel to set specific fit intervals for each Fit Curve.

Because of using individual data interval this method is useful for baseline fitting. In order to fit baseline specify the intervals which does not contain signal (peaks) and contain only noise.

Joining the Parameters of Fit Curves

MagicPlot allows coupling of fit parameters. See Joining the Parameters of Fit Curves for details.

Fit Progress Window

MagicPlot indicates fit process with a special window. Fitting curves are periodically updated on plot while fitting so you can see how fit converges.

Fit progress window

MagicPlot shows current iteration number and deviation decrement with two progress bars while fit is performed. The fit process stops when one of these progress bars reaches the end.

You can see two buttons on fit progress window:

  • Break Iterations: Breaks iterations after current iteration. Use this button if you suspect that further iterations will not change the result.
  • Undo Fit: Breaks iterations and reverts fit parameters to their initial (before fit) values. Use this button if you see that fit process converges to wrong result; change initial values of parameters and run fit again.

Undoing Fit

You can undo fit and undo changing initial parameters as usual using Undo function. It is a handy feature when experimenting with different models and initial parameters.

See Also

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
fitting.1298468329.txt.gz · Last modified: Sun Nov 8 12:20:32 2015 (external edit)