0% found this document useful (0 votes)
4 views67 pages

Time Series

The document discusses the components of time-series data, including trend, seasonality, and noise, and methods for checking stationarity using statistical tests like ADF and KPSS. It also covers autoregressive (AR) and moving average (MA) models for forecasting, as well as ARMA and ARIMA models for analyzing temporal patterns. Additionally, it highlights the importance of time series analysis in various fields and cautions against common pitfalls such as the assumption of stationarity and data quality issues.

Uploaded by

Raj Shah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views67 pages

Time Series

The document discusses the components of time-series data, including trend, seasonality, and noise, and methods for checking stationarity using statistical tests like ADF and KPSS. It also covers autoregressive (AR) and moving average (MA) models for forecasting, as well as ARMA and ARIMA models for analyzing temporal patterns. Additionally, it highlights the importance of time series analysis in various fields and cautions against common pitfalls such as the assumption of stationarity and data quality issues.

Uploaded by

Raj Shah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 67

• The components of time-series data

• Most time-series data can be decomposed into three components:


trend, seasonality and noise.
• Trend — The data has a long-term movement in a series, whether it’s
upwards or downwards. It may be caused by population growth,
inflation, environmental change or the adoption of technology.
Examples could be the long-term increase in the US stock market in
the past ten years, and the growth in the real estate market in most
parts of the world in the past year, and the longevity of people’s lives.
The trend in avocado price in the US in the past five years
• Seasonality — The data is correlated with calendar-related effects,
whether it’s weekly, monthly, or seasonally, and it’s domain-specific.
For example, for most e-commerce platforms, their sales around
December rise because of Christmas. In contrast, for real estate, the
volume of sold houses in the summer would be higher than in the
winter in Canada because people are reluctant to move around in the
winter season.
Temperature data in Delhi with a strong seasonality
• Methods to Check Stationarity
• During the TSA model preparation workflow, we must assess whether
the dataset is stationary or not. This is done using Statistical
Tests. There are two tests available to test if the dataset is stationary:
• Augmented Dickey-Fuller (ADF) Test
• Kwiatkowski-Phillips-Schmidt-Shin (KPSS) Test
• Augmented Dickey-Fuller (ADF) Test or Unit Root Test
• The ADF test is the most popular statistical test. It is done with the
following assumptions:
• Null Hypothesis (H0): Series is non-stationary
• Alternate Hypothesis (HA): Series is stationary
• p-value >0.05 Fail to reject (H0)
• p-value <= 0.05 Accept (H1)
• Steps Involved:
• Difference the series: The ADF test can be performed on the original series or
on the differenced series. Differencing is a way to remove trends or seasonality.

• Test the Significance of γ: If the test statistic is less than the critical value, you
reject the null hypothesis and conclude that the series is stationary.
• Kwiatkowski–Phillips–Schmidt–Shin (KPSS) Test
• These tests are used for testing a NULL Hypothesis (HO) that will
perceive the time series as stationary around a deterministic trend
against the alternative of a unit root. Since TSA is looking for
Stationary Data for its further analysis, we have to ensure that the
dataset is stationary.
• Auto-Correlation Function (ACF)
• ACF indicates how similar a value is within a given time series and the
previous value. (OR) It measures the degree of the similarity between
a given time series and the lagged version of that time series at the
various intervals we observed.
• Python Statsmodels library calculates autocorrelation. It identifies a
set of trends in the given dataset and the influence of former
observed values on the currently observed values.
• Partial Auto-Correlation (PACF)
• PACF is similar to Auto-Correlation Function and is a little challenging
to understand. It always shows the correlation of the sequence with
itself with some number of time units per sequence order in which
only the direct effect has been shown, and all other intermediary
effects are removed from the given time series.
• Noise — Noise is also known as residues or irregulars. It’s what remains
after trend and seasonality are removed. It’s short-term fluctuation
which is not predictable. Sometimes noise can be dominant compared
with trend and seasonality, making this kind of time series data harder
to forecast. The stock price is a manifest example.
• White noise is the extreme situation of noise that has no trend and
seasonality. Therefore it’s nearly impossible to predict, and it’s a kind of
stationary time-series data.
White noise
Decomposition Models

• Time series components can be decomposed with the following


models:
• Additive decomposition
• Multiplicative decomposition
• Additive model
• Additive models assume that the observed time series is the sum of its components:

• Additive models are used when the magnitudes of the seasonal and residual values do not depend on
the level of the trend.

• additive = trend + seasonal + residuals


