Main Content

Parametric Trend Estimation

This example shows how to estimate nonseasonal and seasonal trend components using parametric models. The time series is monthly accidental deaths in the U.S. from 1973 to 1978 (Brockwell and Davis, 2002).

Load Data

Load the accidental deaths data set.

load Data_Accidental 
y = DataTimeTable.NUMD;
T = length(y);

figure
plot(DataTimeTable.Time,y/1000)
title('Monthly Accidental Deaths')
ylabel('Number of Deaths (thousands)')
hold on

Figure contains an axes object. The axes object with title Monthly Accidental Deaths, ylabel Number of Deaths (thousands) contains an object of type line.

The data shows a potential quadratic trend and a strong seasonal component with periodicity 12.

Fit Quadratic Trend

Fit the polynomial

Tt=β0+β1t+β2t2

to the observed series.

t = (1:T)';
X = [ones(T,1) t t.^2];

b = X\y;
tH = X*b;
 
h2 = plot(DataTimeTable.Time,tH/1000,'r','LineWidth',2);
legend(h2,'Quadratic Trend Estimate')
hold off

Figure contains an axes object. The axes object with title Monthly Accidental Deaths, ylabel Number of Deaths (thousands) contains 2 objects of type line. This object represents Quadratic Trend Estimate.

Detrend Original Series

Subtract the fitted quadratic line from the original data.

xt = y - tH;

Estimate Seasonal Indicator Variables

Create indicator (dummy) variables for each month. The first indicator is equal to one for January observations, and zero otherwise. The second indicator is equal to one for February observations, and zero otherwise. A total of 12 indicator variables are created for the 12 months. Regress the detrended series against the seasonal indicators.

mo = repmat((1:12)',6,1);
sX = dummyvar(mo);
  
bS = sX\xt;
st = sX*bS;

figure
plot(DataTimeTable.Time,st/1000)
ylabel 'Number of Deaths (thousands)';
title('Parametric Estimate of Seasonal Component (Indicators)')

Figure contains an axes object. The axes object with title Parametric Estimate of Seasonal Component (Indicators), ylabel Number of Deaths (thousands) contains an object of type line.

In this regression, all 12 seasonal indicators are included in the design matrix. To prevent collinearity, an intercept term is not included (alternatively, you can include 11 indicators and an intercept term).

Deseasonalize Original Series

Subtract the estimated seasonal component from the original series.

dt = y - st;

figure
plot(DataTimeTable.Time,dt/1000)
title('Monthly Accidental Deaths (Deseasonalized)')
ylabel('Number of Deaths (thousands)')

Figure contains an axes object. The axes object with title Monthly Accidental Deaths (Deseasonalized), ylabel Number of Deaths (thousands) contains an object of type line.

The quadratic trend is much clearer with the seasonal component removed.

Estimate Irregular Component

Subtract the trend and seasonal estimates from the original series. The remainder is an estimate of the irregular component.

bt = y - tH - st;

figure
plot(DataTimeTable.Time,bt/1000)
title('Irregular Component')
ylabel('Number of Deaths (thousands)')

Figure contains an axes object. The axes object with title Irregular Component, ylabel Number of Deaths (thousands) contains an object of type line.

You can optionally model the irregular component using a stochastic process model.

References:

Box, G. E. P., G. M. Jenkins, and G. C. Reinsel. Time Series Analysis: Forecasting and Control. 3rd ed. Englewood Cliffs, NJ: Prentice Hall, 1994.

See Also

Related Topics