TREND1D(1gmt) | GMT | TREND1D(1gmt) |
trend1d - Fit a [weighted] [robust] polynomial [and/or Fourier] model for y = f(x) to xy[w] data
trend1d [ table ] -Fxymrw|p|P|c -Nparams [ xy[w]file ] [ -Ccondition_number ] [ -I[confidence_level] ] [ -V[level] ] [ -W ] [ -bbinary ] [ -dnodata ] [ -eregexp ] [ -fflags ] [ -hheaders ] [ -iflags ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
trend1d reads x,y [and w] values from the first two [three] columns on standard input [or file] and fits a regression model y = f(x) + e by [weighted] least squares. The functional form of f(x) may be chosen as polynomial or Fourier or a mix of the two, and the fit may be made robust by iterative reweighting of the data. The user may also search for the number of terms in f(x) which significantly reduce the variance in y.
The ASCII output formats of numerical data are controlled by parameters in your gmt.conf file. Longitude and latitude are formatted according to FORMAT_GEO_OUT, absolute time is under the control of FORMAT_DATE_OUT and FORMAT_CLOCK_OUT, whereas general floating point values are formatted according to FORMAT_FLOAT_OUT. Be aware that the format in effect can lead to loss of precision in ASCII output, which can lead to various problems downstream. If you find the output is not written with enough precision, consider switching to binary output (-bo if available) or specify more decimals using the FORMAT_FLOAT_OUT setting.
If a polynomial model is included, then the domain of x will be shifted and scaled to [-1, 1] and the basis functions will be Chebyshev polynomials provided the polygon is of full order (otherwise we stay with powers of x). The Chebyshev polynomials have a numerical advantage in the form of the matrix which must be inverted and allow more accurate solutions. The Chebyshev polynomial of degree n has n+1 extrema in [-1, 1], at all of which its value is either -1 or +1. Therefore the magnitude of the polynomial model coefficients can be directly compared. NOTE: The stable model coefficients are Chebyshev coefficients. The corresponding polynomial coefficients in a + bx + cxx + ... are also given in Verbose mode but users must realize that they are NOT stable beyond degree 7 or 8. See Numerical Recipes for more discussion. For evaluating Chebyshev polynomials, see gmtmath.
The -N...+r (robust) and -I (iterative) options evaluate the significance of the improvement in model misfit Chi-Squared by an F test. The default confidence limit is set at 0.51; it can be changed with the -I option. The user may be surprised to find that in most cases the reduction in variance achieved by increasing the number of terms in a model is not significant at a very high degree of confidence. For example, with 120 degrees of freedom, Chi-Squared must decrease by 26% or more to be significant at the 95% confidence level. If you want to keep iterating as long as Chi-Squared is decreasing, set confidence_level to zero.
A low confidence limit (such as the default value of 0.51) is needed to make the robust method work. This method iteratively reweights the data to reduce the influence of outliers. The weight is based on the Median Absolute Deviation and a formula from Huber [1964], and is 95% efficient when the model residuals have an outlier-free normal distribution. This means that the influence of outliers is reduced only slightly at each iteration; consequently the reduction in Chi-Squared is not very significant. If the procedure needs a few iterations to successfully attenuate their effect, the significance level of the F test must be kept low.
To remove a linear trend from data.xy by ordinary least squares, use:
gmt trend1d data.xy -Fxr -Np1 > detrended_data.xy
To make the above linear trend robust with respect to outliers, use:
gmt trend1d data.xy -Fxr -Np1+r > detrended_data.xy
To fit the model y(x) = a + bx^2 + c * cos(2*pi*3*(x/l) + d * sin(2*pi*3*(x/l), with l the fundamental period (here l = 15), try:
gmt trend1d data.xy -Fxm -NP0,P2,F3+l15 > model.xy
To find out how many terms (up to 20, say in a robust Fourier interpolant are significant in fitting data.xy, use:
gmt trend1d data.xy -Nf20+r -I -V
gmt, gmtmath, gmtregress, grdtrend, trend2d
Huber, P. J., 1964, Robust estimation of a location parameter, Ann. Math. Stat., 35, 73-101.
Menke, W., 1989, Geophysical Data Analysis: Discrete Inverse Theory, Revised Edition, Academic Press, San Diego.
2019, P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis, and F. Wobbe
May 21, 2019 | 5.4.5 |