SlideShare uma empresa Scribd logo
1 de 13
Baixar para ler offline
UNIT 5
Time Series Analysis
Learn about
Auto
regression and
Moving
average
Models
Understand
the business
scenarios
where Time
Series Analysis
is applicable
Learn about
ARIMA and
SARIMA
models for
forecasting
Get a solid
understanding
of Time Series
Analysis and
Forecasting
Learning Outcomes
Time Series Analysis
Time series is a series of data points in which each data point is associated with a
timestamp. A simple example is the price of a stock in the stock market at different
points of time on a given day. Another example is the amount of rainfall in a region at
different months of the year. R language uses many functions to create, manipulate and
plot the time series data. The data for the time series is stored in an R object called
time-series object. It is also a R data object like a vector or data frame.
Time Series Analysis
The time series object is created by using the ts() function.
The basic syntax for ts() function in time series analysis is −
timeseries.object.name <- ts(data, start, end, frequency)
Following is the description of the parameters used −
• data is a vector or matrix containing the values used in the time series.
• start specifies the start time for the first observation in time series.
• end specifies the end time for the last observation in time series.
•frequency specifies the number of observations per unit time.
Except the parameter "data" all other parameters are optional.
Time Series Analysis
Consider the annual rainfall details at a place starting from January 2012. We create an R time series object for a period of 12 months
and plot it.
# Get the data points in form of a R vector.
rainfall <- c(799,1174.8,865.1,1334.6,635.4,918.5,685.5,998.6,784.2,985,882.8,1071)
# Convert it to a time series object.
rainfall.timeseries <- ts(rainfall,start = c(2012,1),frequency = 12)
# Print the timeseries data.
print(rainfall.timeseries)
# Give the chart file a name.
png(file = "rainfall.png")
# Plot a graph of the time series.
plot(rainfall.timeseries)
# Save the file.
dev.off()
Time Series Analysis
Different Time Intervals
The value of the frequency parameter in the ts() function decides the time intervals at
which the data points are measured. A value of 12 indicates that the time series is for
12 months. Other values and its meaning is as below −
frequency = 12 pegs the data points for every month of a year.
frequency = 4 pegs the data points for every quarter of a year.
frequency = 6 pegs the data points for every 10 minutes of an hour.
frequency = 24*6 pegs the data points for every 10 minutes of a day.
Multiple time Series Analysis
We can plot multiple time series in one chart by combining both the series into a matrix.
# Get the data points in form of a R
vector.rainfall1<-
c(799,1174.8,865.1,1334.6,635.4,918.5,685.5,998.6,784.2,985,882.8,1071)
<-
rainfall2
c(655,1306.9,1323.4,1172.2,562.2,824,822.4,1265.5,799.6,1105.6,1106.7,1337.8)
# Convert them to a matrix.
combined.rainfall <- matrix(c(rainfall1,rainfall2),nrow = 12)
# Convert it to a time series object.
rainfall.timeseries <- ts(combined.rainfall,start = c(2012,1),frequency = 12)
# Print the timeseries data.print(rainfall.timeseries)
# Give the chart file a name.png(file = "rainfall_combined.png")
# Plot a graph of the time series.plot(rainfall.timeseries, main = "Multiple Time
Series")# Save the file.dev.off()
ARIMA
ARMA models are commonly used in time series modeling. In ARMA model, AR stands
for auto-regression and MA stands for moving average. If these words sound
intimidating to you, worry not – I’ll simplify these concepts in next few minutes for you!
Auto-Regressive Time Series Model
Let’s understanding AR models using the case below:
The current GDP of a country say x(t) is dependent on the last year’s GDP i.e. x(t – 1).
The hypothesis being that the total cost of production of products & services in a
country in a fiscal year (known as GDP) is dependent on the set up of manufacturing
plants / services in the previous year and the newly set up industries / plants / services
in the current year. But the primary component of the GDP is the former one.
Time Series Analysis
Hence, we can formally write the equation of GDP as:
x(t) = alpha * x(t – 1) + error (t)
This equation is known as AR(1) formulation. The numeral one (1) denotes that the next
instance is solely dependent on the previous instance. The alpha is a coefficient which
we seek so as to minimize the error function. Notice that x(t- 1) is indeed linked to x(t-
2) in the same fashion. Hence, any shock to x(t) will gradually fade off in future.
Time Series Analysis
For instance, let’s say x(t) is the number of juice bottles sold in a city on a particular
day. During winters, very few vendors purchased juice bottles. Suddenly, on a particular
day, the temperature rose and the demand of juice bottles soared to 1000. However,
after a few days, the climate became cold again. But, knowing that the people got used
to drinking juice during the hot days, there were 50% of the people still drinking juice
during the cold days. In following days, the proportion went down to 25% (50% of
50%) and then gradually to a small number after significant number of days. The
following graph explains the inertia property of AR series:
Moving Average Time Series Analysis
Let’s take another case to understand Moving average time series model.
A manufacturer produces a certain type of bag, which was readily available in the
market. Being a competitive market, the sale of the bag stood at zero for many days.
So, one day he did some experiment with the design and produced a different type of
bag. This type of bag was not available anywhere in the market. Thus, he was able to
sell the entire stock of 1000 bags (lets call this as x(t) ). The demand got so high that
the bag ran out of stock. As a result, some 100 odd customers couldn’t purchase this
bag. Lets call this gap as the error at that time point. With time, the bag had lost its woo
factor. But still few customers were left who went empty handed the previous day.
Following is a simple formulation to depict the scenario :
Moving Average Time Series Analysis
Difference between AR and MA models
The primary difference between an AR and MA model is based on the correlation
between time series objects at different time points. The correlation between x(t) and
x(t-n) for n > order of MA is always zero. This directly flows from the fact that
covariance between x(t) and x(t-n) is zero for MA models (something which we refer
from the example taken in the previous section). However, the correlation of x(t) and
x(t-n) gradually declines with n becoming larger in the AR model. This difference gets
exploited irrespective of having the AR model or MA model. The correlation plot can give
us the order of MA model.
Framework of ARIMA Modelling

