Documentation Center

  • Trial Software
  • Product Updates

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).

Step 1: Load the Data

Load the accidental deaths data set.

load(fullfile(matlabroot,'examples','econ','Data_Accidental.mat'))
Y = Dataset.NUMD;
N = length(Y);

figure
plot(Y/1000)
xlim([0,N])
set(gca,'XTick',[1:12:N])
set(gca,'XTickLabel',datestr(dates(1:12:N),10))
title('Monthly Accidental Deaths')
ylabel('(thousands)')
hold on

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

Step 2: Fit a quadratic trend.

Fit the polynomial

$$T_t = \beta_0 + \beta_1t + \beta_2t^2$$

to the observed series.

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

B = X\Y;
Th = X*B;

h = plot(Th/1000,'r','LineWidth',2);
legend(h,'Quadratic Trend Estimate')
hold off

Step 3. Detrend the original series.

Subtract the fitted quadratic line from the original data.

xt = Y - Th;

Step 4. 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(st/1000)
title('Parametric Estimate of Seasonal Component (Indicators)')
xlim([0,N])
ylabel('(thousands)')
set(gca,'XTick',[1:12:N])
set(gca,'XTickLabel',datestr(dates(1:12:N),10))

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).

Step 5. Deseasonalize the original series.

Subtract the estimated seasonal component from the original series.

dt = Y - st;

figure
plot(dt/1000)
title('Monthly Accidental Deaths (Deseasonalized)')
xlim([0,N])
ylabel('(thousands)')
set(gca,'XTick',[1:12:N])
set(gca,'XTickLabel',datestr(dates(1:12:N),10))

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

Step 6. Estimate the 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(bt/1000)
title('Irregular Component')
xlim([0,N])
ylabel('(thousands)')
set(gca,'XTick',[1:12:N])
set(gca,'XTickLabel',datestr(dates(1:12:N),10))

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 Examples

More About

Was this topic helpful?