This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
fitting [Wed Feb 16 14:43:25 2011] Alexander |
fitting [Thu Jan 14 17:18:27 2021] 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 a Fit Plot, select x and y columns in table, then select '' | ||
- | ' | + | ===== Creating a Fit Plot ===== |
+ | Nonlinear least squares data fitting (nonlinear regression) can be performed using Fit Plot. | ||
+ | To create a Fit Plot, select your X and Y columns in Table, then select '' | ||
+ | |||
+ | {{: | ||
+ | |||
+ | ==== 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 | ||
To fit the data, implement these steps: | To fit the data, implement these steps: | ||
- | - Create a Fit Plot, specify | + | - Create a Fit Plot, specify |
- 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 '' |
- | ===== Further reading | + | ==== Further reading ==== |
This manual does not completely cover the complex nonlinear fitting methodology. We recommend you to take a look at this book: | 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, | + | * H. Motulsky and A. Christopoulos, |
+ | |||
+ | {{:fit_example.png?nolink|Fit example}} | ||
===== Fit Function is a Sum of Fit Curves ===== | ===== 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 | + | MagicPlot considers fit function as a **sum** of Fit Curves. Ordinarily in peaks fitting each Fit Curve corresponds to one peak in experimental data. Click the '' |
- | Fit Plot window contains the list of Fit Curves. Each Fit Curve in the list has three checkboxes: | + | Fit Plot window contains the list of Fit Curves. Each Fit Curve in the list has three checkboxes: |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | Below the Fit Curves | + | {{: |
- | ===== Copying Fit Curves from One Fit Plot to Another ===== | + | * '' |
- | You can copy and paste Fit Curves in curves table as usual. Use context menu in curves table or press '' | + | * '' |
+ | * '' | ||
- | ===== Setting Initial Values of Parameters ===== | + | Below the Fit Curves list, is a parameters table which shows names, |
- | Nonlinear fitting assumes that certain initial | + | |
- | Initial parameters values | + | ==== Fitting by Sum and Fitting One Curve ==== |
+ | MagicPlot allows two alternatives buttons to run the fit: | ||
+ | * '' | ||
+ | * '' | ||
- | ===== Parameter Locking ===== | + | ==== Copying and Pasting Fit Curves |
- | 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 '' | + | 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. |
- | ===== Fit Intervals ===== | + | * The copy of Fit Curves with the same parameters and styles will be created if you paste Fit Curves to a Fit Plot. |
- | You can set the x intervals of the data. Data points outside these intervals are not used to compute | + | * A link to the source Fit Curves will be inserted |
- | Select '' | + | ==== Fit Curves Reordering ==== |
- | * Double click on interval to split it | + | You can reorder Fit Curves by dragging them in the table. The data curve is always drawn the first and fit sum is drawn the last. |
- | * Drag the interval border to move it. If intervals intersect, they will be merged | + | |
- | * Use context menu on the plot to create, delete | + | |
- | | {{: | + | ===== 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 the plot. Initial parameters values for each Fit Curve can also be set in the parameter table. | ||
- | ===== 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 '' | + | |
- | The most appropriate curve type for baseline fitting | + | ==== Adjusting Parameters with Mouse Wheel ==== |
+ | You can adjust Parameters in the table using mouse wheel scrolling when the mouse cursor | ||
- | 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, | + | ===== Guessing Peaks ===== |
+ | If you are fitting a spectrum with multiple peaks, MagicPlot may automatically add and approximately locate peaks before fitting. See [[guess_peaks]] for details. Guessed peaks should be used only as of the initial estimate for fitting: don't forget to click the Fit button after peaks are added. | ||
- | ===== ' | + | ===== Parameter Locking |
- | The ' | + | You can lock (fix) parameter(s) |
- | It is ' | + | {{: |
- | Use ' | + | ===== Parameters Joining ===== |
+ | MagicPlot allows joining (sometimes referred | ||
- | ===== Viewing the Difference between | + | ===== Weighting of Data Points Using Y Errors |
- | MagicPlot | + | MagicPlot |
- | * You can set '' | + | |
- | or | + | |
- | * You can press and hold '' | + | |
- | ===== Fit One Curve ===== | + | Weights are calculated as '' |
- | You can also use MagicPlot to fit the data with single selected Fit Curve by pressing | + | |
- | Because of using individual data interval this method is useful | + | Weights must be positive and finite |
- | ===== Joining the Parameters of Fit Curves | + | ===== Specifying |
- | 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, | + | 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 (especially |
- | To join parameters of two or more Fit Curves select one of desired Fit Curves, select desired parameter in parameters table and press '' | + | Select |
+ | * Double click on the 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 | ||
- | Joined parameters | + | **Note:** Data intervals from the '' |
- | ===== Fitting Algorithm ===== | + | {{: |
- | MagicPlot uses iterative [[wp> | + | |
- | Fit procedure iteratively varies the parameters // | + | ===== 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 '' | ||
- | < | + | Note that if you use data processing |
- | here: | + | ===== ' |
- | * // | + | The ' |
- | * //N// is total number of points, | + | |
- | * //f//(//x, β< | + | |
- | * //p// is the number of fit parameters // | + | |
- | * // | + | |
- | < | + | Use ' |
- | Calculation of the new guess of parameters on each fit iteration is based on the fit function | + | ===== Viewing |
+ | Residual means here the difference between initial data, baseline | ||
+ | * Press and hold the '' | ||
+ | * You can either set '' | ||
- | < | + | ===== Fitting ===== |
+ | To execute the fit click the '' | ||
- | To start minimization, | + | MagicPlot indicates |
- | ==== Fit Procedure Stop Criteria ==== | + | {{:fit_progress.png? |
- | After each iteration except the first MagicPlot evaluates //deviation decrement D//: | + | |
- | <m>D = delim{|} {{chi^2}_{curr. iter.} / {chi^2}_{prev. iter.} – 1} {|}</ | + | MagicPlot |
- | + | ||
- | Deviation decrement | + | |
- | + | ||
- | The iterative fit procedure stops on 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 in Fitting tab of MagicPlot Preferences. | + | |
- | + | ||
- | ===== 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 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: | You can see two buttons on fit progress window: | ||
Line 130: | Line 123: | ||
* '' | * '' | ||
- | ===== Weighting of y data ===== | + | ===== Fitting One Curve ===== |
- | MagicPlot | + | You can use MagicPlot |
- | * If standard //y// errors are **not** specified: all // | + | |
- | * If standard //y// errors // | + | |
- | + | ||
- | < | + | |
- | + | ||
- | here //C// is normalizing coefficient (to make the sum of // | + | |
- | + | ||
- | < | + | |
- | + | ||
- | In '' | + | |
- | * Get y errors from table column(s), | + | |
- | * Percent of data for every point, | + | |
- | * Fixed value or Standard deviation --- do not use in weighting because in this case the error values are the same for all data points. | + | |
- | + | ||
- | ===== Undoing | + | |
- | 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 (e.g. peaks positions). | + | |
+ | Because of using individual data interval this method is useful for baseline fitting. In order to fit baseline specify the intervals which do not contain signal (peaks) and contain only noise. | ||
+ | {{: | ||
- | ===== 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 // | + | |
- | | Residual Standard Deviation | + | |
- | | [[wp> | + | |
- | | Adjusted // | + | |
- | | Covariance Matrix of Parameters // | + | |
- | | Standard Deviation of Parameters // | + | |
- | | Correlation Matrix of Parameters // | + | |
===== 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]] |