Mais conteúdo relacionado

Semelhante a Unit5_Time Series Analysis.pdf

Stochastic Order Level Inventory Model with Inventory Returns and Special Sales
Stochastic Order Level Inventory Model with Inventory Returns and Special SalesStochastic Order Level Inventory Model with Inventory Returns and Special Sales
Stochastic Order Level Inventory Model with Inventory Returns and Special Salestheijes
 
Analysis of Time Series Data & Pattern Sequencing
Analysis of Time Series Data & Pattern SequencingAnalysis of Time Series Data & Pattern Sequencing
Analysis of Time Series Data & Pattern SequencingArchishman Bandyopadhyay
 
DATA STRUCTURES unit 1.pptx
DATA STRUCTURES unit 1.pptxDATA STRUCTURES unit 1.pptx
DATA STRUCTURES unit 1.pptxShivamKrPathak
 
Chapter 16
Chapter 16Chapter 16
Chapter 16bmcfad01
 
Fuzzy Inventory Model of Deteriorating Items under Power Dependent Demand and...
Fuzzy Inventory Model of Deteriorating Items under Power Dependent Demand and...Fuzzy Inventory Model of Deteriorating Items under Power Dependent Demand and...
Fuzzy Inventory Model of Deteriorating Items under Power Dependent Demand and...orajjournal
 
R programming slides
R  programming slidesR  programming slides
R programming slidesPankaj Saini
 
Normality_assumption_for_the_log_re.pdf
Normality_assumption_for_the_log_re.pdfNormality_assumption_for_the_log_re.pdf
Normality_assumption_for_the_log_re.pdfVasudha Singh
 
