How to Decompose Time Series Data into Trend and Seasonality?

158 views (last 30 days)
carolina on 22 Mar 2021
Answered: Michelle Hirsch on 24 Sep 2021
I have a time series with predictive temperature and real temperature. I need to decompose a time series into components. Some components from time series are level, trend,seasonality and one component called noise.
Where the components are added together as follows:
Time series = Level + Trend + Seasonality + Noise
Noise=Time series- seasonality –trend
The purpose of decomposing the time series is to easily analyze the behavior of the results over time
This is the original predicted temperature time series which shows a nonlinear trend
I tried to remove the trend, this is the result it provided
Here is the code I have used
close all
load StepOutTemp__Estacion.mat
%Señal de Temperatura Predicha
title('Tiempo de Predicción adelante: 60 minutos'),ylabel('Temperatura en °C')
xlabel('Muestras de Tiempo'),ylabel('Temperatura en °C')
title('Tiempo de Predicción adelante: 60 minutos-Sin Tendencia')
The ordsignalis the orden a function.
Remove trends from Data
I need to show a similar result or if maybe there is a tool to decompose a time series into
components. I have not been able to estimate noise or residual components and seasonality. Thanks in advance for your help.

Answers (2)

Shashank Gupta
Shashank Gupta on 25 Mar 2021
Hi Carolina,
MATLAB as of now does not have an explicite function for decomposition of time series data. But there are workaround to get these components. Check out this resource material. The trend can be estimated easily through moving average filter, look at this doc page. Similarly, seasonal component can also be estimated by parameteric estimated model, this link should help you. the remaining component you can find out by simply substracting each one of them by original signal (assuming the model is additive in nature).
I hope this helps you.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!