## Documentation Center |

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(fullfile(matlabroot,'examples','econ','Data_Airline.mat')) Y = log(Dataset.PSSG); N = length(Y); figure plot(Y) xlim([0,N]) set(gca,'XTick',[1:12:N]) set(gca,'XTickLabel',datestr(dates(1:12:N),10)) title('Log Airline Passenger Counts')

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 is the series to be transformed, the transformation is

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

Create the lag operator polynomials and . 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, , has coefficient 1 at lag 0 and coefficient -1 at lag 1. The seasonal differencing polynomial, , has coefficient 1 at lag 0, and -1 at lag 12. The product of these polynomials is

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(14:N,dY) xlim([0,N]) set(gca,'XTick',[1:12:N]) set(gca,'XTickLabel',datestr(dates(1:12:N),10)) title('Differenced Log Airline Passenger Counts')

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

Was this topic helpful?