Time Series Analysis - 2 | Time Series in R | ARIMA Model Forecasting | Data ...
Time Series Analysis - 2 | Time Series in R | ARIMA Model Forecasting | Data ...Time Series Analysis - 2 | Time Series in R | ARIMA Model Forecasting | Data ...
Time Series Analysis - 2 | Time Series in R | ARIMA Model Forecasting | Data ...Simplilearn
 
Module 1 notes of data warehousing and data
Module 1 notes of data warehousing and dataModule 1 notes of data warehousing and data
Module 1 notes of data warehousing and datavijipersonal2012
 
Chapter 16-spreadsheet1 questions and answer
Chapter 16-spreadsheet1  questions and answerChapter 16-spreadsheet1  questions and answer
Chapter 16-spreadsheet1 questions and answerRaajTech
 
Different Models Used In Time Series - InsideAIML
Different Models Used In Time Series - InsideAIMLDifferent Models Used In Time Series - InsideAIML
Different Models Used In Time Series - InsideAIMLVijaySharma802
 
ASYMTOTIC NOTATIONS BIG O OEMGA THETE NOTATION.pptx
ASYMTOTIC NOTATIONS BIG O OEMGA THETE NOTATION.pptxASYMTOTIC NOTATIONS BIG O OEMGA THETE NOTATION.pptx
ASYMTOTIC NOTATIONS BIG O OEMGA THETE NOTATION.pptxsunitha1792
 
Byungchul Yea (Project)
Byungchul Yea (Project)Byungchul Yea (Project)
Byungchul Yea (Project)Byung Chul Yea
 
The Power Of Event Chapter 6
The Power Of Event Chapter 6The Power Of Event Chapter 6
The Power Of Event Chapter 6Woojin Joe
 

Semelhante a Unit5_Time Series Analysis.pdf (20)

ARIMA Models - [Lab 3]
ARIMA Models - [Lab 3]ARIMA Models - [Lab 3]
ARIMA Models - [Lab 3]
 
Stochastic Order Level Inventory Model with Inventory Returns and Special Sales
Stochastic Order Level Inventory Model with Inventory Returns and Special SalesStochastic Order Level Inventory Model with Inventory Returns and Special Sales
Stochastic Order Level Inventory Model with Inventory Returns and Special Sales
 
Time Series.pptx
Time Series.pptxTime Series.pptx
Time Series.pptx
 
Analysis of Time Series Data & Pattern Sequencing
Analysis of Time Series Data & Pattern SequencingAnalysis of Time Series Data & Pattern Sequencing
Analysis of Time Series Data & Pattern Sequencing
 
R for Statistical Computing
R for Statistical ComputingR for Statistical Computing
R for Statistical Computing
 
DATA STRUCTURES unit 1.pptx
DATA STRUCTURES unit 1.pptxDATA STRUCTURES unit 1.pptx
DATA STRUCTURES unit 1.pptx
 
Chapter 16
Chapter 16Chapter 16
Chapter 16
 
final.pptx
final.pptxfinal.pptx
final.pptx
 
Fuzzy Inventory Model of Deteriorating Items under Power Dependent Demand and...
Fuzzy Inventory Model of Deteriorating Items under Power Dependent Demand and...Fuzzy Inventory Model of Deteriorating Items under Power Dependent Demand and...
Fuzzy Inventory Model of Deteriorating Items under Power Dependent Demand and...
 
R programming slides
R  programming slidesR  programming slides
R programming slides
 
Normality_assumption_for_the_log_re.pdf
Normality_assumption_for_the_log_re.pdfNormality_assumption_for_the_log_re.pdf
Normality_assumption_for_the_log_re.pdf
 
Time Series Analysis - 2 | Time Series in R | ARIMA Model Forecasting | Data ...
Time Series Analysis - 2 | Time Series in R | ARIMA Model Forecasting | Data ...Time Series Analysis - 2 | Time Series in R | ARIMA Model Forecasting | Data ...
Time Series Analysis - 2 | Time Series in R | ARIMA Model Forecasting | Data ...
 
