0% found this document useful (0 votes)
15 views53 pages

Key Metrics for Time Series Forecasting

Uploaded by

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

Key Metrics for Time Series Forecasting

Uploaded by

Dhruv Suvarna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Q Identify and explain Key Performance Metrics to evaluate the performance

of time series forecasting models

Ans

Evaluating Time Series Forecasting Models

When building and evaluating time series forecasting models, it’s crucial to use
appropriate error metrics to measure the accuracy of the predictions. These metrics
help us understand how well a model performs and guide us in choosing the best
model for our forecasting needs. Commonly used error metrics include:

• Mean Absolute Error (MAE)

• Mean Squared Error (MSE)

• Root Mean Squared Error (RMSE)

• Mean Absolute Percentage Error (MAPE)

• Symmetric Mean Absolute Percentage Error (sMAPE)

• Mean Absolute Scaled Error (MASE)

• Weighted Absolute Percentage Error (WAPE)

Mean Absolute Error (MAE)

MAE is the average of the absolute differences between the actual and predicted
values. It gives an idea of how much the predictions deviate from the actual values
on average.

1
Pros:

• Easy to understand and interpret.

• Not sensitive to outliers.

Cons:

• Does not account for the scale of the data.

Mean Squared Error (MSE)

MSE is the average of the squared differences between the actual and predicted
values. It emphasizes larger errors due to the squaring operation.

Pros:

• Penalizes larger errors more than smaller errors.

• Differentiable, useful for optimization algorithms.

Cons:

• Sensitive to outliers.

• Harder to interpret due to squaring.

Root Mean Squared Error (RMSE)

2
RMSE is the square root of MSE. It provides an error metric on the same scale as
the original data.

Pros:

• Same units as the original data, making it interpretable.

• Penalizes large errors, highlighting poor performance.

Cons:

• Sensitive to outliers.

Mean Absolute Percentage Error (MAPE)

MAPE is the average of the absolute percentage errors between the actual and
predicted values. It expresses the error as a percentage.

Pros:

• Scale-independent, useful for comparing across datasets.

• Easy to interpret as a percentage.

Cons:

• Undefined for zero actual values.


3
• Can be biased if the actual values are very small.

Symmetric Mean Absolute Percentage Error (sMAPE)

sMAPE is a modified version of MAPE that treats over- and under-forecasting


equally.

Pros:

• Scale-independent.

• Balances the treatment of over- and under-forecasting.

Cons:

• Can be less interpretable than MAPE.

• Sensitive to small values in the denominator.

Mean Absolute Scaled Error (MASE)

MASE scales the absolute errors based on the in-sample mean absolute error from a
naive forecast method. This makes it easier to interpret the forecast accuracy.

Pros:

• Scale-independent.

• Useful for comparing forecast methods across different series.

4
Cons:

• Requires in-sample data to calculate the naive forecast error.

• More complex to compute than other metrics.

Weighted Absolute Percentage Error (WAPE)

WAPE is a variant of the Mean Absolute Percentage Error (MAPE), where the
absolute errors are weighted by the actual values. It provides a more balanced view
of forecast accuracy, especially useful when dealing with data with varying scales.

Pros:

• Scale-independent.

• Provides a more balanced view of forecast accuracy for datasets with varying
scales.

• Easy to interpret as a percentage.

Cons:

• Can be biased if actual values are very small.

• Less commonly used compared to other metrics.

5
Q Question: Discuss the working of ARIMA (Autoregressive Integrated
Moving Average) models

ANS

ARIMA (Autoregressive Integrated Moving Average) models are a popular


statistical method for time series forecasting, predicting future values based on past
observations by combining autoregressive (AR), integrated (I), and moving
average (MA) components.

Here's a breakdown of the ARIMA model:

1. Components:

• Autoregressive (AR):

This component uses past values of the time series to predict future values,
assuming that the current value is correlated with its previous values.

• Integrated (I):

This component addresses non-stationary time series data by differencing the


data to make it stationary, meaning its statistical properties (like mean and
variance) remain constant over time.

• Moving Average (MA):


This component uses past prediction errors (the difference between the actual
and predicted values) to improve the accuracy of future predictions.
2. How it Works:

• Data Analysis:

ARIMA models analyze time series data to identify patterns and trends.

• Model Building:

6
The model is built by combining the AR, I, and MA components, with the
order of each component denoted as (p, d, q), where 'p' is the order of the AR
component, 'd' is the order of integration, and 'q' is the order of the MA
component.

• Forecasting:

Once the model is built, it can be used to forecast future values by


extrapolating the identified patterns and trends.

• Stationarity:
The "I" component ensures that the time series data is stationary, which is a
key requirement for ARIMA models.
3. Applications:

• Finance: Predicting stock prices, interest rates, and other financial data.

• Economics: Forecasting economic indicators like GDP growth and inflation.

• Engineering: Predicting demand for products or services.

• Weather Prediction: Forecasting weather patterns.


4. Key Considerations:

• Stationarity:

Ensuring that the time series data is stationary is crucial for the effectiveness of
ARIMA models.

• Model Selection:

Choosing the appropriate values for 'p', 'd', and 'q' is important for building an
accurate model.

• Model Evaluation:

7
Evaluating the performance of the model using metrics like Mean Absolute
Error (MAE) or Root Mean Squared Error (RMSE) is important for ensuring
that the model is accurate.

Why Use ARIMA Forecasting?

Throughout finance, economics and environmental sciences etc., ARIMA has great
interest because it can identify many complex patterns of our past observations
with future needs which makes it a state-of-the-art technique. From predicting the
price of stocks, forecasting weather patterns to getting an idea about consumer
demand, ARIMA is a great way to make accurate and actionable predictive
analyses.

By using ARIMA, we are able to both analyze and forecast time series data in a
sophisticated manner that accounts for patterns, trends, and seasonality. This
facilitates a 360-degree view of the underlying dynamics for making informed
decisions.

Key Components of ARIMA Models

In order to really understand ARIMA, we need to deconstruct its building blocks.


Once we have the components down, it will become easier to understand how this
time series forecasting method works as a whole. Here, I’ll give a detailed
explanation of every component.

8
Autoregressive (AR) part

The Autoregressive (AR) component builds a trend from past values in the AR
framework for predictive models. For clarification, the 'autoregression framework'
works like a regression model where you use the lags of the time series' own past
values as the regressors.

Integrated (I) part

The Integrated (I) part involves the differencing of the time series component
keeping in mind that our time series should be stationary, which really means that
the mean and variance should remain constant over a period of time. Basically, we
subtract one observation from another so that trends and seasonality are eliminated.
By performing differencing we get stationarity. This step is necessary because it
helps the model fit the data and not the noise.

Moving average (MA) part

The moving average (MA) component focuses on the relationship between an


observation and a residual error. Looking at how the present observation is related
to those of the past errors, we can then infer some helpful information about any
possible trend in our data.

We can consider the residuals among one of these errors, and the moving average
model concept estimates or considers their impact on our latest observation. This is
particularly useful for tracking and trapping short-term changes in the data or
random shocks. In the (MA) part of a time series, we can gain valuable information
about its behavior which in turn allows us to forecast and predict with greater
accuracy.

9
How to Build an ARIMA Model

Data collection

The first step is to tee up an appropriate dataset and prepare our environment.

Find a dataset

Collect or search for a dataset from data source platforms. You want one that has
historical data over time

Load the data

We then read the data into our local environment.

Data preprocessing

Our dataset is pretty clean, but in other contexts, we would have to handle indexing
issues, which is important in time series forecasting. For example, since we are
forecasting the closing value of a stock on a particular exchange, we have to
consider that the stock market is not open on weekends.

Handle missing values

As part of data preprocessing, we also often have to consider how to handle


missing values using an imputation method like forward filling or mean
replacement. Do know that even one NA value, depending on the programming
language and the library you are using, can prevent an ARIMA from running.

10
Create a time plot

Check for stationarity and perform differencing if necessary

While ARIMA models can deal with non-stationarity up to a point, they cannot
effectively account for time-varying variance. In other words, for an ARIMA
model to really work, the data has to be stationary.

Q four main Components of Time Series

A graphical representation of time series data shows continuous changes


in its values over time, giving an impression of fluctuating nature of data.

A close look of the graph, however, reveals that the fluctuations are not totally
arbitrary, and a part of these fluctuations has a steady behavior and can be related
to time.

This part is the systematic part of the time series and the remaining part is non
systematic or irregular.
The systematic part is further divided in the following broad categories:

(i) secular trend (T), (ii) seasonal variation (S), and (iii) cyclical variation (C).

The non systematic part is also called (iv) irregular variation (I).

Every time series has some or all of these components.

Of course, only the systematic components of a time series are useful in


forecasting its future values.

We now discuss the four components of a time series in detail.


11
Secular Trend (T)

The secular trend is the long term pattern of a time [Link] secular trend can be
positive or negative depending on whether the time series exhibits an increasing
long term patternor a decreasing long term [Link] secular trend shows a
smooth and regular long term movement of the time series.
The secular trend does not include short term fluctuations, but only consists of a
steady movement over a long period of time. It is the movement that the series
would take if there are no seasonal, cyclical or irregular variations. It is the effect
of factors that are more or less constant for a long time or that change very
gradually and slowly over [Link] a time series does not s ow an increasing or
decreasing pattern, then the series is stationary around the mean.

12
There are ups and downs in the graph, but the time series shows an upward trend
in long run.

13
14
The above graph shows a downward trend.

Seasonal Variation (S)

Many time series related to financial, economic, and business activities consist of
monthly or quarterly data. It is observed very often that these time series exhibit
seasonal variation in the sense that similar patterns are repeated from year to year.
Seasonal variation is the component of a time series that involves patterns of
change within a year that repeat from year to year.

Several commodities show seasonal fluctuations in their demand.

Warm clothes and woolen products have a market during the winter season.

Fans, coolers, cold drinks and ice creams are in great demand during summer.

Umbrellas and raincoats are in great demand during the rainy season.
Different festivals are associated with different commodities and every festival
season is associated with an increase in demand for related commodities.

For example, clothes and firecrackers are in great demand during Diwali. Most of
the seasonal variations in demand reflect changes in climatic conditions or customs
and habits of people.

All the above examples have one year as the period of seasonal variation.

However, the period of seasonal variation can be a month, a week, a day, or even
an hour, depending on the nature of available data.

