# How to use Qnfit

How to use Qnfit for curve fitting

Before attemting to use QNFIT you should fit one a of the test files to see just how it works with properly formatted data. A good example would be to fit gauss3.tf1, selecting the expert mode, then fitting a sum of three Gaussian pdfs (spikes) with no constant term. Use the graphical deconvolution option to see how the best fit curve is composed of three independent contributing sub-functions. Also explore the option to calculate error bars interactively from data with replicates

You can curve-fit with sequences of models or the same model from different start estimates. You can decide to fix any of the parameters at constant values or else define windows, e.g.

         Lower limit =< Parameter value =< Upper limit

to constrain any sub-set of parameters. Once you have chosen a single model (or a model from a sequence) and decided upon appropriate parameter limits (and constraints), you can then start curve-fitting using the initial starting estimates, or give the program a chance to improve upon these by a random search within the window set by the parameter limits.

The program minimises the normalised weighted sum of squared residuals WSSQ/NDOF which has expectation unity at the solution point if the model is correct and accurate weights are used. It is assumed that you can suppy good estimates of standard errors of the data for weighting. Otherwise set all weights to unit (i.e. all s(i) = 1) and do unweighted regression. Supply all your observations in sequence, not as means and standard errors of means, or biased statistics will result. If you ever supply Simfit with data consisting of means of replicates rather than the original data, you are doing something wrong.

You can fit functions of 1, 2 or 3 independent variables or scalar differential equations, by selecting models from a dll library or by supplying models as ASCII text files.

For functions of 1 variable use MAKFIL to make a file like this:

         ... Title
         ... No. rows  No. columns (i.e.n, 3)
         ... x   f(x)   s.e.f(x)

Edit/weight such files using EDITFL.

For functions of 2 or 3 variables use MAKMAT for a file like

         ... Title
         ... No. rows  No. columns (e.g. n, 4)
         ... x   y   g(x,y)   s.e.g(x,y)

         or

         ... Title
         ... No. rows  No. columns (e.g.n, 5)
         ... x   y   z   h(x,y,z)   s.e.h(x,y,z)

Here n is the number of observations, x, y, z are values of the known independent variables (i.e error free) while f(x), g(x,y), h(x,y,z) are the observed function values (i.e. with experimental error) while the s.e. are the estimated standard errors for weighting w = 1/s.e.^2. Setting s.e. = 1 results in unweighted fitting.
Edit such files using EDITMT.

If possible, with k parameters, end data files like this

         begin{limits}
         lower limit 1   starting estimate 1   upper limit 1
         lower limit 2   starting estimate 2   upper limit 2
         lower limit 3   starting estimate 3   upper limit 3
         ...
         ...
         lower limit k   starting estimate k   upper limit k
         end{limits}

as with test file gauss3.tf1. Or you can end data files as follows

         ... last line of data ...
         No. extra lines (> k + 1)
         k
         lower limit 1   starting estimate 1   upper limit 1
         lower limit 2   starting estimate 2   upper limit 2
         lower limit 3   starting estimate 3   upper limit 3
         ...
         ...
         lower limit k   starting estimate k   upper limit k
                   ...

as with test file gauss3.tf2.
These techniques allow you to use EXPERT mode where defaults are read from the file but can still be over-ridden interactively. See other test files such as qnfit.tf1, qnfit.tf2, and qnfit.tf3 for examples.

# Configuring QNFIT

Here is a list of the configuration options that can be set when the program starts, or after a model has been fitted.

1. Best-fit model: display and file a short summary
   This summarises the results from optimisation and should always be switched on.

2. Best-fit model: display and file table of parameters
   This summarises the parameters and standard errors resulting from the optimisation and should always be switched on.

3. Best-fit model: plot data with best-fit curve
   For functions of one variable this should always be switched on.

   However, functions of two or three variables need more careful interpretation of the surfaces and contours and these facilities may not be be provided in this version.

4. Best-fit model: display and file correlation matrix
   Only needed by experienced users.

5. Best-fit model: display and file Hessian eigenvalues, etc.
   Only needed by very experienced users.

6. Table of residuals: display
   Probably only needed for relatively short data sets.

7. Table of residuals: file
   Certainly only needed for relatively short data sets.

8. Table of residuals: Save As ...
   Only needed by experts who wish to write the residuals to file for further analysis.

9. Analysis of residuals: display
   A useful summary that should always be switched on.

10. Analysis of residuals: file
    A useful summary that should always be written to the results file.

11. Analysis of residuals: display diagnostic plots
    A vital way to assess goodness of fit, especially the half normal plot.

12. Parameters: warning if there are a large number
    May be switched on for inexperienced users or group use to alert users to the possibility that an incorrect or over-determined model has been selected.

13. Parameters: display limits provided by data file
    Allows users to check limits supplied on the end of the data file using the begin{limits} ... end{limits} technique.

14. Parameters: display when at limits before fitting
    A reminder of variables that are fixed before fitting.

15. Parameters: display when at limits after fitting
    A warning about which parameters have reached limits.

16. Parameters: random search for starting estimates
    If the model is correct, the data extensive and accurate, and good starting estimates are available, this should not be used.
    It should only be used to explore parameter space for the possibility of several minima in the objective function, as in global optimisation.

17. Data: check for x not in increasing order, etc.
    This is automatically switched on for differential equations to be sure x is in non-decreasing order, which is assumed by the ODE solvers.
    It also checks for very large or very small data values, which suggests re-scaling, or for very large or very small signal to noise ratios, which suggest noisy or impossibly accurate data.
    So it could be switched on if convergence is not taking place.

18. Data: suppress or restore values interactively
    This offers users the chance to explore the effect of suppressing or restoring data points, e.g. possible outliers.

The initial defaults will be suitable for most purposes, but advanced users may wish to switch on appropriate additional options.

Back to Help Menu or End Help