GMTREGRESS(1gmt) | GMT | GMTREGRESS(1gmt) |

*table*- One or more ASCII (or binary, see
**-bi**[*ncols*][*type*]) data table file(s) holding a number of data columns. If no tables are given then we read from standard input. The first two columns are expected to contain the required*x*and*y*data. Depending on your**-W**and**-E**settings we may expect an additional 1-3 columns with error estimates of one of both of the data coordinates, and even their correlation.

**-A***min*/*max*/*inc*- Instead of determining a best-fit regression we explore the
full range of regressions. Examine all possible regression lines with
slope angles between
*min*and*max*, using steps of*inc*degrees [-90/+90/1]. For each slope the optimum intercept is determined based on your regression type (**-E**) and misfit norm (**-N**) settings. For each segment we report the four columns*angle*,*E*,*slope*,*intercept*, for the range of specified angles. The best model parameters within this range are written into the segment header and reported in verbose mode (**-V**).

**-C***level*- Set the confidence level (in %) to use for the optional
calculation of confidence bands on the regression [95]. This is only used
if
**-F**includes the output column**c**.

**-Ex**|**y**|**o**|**r**- Type of linear regression, i.e., select the type of misfit
we should calculate. Choose from
**x**(regress*x*on*y*; i.e., the misfit is measured horizontally from data point to regression line),**y**(regress*y*on*x*; i.e., the misfit is measured vertically [Default]),**o**(orthogonal regression; i.e., the misfit is measured from data point orthogonally to nearest point on the line), or**r**(Reduced Major Axis regression; i.e., the misfit is the product of both vertical and horizontal misfits) [**y**].

**-F***flags*- Append a combination of the columns you wish returned; the
output order will match the order specified. Choose from
**x**(observed*x*),**y**(observed*y*),**m**(model prediction),**r**(residual = data minus model),**c**(symmetrical confidence interval on the regression; see**-C**for specifying the level),**z**(standardized residuals or so-called*z-scores*) and**w**(outlier weights 0 or 1; for**-Nw**these are the Reweighted Least Squares weights) [**xymrczw**]. As an alternative to evaluating the model, just give**-Fp**and we instead write a single record with the model parameters*npoints xmean ymean angle misfit slope intercept sigma_slope sigma_intercept*.

**-N1**|**2**|**r**|**w**- Selects the norm to use for the misfit calculation. Choose
among
**1**(L-1 measure; the mean of the absolute residuals),**2**(Least-squares; the mean of the squared residuals),**r**(LMS; The least median of the squared residuals), or**w**(RLS; Reweighted Least Squares: the mean of the squared residuals after outliers identified via LMS have been removed) [Default is**2**]. Traditional regression uses L-2 while L-1 and in particular LMS are more robust in how they handle outliers. As alluded to, RLS implies an initial LMS regression which is then used to identify outliers in the data, assign these a zero weight, and then redo the regression using a L-2 norm.

**-S**[**r**]- Restricts which records will be output. By default all data
records will be output in the format specified by
**-F**. Use**-S**to exclude data points identified as outliers by the regression. Alternatively, use**-Sr**to reverse this and only output the outlier records.

**-T***min*/*max*/*inc*|**-T***n*- Evaluate the best-fit regression model at the equidistant
points implied by the arguments. If
**-T***n*is given instead we will reset*min*and*max*to the extreme*x*-values for each segment and determine*inc*so that there are exactly*n*output values for each segment. To skip the model evaluation entirely, simply provide**-T**0.

**-W**[**w**][**x**][**y**][**r**]- Specifies weighted regression and which weights will be
provided. Append
**x**if giving 1-sigma uncertainties in the*x*-observations,**y**if giving 1-sigma uncertainties in*y*, and**r**if giving correlations between*x*and*y*observations, in the order these columns appear in the input (after the two required and leading*x*,*y*columns). Giving both**x**and**y**(and optionally**r**) implies an orthogonal regression, otherwise giving**x**requires**-Ex**and**y**requires**-Ey**. We convert uncertainties in*x*and*y*to regression weights via the relationship weight = 1/sigma. Use**-Ww**if the we should interpret the input columns to have precomputed weights instead. Note: residuals with respect to the regression line will be scaled by the given weights. Most norms will then square this weighted residual (**-N1**is the only exception).

**-V**[*level*] (more ...)- Select verbosity level [c].

**-a***col*=*name*[*...*] (more ...)- Set aspatial column associations
*col*=*name*.

**-bi**[*ncols*][**t**] (more ...)- Select native binary input.

**-bo**[*ncols*][*type*] (more ...)- Select native binary output. [Default is same as input].

**-d**[**i**|**o**]*nodata*(more ...)- Replace input columns that equal
*nodata*with NaN and do the reverse on output.

**-e**[**~**]*"pattern"***|****-e**[**~**]/*regexp*/[**i**] (more ...)- Only accept data records that match the given pattern.

**-g**[**a**]**x**|**y**|**d**|**X**|**Y**|**D**|[*col*]**z**[+|-]*gap*[**u**] (more ...)- Determine data gaps and line breaks.

**-h**[**i**|**o**][*n*][**+c**][**+d**][**+r***remark*][**+r***title*] (more ...)- Skip or produce header record(s).

**-i***cols*[**+l**][**+s***scale*][**+o***offset*][,*...*] (more ...)- Select input columns and transformations (0 is first column).

**-o***cols*[,...] (more ...)- Select output columns (0 is first column).

**-^**or just**-**- Print a short message about the syntax of the command, then
exits (NOTE: on Windows just use
**-**).

**-+**or just**+**- Print an extensive usage (help) message, including the explanation of any module-specific option (but not the GMT common options), then exits.

**-?**or no arguments- Print a complete usage (help) message, including the explanation of all options, then exits.

gmt regress points.txt -Fxymc -C99 > points_regressed.txt

slope=`gmt regress points.txt -Fp -o5`

gmt regress rough.txt -Fxymw > points_regressed.txt

gmt regress crazy.txt -Eo -Fxymz -i0-1l > points_regressed.txt

gmt regress points.txt -A0/90/0.2 -Eo -Nr > points_analysis.txt

June 26, 2017 | 5.4.2 |