Module 1 notes of data warehousing and data
Module 1 notes of data warehousing and dataModule 1 notes of data warehousing and data
Module 1 notes of data warehousing and data
 
Chapter 16-spreadsheet1 questions and answer
Chapter 16-spreadsheet1  questions and answerChapter 16-spreadsheet1  questions and answer
Chapter 16-spreadsheet1 questions and answer
 
Different Models Used In Time Series - InsideAIML
Different Models Used In Time Series - InsideAIMLDifferent Models Used In Time Series - InsideAIML
Different Models Used In Time Series - InsideAIML
 
ASYMTOTIC NOTATIONS BIG O OEMGA THETE NOTATION.pptx
ASYMTOTIC NOTATIONS BIG O OEMGA THETE NOTATION.pptxASYMTOTIC NOTATIONS BIG O OEMGA THETE NOTATION.pptx
ASYMTOTIC NOTATIONS BIG O OEMGA THETE NOTATION.pptx
 
Byungchul Yea (Project)
Byungchul Yea (Project)Byungchul Yea (Project)
Byungchul Yea (Project)
 
A FLEXIBLE APPROACH TO MINE HIGH UTILITY ITEMSETS FROM TRANSACTIONAL DATABASE...
A FLEXIBLE APPROACH TO MINE HIGH UTILITY ITEMSETS FROM TRANSACTIONAL DATABASE...A FLEXIBLE APPROACH TO MINE HIGH UTILITY ITEMSETS FROM TRANSACTIONAL DATABASE...
A FLEXIBLE APPROACH TO MINE HIGH UTILITY ITEMSETS FROM TRANSACTIONAL DATABASE...
 
The Power Of Event Chapter 6
The Power Of Event Chapter 6The Power Of Event Chapter 6
The Power Of Event Chapter 6
 
Aq4201280292
Aq4201280292Aq4201280292
Aq4201280292
 

Último

Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 

Último (20)

Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 