• Multiplicative Model
• Assumes that the observed time series is the product of its
components:

• It is possible to transform a multiplicative model to an additive one by


applying a log transformation:
• Multiplicative models are used when the magnitudes of seasonal and
residual values depends on trend.
• multiplicative = trend * seasonal # we do not include the residuals to
make the pattern more clear
• Differencing − This method includes taking the trend component out
of the data by subtracting successive observations from one another.
• Seasonal Decomposition of Time Series (STL) − This approach divides
a time series into trend, seasonal, and residual components.
• Log transformations − This method can be used to reduce the trend
component and stabilize the variance.
➢ Autoregressive (AR) Models

● Autoregressive models are widely used in Time Series


forecasting to estimate future values of a variable based on its
past values.
● These models assume that the future values of a variable
depend on the past values of the same variable.
● Autoregressive models are used in various fields, such as
finance, meteorology, and economics.
● For example, a stock analyst can use an autoregressive model to
predict the future value of a stock based on its past
performance.

2
➢ Autoregressive Models

2
➢ Autoregressive Models

2
➢ Autoregressive Models

2
What Is an Autoregressive
Model?
• Autoregressive models predict future values based on past values.
• For example, an autoregressive model might seek to predict a stock's
future prices based on its past performance.
• They are widely used in technical analysis to forecast future security
prices.
• Autoregressive models implicitly assume that the future will resemble
the past.
• Therefore, they can prove inaccurate under certain market conditions,
such as financial crises or periods of rapid technological change.
AR (Auto-Regressive) Model
• The time period at t is impacted by the observation at various slots t-
1, t-2, t-3, ….., t-k. The impact of previous time spots is decided by the
coefficient factor at that particular period of time.
• The price of a share of any particular company X may depend on all
the previous share prices in the time series. This kind of model
calculates the regression of past time series and calculates the
present or future values in the series in know as Auto Regression (AR)
model.
Yt = β₁* y ₜ- + β₂* yₜ-₂ + β₃ * yₜ-₃ + ………… + βₖ * yₜ-ₖ
1
• An Autoregressive (AR) model is a type of statistical model used to describe
certain time-varying processes in nature, economics, and many other fields.
The model predicts future values based on past values of the same variable.
• Autoregressive (AR) Model: The term "autoregressive" consists of two
parts: "auto" means "self," and "regression" refers to a statistical
relationship between variables. In this model, the dependent variable is
regressed against its own previous values.
• It is called an autoregressive model because it uses the relationship
between a series of past observations to predict future values.
• An AR model of order p (denoted as AR(p)) implies that the value at any
given time is a linear combination of the past p values.
• Consider an example of a milk distribution company that produces
milk every month in the country.
• We want to calculate the amount of milk to be produced current
month considering the milk generated in the last year.
• We begin by calculating the PACF values of all the 12 lags with
respect to the current month.
• If the value of the PACF of any particular month is more than a
significant value only those values will be considered for the model
analysis.
AR (Auto-Regressive) Model
For e.g in the figure the values 1,2, 3 up to 12 displays the
direct effect(PACF) of the milk production in the current
month w.r.t the given the lag t. If we consider two
significant values above the threshold then the model will
be termed as AR(2).
Year 2000 2001 2002 2003 2004 2005 2006
Profit 60 72 75 65 80 95 102
(Rs in
lakh)

Fit a trend line to the following data by the method of least square.
(i)Calculate the estimated trend values.
(ii)Also estimate the likely profit for 2008.
Month Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
Sales $000 125 145 186 131 151 192 137 157 198 143 163 204

Describe moving average


Monthly sales revenue data were collected for a company for 2022:

calculate a three-month moving average


Year 1977 1978 1979 1980 1981 1982 1983 1984
Profit (Rs in lakh) 1 0 3 8 10 4 5 8

Fit a trend line to the following data by the method of least square.
• Calculate the seasonal indices for the rain fall (in mm) data in Tamil Nadu given below by simple average method