For example, cash withdrawals in a bank show seasonal variation among the days
of a month, the number of books borrowed by readers from a library show
15
seasonal variation according to days of a week, passenger traffic at

a railway station has seasonal variation during hours of a day, and the temperature
recorded in a city exhibits seasonal variation over hours of a day, in addition to
seasonal variation with changing seasons in a year.

Seasonal variation is measured with help of seasonal indices, which are useful for
short term forecasting. Such short term forecasts are useful for a departmental store
in planning its inventory according to months of a year.

A bank manager can use such short term forecasts in managing cash flow on
different days of a week or a month.

16
Figure shows a pattern that is repeated year after year. The values are lowest (in the
year) in second quarter and highest (in the year) in fourth quarter of every year.
Although the

overall graph of the time series in Figure 4.3 shows an increasing trend, the
seasonal variation within every year is very clearly visible in the graph.

Cyclical Variation (C)

Cyclical variation is a long term oscillatory movement in values of a time series.


Cyclical variation occurs over a long period, usually several years, if seasonal
variation occurs within a year. One complete round of oscillation is called a cycle.
Cyclical variations need not be periodic in the sense that the length of a cycle or the
magnitude of variation within a cycle can change from one cycle to another.

17
Cyclical variations are observed in almost all time series related to economic or
business activities, where a cycle is known as a business cycle or trade cycle.
Recurring ups and downs in a business are the main causes of cyclical variation.A
typical business cycle consists of the following four phases: (i) prosperity, (ii)
recession, (iii) depression, (iv) recovery.

Figure depicts these four phases of a business cycle, where every phase changes to
the next phase gradually in the order mentioned above.

18
Cyclical variations can consist of a period of 5 years, 10 years, or even longer
duration. The period often changes from one cycle to another. Cyclical variation
may be attributed to internal organizational factors such as purchase and inventory
policies or external factors such as financial market conditions and government
policies.

19
Irregular Variation (I)
Irregular variations are unexpected variations in time series caused by unforeseen
events that can include natural disasters like floods or famines, political events line
strikes or agitations, or international events like wars or others conflicts.

As the name suggests, irregular variations do not follow any patterns and are,
therefore, totally unpredictable. For this reason, irregular variation are also known
as unexplained or unaccounted variations.

ANS

Q Single, double and triple exponential Smoothing

Ans

• Single Exponential Smoothing, also called Simple Exponential Smoothing,


is a time series forecasting method for univariate data without a trend or
seasonality. It requires a single parameter, called alpha (a), also called the
smoothing factor or smoothing coefficient

20
This parameter controls the rate at which the influence of observations at
prior time steps decays exponentially.

Alpha is often set to a value between 0 and 1.

• Large values mean that the model pays attention mainly to the most recent
past observations, whereas smaller values mean more of the history is taken
into account when making a prediction.

Double Exponential Smoothing

• Double Exponential Smoothing is an extension to Exponential Smoothing


that explicitly adds support for trends in the univariate time series.

• In addition to the alpha parameter for controlling the smoothing factor for
the level, a smoothing factor is added to control the decay of the influence of
the change in a trend, called beta (b).

• The method supports trends that change in different ways: an additive and a
multiplicative, depending on whether the trend is linear or exponential
respectively.

• Double Exponential Smoothing with an additive trend is classically referred


to as Holt’s linear trend model, named after the developer of the
method, Charles Holt.

Triple Exponential Smoothing

• Triple Exponential Smoothing is an extension of Exponential Smoothing


that explicitly adds support for seasonality to the univariate time series.

21
• In addition to the alpha and beta smoothing factors, a new parameter is
added called gamma (g), which controls the influence on the seasonal
component.

• As with the trend, the seasonality may be modeled as either an additive or


multiplicative process, for a linear or exponential change in the seasonality.

Q Moving Average (MA) models in time series forecasting

Ans

In time series forecasting, the moving average method smooths data by calculating
the average of values over a specific period, helping to identify underlying trends
and patterns while reducing short-term fluctuations.
Here's a more detailed explanation:

• What it is:

A moving average is a series of averages calculated from historical data, where


each average is calculated over a fixed-width "window" of data points.

• How it works:

• You choose a period (e.g., 3-month, 7-day) and calculate the average of
the data points within that period.
• As new data becomes available, you "slide" the window forward,
dropping the oldest data point and adding the newest, then recalculating
the average.
• This process creates a new series of averages, which is the moving
average.

22
• Why it's useful:

• Smoothing: Moving averages reduce the impact of short-term fluctuations


and noise, revealing the underlying trend or long-term pattern in the data.
• Trend Identification: By smoothing out the data, moving averages make it
easier to identify trends, cycles, and seasonal patterns.
• Forecasting: While not a perfect forecasting method on its own, moving
averages can be used as a basis for forecasting by extrapolating the trend.
• Types of Moving Averages:

• Simple Moving Average (SMA): The average of the values over the last n
periods.
• Weighted Moving Average (WMA): Assigns different weights to data
points, with more recent data points having higher weights.
• Exponential Moving Average (EMA): A type of weighted moving
average that gives more weight to recent data points, but with a
decreasing weight for older data.
• Limitations:

