fit: non-linear curve fitting

Usage:

fit -mac macro.M -pars "par1 par2 ..." [-nsims num_sims] [-iter num_iter] [-cf conf_level] [-tf tolerance] [-f] data_file

Description:

fit is a simpler interface to the modelXY provied as part of the nmrPipe package. The data in data_file is fit using the macro specified in macro.M as the equation to which the data should be fit. During the curve fitting, par1, par2, ... are used as the initial values for the parameters to the equation, with at most num_iter iterations of least-squares regression used to fit the data to the equation. num_sim Monte Carlo simulations are used to generate the conf_level confidence level. The relative tolerance of the function is specified by tolerance.

If the -f ("fake") flag is specified, the modelXY command is printed instead of being executed. This allows the user to capture the command and add other modelXY parameters that fit does not handle.

Options may be abbreviated to their shortest unique string.

Defaults:

Except for the -nsims option, which is set to 10 unless specified otherwise, all other optional parameters default the the same values given in the modelXY documentation.

The following locations will be searched, in the specified order, for the file macro.M. The current directory (or the absolute path if specified), the directories in the environment variable PIPEMACROLIB which is a colon-separated list of directories, and finally in /usr/groupS/lib/pipe. If the macro file is not found in any of those places, an error message is generated and the program terminates.

File formats:

The data file should consist of rows of data each of which has entries for the x and y points, and optionally a third column for the estimate of the noise for that point. If the noise is specified, it should be given for all points. On any line, everthing following a "#" is ignored Example:

	#  sample data
	1.205050 0.190500 0.011810
	0.020084 0.471300 0.017426
	0.903789 0.231500 0.012630
	0.100421 0.441600 0.016832
	0.702947 0.268600 0.013372
	0.200842 0.411800 0.016236
	0.502105 0.316500 0.014330
	0.351473 0.377600 0.015552
	

An annotated example macro file that could be used for linear fitting is given below.


	/* this is a comment */
	slope = pList[0];         /* the first parameter is the slope */
	intercept = pList[1];     /* the second parameter is the y intercept */

	/* xyCount is the number of data points */
	for(i = 0; i < xyCount ; i++) {
		/* for each x-point, calculate the (theoretical) y-point using the
		   slope and intercept that were passed in */
		yList[i] = slope * xList[i] + intercept;
	}
	

Example:

If the above data were in file.dat and the macro was called line.M, the data could be fit with twenty Monte Carlo simualtions using 1.0 as the initial guess for the value of both the slope and intercept with the following command:

fit -n 20 -m line.M -p "1 1" file.dat