Decompose Time Series Into Additive Trend Components - MATLAB & Simulink (2024)

Open Live Script

This example shows how to estimate nonseasonal and seasonal trend components using parametric models. For details on trend components of a time series, see internal link.

The sample data is a time series of 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);figureplot(DataTimeTable.Time,y/1000)title('Monthly Accidental Deaths')ylabel('Number of Deaths (thousands)')hold on

Decompose Time Series Into Additive Trend Components- MATLAB & Simulink (1)

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

Decompose Time Series Into Additive Trend Components- MATLAB & Simulink (2)

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;figureplot(DataTimeTable.Time,st/1000)ylabel 'Number of Deaths (thousands)';title('Parametric Estimate of Seasonal Component (Indicators)')

Decompose Time Series Into Additive Trend Components- MATLAB & Simulink (3)

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;figureplot(DataTimeTable.Time,dt/1000)title('Monthly Accidental Deaths (Deseasonalized)')ylabel('Number of Deaths (thousands)')

Decompose Time Series Into Additive Trend Components- MATLAB & Simulink (4)

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;figureplot(DataTimeTable.Time,bt/1000)title('Irregular Component')ylabel('Number of Deaths (thousands)')

Decompose Time Series Into Additive Trend Components- MATLAB & Simulink (5)

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

What is Time Series Decomposition

Time series decomposition involves separating a time series into several distinct components. In most cases, time series are decomposed into three components:

  • Tt — Deterministic, nonseasonal secular trend component. Usually, this component is a linear trend, but higher-degree polynomials are possible.

  • St — Deterministic seasonal component with known periodicity. This component captures level shifts that repeat systematically within the same period (e.g., month or quarter) between successive years. Often, St is considered a nuisance component; you can eliminate it by applying a seasonal adjustment.

  • It — Stochastic irregular component. This component is not necessarily a white noise process; it can exhibit autocorrelation and cycles of unpredictable duration. As a result, this component might contain information about the business cycle.

The following functional forms are most often used to represent a time series yt as a function of its trend, seasonal, and irregular components:

  • Additive Decompositionyt=Tt+St+It. This form is the classical decomposition, appropriate when the series has no exponential growth and the amplitude of the seasonal component is constant over time. For identifiability from the trend component, the seasonal and irregular components are assumed to fluctuate around zero.

  • Multiplicative Decompositionyt=TtStIt. This decomposition is appropriate when the series exhibits exponential growth and the amplitude of the seasonal component grows with the level of the series. For identifiability from the trend component, the seasonal and irregular components are assumed to fluctuate around one.

  • Log-additive decompositionlogyt=Tt+St+It. This decomposition is an alternative to the multiplicative decomposition. If yt has a multiplicative decomposition, the logged series has an additive decomposition. This decomposition is well suited when yt is positive and has many values that are close to 0. For identifiability from the trend component, the seasonal and irregular components are assumed to fluctuate around zero.

You can estimate the trend and seasonal components by using filters (moving averages) or parametric regression models. Given estimates Ttˆ and Stˆ, the irregular component is estimated as Itˆ=yt-Ttˆ-Stˆ using the additive decomposition, and Itˆ=ytTtˆStˆ using the multiplicative decomposition.

The series yt-Ttˆ (or ytTtˆ using the multiplicative decomposition) is a detrended series. Similarly, the series yt-Stˆ (or ytStˆ using the multiplicative decomposition) is called a deseasonalized series.

See Also

dummyvar | hpfilter | bkfilter | cffilter | hfilter

Related Topics

  • Data Transformations
  • Use Hodrick-Prescott Filter to Reproduce Original Result
  • Choose Time Series Filter for Business Cycle Analysis
  • Estimate Moving Average Trend Using Moving Average Filter
  • Seasonal Adjustment Using a Stable Seasonal Filter
  • Seasonal Adjustment Using S(n,m) Seasonal Filters
  • Seasonal Adjustment
Decompose Time Series Into Additive Trend Components
- MATLAB & Simulink (2024)

FAQs

What is decomposition of additive time series? ›

Additive decomposition argues that time series data is a function of the sum of its components. Thus, where Y is the time series data, T is the trend-cycle component, S is the seasonal component, and R is the remainder.