Unit5_Time Series Analysis.pdf

  • 2. Learn about Auto regression and Moving average Models Understand the business scenarios where Time Series Analysis is applicable Learn about ARIMA and SARIMA models for forecasting Get a solid understanding of Time Series Analysis and Forecasting Learning Outcomes
  • 3. Time Series Analysis Time series is a series of data points in which each data point is associated with a timestamp. A simple example is the price of a stock in the stock market at different points of time on a given day. Another example is the amount of rainfall in a region at different months of the year. R language uses many functions to create, manipulate and plot the time series data. The data for the time series is stored in an R object called time-series object. It is also a R data object like a vector or data frame.
  • 4. Time Series Analysis The time series object is created by using the ts() function. The basic syntax for ts() function in time series analysis is − timeseries.object.name <- ts(data, start, end, frequency) Following is the description of the parameters used − • data is a vector or matrix containing the values used in the time series. • start specifies the start time for the first observation in time series. • end specifies the end time for the last observation in time series. •frequency specifies the number of observations per unit time. Except the parameter "data" all other parameters are optional.
  • 5. Time Series Analysis Consider the annual rainfall details at a place starting from January 2012. We create an R time series object for a period of 12 months and plot it. # Get the data points in form of a R vector. rainfall <- c(799,1174.8,865.1,1334.6,635.4,918.5,685.5,998.6,784.2,985,882.8,1071) # Convert it to a time series object. rainfall.timeseries <- ts(rainfall,start = c(2012,1),frequency = 12) # Print the timeseries data. print(rainfall.timeseries) # Give the chart file a name. png(file = "rainfall.png") # Plot a graph of the time series. plot(rainfall.timeseries) # Save the file. dev.off()
  • 6. Time Series Analysis Different Time Intervals The value of the frequency parameter in the ts() function decides the time intervals at which the data points are measured. A value of 12 indicates that the time series is for 12 months. Other values and its meaning is as below − frequency = 12 pegs the data points for every month of a year. frequency = 4 pegs the data points for every quarter of a year. frequency = 6 pegs the data points for every 10 minutes of an hour. frequency = 24*6 pegs the data points for every 10 minutes of a day.
  • 7. Multiple time Series Analysis We can plot multiple time series in one chart by combining both the series into a matrix. # Get the data points in form of a R vector.rainfall1<- c(799,1174.8,865.1,1334.6,635.4,918.5,685.5,998.6,784.2,985,882.8,1071) <- rainfall2 c(655,1306.9,1323.4,1172.2,562.2,824,822.4,1265.5,799.6,1105.6,1106.7,1337.8) # Convert them to a matrix. combined.rainfall <- matrix(c(rainfall1,rainfall2),nrow = 12) # Convert it to a time series object. rainfall.timeseries <- ts(combined.rainfall,start = c(2012,1),frequency = 12) # Print the timeseries data.print(rainfall.timeseries) # Give the chart file a name.png(file = "rainfall_combined.png") # Plot a graph of the time series.plot(rainfall.timeseries, main = "Multiple Time Series")# Save the file.dev.off()
  • 8. ARIMA ARMA models are commonly used in time series modeling. In ARMA model, AR stands for auto-regression and MA stands for moving average. If these words sound intimidating to you, worry not – I’ll simplify these concepts in next few minutes for you! Auto-Regressive Time Series Model Let’s understanding AR models using the case below: The current GDP of a country say x(t) is dependent on the last year’s GDP i.e. x(t – 1). The hypothesis being that the total cost of production of products & services in a country in a fiscal year (known as GDP) is dependent on the set up of manufacturing plants / services in the previous year and the newly set up industries / plants / services in the current year. But the primary component of the GDP is the former one.
  • 9. Time Series Analysis Hence, we can formally write the equation of GDP as: x(t) = alpha * x(t – 1) + error (t) This equation is known as AR(1) formulation. The numeral one (1) denotes that the next instance is solely dependent on the previous instance. The alpha is a coefficient which we seek so as to minimize the error function. Notice that x(t- 1) is indeed linked to x(t- 2) in the same fashion. Hence, any shock to x(t) will gradually fade off in future.
  • 10. Time Series Analysis For instance, let’s say x(t) is the number of juice bottles sold in a city on a particular day. During winters, very few vendors purchased juice bottles. Suddenly, on a particular day, the temperature rose and the demand of juice bottles soared to 1000. However, after a few days, the climate became cold again. But, knowing that the people got used to drinking juice during the hot days, there were 50% of the people still drinking juice during the cold days. In following days, the proportion went down to 25% (50% of 50%) and then gradually to a small number after significant number of days. The following graph explains the inertia property of AR series:
  • 11. Moving Average Time Series Analysis Let’s take another case to understand Moving average time series model. A manufacturer produces a certain type of bag, which was readily available in the market. Being a competitive market, the sale of the bag stood at zero for many days. So, one day he did some experiment with the design and produced a different type of bag. This type of bag was not available anywhere in the market. Thus, he was able to sell the entire stock of 1000 bags (lets call this as x(t) ). The demand got so high that the bag ran out of stock. As a result, some 100 odd customers couldn’t purchase this bag. Lets call this gap as the error at that time point. With time, the bag had lost its woo factor. But still few customers were left who went empty handed the previous day. Following is a simple formulation to depict the scenario :
  • 12. Moving Average Time Series Analysis Difference between AR and MA models The primary difference between an AR and MA model is based on the correlation between time series objects at different time points. The correlation between x(t) and x(t-n) for n > order of MA is always zero. This directly flows from the fact that covariance between x(t) and x(t-n) is zero for MA models (something which we refer from the example taken in the previous section). However, the correlation of x(t) and x(t-n) gradually declines with n becoming larger in the AR model. This difference gets exploited irrespective of having the AR model or MA model. The correlation plot can give us the order of MA model.
  • 13. Framework of ARIMA Modelling