1TREND1D(1) GMT TREND1D(1)
2
3
4
6 trend1d - Fit a [weighted] [robust] polynomial [and/or Fourier] model
7 for y = f(x) to xy[w] data
8
10 trend1d [ table ] -Fxymrw|p|P|c -Nparams [ xy[w]file ] [ -Ccondi‐
11 tion_number ] [ -I[confidence_level] ] [ -V[level] ] [ -W ] [
12 -bbinary ] [ -dnodata ] [ -eregexp ] [ -fflags ] [ -hheaders ] [
13 -iflags ] [ -:[i|o] ]
14
15 Note: No space is allowed between the option flag and the associated
16 arguments.
17
19 trend1d reads x,y [and w] values from the first two [three] columns on
20 standard input [or file] and fits a regression model y = f(x) + e by
21 [weighted] least squares. The functional form of f(x) may be chosen as
22 polynomial or Fourier or a mix of the two, and the fit may be made
23 robust by iterative reweighting of the data. The user may also search
24 for the number of terms in f(x) which significantly reduce the variance
25 in y.
26
28 -Fxymrw|p|P|c
29 Specify up to five letters from the set {x y m r w} in any order
30 to create columns of ASCII [or binary] output. x = x, y = y, m =
31 model f(x), r = residual y - m, w = weight used in fitting.
32 Alternatively, choose just the single selection p to output a
33 record with the polynomial model coefficients, P for the normal‐
34 ized polynomial model coefficients, or c for the normalized
35 Chebyshev model coefficients.
36
37 -N[p|P|f|F|c|C|s|S|x]n[,...][+llength][+oorigin][+r]
38 Specify the components of the (possibly mixed) model. Append
39 one or more comma-separated model components. Each component is
40 of the form Tn, where T indicates the basis function and n indi‐
41 cates the polynomial degree or how many terms in the Fourier
42 series we want to include. Choose T from p (polynomial with
43 intercept and powers of x up to degree n), P (just the single
44 term x^n), f (Fourier series with n terms), c (Cosine series
45 with n terms), s (sine series with n terms), F (single Fourier
46 component of order n), C (single cosine component of order n),
47 and S (single sine component of order n). By default the x-ori‐
48 gin and fundamental period is set to the mid-point and data
49 range, respectively. Change this using the +oorigin and
50 +llength modifiers. We normalize x before evaluating the basis
51 functions. Basically, the trigonometric bases all use the nor‐
52 malized x' = (2*pi*(x-origin)/length) while the polynomials use
53 x' = 2*(x-x_mid)/(xmax - xmin) for stability. Finally, append +r
54 for a robust solution [Default gives a least squares fit]. Use
55 -V to see a plain-text representation of the y(x) model speci‐
56 fied in -N.
57
59 table One or more ASCII [or binary, see -bi] files containing x,y [w]
60 values in the first 2 [3] columns. If no files are specified,
61 trend1d will read from standard input.
62
63 -Ccondition_number
64 Set the maximum allowed condition number for the matrix solu‐
65 tion. trend1d fits a damped least squares model, retaining only
66 that part of the eigenvalue spectrum such that the ratio of the
67 largest eigenvalue to the smallest eigenvalue is condition_#.
68 [Default: condition_# = 1.0e06. ].
69
70 -I[confidence_level]
71 Iteratively increase the number of model parameters, starting at
72 one, until n_model is reached or the reduction in variance of
73 the model is not significant at the confidence_level level. You
74 may set -I only, without an attached number; in this case the
75 fit will be iterative with a default confidence level of 0.51.
76 Or choose your own level between 0 and 1. See remarks section.
77 Note that the model terms are added in the order they were given
78 in -N so you should place the most important terms first.
79
80 -V[level] (more ...)
81 Select verbosity level [c].
82
83 -W Weights are supplied in input column 3. Do a weighted least
84 squares fit [or start with these weights when doing the itera‐
85 tive robust fit]. [Default reads only the first 2 columns.]
86
87 -bi[ncols][t] (more ...)
88 Select native binary input. [Default is 2 (or 3 if -W is set)
89 columns].
90
91 -bo[ncols][type] (more ...)
92 Select native binary output. [Default is 1-5 columns as given by
93 -F].
94
95 -d[i|o]nodata (more ...)
96 Replace input columns that equal nodata with NaN and do the
97 reverse on output.
98
99 -e[~]"pattern" | -e[~]/regexp/[i] (more ...)
100 Only accept data records that match the given pattern.
101
102 -f[i|o]colinfo (more ...)
103 Specify data types of input and/or output columns.
104
105 -h[i|o][n][+c][+d][+rremark][+rtitle] (more ...)
106 Skip or produce header record(s).
107
108 -icols[+l][+sscale][+ooffset][,...] (more ...)
109 Select input columns and transformations (0 is first column).
110
111 -:[i|o] (more ...)
112 Swap 1st and 2nd column on input and/or output.
113
114 -^ or just -
115 Print a short message about the syntax of the command, then
116 exits (NOTE: on Windows just use -).
117
118 -+ or just +
119 Print an extensive usage (help) message, including the explana‐
120 tion of any module-specific option (but not the GMT common
121 options), then exits.
122
123 -? or no arguments
124 Print a complete usage (help) message, including the explanation
125 of all options, then exits.
126
128 The ASCII output formats of numerical data are controlled by parameters
129 in your gmt.conf file. Longitude and latitude are formatted according
130 to FORMAT_GEO_OUT, absolute time is under the control of FOR‐
131 MAT_DATE_OUT and FORMAT_CLOCK_OUT, whereas general floating point val‐
132 ues are formatted according to FORMAT_FLOAT_OUT. Be aware that the for‐
133 mat in effect can lead to loss of precision in ASCII output, which can
134 lead to various problems downstream. If you find the output is not
135 written with enough precision, consider switching to binary output (-bo
136 if available) or specify more decimals using the FORMAT_FLOAT_OUT set‐
137 ting.
138
140 If a polynomial model is included, then the domain of x will be shifted
141 and scaled to [-1, 1] and the basis functions will be Chebyshev polyno‐
142 mials provided the polygon is of full order (otherwise we stay with
143 powers of x). The Chebyshev polynomials have a numerical advantage in
144 the form of the matrix which must be inverted and allow more accurate
145 solutions. The Chebyshev polynomial of degree n has n+1 extrema in [-1,
146 1], at all of which its value is either -1 or +1. Therefore the magni‐
147 tude of the polynomial model coefficients can be directly compared.
148 NOTE: The stable model coefficients are Chebyshev coefficients. The
149 corresponding polynomial coefficients in a + bx + cxx + ... are also
150 given in Verbose mode but users must realize that they are NOT stable
151 beyond degree 7 or 8. See Numerical Recipes for more discussion. For
152 evaluating Chebyshev polynomials, see gmtmath.
153
154 The -N...+r (robust) and -I (iterative) options evaluate the signifi‐
155 cance of the improvement in model misfit Chi-Squared by an F test. The
156 default confidence limit is set at 0.51; it can be changed with the -I
157 option. The user may be surprised to find that in most cases the reduc‐
158 tion in variance achieved by increasing the number of terms in a model
159 is not significant at a very high degree of confidence. For example,
160 with 120 degrees of freedom, Chi-Squared must decrease by 26% or more
161 to be significant at the 95% confidence level. If you want to keep
162 iterating as long as Chi-Squared is decreasing, set confidence_level to
163 zero.
164
165 A low confidence limit (such as the default value of 0.51) is needed to
166 make the robust method work. This method iteratively reweights the data
167 to reduce the influence of outliers. The weight is based on the Median
168 Absolute Deviation and a formula from Huber [1964], and is 95% effi‐
169 cient when the model residuals have an outlier-free normal distribu‐
170 tion. This means that the influence of outliers is reduced only
171 slightly at each iteration; consequently the reduction in Chi-Squared
172 is not very significant. If the procedure needs a few iterations to
173 successfully attenuate their effect, the significance level of the F
174 test must be kept low.
175
177 To remove a linear trend from data.xy by ordinary least squares, use:
178
179 gmt trend1d data.xy -Fxr -Np1 > detrended_data.xy
180
181 To make the above linear trend robust with respect to outliers, use:
182
183 gmt trend1d data.xy -Fxr -Np1+r > detrended_data.xy
184
185 To fit the model y(x) = a + bx^2 + c * cos(2*pi*3*(x/l) + d *
186 sin(2*pi*3*(x/l), with l the fundamental period (here l = 15), try:
187
188 gmt trend1d data.xy -Fxm -NP0,P2,F3+l15 > model.xy
189
190 To find out how many terms (up to 20, say in a robust Fourier inter‐
191 polant are significant in fitting data.xy, use:
192
193 gmt trend1d data.xy -Nf20+r -I -V
194
196 gmt, gmtmath, gmtregress, grdtrend, trend2d
197
199 Huber, P. J., 1964, Robust estimation of a location parameter, Ann.
200 Math. Stat., 35, 73-101.
201
202 Menke, W., 1989, Geophysical Data Analysis: Discrete Inverse Theory,
203 Revised Edition, Academic Press, San Diego.
204
206 2019, P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis, and F. Wobbe
207
208
209
210
2115.4.5 Feb 24, 2019 TREND1D(1)