Year Season
I II III IV
2001 118.4 260.0 379.4 70
2002 85.8 185.4 407.1 8.7
2003 129.8 336.5 403.1 12.0
2004 283.4 360.7 472.1 14.3
2005 231.7 308.5 828.8 15.9
Difference between AR to MA
• The AR model relates the current value of the series to
its past values. It assumes that past values have a
linear relationship with the current value.
• The MA model relates the current value of the series to
past white noise or error terms. It captures the shocks
or unexpected events in the past that are still affecting
the series.
• Key Characteristics
• Linearity: The AR model is a linear model, as it assumes a linear
relationship between the current value and past values.
• Stationarity: The AR model assumes that the underlying time series is
stationary, meaning its statistical properties (mean, variance,
autocorrelation) do not change over time. If the time series is not
stationary, it is usually differenced to achieve stationarity before applying
the AR model.
• Lagged Values: The model uses a specified number of lagged values,
which is denoted by ppp, the order of the model. Higher-order models
use more lagged values.
MA (Moving Average) Model
• The time period at t is impacted by the unexpected external factors at
various slots t-1, t-2, t-3, ….., t-k. These unexpected impacts are
known as Errors or Residuals.
• The impact of previous time spots is decided by the coefficient factor
α at that particular period of time.
• The price of a share of any particular company X may depend on
some company merger that happened overnight or maybe the
company resulted in shutdown due to bankruptcy.
• This kind of model calculates the residuals or errors of past time
series and calculates the present or future values in the series in know
as Moving Average (MA) model.
➢ Moving Average Models

4
➢ Moving Average Models

● A moving average term in


a time series model is a
past error (multiplied by
a coefficient).

● A moving average
model is used for
forecasting future values,
while moving average
smoothing is used for
estimating the trend-cycle
of past values.

● Denoted as MA(q).

4
➢ Moving Average Models

4
➢ Moving Average Models

4
5
➢ ARMA and ARIMA Models

5
➢ ARMA and ARIMA Models

● ARMA (AutoRegressive Moving Average) and ARIMA (AutoRegressive Integrated


Moving Average) models are commonly used in time series analysis for modeling
and forecasting temporal patterns.
● Both ARMA and ARIMA models combine autoregressive and moving average
components, but they differ in terms of the integration order.

5
➢ ARIMA Model

5
➢ ARIMA Model

● The ARIMA (AutoRegressive Integrated Moving Average)


model stands as a statistical powerhouse for analyzing and
forecasting time series data.

5
➢ ARIMA Model

5
➢ ARIMA Model

5
➢ ARIMA Model

Data Analytics and Visualization


Department of AI & DS Mrs. Aditi Malkar 5
➢ ARIMA Model

5
➢ ARIMA Model

5
➢ Autocorrelation Function (ACF)

https://allisonhorst.com/time-series-acf

6
➢ Building and Evaluating an ARIMA Model

6
➢ Building and Evaluating an ARIMA Model

6
➢ Reasons to Choose and Cautions

6
➢ Reasons to Choose

● Temporal Patterns: Time series analysis is essential when data exhibits


temporal patterns, such as trends, seasonality, or cyclic behavior. It helps in
understanding the underlying dynamics.
● Forecasting: Time series analysis allows for forecasting future values based on
historical patterns. It is crucial for making informed decisions and planning.
● Policy and Strategy Planning: Businesses and governments use time series
analysis to plan strategies and policies, especially in areas such as finance,
economics, and resource management.
● Resource Allocation: Understanding the patterns in time series data helps in
optimizing resource allocation, managing inventory, and planning production
schedules.
● Economic Indicators: Time series analysis is widely used to analyze economic
indicators such as GDP, unemployment rates, and inflation, providing insights into
economic trends.
● Stock Price Prediction: Investors use time series analysis to predict stock
prices based on historical market data, helping in making investment decisions.
● Weather Forecasting: Meteorologists use time series analysis to predict
weather patterns, temperatures, and other meteorological variables.
● Marketing and Sales: Time series analysis helps businesses analyze sales
trends, plan marketing strategies, and manage inventory based on demand
forecasts.

6
➢ Reasons to Cautions

● Stationarity Assumption: Many time series models assume stationarity. If


the data is non-stationary, transformations or differencing may be required.
● Data Quality: Poor data quality, missing values, or outliers can significantly
impact the reliability of time series analysis.
● Model Complexity: Choosing overly complex models may lead to
overfitting, especially if the data is noisy.
● Seasonality and Trends: Accurately identifying and modeling seasonality
and trends is challenging. Incorrect modeling can lead to biased forecasts.
● Overemphasis on Historical Data: Relying solely on historical data
without considering external factors or changes in the environment may
result in inaccurate predictions.
● Handling Dynamic Environments: Time series models may struggle to
adapt to dynamic environments or sudden changes.
● Model Validation: Proper validation is crucial to ensure the model's
generalization to unseen data. Overfitting or underfitting should be
assessed.
● Assumptions of Forecasting Models: Different forecasting models make
different assumptions, and it's essential to be aware of these assumptions to
choose an appropriate model for the data.

6
66
67

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy