**tablsqfit
in=**table-file [parameter=value]

The
inputfile is an ascii file in a tabular format, where on every line there
must be an assigned column for the X- and Y-coordinates. An optional column
can be assigned to the errors in Y (the DY-coordinates). If no DY-column is
assigned, it is assumed that the errors in Y are all the same and equal
to 1. Lines starting with the ’#’ symbol are comment lines. Certain models
(see **fit=** below) allow multiple X or Y columns. For **fit=line** a proper goodness-of-fit
is also computed in a second fit an error column (**dycol=**) is given.

For
most linear functions the non-linear version of this program will also work
fine, and has the added power that certain parameters can be fixed, and
error estimates are returned. See *tabnllsqfit(1NEMO)*
.

**in=***in-file*- (ascii) input file, a table of values from which data is taken. No default.
**xcol=***col,...*- The column(s) from which the (independant) X-values are taken.
The first column is called 1 by definition [default:
**1**]. **ycol=***col,...*- The column(s)
from which the (dependant) Y-values are taken [default:
**2**]. **dxcol=***int*- Optional column from which the DX-values (errors in X) are taken. Currently only a straight line fit can use this option. See below.
**dycol=***int*- Optional column from which the DY-values (errors in Y) are taken. The inverse square of the errors are uses as weights for those fits where these are used [default: none assigned].
**xrange=***xmin:xmax*- Range in X-values for which the fit is done. If only one number is given, the other one is considered zero. [default: no entry, i.e. all].
**fit=***model*- Model name what to fit. Currently implemented
are
*line*,*plane*,*poly*,*ellipse*,*peak*,*zero*,*imageshift*,*area*,*gauss1d*, and*gauss2d*. [default:**line**]. **order=***order*- Highest order of the polynomial
fit (
**fit=poly**) or dimension of the hyper-plane fit (**fit=plane**). 0 would fit a constant. 0 and 1 would have the same meaning in both the**plane**and**poly**cases [Default:**0**]. - out=
*filename* - Optional output filename (only active
under certain options) where the data and residuals are stored. Column 1,
2 and 3 will contain the X, Y and residuals F(X)-Y respectively. A future
release will also store the errors (if it was given, see keyword
**dycol**above) in the 4th column. [default: empty, no output file created]. - nsigma=
*sigma_factor* - A positive number will delete points more than
*sigma_factor*from the fit, and fit again. [Default:**-1**]. **estimate=**- Optional estimate for parameters of non-linear fits
**nmax=***max_lines*- Maximum number of lines allocated if the
input file was being read from a pipe. If not, the routine
*file_lines(3NEMO)*is used to allocate space for the table. [Default:**10000**]. **mpfit=***mode*- The
fitting mode in which
*mpfit(3NEMO)*is used. 0=no errors. 1=only errors in X used (dxcol=), 2=only errors in Y used (dycol=), 3=errors in both X and Y used. See also*linreg(1NEMO)*. **tab=t|f**- Output results in simple tabular format. Default: false.

% nemoinp 1:100 | tabmath - - "%1+rang(0,10),ranu(1,2)" seed=123 | tablsqfit - a = 0.974146 uncertainty: 0.039389 b = 1.755022 uncertainty: 2.291149 x0 = -1.801599 uncertainty: 2.353083 y0 = 1.755022 uncertainty: 2.291149 chi-squared: 12668.983284 goodness-of-fit: 1.000000 (no Y errors supplied [dycol=]) r: 0.92923 prob: 3.65557e-44 z: 1.65272The fitted line is written either as

mpfit: http://www.physics.wisc.edu/~craigm/idl/cmpfit.html (author: Craig B. Markwardt)

http://arxiv.org/abs/1008.4686:
*Data analysis recipes:
Fitting a model to data P (Hogg, Bovy & Lang 2010)
*

~/src/kernel/tabtablsqfit.c

5-Aug-87V1.0 createdPJT 18-May-88V1.4 various new optionsPJT 31-May-88V2.0 ’float’-> ’double’ for NumRecPJT 14-nov-91V2.4 ellips fit and various othersPJT 13-Mar-92V2.5 added imageshift optionPJT 15-nov-93V2.6 added nmax=PJT 13-jun-94V2.7 code overhaul to add line/polyPJT 8-jun-95V2.8 added option fit=peakPJT 26-jan-98V2.9 added goodness-of-fit for fit=linePJT 4-feb-98V2.9a compute r (corr.coeff.) for line fitPJT 14-aug-00V3.0 added tab=PJT 8-aug-01V3.1c added area, using natof, error in ellipsePJT 24-feb-03V3.4: added fit=zeroPJT 21-nov-05V3.4b: added fit=gauss1d,gauss2dPJT 9-dec-09V4.0: added xcol= and mpfit=PJT