Time Series Analysis Package

SEASONTEST Method

  • rc = TSA.SEASONTEST (y, s, <dif>, <p>, <alpha>, <aic>);

The SEASONTEST function tests whether a univariate time series is seasonal by comparing two time series models: one seasonal and one nonseasonal.

Required Arguments

You must specify the following arguments, separated by a comma:

y

specifies the times series array to test.

s

specifies the seasonality to test, where s must be either a positive integer or _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 runTimeCode action 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).

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.

dif

specifies an array of positive integers or a positive integer that is used for differencing. The default value is 0.

p

specifies the autoregressive order (0 or 1). The default value is 0.

alpha

specifies the significance level. The default value is 0.01.

Returned Values

The SEASONTEST function returns the following values:

rc

returns one of the following scalar return codes:

rc Termination Reason
0 Time series is not seasonal
1 Time series is seasonal
< 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.

aic

returns an array of three values: Akaike’s information criterion (AIC) for the nonseasonal model, AIC for seasonal model, and the p-value for the F test.

Details

The time series y is first predifferenced according to the specified dif. The predifferenced time series is fit by a nonseasonal autoregressive model of order p and a seasonal autoregressive model of order p. The AICs of both models and the F statistic of the seasonal model are calculated. If the seasonal model has a smaller AIC, and if the p-value of the F statistic is smaller than the significance level alpha, then the time series is identified as seasonal. Otherwise, the time series is identified as nonseasonal. The test is conducted only for series of at least two seasonal cycles. In general, seasonality is more difficult to identify in a series when the sample size is small because there are only a few seasonal cycles of data.

Example

The following example uses the TSMODEL procedure to test the seasonality of the time series array Air:

proc tsmodel data=mylib.air outscalar=mylib.outscalars
              outarray=mylib.outarray;
   id date interval=month;
   var air;
   outscalars seasonal;
   outarrays aic;
   require tsa;
   submit;
   declare object TSA(tsa);
   seasonal=0;
   rc=TSA.SEASONTEST(air, _SEASONALITY_, 0, 1, , aic); /*- no detrending -*/
   if rc>0 then seasonal= 1;
   rc=TSA.SEASONTEST(air, _SEASONALITY_, 1, 1, 0.05, ); /*- detrending -*/
   if rc>0 then seasonal= 1;
   endsubmit;
run;
Last updated: July 09, 2026