Independent variable to find seasonality effect?

266 Views Asked by At

I'm not sure if it's right to ask this here but any help greatly appreciated. I'm working on sas forecast studio.

This is my time series dataset (quarterly data):

  • Date e.g. 1-Jan-80, 1-Apr-80, 1-Jul-80
  • DateQ e.g. 1980Q1, 1980Q2, 1980Q3
  • Year e.g. 1980, 1981, 1982
  • GDP (dependable variable) e.g. 2650.1
  • T e.g. 1, 2, 3

Which of this variable, or should I create a new quarterly variable, to use as an independent variable for a linear regression to evaluate if there is any seasonal effect?

1

There are 1 best solutions below

0
On

Seasonal effects should not be identified using simple linear regression on the time variable when analyzing time-series data. But, to answer your question, use date with the intnx() function to convert it to quarter.

data want;
    format quarter yyq.;
    set have;
    quarter = intnx('quarter', date, 0, 'B');
run;

Seasonal effects can be identified a number of ways:

1. Graphing it

If a time series has a seasonal effect, it will tend to be clear. Simply looking at a graph of the data will let you know whether it is seasonal by your chosen interval.

enter image description here

In sashelp.air, it's very clear that there is a 12-month season.

2. Spectral Density Analysis

proc timeseries will give you a spectrum analysis to help identify significant seasons within the data. Peaks indicate possible cycles or seasons. You will need to do some filtering to a reasonable seasonal amount since the density may increase significantly after a certain point, and it is not representative of the true season.

Forecast Studio and Time Series Studio will do this for you and can give you similar output to the below.

proc timeseries data=sashelp.air 
                outspectra=outspectra;
    id date interval=month;
    var air;
    spectra;
run;

proc sgplot data=outspectra;
    where period BETWEEN 1 AND 24;
    scatter x=period y=p;
    series x=period y=p;
run;

enter image description here

We can see a strong indicator for a seasonality of 12. We also see some potential 3-month and 6-month cycles that could be tested within a model for significance.

3. ACF/PACF/IACF plots Your ACF/PACF/IACF plots in Forecast Studio will also help you identify clear seasons.

enter image description here

The classic decaying suspension-bridge look is indicative of a seasonal effect. Note that the season increases around 12 and then decreases again. Additionally, the significant negative spike at 12 in the PACF and IACF plots are other indicators of a significant seasonal effect at 12.

Model Building and Testing

Tools like the seasonal augmented dickey fuller test that are available Forecast Studio can help you identify if you've captured seasonality and achieved stationarity after differencing.

The selection boxes in the Series view allow you to quickly add simple or seasonal differencing. Selecting (1) for simple differencing will add one simple difference. i.e:

y = y - lag(y)

Selecting (1) for seasonal differencing will add 1 seasonal difference. Note that when you create a project in Forecast Studio, the season is automatically diagnosed and assumed. This should be done after doing our diagnostics above for our best guess as to what the true season is. In our case, we've assumed our season is 12. This would be equivalent to:

y = y - lag12(y)

We can then use stationarity tests to ensure we've achieved stationarity. In our case, we'll add 1 simple and seasonal difference.

enter image description here

enter image description here

Notice how our white noise plot has improved and our spikes at 12 have decreased to non-significance. Additionally, our stationarity tests are looking good and significant - that is, there is no unit root present.

enter image description here

Adding Seasonal or Cyclical Effects

Your model choice will dictate how seasonal or cyclical effects are added. Differencing in an ARIMA model will take care of seasonality. Dummy variables can be used for additional cyclical effects in the ARIMA model. For example:

data want;
    set have;
    q1 = (qtr(date) = 1);
    q2 = (qtr(date) = 2);
    q3 = (qtr(date) = 3);
run;

UCMs can take care of all of these by adding both seasonal and cyclical effects. Holt-Winters ESMs take care of trend and seasonality without requiring dummy variables. Your modeling goals and performance considerations for each type of model will dictate which model you choose.