Time series analysis is a statistical technique used to analyze data points recorded at regular time intervals. It can help identify patterns, trends, and seasonal variations, making it useful for forecasting results over time.
Engineers and scientists working with time series data can use time series analysis to monitor, model, and predict system behaviors, which optimizes systems and improves forecasting accuracy.
How Time Series Analysis Works
Time series analysis involves working with time series data to analyze the data systematically. Time series data is a sequence of data points collected or recorded at specific points in time such that each data point is associated with a particular timestamp, enabling analysis of how the data changes relative to time.
Components of Time Series Data
Time series data can be broken down into several fundamental components to help understand underlying patterns and forecast.
Component | Definition | Example | |
|
Trend | Overall direction of the data over time, such as increasing, decreasing, or constant | Adoption of EV technology, revenue for a start-up company |
|
Seasonality | Repeating patterns of data over a set of periods of time, such as daily, monthly, or yearly | Electricity demand peaks during summer months |
|
Cyclic Variations | Repeating but nonseasonal patterns in the data, occurring over several years | Real estate market cycles |
|
Irregular Variations | Unpredictable ups and downs that cannot be explained by other components | Sudden stock market crash due to unforeseen events |
Time Series Analysis Steps
Analyzing time series data involves a systematic approach that integrates various techniques for understanding, modeling, and forecasting data points collected over time.
Exploratory Data Analysis
Exploratory data analysis (EDA) involves collecting raw data and then preprocessing and visualizing the data for further analysis. It includes:
- Data collection: Gathering observations over a specified period and ensuring the quality and accuracy of the data set.
- Data preprocessing and data visualization: Understanding and preparing the data set for analysis and modeling. Data preprocessing includes data cleaning, data transformation, and structural operations.
Decomposition
Decomposition is a technique used to break down time series data into its fundamental components—trends, seasonal, cyclic, and remainder—making it easier to analyze the underlying patterns and interpret data.
Decomposing a time series data set into long-term trends, seasonal patterns, and the remainder using the Singular Spectrum Analysis algorithm implemented via the trenddecomp
function. (See MATLAB code.)
Model Selection and Fitting
Model selection finds the most suitable model to capture the underlying data patterns based on characteristics such as seasonality, trend, and stationarity. Model fitting focuses on training the selected model to minimize the difference between observed data and predictions, ensuring it generalizes well to new data.
Model Prediction and Forecasting
In model prediction and forecasting, the model trained in the previous step is applied to new data to generate future data points based on historical patterns.
Model Evaluation
Model evaluation involves assessing how well a model performs and the accuracy of its predictions. It comprises of three key components:
- Performance metrics: Metrics such as root mean squared error (RMSE) calculate the differences between predicted and actual values, providing a measure of the accuracy of a model.
- Validation techniques: Cross-validation, backtesting, and other techniques assess the reliability of a model by evaluating its performance in making predictions on new data sets.
- Interpretability methods: Techniques such as local interpretable model-agnostic explanations (LIME) and Shapley additive explanations (SHAP) help with understanding model predictions, making the model’s decisions more transparent.
Visualizing the distribution of RMSE values for new data to identify anomalous sequences. (See MATLAB code.)
Visualizing network predictions using the imageLIME
function (See MATLAB code.)
Common Approaches to Time Series Modeling
Three common approaches to modeling time series data are traditional forecasting models, machine learning models, and deep learning models.
Traditional Forecasting Models
Traditional forecasting models use statistical techniques to identify and model underlying data patterns and trends.
The auto regressive integrated moving average (ARIMA) statistical model predicts future values by analyzing historical data. It captures trends and seasonality, making it applicable for both stationary and nonstationary data sets and suitable for short- to medium-term forecasting, such as stock prices and sales.
Estimating an ARIMA model using System Identification Toolbox for time series forecasting. (See MATLAB code.)
The exponential smoothing model applies exponentially decreasing weights to past observations, prioritizing more recent data. This method effectively smooths short-term fluctuations while capturing underlying trends and patterns in time series data. It is particularly useful for data with trends or seasonality.
Machine Learning Models
Machine learning models can capture the complex patterns in data that traditional models might miss.
Random forest models build multiple decision trees and combine their outputs to improve prediction accuracy in time series analysis. They handle large, high-dimensional data sets and are robust to overfitting. By using past data as predictors, they capture nonlinear relationships and interactions, making them well-suited for modeling irregular patterns.
Support vector machines (SVMs) are supervised learning models used for classification and regression. In time series analysis, they can model nonlinear relationships and handle high-dimensional data, especially with small, complex data sets. For example, SVMs can forecast energy demand by capturing nonlinear interactions between historical consumption, weather, and economic indicators.
Plot showing classification of ECG signals using signal processing, wavelet-based feature extraction, and a support vector machine (SVM) classifier to distinguish between arrhythmia (ARR), congestive heart failure (CHF), and normal sinus rhythm (NSR). (See MATLAB code.)
Deep Learning Models
Deep learning enhances time series analysis by automatically learning patterns and dependencies directly from data. These models capture both short-term fluctuations and long-term trends, making them ideal for forecasting and anomaly detection.
Long short-term memory (LSTM) models are a specialized type of recurrent neural network (RNN) designed to overcome the limitations of traditional RNNs by using memory cells and gating mechanisms. This design enables them to capture long-term dependencies effectively, making LSTMs particularly useful for time series analysis tasks such as forecasting and sequence prediction.
Using a simple long short-term memory (LSTM) network for closed-loop forecasting to predict time series data. (See MATLAB code.)
Convolutional neural networks (CNNs) are used in time series analysis as they can automatically extract features from data using convolutional layers. They identify local patterns and hierarchies, making them effective for identifying short-term dependencies for tasks such as multivariate time series classification.
Classifying time series data using wavelet analysis and deep learning. (See MATLAB code.)
Sequence classification using 1D convolutions. (See MATLAB code.)
Types of Time Series Analysis
Time series analyses can be classified into categories that describe, explain, forecast, and optimize data trends and patterns effectively:
- Descriptive analysis summarizes the key features of a data set. It helps in understanding the underlying patterns, trends, and seasonal variations in the data.
- Explanatory analysis aims to understand the relationships and causal effects within the data. It seeks to explain why certain patterns or trends occur by examining the underlying factors and correlations.
- Predictive analysis uses historical data, statistical models, and machine learning algorithms to predict future trends and patterns.
- Prescriptive analysis provides recommendations and actions based on predictive insights. It suggests optimal decisions by evaluating different scenarios and their potential outcomes.
Challenges in Time Series Analysis
Certain types of obstacles are typical of time series analysis. During data acquisition, it’s common for sensors or instruments to record data at inconsistent intervals, a problem for many time series models designed to handle monotonically increasing data. Preparing the data may include handling missing data, outliers, noise, and other irregularities as well as resampling the data to create uniform intervals. Exploratory data analysis techniques discussed above can help in mitigating these issues.
Additionally, the inherent seasonality and cyclical patterns in time series data can complicate the process of choosing and fitting models. A solid understanding of the data set and applicable modeling options is a great starting point. The outlined modeling approaches, along with cross-validation and other established model verification techniques, will be helpful in these cases.
Why Time Series Analysis Is Important
Time series analysis can be used to model and predict future trends in various domains, such as stock prices, weather conditions, sales, and demand forecasting. This approach enhances the accuracy of planning and supports strategic decision-making by anticipating upcoming developments. Examples of applications that benefit from time series analysis include:
Economic and financial analysis: Understand economic indicators and financial markets, providing insights for risk management and strategic planning.
Environmental monitoring: Perform continuous environmental monitoring and assess climate risks, which helps in understanding long-term trends and risks.
Predictive maintenance: Anticipate equipment failures and optimize maintenance schedules, reducing downtime and operational costs.
Signal processing: Interpret signals from IoT devices, sensors, and health systems to enhance performance, detect anomalies, and improve reliability.
Examples of Time Series Analysis
Time series analysis involves techniques for understanding and forecasting data that evolves over time. The examples below illustrate various applications, highlighting unique methods and tools for extracting meaningful insights from complex data sets.
Loma Prieta Earthquake Analysis
See how to store timestamped earthquake data in a timetable and use timetable
functions to analyze and visualize ground acceleration over a specific time interval for understanding seismic activity.
Time series of acceleration components. (See MATLAB code.)
Practical Introduction to Time-Frequency Analysis
Learn how to perform and interpret basic time-frequency analysis to analyze a nonstationary signal such as dual-tone multi-frequency (DTMF) tones.
Spectrogram of dialed DTMF tones for the number 508 showing tone durations and sequences, highlighting a 1336 Hz tone for second column keypad entry. (See MATLAB code.)
Forecast Multivariate Time Series
Learn how to perform multivariate time series forecasting of data measured from predator and prey populations in a prey crowding scenario.
Comparative forecasting analysis for predator-prey populations using ARMA, Polynomial AR, Gaussian process (GP), and grey-box models. (See MATLAB code.)
Classify ECG Signals Using LSTM
See how to classify ECG data using LSTM networks and time-frequency analysis.
Comparison of instantaneous frequency in normal and atrial fibrillation (AFib) ECG signals. (See MATLAB code.)
Keep Exploring This Topic
Prepare Data for Time Series Analysis with Timetables
If you plan to use time-based operations, either before or after preprocessing tasks such as handling missing values and managing outliers, you need to convert the data into a format suitable for time series analysis. The timetable
function is designed for timestamped data, associating a time with each row and storing column-oriented variables with the same number of rows. It simplifies time series analysis by providing time-specific functions for aligning, combining, and calculating data, as well as features such as synchronization and resampling.
Organizing and preprocessing timestamped sensor data with the timetable data container to analyze bicycle traffic patterns. (See MATLAB code.)
MATLAB provides specialized toolboxes to help with your complete workflows depending on your specific application area.
Application | Time Series Analysis Next Steps | Toolbox and Key Features | Examples and Resources |
Statistics and machine learning | Model time series data by applying statistical models and machine learning algorithms | Statistics and Machine Learning Toolbox™
|
Analyze Time Series Data |
Economic forecasting | Perform econometric modeling and analysis, including time series forecasting and hypothesis testing |
|
Estimate Multiplicative ARIMA Model |
Dynamic system modeling | Create, estimate, and forecast time-series models | System Identification Toolbox™
|
Use Timetable Data for Time-Domain System Identification |
Condition monitoring and predictive maintenance | Develop algorithms by analyzing sensor data to predict equipment failures and optimize maintenance | Predictive Maintenance Toolbox™
|
Analyze and Select Features for Pump Diagnostics |
Signal analysis | Filter and analyze signals; extract features from time series data |
|
Extract Regions of Interest from Whale Song |
Deep learning | Use neural networks to capture complex patterns |
|
Time Series Forecasting Using Deep Learning |
Resources
Expand your knowledge through documentation, examples, videos, and more.
30-Day Free Trial
Get startedSélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.
Amériques
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)