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
The data shows a potential quadratic trend and a strong seasonal component with periodicity 12.
Fit Quadratic Trend
Fit the polynomial
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
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)')
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)')
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)')
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
- Moving Average Trend Estimation
- Seasonal Adjustment Using a Stable Seasonal Filter
- Seasonal Adjustment Using S(n,m) Seasonal Filters