• Lag: Moving averages lag behind the actual data, as they are based on
past values.
• Sensitivity to Period Length: The choice of the moving average period
can significantly impact the results, and a longer period can smooth out
too much detail, while a shorter period may not smooth out enough.
• Not Suitable for All Data: Moving averages are best suited for data that
has a clear underlying trend or cycle, and may not be effective for data
that is highly random or irregular.
• Applications:

23
• Stock Market Analysis: Moving averages are commonly used by traders
and investors to identify trends and potential trading opportunities.
• Sales Forecasting: Businesses can use moving averages to forecast future
sales based on past sales data.
• Other Time Series Data: Moving averages can be applied to a wide range
of time series data, such as weather patterns, economic indicators, and
website traffic.

Q Explain the Forecasting Process

Ans

A process is a series of connected activities that transform one or more inputs into
one or more outputs. All work activities are performed in processes, and
forecasting is no exception.

The activities in the forecasting process are:

1. Problem definition

2. Data collection

3. Data analysis

4. Model selection and fitting

5. Model validation

6. Forecasting model deployment

7. Monitoring forecasting model performance

24
Problem definition

Problem definition involves developing understanding of how the forecast will be


used along with the expectations of the "customer" (the user of the forecast).
Questions that must be addressed during this phase include the desired form of the
forecast (e.g., are monthly forecasts required). the forecast horizon or lead time.
how often the forecasts need to be revised (the forecast interval). and what level of
forecast accuracy is required in order to make good business decisions. This is also
an opportunity to introduce the decision makers to the use of prediction intervals as
a measure of the risk associated with forecasts. if they are unfamiliar with this
approach. Often it is necessary to go deeply into many aspects of the business
system that requires the forecast to properly define the forecasting component of
the entire problem. For example, in designing a forecasting system for inventory
control. information may be required on issues such as product shelf life or other
aging considerations. the time required to manufacture or otherwise obtain the
products (production lead time). and the economic consequences of having too
many or too few units of product available to meet customer demand. When
multiple products are involved. the level of aggregation of the forecast (e.g., do we
forecast individual products or families consisting of several similar products) can
be an important con~ideration. Much of the ultimate success of the forecasting
model in meeting the customer expectations is determined in the problem
definition phase.

25
Data collection

consists of obtaining the relevant history for the variable( s) that are to be forecast,
including historical information on potential predictor variables. The key here is
"relevant"; often information collection and storage methods and systems change
over time and not all historical data is useful for the current problem. Often it is
necessary to deal with missing values of some variables, potential outliers, or other
data-related problems that have occurred in the past. During this phase it is also
useful to begin planning how the data collection and storage issues in the future
will be handled so that the reliability and integrity of the data will be preserved

Data analysis

Data analysis is an important preliminary step to selection of the forecasting model


to be used. Time series plots of the data should be constructed and visually
inspected for recognizable patterns, such as trends and seasonal or other cyclical
components. A trend is evolutionary movement, either upward or downward, in the
value of the variable. Trends may be long term or more dynamic and of relatively
short duration. Seasonality is the component of time series behavior that repeats on
a regular basis, such as each year. Sometimes we will smooth the data to make
identification of the patterns more obvious . Numerical summaries of the data, such
as the sample mean, standard deviation, percentiles, and autocorrelations, should
also be computed and evaluated.. If potential predictor variables are available,
scatter plots of each pair of variables should be examined. Unusual data points or
potential outliers should be identified and flagged for possible further study. The
purpose of this preliminary data analysis is to obtain some "feel" for the data, and a
sense of how strong the underlying patterns such as trend and seasonality are. This
information will usually suggest the initial types of quantitative forecasting
methods and models to explore.
26
Model selection

Model selection and fitting consists of choosing one or more forecasting models
and fitting the model to the data. By fitting, we mean estimating the unknown
model parameters, usually by the method of least squares.

Model validation

Model validation consists of an evaluation of the forecasting model to determine


how it is likely to perform in the intended application. This must go beyond just
evaluating the "fit" of the model to the historical data and must examine what
magnitude of forecast errors will be experienced when the model is used to
forecast "fresh" or new data. The fitting errors will always be smaller than the
forecast errors, and this is an important concept that we will emphasize in this
book. A widely used method for validating a forecasting model before it is turned
over to the customer is to employ some form of data splitting, where the data is
divided into two segments-a fitting segment and a forecasting segment. The model
is fit to only the fitting data segment, and then forecasts from that model are
simulated for the observations in the forecasting segment. This can provide useful
guidance on how the forecasting model will perform when exposed to new data
and can be a valuable approach for discriminating between competing forecasting
models

Forecasting model deployment

Forecasting model deployment involves getting the model and the resulting
forecasts in use by the customer. It is important to ensure that the customer
understands how to use the model and that generating timely forecasts from the
model becomes as routine as possible. Model maintainance, including making sure
that data sources and other required information will continue to be available to the

27
customer is also an important issue that impacts the timeliness and ultimate
usefulness of forecasts

Monitoring forecasting model

Monitoring forecasting model performance should be an ongoing activity after the


model has been deployed to ensure that it is still performing ~atisfactorily. It is the
nature of forecasting that conditions change over time, and a model that performed
well in the past may deteriorate in performance. Usually performance deterioration
will result in larger or more systematic forecast errors. Therefore monitoring of
forecast errors is an essential part of good forecasting system design. Control
charts of forecast errors are a simple but effective way to routinely monitor the
performance of a forecasting model.

