This dialog is activated by selecting the command Fit Wizard from the Fitting -> Analysis menu. This command is active if a plot or a table window is selected. In the latter case, this command first creates a new plot window using the list of selected columns in the table.
This dialog is used to fit discrete data points with a mathematical function. The fitting is done by minimizing the least square differences between the data points and the Y values of the function, see the Data Fitting section of the Analysis chapter for more details.
Figure 5-153. The first step of the Fit Wizard dialog box.
This first step is used to define the function which will be used for fitting. When you are ready
to perform the fit, click on the button to activate the Fitting Session.
The top of the dialog box is used to select one of the three Categories of functions:
functions which have been previously edited and saved by the user.
the fit models provided by QtiPlot in the from the Fitting -> Analysis menu.
simple elementary functions.
To choose a function, first select a category and then the desired function from the displayed Function list.
If the selected function is from the Built-in category and you wish to perform the fit operation using the selected built-in model, you must check the option Fit using built-in function. This will clear the contents of the edit text pane (see image below) and copy the selected function into it.
If the selected built-in model is one of the following peak shape functions: Gauss, GaussAmp, Lorentz, Peaks, PsdVoigt1 or PsdVoigt2, the Peaks input box becomes available, allowing to choose the number of individual peaks for a multi-peak fit operation.
The Peaks built-in fit model is only available in the Pro edition of QtiPlot. If this fit model is selected the Profiles box becomes visible and can be used to customize the profile of each peak, making possible to perform a multi-peak fit with mixed peak profiles.
When the selected built-in model is the Polynomial function the Polynomial order input box becomes available, allowing to choose the order of the polynomial fit function.
If you wish to define your own fit model, the Fit using built-in function option
should be unchecked. In this case you can also click the Add expression button
to copy the selected function at the current cursor position. If you've
selected one of the Basic functions, there are no checkboxes/options available and you need
to use the Add expression button.
The bottom half of the dialog box allows to define your own fit models. You can either write your own
mathematical expressions from scratch or add expressions from the function selector with the help of the
Σ button. When pressing this button a menu pops-up listing all basic mathematical functions provided by QtiPlot.
Selecting one of the actions from this menu copies the displayed function into the edit box at the position of the text
cursor. Clicking the Clear button removes the contents of the function definition text
box.
It is worth mentioning that it is possible to write the name of a basic mathematical function or of a built-in/user defined fit model in the editing panel and after the first two characters QtiPlot pops-up a case sensitive selection list for a faster editing process. The names of built-in/user defined fit models are automatically replaced with their analytical expression.
Once a custom expression is completed, clicking on the Save button
adds the function to the list of user defined fit models. The text in the Name field is used
as the title of the function. A copy of the function is saved on disk with the extension .fit. You can define
the folder where .fit files are saved using either the Choose models folder... button
(shown only when "User defined" is selected) or by selecting a new folder in the Save file dialog. Functions can
be removed from the User Defined list by selecting them and clicking on the
Remove button. You will be asked to confirm the deletion.
In this second step a starting point should be provided for the fit parameters via the
Value column of the Parameters table.
The initial values of the fit parameters are by default set to 1.0.
The built-in fit models provide a guessing mechanism for the initial values of the parameters.
These guesses can be displayed by pressing the button.
Boundary constraints can be defined for the fit parameters if the Range box is checked. This shows the From and To columns of the parameters table. It is also possible to keep the value of some parameters constant during the iterative fit process by checking their corresponding box from the Fixed column. If all the boxes from the Fixed column are checked QtiPlot raises an error message informing that there are no free parameters and that the fit operation cannot be performed.
Figure 5-154. The Fit Wizard dialog box: providing initial guesses for the fit parameters and defining constraints.
The numerical format used to display the results of the fit operations can be chosen from the Format list box. The value set in the Precision input box has a different meaning depending on the numeric format. The following format and precision options are available:
Decimal or scientific e-notation, whichever is the most concise. The Precision value represents the maximum number of significant figures in the output (trailing zeroes are omitted).
Decimal notation. The Precision value represents the number of digits after the decimal point.
Scientific e-notation where the letter e
is used to represent "times ten raised to the power of" and is followed by the value of the exponent. The Precision value represents the number of digits after the decimal point.
Scientific e-notation where the letter E
is used to represent "times ten raised to the power of" and is followed by the value of the exponent. The Precision value represents the number of digits after the decimal point.
In the Data Set tab you can choose the input data set(s) and also choose a weighting method for your fit (the default is No weighting). The available weighting methods are:
No weighting: all weighting coefficients are set to 1 (wi = 1).
Instrumental: the values of the associated error bars are used as weighting coefficients wi = 1/eri2, where eri are the error bar sizes stored in error bar columns. You must add error bars to the analyzed curve before performing the fit.
Statistical: the weighting coefficients are calculated as wi = 1/yi, where yi are the y values in the fitted data set.
Arbitrary Dataset: allows setting the weighting coefficients using an arbitrary data set wi = 1/ci2, where ci are the values in the arbitrary data set. The column used for the weighting must have a number of rows equal to the number of points in the fitted curve.
Direct Weighting: allows setting the weighting coefficients using an arbitrary data set wi = ci, where ci are the values in the arbitrary data set. The column used for the weighting must have a number of rows equal to the number of points in the fitted curve.
In the Algorithm tab you can choose the type of solver as well as a maximum number of Iterations and a Tolerance value. The last two parameters are stopping criteria for the iterative fit process.
The available algorithms are: Scaled Levenberg-Marquardt (obsolete), Unscaled Levenberg-Marquardt (obsolete), Nelder-Mead simplex and Levenberg-Marquardt (MPFIT). The first two algorithms are obsolete and will be removed in a future release of QtiPlot. The Levenberg-Marquardt (MPFIT) algorithm is provided by the MPFIT library. It is the default solver, since it allows defining constant fit parameters for the built-in fit functions. It also handles better the boundary constraints for the fit parameters. In exchange, it cannot be used with plugin fit models. Therefore, the support for plugin fit models will be also dropped, simultaneously with the obsolete fit algorithms.
It is possible to specify how the fit operation responds to modifications of the source data curve using the Recalculate list box. The available options are:
- No recalculation when data changes, the fit object is deleted from memory when the operation ends.
- A recalculation is automatically performed when input data changes.
- No recalculation is triggered when data changes, instead you can perform a recalculation at any time by pressing the Recalculate button from the Analysis tab of the plot details dialog.
The recalculation mode can be changed later on via the Analysis tab of the plot details dialog.
Depending on the settings in the Custom Output tab, a function curve (option Uniform X Function) or a new table (if you choose the option Same X as Fitting Data) will be created for each fit. The new table includes all the X and Y values used to compute and to plot the fitted function and is hidden by default. It can be found in and viewed from the project explorer.
After the fit, if the Write Parameters to Result Log box from the Options group is checked, the log window is opened to show the results of the fitting process.
The options in the Curves group box can be used to specify if some additional plot curves should be generated after each fit operation. If the Conf. Bands and Pred. Bands options are checked QtiPlot generates confidence bands and prediction bands for the current fit, based on the user defined value for the confidence level. If the Residuals Plot option is checked the curve of the fit residuals is also displayed. The residuals are calculated as the difference between the experimental Yi values and the response values predicted by the fit model.
The controls in the Parameters Output group box can be used in order to define the options for the display of the results from data fit operations.
The errors on the fit parameters are displayed in the log window only if the Error box from the Results Log group is checked. The Scale Errors with sqrt(Chi^2/doF) option only affects the errors on the parameters reported after the fit operation. It does not affect the fitting process or the data in any way. If checked, the reported errors on the parameters, εj, are calculated as the square root of the diagonal elements of the covariance matrix Cov(j, j) multiplied with sqrt(Chi2/(n - p)), where n is the number of data points and p the number of fit parameters. Otherwise, the reported errors equal the square root of the diagonal elements of the covariance matrix Cov(j, j).
If the LCL and UCL options from the Results Log group box are checked QtiPlot also displays the confidence limits for each fit parameter based on the value of the confidence level specified in the Curves box.
After the fit, a series of statistics are displayed in the log window allowing evaluation of the goodness of fit. The controls in the Statistics group box can be used to specify which of these fit statistics should be displayed by default. For more details about these values please visit the Data fiting section from the chapter dedicated to the Analysis of data and curves.