This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
fitting [Tue Oct 26 14:17:16 2010] Alexander |
fitting [Tue Apr 7 17:12:13 2020] Alexander |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Nonlinear Curve Fitting: Fit Plot ====== | ====== Nonlinear Curve Fitting: Fit Plot ====== | ||
- | Nonlinear least squares data fitting can be performed using Fit Plot. | ||
- | To create Fit Plot select x and y columns in table, then select '' | ||
- | 'Nonlinear' means here that analytical | + | ===== Creating a Fit Plot ===== |
+ | Nonlinear | ||
+ | To create | ||
- | To fit the data you must implement these steps: | + | {{: |
- | - Create Fit Plot, specify | + | |
+ | ==== MagicPlot has been verified with NIST Datasets ==== | ||
+ | National Institute of Standards and Technology (NIST) has created the Statistical Reference Datasets Project which includes [[http:// | ||
+ | |||
+ | ===== Fitting Methodology ===== | ||
+ | ' | ||
+ | Fit procedure iteratively varies the parameters of the fit function to minimize the residual sum of squares. The nonlinear fitting algorithm needs the user to set the initial values of fit parameters. | ||
+ | |||
+ | To fit the data, implement these steps: | ||
+ | - Create | ||
- Specify fit function by adding Fit Curves | - Specify fit function by adding Fit Curves | ||
- Specify initial values of fit parameters (drag curves or enter accurate values) | - Specify initial values of fit parameters (drag curves or enter accurate values) | ||
- | - Specify used x data interval | + | - Specify used X data interval |
- Run fitting | - Run fitting | ||
- | {{: | + | You can undo fit and also undo changing initial parameters as any other action using '' |
- | ===== Fit Function is a Sum of Fit Curves ===== | + | ==== Further reading |
- | MagicPlot considers fit function as a **sum** of Fit Curves. Ordinarily in peaks fitting each Fit Curve corresponds | + | This manual does not completely cover the complex nonlinear fitting methodology. We recommend you to take a look at this book: |
- | Fit Plot window contains the list of Fit Curves. Each Fit Curve in the list has 3 check boxes: '' | + | * H. Motulsky and A. Christopoulos, //Fitting Models to Biological Data Using Linear and Nonlinear Regression: A Practical Guide to Curve Fitting, 2004.// |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | Below the Fit Curves list is parameters table which shows parameters names, values, descriptions of the selected Fit Curve. | + | {{: |
- | ===== Coping | + | ===== Fit Function is a Sum of Fit Curves |
- | You can copy and paste Fit Curves in curves table as usual. Use context menu in curves table or press '' | + | MagicPlot considers fit function as a **sum** of Fit Curves. Ordinarily |
- | ===== Setting Initial Values | + | Fit Plot window contains the list of Fit Curves. |
- | Nonlinear fitting assumes that certain initial values of parameters are set before fitting. This procedure is just easy if you use predefined | + | |
- | Initial parameters values for each Fit Curve can also be set in parameters | + | {{: |
- | ===== Parameter Locking ===== | + | * '' |
- | You can lock parameter(s) | + | * '' |
+ | * '' | ||
- | ===== Fit Intervals ===== | + | Below the Fit Curves list, is a parameters table which shows names, values, and descriptions |
- | You can set the x intervals | + | |
- | Select | + | ==== Fitting by Sum and Fitting One Curve ==== |
- | * Double click on interval to split it | + | MagicPlot allows two alternatives buttons to run the fit: |
- | * Drag the interval border to move it. If intervals intersect, intervals | + | * '' |
- | * Use context menu on the plot to create, delete and split intervals | + | * '' |
- | | {{: | + | ==== 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. | ||
- | ===== Baseline Fitting and Extraction ===== | + | * The copy of Fit Curves with the same parameters |
- | Fit Interval is also usable when baseline fitting. Before baseline fitting you can specify | + | * A link to the source Fit Curves will be inserted if you paste Fit Curves in a Figure. |
- | The most usable | + | ==== Fit Curves Reordering ==== |
+ | You can reorder Fit Curves by dragging them in the table. | ||
- | Note that if you execute one of data processing algorithms | + | ===== Setting Initial Values of Parameters ===== |
+ | Nonlinear fitting assumes | ||
- | ===== ' | + | {{: |
- | The ' | + | |
- | It is 'Data-Baseline' | + | ==== Adjusting Parameters with Mouse Wheel ==== |
+ | You can adjust Parameters in the table using mouse wheel scrolling when the mouse cursor | ||
- | Use ' | + | ===== Guessing Peaks ===== |
+ | If you are fitting a spectrum with multiple peaks, MagicPlot may automatically add and approximately locate peaks before fitting (Pro edition only). See [[guess_peaks]] for details. Guessed peaks should be used only as of the initial | ||
- | ===== Fit One Curve ===== | + | ===== Parameter Locking |
- | You can also use MagicPlot | + | You can lock (fix) parameter(s) |
- | ===== Joining the Parameters of Fit Curves ===== | + | {{: |
- | In some cases you may want to fit the data with two Gauss or Lorentz peaks with the same width but different positions and amplitudes, for example. You can do this in two ways: by specifying custom Fit Curve with your equation or by //joining// the ' | + | |
- | To join parameters of two or more Fit Curves | + | ===== Parameters Joining ===== |
+ | MagicPlot allows joining (sometimes referred to as coupling, binding, linking) of fit parameters of different | ||
- | Joined parameters are showed with blue color (instead | + | ===== Weighting |
+ | MagicPlot allows the weighting of data points with Y error data. You can specify Y error data in Fit Plot properties dialog. If no Y error data are specified weighting is not used. | ||
- | ===== Fitting Algorithm ===== | + | Weights are calculated as '' |
- | MagicPlot uses iterative [[wp>Levenberg–Marquardt_algorithm|Levenberg–Marquardt]] | + | |
- | Fit procedure iteratively varies | + | Weights must be positive and finite for all points so the Y error values must be positive and non-zero |
- | < | + | ===== Specifying Fit Intervals ===== |
+ | You can set the X intervals of the data which will be used for fitting. Data points outside these intervals are not used to compute the minimizing residual sum of squares. You can use this feature if some data points | ||
- | here: | + | Select '' |
- | * // | + | * Double click on the interval to split it |
- | * //N// is total number of points, | + | * Drag the interval border to move it. If intervals intersect, they will be merged |
- | * //f//(//x, β< | + | * Use context menu on the plot to create, delete and split intervals |
- | * //p// is the number of fit parameters // | + | |
- | * // | + | |
- | < | + | **Note:** Data intervals from the '' |
- | The calculation of the new guess of parameters on each fit iteration is based on the fit function partial derivatives for current values of fit parameters and for each x value: | + | {{:interval_context_menu1.png? |
- | < | + | ===== 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 '' | ||
- | To start minimization, you have to provide an initial guess for the parameters. | + | Note that if you use data processing (integration, FFT, etc.) on Fit Plot, then the difference between the data and baseline curves (which |
- | ==== Fit Procedure Stop Criteria | + | ===== ' |
- | After each iteration except | + | The ' |
- | <m>D = delim{|} {{chi^2}_{curr. iter.} / {chi^2}_{prev. iter.} – 1} {|}</ | + | Use 'Data-Baseline' |
- | + | ||
- | Deviation decrement shows how the residual sum of squares (< | + | |
- | + | ||
- | The iterative fit procedure stops on the one of two conditions: | + | |
- | * If the deviation decrement //D// is less than minimum allowable deviation decrement, which is 10< | + | |
- | or (and) | + | |
- | * If the number of iterations exceeds maximum number of iterations, which is 100 by default | + | |
- | + | ||
- | You can change the minimum allowable deviation decrement and maximum number of iterations | + | |
- | + | ||
- | ==== 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. | + | |
- | + | ||
- | {{: | + | |
- | + | ||
- | MagicPlot shows current iteration number and deviation decrement by two progress bars while fit is performed. The fit process | + | |
- | + | ||
- | Two buttons are located on fit progress window: | + | |
- | * '' | + | |
- | * '' | + | |
- | ===== Weighting of y data ===== | + | ===== Viewing the Residual Plot ===== |
- | MagicPlot | + | Residual means here the difference between initial data, baseline function and Fit Sum function. |
- | * If standard //y// errors are **not** specified: all // | + | * Press and hold the '' |
- | * If standard //y// errors // | + | * You can either set '' |
- | < | + | ===== Fitting ===== |
+ | To execute the fit click the '' | ||
- | here //C// is normalizing coefficient (to make the sum of // | + | MagicPlot indicates |
- | < | + | {{: |
- | In '' | + | MagicPlot shows the current iteration number and deviation |
- | * Get y errors from table column(s), | + | |
- | * Percent of data for every point, | + | |
- | * Fixed value or Standard | + | |
- | ===== Calculation of Standard Deviation of Fit Parameters ===== | + | You can see two buttons on fit progress window: |
- | The standard deviations (//std. dev.//) of fit parameters | + | * '' |
+ | * '' | ||
- | < | + | ===== Fitting One Curve ===== |
+ | You can use MagicPlot to fit the data with single selected Fit Curve by pressing '' | ||
- | here α is the matrix | + | Because |
- | < | + | {{: |
- | ===== Formulas | + | ===== Why My Fit is Not Converged? |
- | In the table below you can find the formulas which MagicPlot uses to calculate | + | In some cases, |
- | Because | + | === The origin |
+ | * Fit is not converged through one or more parameters: | ||
+ | * Mutual dependency exists between some parameters. The algorithm cannot resolve which parameter to vary. | ||
+ | * Fit function is ill-conditioned: | ||
+ | * Numeric overflow | ||
- | ^ Parameter Name ^ Symbol | + | === Try one of the following: |
- | ^ Original Data and Fit Model Properties | + | |
- | | Number | + | |
- | | Fit parameters | + | |
- | | Number of fit function parameters //β// | < | + | |
- | | [[wp> | + | |
- | | Estimated mean of data | < | + | |
- | | Estimated variance of data | < | + | |
- | | Data total sum of squares, TSS | TSS | < | + | |
- | ^ Fit Result | + | |
- | | Residual sum of squares, < | + | |
- | | Reduced // | + | |
- | | Standard deviation of the model | //s// | < | + | |
- | | [[wp> | + | |
- | | Adjusted // | + | |
===== See Also ===== | ===== See Also ===== | ||
+ | * [[fit_formulas]] | ||
* [[custom_fit_equation]] | * [[custom_fit_equation]] | ||
* [[spline]] | * [[spline]] | ||
+ | * [[joining]] | ||
* [[guess_peaks]] | * [[guess_peaks]] | ||
* [[fit_equations]] | * [[fit_equations]] | ||
- | * [[transform_xy]] | ||
* [[interval_statistics]] | * [[interval_statistics]] | ||
+ | * [[table_from_curves]] |