Q Exponential smoothing time series forecasting method

Ans

Exponential smoothing is a time series forecasting method that uses a weighted


average of past observations, giving more weight to recent data points, to predict
future values. The weights assigned to past observations decrease exponentially as
they become older, allowing the forecast to adapt to changing trends in the data.

Here's a more detailed explanation:

Key Concepts:

• Weighted Average:

28
Exponential smoothing calculates a weighted average of past data points,
meaning that each data point contributes to the forecast based on a specific
weight.

• Exponential Decay:

The weights assigned to past observations decrease exponentially as they


become older, with more recent observations having higher weights than older
ones.

• Smoothing Effect:

By giving more weight to recent data, exponential smoothing creates a


"smoothed" version of the original time series, making it less sensitive to
random fluctuations or noise.

• Types of Exponential Smoothing:

• Simple Exponential Smoothing: Used for time series with no trend or


seasonality.

• Double Exponential Smoothing (Holt's Method): Used for time series


with a trend but no seasonality.

• Triple Exponential Smoothing (Holt-Winters Method): Used for time


series with both trend and seasonality.
• Smoothing Parameter (α):
A value between 0 and 1 that controls the rate at which past observations are
discounted. A higher value of α gives more weight to recent observations,
while a lower value gives more weight to older observations.
How it Works:

29
1. Initialization: Start with an initial forecast (or estimate) for the first time
period.

2. Calculate the Forecast: For each subsequent time period, calculate the
forecast by taking a weighted average of the previous forecast and the actual
value from the previous period.

3. Update the Forecast: Use the calculated forecast as the new forecast for the
next time period.

4. Repeat: Continue this process for all time periods in the time series.
Advantages:

• Simplicity: Exponential smoothing is relatively easy to understand and


implement.

• Adaptability: It can adapt to changing trends in the data by giving more


weight to recent observations.

• Efficiency: It requires minimal computation and data storage.


Disadvantages:

• Sensitivity to Parameters: The choice of smoothing parameter (α) can


significantly impact the forecast accuracy.

• Limited for Complex Patterns: It may not be suitable for time series with
complex patterns, such as multiple seasonalities or non-linear trends.

• Long-Term Forecast Accuracy: Long-term forecasts using exponential


smoothing can be unreliable.

Q Explain the four broad categories of Time Series forecasting techniques


30
Ans

Time Series forecasting can be further classified into four broad categories of
techniques:

1. Time Series Decomposition: This approach involves breaking down a time


series into its trend, seasonality, and residual components, and then
forecasting each component separately. The final forecast is obtained by
adding the forecasts of each component

2. Smoothing Based Techniques: This category includes methods like moving


average and exponential smoothing that use past values to smooth out noise
in the time series and make predictions
3. Regression Based Techniques: This category includes methods like linear
regression and ARIMA that use a combination of past values and other
predictors to make predictions.
4. Machine Learning Based Techniques: This category includes methods like
random forests, neural networks, and support vector machines that use
algorithms from machine learning to fit models to the time series data and
make predictions. These methods can handle complex and non-linear data and
have achieved state-of-the-art performance in many time series forecasting
tasks.

Smoothing methods are a class of time series forecasting techniques that aim to
remove noise and make predictions by averaging the past values of a time series.
There are two commonly used smoothing methods:

31
1. Average Method: This method involves taking the average of a fixed number
of past values to make predictions. For example, if we have a time series y
with n values, the average method would predict the next value as the average
of the last n values.
2. Moving Average Smoothing: This method is similar to the average method,
but instead of using a fixed number of past values, it uses a sliding window of
a fixed size to average the past values. For example, if the window size is m,
the moving average method would predict the next value as the average of the
last m values.

Regression Based Techniques

1. Linear Regression: Time series analysis can also be performed using linear
regression, which is a supervised machine learning method used to model the
relationship between a dependent variable and one or more independent
variables. In time series analysis, the dependent variable is the time series
data, and the independent variable is time.
2. ARIMA Model: ARIMA is a commonly used method for time series analysis
and forecasting, which stands for Autoregressive Integrated Moving Average.
It is a type of regression-based model that uses past values of the time series
to make predictions.

Discuss Autoregressive (AR) models

Ans

32
Autoregressive (AR) models in time series forecasting predict future values based
on the linear combination of past values, assuming current values depend on
previous ones. They are denoted as AR(p), where 'p' represents the order (number
of past values used).

Here's a more detailed explanation:

• Core Concept:

AR models are a type of statistical model that uses past data points to predict
future values in a time series.

• Linear Relationship:

The model assumes that the current value of a time series is a linear function of
its past values.

• AR(p) Notation:

The "p" in AR(p) indicates the order of the model, which is the number of
lagged values (past time steps) used to predict the current value. For example,
AR(1) uses the previous value, AR(2) uses the previous two values, and so on.

• Mathematical Representation:

An AR(p) model can be represented as: Yt = c + φ1Yt-1 + φ2Yt-2 + ... + φpYt-


p + εt.

• Yt: The value of the time series at time t.

• c: A constant term.

• φ1, φ2, ..., φp: The autoregressive coefficients, which determine the
influence of past values on the current value.

• Yt-1, Yt-2, ..., Yt-p: The values of the time series at previous time steps.

33
• εt: A white noise term, representing random shocks or errors.
• Applications:

AR models are widely used in various fields, including finance (predicting


stock prices), economics (forecasting economic indicators), and engineering
(predicting system behavior).

• Limitations:

AR models are most effective when the time series data exhibits a strong
dependence on its past values and is stationary (meaning its statistical
properties, like mean and variance, do not change over time).

• Advanced Models:
More complex models like ARIMA (Autoregressive Integrated Moving
Average) and ARMAX (Autoregressive Moving Average with eXogenous
variables) build upon the AR model by incorporating additional factors like
trends, seasonality, and external variables.

Predicting future values is fundamental when working with time-series data, which
records observations over time. Autoregressive (AR) models are among the most
foundational tools for this, using past data points to forecast future outcomes.
These models are essential for analysts working with time-series data in areas like
finance, economics, and forecasting, as they provide a first step towards more
advanced predictive approaches.

Understanding autoregressive models is critical, as they form the basis for more
sophisticated techniques like ARIMA (autoregressive integrated moving average),

34
which incorporates additional complexities. By mastering AR models, analysts can
tackle time-series problems more effectively, building a strong foundation for
tackling real-world scenarios.

What Is an Autoregressive Model?

An autoregressive (AR) model is a statistical model used in time-series analysis


that leverages past data points to predict future values. Specifically, it builds a
multilinear function where the future value of a time series is expressed as a linear
combination of previous observations. By doing so, the model attempts to capture
the dependencies between the current and past data points.

Let’s consider a simple time series with 100 entries (starting at t=0 and ending at
t=99). The goal of an AR model is to predict the value at the next time step, t=100,
by using previous data points.

Autoregressive model example

Suppose we want to predict the value at t=100. An autoregressive model will look
at a specific number of previous data points to make this prediction. For instance,
if we decide to use the three most recent entries—known as a lag of 3—we would
use the data points at t=97, t=98, and t=99 to predict the value at t=100

The autoregressive model for X(100) can be written as:

X(100) = C0 + C1X(99) + C2X(98) + C3X(97)

where:

• X(100) represents the value at time step t=100.

35
• C0, C1, C2, C3 are coefficients that the model will learn from the data.
• The coefficients are determined using a multilinear regression fit on the
previous data points: X(t) = C0+C1X(t−1)+C2X(t−2)+C3X(t−3)

How Autoregression Predicts Future Values

Autoregressive models are not limited to predicting just the next data point; they
can also project further into the future. For example, after predicting X(100), the
model can use this predicted value, along with other past values, to forecast X(101)
and continue this process for subsequent points. This technique is known
as recursive forecasting.

To illustrate:

• First, predict X(100) using X(99), X(98), and X(97)


• Then, predict X(101) using X(100) (which was predicted), X(99), and X(98)

However, there’s a catch. Since the model uses predicted values for future
predictions, compounding errors occur. The further into the future you predict,
the more the errors accumulate, causing predictions to become less accurate over
time. For example, the prediction for X(101) is based on X(100), which may
already have some prediction error, leading to an amplified error for X(101)

Lag Correlation and Model Order

Lag correlation refers to the correlation between a time series value at a specific
time t, denoted as X(t), and a previous series value at a lagged time t-k, where k is
the lag. For instance, X(t) and X(t-1) are lagged by 1, and their correlation is
called lag 1 correlation.

36
The lag correlation can tell us how well past values of the time series can predict
future values. High lag correlation (close to 1) suggests that an autoregressive
model might be appropriate because there’s a significant relationship between the
current and previous data points.

Q Define Time Series. Write the Objectives, examples and uses of time series
analysis.

Ans

Time Series is a sequence of observations made on a variable at regular time


intervals over a specified period of time.

Data collected arbitrarily or irregularly does not form a time series.

Time series analysis involves the use of statistical methods to analyze time
series data in order to extract meaningful statistics and understand important
characteristics of the observed data.

Time Series Analysis helps us understand the underlying forces leading to a


particular pattern in the time series and helps us in monitoring and
forecasting data with help of appropriate statistical models.

Analysis of time series data requires maintaining records of values of the variable
over time.

37
Some examples from day-to-day life may give a better idea of time series.

1. Monthly, quarterly, or yearly production of an industrial product.

2. Yearly GDP (Gross Domestic Product) of a country.

3. Monthly sales in a departmental store.

4. Weekly prices of vegetables.

5. Daily closing price of a share at a stock exchange.

6. Hourly temperature of a city recorded by the Meteorological


Department.

Uses of Time Series Analysis

The main objective of time series analysis is to understand, interpret and

assess chronological changes in values of a variable in the past, so that reliable


predictions can be made about its future values.

For example, the government may be interested in predicting population growth in


near future for planning its welfare schemes, the agricultural ministry may be
interested in predicting annual crop yield before declaring the MSP (minimum
support price) of agricultural produce or an industrialist may be interested in
predicting the weekly demand for his product for making the production
schedule.
38
Following are considered to be some of the important uses of time series
analysis.

1-It is useful for studying the past behaviour of a variable.

In a time series, the past observations on a variable are arranged in an orderly


manner over a period of time.

By simple observation of such a series, one can understand the nature of changes
that have taken place in values of the variable during the course of time.

Further, by applying appropriate technique of analysis to the series, one can study
the general tendency of the variable in addition to seasonal changes, cyclical
changes, and irregular or accidental changes in values of the variable.

2. It is useful for forecasting future behaviour of a variable.

Analysis of a time series reveals the nature of changes in the value of a variable
during the course of times.

This can be useful in forecasting the future values of the variable. Thus, with the
help of observations on an appropriate time series, future plans can be made
relating to certain matters like purchase, production, sales, etc.

This is how a planned economy makes plans for the future development on the basis
of time series analysis of the relevant data.

3 It is useful in evaluating the performance.

39
Evaluation of the actual performances in comparison with predetermined targets is
necessary to judge efficiency of the work.

For example, the achievements of Five- Year Plans are evaluated by determining
the annual rate of growth in the gross national product. Similarly, the national
policy of controlling inflation and pricerises is evaluated with the help of different
price indices. All these are made possible by analysis of time series of the relevant
variables.

4. It is useful in making a comparative study.


A comparative study of data relating to two or more periods, regions, or industries
reveals a lot of valuable information that can guide management in taking a proper
course of action.

A time series itself provides a scientific basis for making comparisons between two
or more related sets of data.

Note that data are arranged chronologically in such a series, and the effects of
its various components are gradually isolated, analyzed, and interpreted.

Q Question: Explain the Mathematical Models of Time Series

Ans

Let Xt denote the value of the variable at time t. The time series is denoted by the
collection of values, {Xt, t = 0, 1, ... , T} where T is the total duration of
observation.

40
There are two standard mathematical models for time series based on the four
components mentioned earlier, namely, secular trend (T), seasonal variation (S),
cyclical variation (C), and irregular variation (I).

Additive Model

The additive model assumes that the value Xt at time t is the sum of the four
components at time t.

Thus,

Xt = Tt + St + Ct + It

The additive model assumes that the four components of the time series are
independent of one another.

It is also important to remember that all the four components in the additive model
must be measured in the same unit of measurement.

The magnitude of the seasonal variation does not depend on the value of the time
series in the additive model. In other words, the magnitude of the seasonal
variation does no change as the series goes up or down.

The assumption of independence of the components is often not realistic. In such


situations, the multiplicative model can be used.

Multiplicative Model

The multiplicative model that the value Xt at the time t is obtained by

41
multiplication of the four components at time t. That is,

Xt = Tt × St × Ct × It

The multiplicative model does not assume independence of the four components of
the series and is, therefore, more realistic.
Values of the trend are expressed in units of measurements and other components
are expressed as percentage or relative values, and hence are free from units of
measurements.

It is recommended to choose the multiplicative model when the magnitude of the


seasonal variation in the data depends on the magnitude of the data. In other words,
the magnitude of the seasonal variation increases as the data values increase, and
decreases as the data values decrease.

Time Series Decomposition models

➢ Additive model
Multiplicative model
➢ Pseudo-additive models

• Additive model

• The additive model assumes the observed time series is the sum of
components:

• Observation = trend + seasonality

42
• Additive models are used when the magnitude of seasonal and
residual values are independent of the trend.

• Multiplicative model

• The multiplicative model assumes the observed time series is a product of its
components:

• Observation = trend * seasonality * residual

• We can transform the multiplicative model to an additive model by applying


a log transformation:

• log(time * seasonality * residual) = log(Time) + log(seasonality) +


log(residual)

• These are used if the magnitudes of seasonal and residual values fluctuate
with the trend.

Pseudo-additive models

• Pseudo-additive models combine the elements of both additive and


multiplicative models.

• They can be useful when:

• Time series values are close to or equal to zero

• We expect features related to the multiplicative model

• Division by zero often becomes a problem when this is the case

43
Q Question: Discuss Applications of Forecasting

Ans

Ans

1-Operations Management. Business organizations routinely use forecasts of


product sales or demand for services in order to schedule production. control
inventories, manage the supply chain, determine staffing requirements. and plan
capacity. Forecasts may also be used to determine the mix of products or services
to be offered and the locations at which products are to be produced.

2-Marketing. Forecasting is important in many marketing decisions. Forecasts of


sales response to advertising expenditures, new promotions, or changes in pricing
polices enable businesses to evaluate their effectiveness, determine whether goals
are being met, and make adjustments.

3. Finance and Risk Management. Investors in financial assets are interested in


forecasting the returns from their investments. These assets include but are not
limited to stocks, bonds, and commodities; other investment decisions can be made
relative to forecasts of interest rates, options, and currency exchange rates.
Financial risk management requires forecasts of the volatility of asset returns so
that the risks associated with investment portfolios can be evaluated and insured,
and so that financial derivatives can be properly priced.

4. Economics. Governments, financial institutions, and policy organizations require


forecasts of major economic variables, such as gross domestic product, population
growth, unemployment, interest rates, inflation, job growth, production, and
consumption. These forecasts are an integral part of the guidance behind monetary
and fiscal policy and budgeting plans and decisions made by governments. They

44
are also instrumental in the strategic planning decisions made by business
organizations and financial institutions.

5. Industrial Process Control. Forecasts of the future values of critical quality


characteristics of a production process can help determine when important
controllable variables in the process should be changed, or if the process should be
shut down and overhauled. Feedback and feedforward control ~chemes are widely
used in monitoring and adjustment of industrial processes, and predictions of the
process output are an integral part of these schemes.

6. Demography. Forecasts of population by country and regions are made


routinely, often stratified by variables such as gender, age, and race. Demographers
also forecast births, deaths, and migration patterns of populations. Governments
use these forecasts for planning policy and social service actions, such as spending
on health care, retirement programs, and antipoverty programs. Many businesses
use forecasts of populations by age groups to make strategic plans regarding
developing new product lines or the types of services that will be offered.

Q Question: Explain Exponential smoothing time series forecasting method

Ans

Exponential smoothing is a time series forecasting method that uses a weighted


average of past observations, giving more weight to recent data points, to predict
future values. The weights assigned to past observations decrease exponentially as
they become older, allowing the forecast to adapt to changing trends in the data.

Here's a more detailed explanation:

Key Concepts:
45
• Weighted Average:

Exponential smoothing calculates a weighted average of past data points,


meaning that each data point contributes to the forecast based on a specific
weight.

• Exponential Decay:

The weights assigned to past observations decrease exponentially as they


become older, with more recent observations having higher weights than older
ones.

• Smoothing Effect:

By giving more weight to recent data, exponential smoothing creates a


"smoothed" version of the original time series, making it less sensitive to
random fluctuations or noise.

• Types of Exponential Smoothing:

• Simple Exponential Smoothing: Used for time series with no trend or


seasonality.

• Double Exponential Smoothing (Holt's Method): Used for time series


with a trend but no seasonality.

• Triple Exponential Smoothing (Holt-Winters Method): Used for time


series with both trend and seasonality.
• Smoothing Parameter (α):
A value between 0 and 1 that controls the rate at which past observations are
discounted. A higher value of α gives more weight to recent observations,
while a lower value gives more weight to older observations.
How it Works:

46
5. Initialization: Start with an initial forecast (or estimate) for the first time
period.

6. Calculate the Forecast: For each subsequent time period, calculate the
forecast by taking a weighted average of the previous forecast and the actual
value from the previous period.

7. Update the Forecast: Use the calculated forecast as the new forecast for the
next time period.

8. Repeat: Continue this process for all time periods in the time series.
Advantages:

• Simplicity: Exponential smoothing is relatively easy to understand and


implement.

• Adaptability: It can adapt to changing trends in the data by giving more


weight to recent observations.

• Efficiency: It requires minimal computation and data storage.


Disadvantages:

• Sensitivity to Parameters: The choice of smoothing parameter (α) can


significantly impact the forecast accuracy.

• Limited for Complex Patterns: It may not be suitable for time series with
complex patterns, such as multiple seasonalities or non-linear trends.

• Long-Term Forecast Accuracy: Long-term forecasts using exponential


smoothing can be unreliable.

QQuestion: Discuss Simple Forecasting Methods


47
Ans

A few simple forecasting methods are:

1. Simple Average Method

2. Moving Average Method

3. Weighted Moving Average Method

4. Naive Method

5. Seasonal Naive Method

6. Exponential Smoothing Method

Simple Average Method

In this method of forecasting, all the future values are equal to the average of the
past values i.e. the historical data.

What will happen in the future is the average of everything that has happened until
now.

48
Simple Average Method to forecast the demand for 2023

Moving Average Method

In this method of forecasting, the future values are equal to the average of the past
values over a defined period of time.

For example, we can use 2-point moving average, 3-point moving average etc. In
2-point moving average, we consider the past 2 data points and for 3-point moving
average, we consider the past 3 data points and so on.

The moving average is extremely useful for forecasting long-term trends.

2 year Moving Average (MA) to forecast the demand for 2023

3 year Moving Average (MA) to forecast the demand for 2023

Weighted Moving Average Method

49
This method of forecasting puts more weight on recent data and less on past data.
The weighted average is calculated by multiplying the given data by its associated
weighting and totaling the values. The weights used in a weighted moving average
are typically based on the time period being analyzed and the specific requirements
of the analysis.

In the below example, we have assumed the weights to be 3 and 2. 3+2 = 5, so we


have denominator as 5 in the calculation.

Link for reference

2 year Weighted Moving Average to forecast sales for week 5

Naive Method

In this method of forecasting, the future values are set to be values of the last
observation. When data is not enough to create a predictive model, this method is
used to supplement forecasts for the near future.

No formula is used for this method.

50
Naive Method to forecast the demand for 2023

Seasonal Naive Method

This method of forecasting is a variation of Naive method. Here, we assume the


magnitude of seasonal patterns will remain constant. The future values are set to be
equal to the last observed value from the same season.

This method is used for highly seasonal time series data.

Seasonal Naive Method to forecast the demand for 2023 Q1 and Q2

Exponential Smoothing Method

In this method, the forecasted value is calculated based on the formula:

51
Where,

Ft+1 = New forecasted value

Ft = Previous period forecasted value

α = Smoothing constant; 0 ≤ α ≤1

At = Actual value

For the example below, we assumed α = 0.2

Exponential Smoothing Method to forecast sales for week 5

52
53

You might also like