1TREND1D(1) Generic Mapping Tools TREND1D(1)
2
3
4
6 trend1d - Fit a [weighted] [robust] polynomial [or Fourier] model for y
7 = f(x) to xy[w] data.
8
10 trend1d -Fxymrw -N[f]n_model[r] [ xy[w]file ] [ -Ccondition_number ] [
11 -H[i][nrec] ] [ -I[confidence_level] ] [ -V ] [ -W ] [ -:[i|o] ] [
12 -b[i|o][s|S|d|D[ncol]|c[var1/...]] ] [ -f[i|o]colinfo ]
13
15 trend1d reads x,y [and w] values from the first two [three] columns on
16 standard input [or xy[w]file] and fits a regression model y = f(x) + e
17 by [weighted] least squares. The functional form of f(x) may be chosen
18 as polynomial or Fourier, and the fit may be made robust by iterative
19 reweighting of the data. The user may also search for the number of
20 terms in f(x) which significantly reduce the variance in y.
21
23 -F Specify up to five letters from the set {x y m r w} in any order
24 to create columns of ASCII [or binary] output. x = x, y = y, m
25 = model f(x), r = residual y - m, w = weight used in fitting.
26
27 -N Specify the number of terms in the model, n_model, whether to
28 fit a Fourier (-Nf) or polynomial [Default] model, and append r
29 to do a robust fit. E.g., a robust quadratic model is -N3r.
30
32 xy[w]file
33 ASCII [or binary, see -b] file containing x,y [w] values in the
34 first 2 [3] columns. If no file is specified, trend1d will read
35 from standard input.
36
37 -C Set the maximum allowed condition number for the matrix solu‐
38 tion. trend1d fits a damped least squares model, retaining only
39 that part of the eigenvalue spectrum such that the ratio of the
40 largest eigenvalue to the smallest eigenvalue is condition_#.
41 [Default: condition_# = 1.0e06. ].
42
43 -H Input file(s) has Header record(s). Number of header records
44 can be changed by editing your .gmtdefaults4 file. If used, GMT
45 default is 1 header record. Use -Hi if only input data should
46 have header records [Default will write out header records if
47 the input data have them]. Blank lines and lines starting with #
48 are always skipped.
49
50 -I Iteratively increase the number of model parameters, starting at
51 one, until n_model is reached or the reduction in variance of
52 the model is not significant at the confidence_level level. You
53 may set -I only, without an attached number; in this case the
54 fit will be iterative with a default confidence level of 0.51.
55 Or choose your own level between 0 and 1. See remarks section.
56
57 -V Selects verbose mode, which will send progress reports to stderr
58 [Default runs "silently"].
59
60 -W Weights are supplied in input column 3. Do a weighted least
61 squares fit [or start with these weights when doing the itera‐
62 tive robust fit]. [Default reads only the first 2 columns.]
63
64 -: Toggles between (longitude,latitude) and (latitude,longitude)
65 input and/or output. [Default is (longitude,latitude)]. Append
66 i to select input only or o to select output only. [Default
67 affects both].
68
69 -bi Selects binary input. Append s for single precision [Default is
70 d (double)]. Uppercase S or D will force byte-swapping.
71 Optionally, append ncol, the number of columns in your binary
72 input file if it exceeds the columns needed by the program. Or
73 append c if the input file is netCDF. Optionally, append
74 var1/var2/... to specify the variables to be read. [Default is
75 2 (or 3 if -W is set) columns].
76
77 -bo Selects binary output. Append s for single precision [Default
78 is d (double)]. Uppercase S or D will force byte-swapping.
79 Optionally, append ncol, the number of desired columns in your
80 binary output file. [Default is 1-5 columns as given by -F].
81
82 -f Special formatting of input and/or output columns (time or geo‐
83 graphical data). Specify i or o to make this apply only to
84 input or output [Default applies to both]. Give one or more
85 columns (or column ranges) separated by commas. Append T (abso‐
86 lute calendar time), t (relative time in chosen TIME_UNIT since
87 TIME_EPOCH), x (longitude), y (latitude), or f (floating point)
88 to each column or column range item. Shorthand -f[i|o]g means
89 -f[i|o]0x,1y (geographic coordinates).
90
92 The ASCII output formats of numerical data are controlled by parameters
93 in your .gmtdefaults4 file. Longitude and latitude are formatted
94 according to OUTPUT_DEGREE_FORMAT, whereas other values are formatted
95 according to D_FORMAT. Be aware that the format in effect can lead to
96 loss of precision in the output, which can lead to various problems
97 downstream. If you find the output is not written with enough preci‐
98 sion, consider switching to binary output (-bo if available) or specify
99 more decimals using the D_FORMAT setting.
100
102 If a Fourier model is selected, the domain of x will be shifted and
103 scaled to [-pi, pi] and the basis functions used will be 1, cos(x),
104 sin(x), cos(2x), sin(2x), ... If a polynomial model is selected, the
105 domain of x will be shifted and scaled to [-1, 1] and the basis func‐
106 tions will be Chebyshev polynomials. These have a numerical advantage
107 in the form of the matrix which must be inverted and allow more accu‐
108 rate solutions. The Chebyshev polynomial of degree n has n+1 extrema
109 in [-1, 1], at all of which its value is either -1 or +1. Therefore
110 the magnitude of the polynomial model coefficients can be directly com‐
111 pared. NOTE: The stable model coefficients are Chebyshev coefficients.
112 The corresponding polynomial coefficients in a + bx + cxx + ... are
113 also given in Verbose mode but users must realize that they are NOT
114 stable beyond degree 7 or 8. See Numerical Recipes for more discussion.
115 For evaluating Chebyshev polynomials, see gmtmath.
116
117 The -Nr (robust) and -I (iterative) options evaluate the significance
118 of the improvement in model misfit Chi-Squared by an F test. The
119 default confidence limit is set at 0.51; it can be changed with the -I
120 option. The user may be surprised to find that in most cases the
121 reduction in variance achieved by increasing the number of terms in a
122 model is not significant at a very high degree of confidence. For
123 example, with 120 degrees of freedom, Chi-Squared must decrease by 26%
124 or more to be significant at the 95% confidence level. If you want to
125 keep iterating as long as Chi-Squared is decreasing, set confi‐
126 dence_level to zero.
127
128 A low confidence limit (such as the default value of 0.51) is needed to
129 make the robust method work. This method iteratively reweights the
130 data to reduce the influence of outliers. The weight is based on the
131 Median Absolute Deviation and a formula from Huber [1964], and is 95%
132 efficient when the model residuals have an outlier-free normal distri‐
133 bution. This means that the influence of outliers is reduced only
134 slightly at each iteration; consequently the reduction in Chi-Squared
135 is not very significant. If the procedure needs a few iterations to
136 successfully attenuate their effect, the significance level of the F
137 test must be kept low.
138
140 To remove a linear trend from data.xy by ordinary least squares, use:
141
142 trend1d data.xy -Fxr -N2 > detrended_data.xy
143
144 To make the above linear trend robust with respect to outliers, use:
145
146 trend1d data.xy -Fxr -N2r > detrended_data.xy
147
148 To find out how many terms (up to 20, say) in a robust Fourier inter‐
149 polant are significant in fitting data.xy, use:
150
151 trend1d data.xy -Nf20r -I -V
152
154 GMT(1), gmtmath(1), grdtrend(1), trend2d(1)
155
157 Huber, P. J., 1964, Robust estimation of a location parameter, Ann.
158 Math. Stat., 35, 73-101.
159
160 Menke, W., 1989, Geophysical Data Analysis: Discrete Inverse Theory,
161 Revised Edition, Academic Press, San Diego.
162
163
164
165GMT 4.3.1 15 May 2008 TREND1D(1)