Main Content

Nonseasonal and Seasonal Differencing

This example shows how to apply both nonseasonal and seasonal differencing using lag operator polynomial objects. The time series is monthly international airline passenger counts from 1949 to 1960.

Load the airline data set (Data_Airline.mat).

load Data_Airline
y = log(DataTimeTable.PSSG);
T = length(y);

figure
plot(DataTimeTable.Time,y)
title('Log Airline Passenger Counts')

Figure contains an axes object. The axes object with title Log Airline Passenger Counts contains an object of type line.

The data shows a linear trend and a seasonal component with periodicity 12.

Take the first difference to address the linear trend, and the 12th difference to address the periodicity. If yt is the series to be transformed, the transformation is

ΔΔ12yt=(1-L)(1-L12)yt,

where Δ denotes the difference operator, and L denotes the lag operator.

Create the lag operator polynomials 1-L and 1-L12. Then, multiply them to get the desired lag operator polynomial.

D1 = LagOp({1 -1},'Lags',[0,1]);
D12 = LagOp({1 -1},'Lags',[0,12]);
D = D1*D12
D = 
    1-D Lag Operator Polynomial:
    -----------------------------
        Coefficients: [1 -1 -1 1]
                Lags: [0 1 12 13]
              Degree: 13
           Dimension: 1

The first polynomial, 1-L, has coefficient 1 at lag 0 and coefficient -1 at lag 1. The seasonal differencing polynomial, 1-L12, has coefficient 1 at lag 0, and -1 at lag 12. The product of these polynomials is

(1-L)(1-L12)=1-L-L12+L13,

which has coefficient 1 at lags 0 and 13, and coefficient -1 at lags 1 and 12.

Filter the data with differencing polynomial D to get the nonseasonally and seasonally differenced series.

dY = filter(D,y);
length(y) - length(dY)
ans = 
13

The filtered series is 13 observations shorter than the original series. This is due to applying a degree 13 polynomial filter.

figure
plot(DataTimeTable.Time(14:end),dY)
title('Differenced Log Airline Passenger Counts')

Figure contains an axes object. The axes object with title Differenced Log Airline Passenger Counts contains an object of type line.

The differenced series has neither the trend nor seasonal component exhibited by the original series.

See Also

|

Related Examples

More About