Time Series Analysis Package
MKTEST Method
rc = TSA.MKTEST (y, <seasonality> ,<alpha>, <sum>, <sigma>, <z>, <crit>, <pval>);
The MKTEST function runs a Mann-Kendall test or a seasonal Mann-Kendall test.
Required Arguments
You must specify the following arguments, separated by commas:
- y
specifies the input time series array.
Optional Arguments
You can also specify the following arguments, separated by commas. If you want to use a default value for any of these arguments, enter a space for it.
- seasonality
specifies the seasonality of the series. You can specify an integer, or you can specify _SEASONALITY_. The predefined symbol _SEASONALITY_ is the length of the seasonal cycle that is computed by using the seasonality or the time ID interval that you specify in a PROC TSMODEL step or a
runTimeCodeaction call. For more information about predefined symbols, see the section "Predefined Symbols" in Chapter 16, TSMODEL Procedure (SAS Visual Forecasting: Forecasting Procedures). For more information about seasonality, see the section "Seasonality in Models" in Chapter 17, Forecasting Details (SAS Visual Forecasting: Time Series Packages). The default value is 1.- alpha
specifies the significance level of the test. The default value is 0.05.
Returned Values
The MKTEST function returns the following values:
- rc
-
returns one of the following scalar return codes:
rc Test Result 1 Series has a monotonic trend 0 Series has no trend < 0 Computational failure
Optional Returned Values
You can also specify the following arguments, separated by commas, to request additional returned values. If you do not want the value to be returned, enter a space for it.
- sum
returns the sum of the signs.
- sigma
returns the standard deviation of the sum of the signs.
- z
returns the Z-transformation of the sum of the signs.
- crit
returns the test critical value of the Z-transformation.
- pval
returns the p-value.
Details
When the specified seasonality is 1, the MKTEST function runs the Mann-Kendall test on a univariate time series and outputs the corresponding statistics. The Mann-Kendall test is a nonparametric test that is commonly used to detect monotonic trends in series. The null hypothesis, , is that the data come from a population that has independent realizations and the data are identically distributed. The alternative hypothesis,
, is that the data follow a monotonic trend. Given the series
,
, the Mann-Kendall test statistic S is calculated as
where
Under the null hypothesis, the mean of S is , and the variance
is
where p is the number of tied groups in the data set and is the number of data points in the kth tied group.
When the specified seasonality is greater than 1, the MKTEST function runs a seasonal Mann-Kendall test on a univariate time series. The null hypothesis, , is that, for each season, the data come from a population that has independent realizations and the data are identically distributed. The alternative hypothesis,
, is that the data follow a monotonic trend in one or more seasons. For the gth season,
and the corresponding variance is
where is the number of tied groups in the data set and
is the number of data points in the kth tied group. The seasonal Mann-Kendall statistic, S, for the entire series of m seasons is calculated according to
The corresponding seasonal variance is
The following Z-transformation of the statistic S approximately follows a standard normal distribution:
The test result is obtained by comparing the Z-transformation to the critical value.
The Mann-Kendall test requires at least three nonmissing observations. The constant series is regarded as no trend by the Mann-Kendall test. If any season has fewer than three nonmissing observations, the seasonal Mann-Kendall test ignores it. If no season has enough nonmissing observations, the seasonal Mann-Kendall test cannot be performed. If any season has a constant series, this season is also ignored. If all seasons have constant series, the whole series is regarded as having no trend by the seasonal Mann-Kendall test.
Examples
This example uses the TSMODEL procedure to run the Mann-Kendall test on the time series array Air:
proc tsmodel data=mylib.air outscalar = mylib.scalars;
id date interval=month;
var air;
outscalar rc sum sig z crit pval;
require tsa;
submit;
declare object tsa(tsa);
rc = tsa.mktest(air,1,0.05,sum,sig,z,crit,pval);
endsubmit;
run;