TREND Name
TREND
Purpose
This function calculates the least-squares linear trend in the
input vector. Category
Time Series Analysis Calling Sequence
Result = TREND( [X,] Y ) Inputs
Y: The input vector of type integer or floating point and length N.
Optional Inputs
X: An ordinate vector of type integer or floating point. If
not set, Y-elements are positioned at [0,1,2,...,N-1].
Keyword Parameters
ALPHA: The significance level for statistics output. The
default value is 0.05.
CTREND: The critical trend for the calculation of the one-sided
significance level of the output trend. The default
is 0. The significance level is returned in SIGLEV.
NAN: If set, the function ignores NaNs (Not-a-Number) as missing
values if any appear in X or Y. The default is to return NaN.
Outputs
Result: Returns the least-squares linear trend of Y(X).
CONFINT: The (1-ALPHA) confidence interval of Result.
SIGLEV: The ALPHA one-sided significance level of the difference
between Result and CTREND.
FIT: Returns a vector of the linear least-squares fit values,
with X as the ordinate. Uses
-
Procedure
This function uses IDL's POLY_FIT.pro to calculate the least-
squares linear trend to Y(X). It also calculates statistics of
the calculated trend value. Example
Create a vector of 20 data elements.
y = randomn( seed, 20 )
Calculate the linear trend in y.
tr = trend( y )
Modification History
Written by: Daithi A. Stone (stoned@atm.ox.ac.uk), 2000-07-12.
Modified: DAS, 2001-04-03 (fixed bug with SIGLEV and CONFINT).
Modified: DAS, 2005-08-05 (replaced SUM.PRO use with TOTAL;
removed CONSTANTS.PRO use; edited coding style;
reversed definition of NAN keyword for consistency
with other routines)
Modified: DAS, 2005-11-23 (fixed bug with NAN option).