Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
Visualization IN DATA ANALYTICS IN TIME SERIES
1. TIME SERIES FORECASTING
9-Jan-18 1
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
2. VISUALIZING TIME SERIES
COMPONENTS
9-Jan-18 2
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
3. Steps in Forecasting
1. Problem definition:
2. Gathering information
3. Preliminary (exploratory) analysis.
4. Choosing and fitting models
5. Using and evaluating a forecasting model.
3
Objective of this lesson is to explore several time series data
sets and apply visual methods using R to extract information
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
4. Problem Definition
Time series forecasting involves
• Understanding historical pattern of data
• Using past knowledge forecasting for future
Before a forecasting problem is taken up, decision needs to be
made regarding the forecast horizon
4
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
5. Forecast Range
Different industry needs different forecast range for different purpose
Example: Airlines industry: Interested in passenger volume forecast
Passenger volume is the driving force behind all its operation
• Long-term forecast: 5-10 years
̶ Required for strategic decision making
̶ Acknowledging limited reliability of these forecasts
• Mid-term forecast: 2-5 years
̶ Manpower hiring
̶ Decision on addition/alteration in new and existing routes
• Short-term forecast: 2 weeks – 6 months
̶ Manpower rostering
̶ Dynamic pricing
5
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
6. Forecast Range
• Supply Chain: Responds to customer demand
̶ Very long range forecast will not serve the purpose well
̶ In addition to taking into account the past demand, lead time
and planned advertising and other marketing activity must be
incorporated into forecast horizon
6
• Contract Research Organization doing clinical trials
̶ 2000 trials running simultaneously across the world
̶ Need to forecast monthly for each of some 5000 items required
for trials for next 6 months
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
7. Gathering Information
Historical data required for future prediction
If volume of data is limited, forecasts will not
be reliable enough
If data is available for very long past, data may
not be useful at all
7
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
8. Example: Clay Brick Production
8
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
9. Example: Clay Brick Production
9
Series not stable
Use stable part for forecast
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
11. Exploratory analysis
Plotting of both series highlighted the changed pattern in the
series
First step: Plot the time series.
Graphs enable many features of the data to be visualized,
including patterns, unusual observations, changes over time,
and relationships between variables.
Appropriate graph captures the inherent features of time
series
11
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
12. Time Series in R
A time series is saved as a ts object in R with special properties
appropriate to the series
USGDP <- ts(US_GDP[,2], start=c(1929,1), end=c(1991,1),
frequency=1)
plot(USGDP)
Shoe <- ts(Shoe_Sales[,3], start=c(2011,1), frequency=12)
plot(Shoe)
Income <- ts(Quarterly_Income[,3], start=c(2000,4), frequency=4)
plot(Income)
12
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
13. What do graphs reveal?
GDP shows a continuous upward movemet
Shoe sales show two features:
There is a typical movement within a year
This type of shoe sales went up from 2011 – 2014 and past that
it shows decline
Quarterly income started low, went up to some extent but
movement of this series is spikey – some quarters show sudden
jump
13
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
14. What do graphs reveal?
These observations give clue to inherent features of the time
series, known as components of time series
14
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
15. Components of Time Series
15
Time Series Components
Trend
Seasonal component
Cyclic component
Irregular component (Error or Random Component)
Graphs highlight variety of patterns inherent to TS
A TS can be split into several components, each representing one of the
underlying categories of patterns,
Systematic
Component
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
16. Trend
16
• Long term movement of a series: either increasing or
decreasing
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
17. Example: Demand of Bricks
9-Jan-18 17
75
95
115
135
155
175
195
215
1988-01
1988-02
1988-03
1988-04
1988-05
1988-06
1988-07
1988-08
1988-09
1988-10
1988-11
1988-12
1989-01
1989-02
1989-03
1989-04
1989-05
1989-06
1989-07
1989-08
1989-09
1989-10
1989-11
1989-12
1990-01
1990-02
1990-03
1990-04
1990-05
1990-06
1990-07
1990-08
1990-09
1990-10
1990-11
1990-12
1991-01
1991-02
1991-03
1991-04
1991-05
1991-06
1991-07
1991-08
1991-09
1991-10
1991-11
1991-12
Bricks
High Demand (May)
Low Demand (Jan)
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
18. Example: Demand of Bricks
Across each year demand for bricks follow a
repetitive pattern
In a particular month (Jan) demand is the
lowest
In some other months, demand fluctutaes
18
9-Jan-18
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
19. Seasonality
19
• Representing intra-year stable fluctuations repeatable year
after year with respect to timing, direction and magnitude
• Normal variations that recur every year to the
same extent
• A Yearly series does not have seasonality
.
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
20. Seasonality
• Demand for winter clothes
• Airlines and train ticket demands
• Incidence of influenza or other vector-borne
diseases
20
9-Jan-18
Stock prices typically will not show any
seasonal pattern
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
21. Example: Sale of Shoes
21
2011-13 demand increasing
2013-15 stable demand
2015 onwards demand declining
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
22. Cyclical Component
22
• In addition to within year stable fluctuation,
demand for this particular style of shoes show
increase over years for a period and then decrease
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
23. Systematic Components
• Trend, Seasonality, Cyclicality are part of
systematic component
• These patterns are interpretable
• These can be estimated
• Forecast of time series involves estimation
and extrapolation of these components
23
We focus on Trend and Seasonality only
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
24. Irregular Component
The error or variability associated with the series is the Irregular
component
This component is a random component
The part of the series that cannot be explained through Systematic
component forms the Irregular Component
Other names of this component is Error or White Noise
This component is assumed to have a normal distribution with 0 mean and
constant variance σ2
24
9-Jan-18
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
25. Graphically identify Important
Characteristics
• Time Series plots are the first step in understanding the
pattern of the data
• Not only it identifies whether there are trend, seasonality or
cyclicality, it also identifies
̶ Which historical horizon to include for forecasting
̶ Is there any abrupt change in the level of the series?
̶ Whether there are any unusual observations in the series
̶ sudden spikes or sudden drops!
25
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
26. Time Series: Important Characteristics
26
Is there a Trend?
Is there a Seasonality?
Are there Outliers? [How to handle?]
Is there a Long-run cycle?
Is there any Abrupt change in the level?
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
27. Example 1: Reserve Bank of Australia
Govt Bond 2-Year Security
27
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
28. Example 1: Important Characteristics
28
Is there a Trend? No perceptible trend overall; might
depend on which portion you are considering
Is there a Seasonality? No seasonality
Are there Outliers? Does not look like
Is there a Long-run cycle? Difficult to say
Is there any Abrupt change in the level? Yes
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
29. Example 2: Champagne Sales
29
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
30. Example 2: Important Characteristics
30
Is there a Trend? No
Is there a Seasonality? Definite seasonality
Are there Outliers? Does not look like
Is there a Long-run cycle? No
Is there any Abrupt change in the level? No
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
31. Example 3: International Air Passengers
31
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
32. Example 3: Important Characteristics
32
Is there a Trend? Yes, increasing trend
Is there a Seasonality? Definite seasonality
Are there Outliers? Does not look like
Is there a Long-run cycle? No
Is there any Abrupt change in the level? No
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
33. Example 4: Brick Production
33
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
34. Example 4: Important Characteristics
34
Is there a Trend? Increasing to start but after a while
became constant
Is there a Seasonality? Yes
Are there Outliers? Yes, possibly
Is there a Long-run cycle? Most likely, yes
Is there any Abrupt change in the level? No
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
35. Visualization for Seasonality:
Seasonal Subseries for Champagne
Sales
35
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
36. Visualization for Seasonality:
Seasonal Subseries
• Emphasizes the seasonality pattern where the data for each
season are collected together in separate mini time plots.
• The horizontal lines indicate the means for each season.
• The underlying seasonal pattern are clearly seen
• Changes in seasonality over time is clear
̶ Higher fluctuations in the later months
̶ Maximum fluctuation in Nov & Dec
36
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
37. Seasonal Subplot: Airlines
Passengers
37
Every month of
every year
passenger volume
increases
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
38. Seasonal Subplot: Quarterly
Income
38
Initially revenue
was low in every
quarter
Q3 shows one
high spike –
unusual
observation?
Q4 movements
almost
metronomic!
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
39. Seasonal Subplot: Quarterly
Income
A thought:
Since all quarters of initial
years’ revenue seems
significantly lower compared
to the later years, would it
make more sense to discard
those initial years data for
forecasting?
9-Jan-18 39
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
40. Next Step
In the next lesson we extract the components
of time series, namely trend and seasonality, to
improve understanding of time series and use
the information for forecasting
40
9-Jan-18
Thank You
haritika74@gmail.com
BABIINTLMAY19001
This file is meant for personal use by haritika74@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.