How do you Deseasonalize a time series in Matlab? ›

Deseasonalize the original series. For an additive decomposition, calculate d t = y t − S ^ t . For a multiplicative decomposition, calculate d t = y t / S ^ t . This is the final deseasonalized series.

What are the components and decomposition of time series? ›

A given time series is thought to consist of three systematic components including level, trend, seasonality, and one non-systematic component called noise. These components are defined as follows: Level: The average value in the series. Trend: The increasing or decreasing value in the series.

How do you calculate time series decomposition? ›

There are two ways in which we can decompose the time series:
  1. Multiplicative : y(t) = T(t) * S(t) * R(t)
  2. Additive : y(t) = T(t) + S(t) + R(t)
Oct 18, 2019

How do you do the decomposition method? ›

To decompose a number, break apart the number into parts. The number 9 can be decomposed into 9 and 0, 1 and 8, 2 and 7, 3 and 6, or 4 and 5.

What is the decomposition method in MATLAB? ›

dA = decomposition( A ) returns a decomposition of matrix A that you can use to solve linear systems more efficiently. The decomposition type is automatically chosen based on the properties of the input matrix. dA = decomposition( A , type ) specifies the type of decomposition to perform.

Why is it beneficial to deseasonalize data? ›

Deseasonalized data holds significant importance in analytics as it enables accurate trend analysis, statistical modeling, and precise forecasting by removing the seasonal effects and providing normalized, transformed data for in-depth analysis and interpretation.

How do you remove a trend from a time series in MATLAB? ›

To eliminate the linear trend, use the MATLAB® function detrend . dt_ecgl = detrend(ecgl); To eliminate the nonlinear trend, fit a low-order polynomial to the signal and subtract it.

What is the decomposition of the time series called? ›

This is called detrending . Time series data is often thought of as being comprised of several components: a long-term trend, seasonal variation, and irregular variations. Was this answer helpful?

What is the additive model of the time series? ›

1) Additive Model

In the additive model, we represent a particular observation in a time series as the sum of these four components. where O represents the original data, T represents the trend. S represents the seasonal variations, C represents the cyclical variations and I represents the irregular variations.

What is the equation for decomposition? ›

A decomposition reaction occurs when one reactant breaks down into two or more products. This can be represented by the general equation: AB → A + B. Examples of decomposition reactions include the breakdown of hydrogen peroxide to water and oxygen, and the breakdown of water to hydrogen and oxygen.

How do you get rid of a trend in a time series? ›

The simplest way to detrend a time series is by subtracting the mean value of the data. This is called a constant model, and it assumes that the trend of the time series is a straight horizontal line.

What are the methods of isolating trend values in a time series? ›

There are several methods of isolating the trend of which we shall discuss only two methods which are most frequently used in the business and economic time series data analysis. They are: Free Hand Method, and Method of Least Square. In this method, the first requirement is that a graph is drawn of the original data.

What is trend cycle decomposition? ›

The trend-cycle decomposition of Total Factor Productivity is found robust to variations in the prior distribution of model parameters, in the set of survey indicators used to proxy capacity utilisation, and in the specification of the process that drives the cyclical fluctuations of productivity.

What is decomposition in forecasting? ›

Classical time series decomposition separates a time series into five components: mean, long-range trend, seasonality, cycle, and randomness. The decomposition model is. Value = (Mean) x (Trend) x (Seasonality) x (Cycle) x (Random) Note that this model is multiplicative rather than additive.

Top Articles
Latest Posts
Article information

Author: Manual Maggio

Last Updated:

Views: 6217

Rating: 4.9 / 5 (49 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Manual Maggio

Birthday: 1998-01-20

Address: 359 Kelvin Stream, Lake Eldonview, MT 33517-1242

Phone: +577037762465

Job: Product Hospitality Supervisor

Hobby: Gardening, Web surfing, Video gaming, Amateur radio, Flag Football, Reading, Table tennis

Introduction: My name is Manual Maggio, I am a thankful, tender, adventurous, delightful, fantastic, proud, graceful person who loves writing and wants to share my knowledge and understanding with you.