SlideShare a Scribd company logo
1 of 25
Download to read offline
Moving Average Methods
Edward L. Boone
Department of Statistical Sciences and Operations Research
Virginia Commonwealth University

November 11, 2013

Edward L. Boone
Simple Moving Average

We are considering time series data xt where t = 1, 2, ..., T .
The order of the observations matter.
A simple moving average attempts to ļ¬nd a local mean.
This can be done simply by taking the average of the
points around the time of interest.
For example if we are interested in a window of width k we
simply take xt , xtāˆ’1 , xt+1 ,...,xt+k ,xtāˆ’k and compute their
average.

Edward L. Boone
Example
Consider the following example:
x1
1.2

x2
1.3

x3
1.1

x4
1.2

x5
1.4

x6
1.7

x7
1.6

x8
1.8

x9
1.5

x10
1.6

If we want the moving average at time t = 3 with window 2.
ĀÆ
x3,2 =

x1 + x2 + x3 + x4 + x5
1.2 + 1.3 + 1.1 + 1.2 + 1.4
=
= 1.24
5
5

If we want the moving average at time t = 7 with window 2.
ĀÆ
x7,2 =

x5 + x6 + x7 + x8 + x9
1.4 + 1.7 + 1.6 + 1.8 + 1.5
=
= 1.6
5
5

Notice that the ā€œlocalā€ means are not similar.
Edward L. Boone
Trailing Moving Average
The problem with a standard moving average is that for the
mean at time t we need to know t + 1, t + 2,...,t + k , which is in
the future.
In many useful cases we donā€™t know the future.
We want to just use past values.
This leads to the idea of the trailing moving average.
Only take the average of xtāˆ’k , xtāˆ’k +1 ,...x1 , xt .
ĀÆ
xt,k =

Edward L. Boone

1
k

t

xt
i=tāˆ’k
Example
Again consider the following example.
x1
1.2

x2
1.3

x3
1.1

x4
1.2

x5
1.4

x6
1.7

x7
1.6

x8
1.8

x9
1.5

Trailing moving average with window k = 2
ĀÆ
x3,2 =

1.3 + 1.1 + 1.2
x2 + x3 + x4
=
= 1.2
3
3
.
.
.
x5 + x6 + x7
1.4 + 1.7 + 1.6
ĀÆ
=
=
= 1.56
3
3

ĀÆ
x4,2 =

ĀÆ
x7,2
Edward L. Boone

x1 + x2 + x3
1.2 + 1.3 + 1.1
=
= 1.2
3
3

x10
1.6
Simple vs. Trailing Moving Average

There are some issues that we will have to confront with all
time series methods.
How to handle the starting values?
Outliers?
Gaps?
Prediction?
Some of these are easier to deal with than others.

Edward L. Boone
Simple vs. Trailing Moving Average

23

Consider the example to the
right.

Edward L. Boone

22
x

20
19
18
17

Notice that the red line is
ā€œsmootherā€ than the blue
line.

21

Red is centered moving
average.
Blue is trailing moving
average.

True
Center
Trail

0

20

40

60
t

80

100
Issues with Moving Averages

Problems with simple moving average techniques.
In the previous methods, all observations in window get the
same weight.
We may wish to downweight observations as they get
farther in the past and always use all observations.
Gaps?
Prediction?
Some of these are easier to deal with than others.

Edward L. Boone
Exponentially Weighted Moving Average
A ā€œsimpleā€ way to address the weighting problem is using a
weighted moving average.
There are several versions of these.
Each attempts to model the components of a time series
dataset.
If we just want to model the level then the Exponentially
Weighted Moving Average may be reasonable.
S1 = x1
St = Ī±xt + (1 āˆ’ Ī±)Stāˆ’1
These downweight the previous observations but still use
all observations.
Edward L. Boone
Example
Again consider the following example using Ī± = 0.3.
x1
1.2
S1
S2
S3
S4
S5
S6
S7
S8
S9
S10
Edward L. Boone

=
=
=
=
=
=
=
=
=
=

x2
1.3

x3
1.1

x4
1.2

x1 = 1.2
Ī±x2 + (1 āˆ’ Ī±)S1
Ī±x3 + (1 āˆ’ Ī±)S2
Ī±x4 + (1 āˆ’ Ī±)S3
Ī±x5 + (1 āˆ’ Ī±)S4
Ī±x6 + (1 āˆ’ Ī±)S5
Ī±x7 + (1 āˆ’ Ī±)S6
Ī±x8 + (1 āˆ’ Ī±)S7
Ī±x9 + (1 āˆ’ Ī±)S8
??

x5
1.4

x6
1.7

x7
1.6

x8
1.8

x9
1.5

x10
1.6

= 0.3(1.3) + 0.7(1.2) = 1.23
= 0.3(1.1) + 0.7(1.23) = 1.191
= 0.3(1.2) + 0.7(1.191) = 1.1937
= 0.3(1.4) + 0.7(1.1937) = 1.2559
= 0.3(1.7) + 0.7(1.2559) = 1.3891
= 0.3(1.6) + 0.7(1.3891) = 1.4523
= 0.3(1.8) + 0.7(1.4523) = 1.5566
= 0.3(1.5) + 0.7(1.5566) = 1.5396
Example

1.1

1.2

1.3

1.4

x

1.5

1.6

1.7

1.8

A picture of what the calculations give.

2

4

6
time

Edward L. Boone

8

10
Exponentially Weighted Moving Average

What we have looked at so far is only concerned in estimating a
level (mean).
Only models the level.
We want to model the trend.
We want to model the Seasonality as well.
In order to do this we will need to build the model using
these basic components.

Edward L. Boone
Double Exponential Smoothing
Now we can add in a trend term bt .
Starting values:
S1 = x1
b1 = x2 āˆ’ x1
Process smoothing:
St
bt

Edward L. Boone

= Ī±xt + (1 āˆ’ Ī±)(Stāˆ’1 + btāˆ’1 )
= Ī²(St āˆ’ Stāˆ’1 ) + (1 āˆ’ Ī²)btāˆ’1
Example
Again consider the following example using Ī± = 0.3 and
Ī² = 0.2.
x1
1.2

x2
1.3

x3
1.1

x4
1.2

x5
1.4

x6
1.7

x7
1.6

x8
1.8

x9
1.5

S1 = x1 = 1.2
b1 = x2 āˆ’ x1 = 1.3 āˆ’ 1.2 = 0.1
S2 = Ī±x2 + (1 āˆ’ Ī±)(S1 + b1 )
= 0.3(1.3) + 0.7(1.2 + 0.1) = 1.3
b2 = Ī²(S1 āˆ’ S2 ) + (1 āˆ’ Ī²)(b1 )
= 0.2(1.3 āˆ’ 1.2) + 0.8(0.1) = 0.1
.
.
.
S10 = 1.7343
b10 = 0.0576
Edward L. Boone

x10
1.6
Example
Again consider the following example using Ī± = 0.3 and
Ī² = 0.2.
x1
1.2

x2
1.3

x3
1.1

x4
1.2

x5
1.4

x6
1.7

x7
1.6

x8
1.8

Predict x11 and x12 .
S10 = 1.7343
b10 = 0.0576
x11 = S10 + b10
= 1.7343 + 0.0567
= 1.7919
x12 = S10 + 2b10
= 1.7343 + 2(0.0567)
= 1.8496
Edward L. Boone

x9
1.5

x10
1.6
Triple Exponential Smoothing

To have a level, trend and season can get a bit complicated.
We need to know what period the seasonality manifests.
Quarterly data the seasonal ā€œlag" L may be 4.
Monthly data the seasonal ā€œlag" L may be 12.
Weekly data the seasonal ā€œlag" L may be 52.
Daily data the seasonal ā€œlag" L may be 365.
Think how complicated hourly data would be.
For simplicity we will consider Quarterly data with L = 4.

Edward L. Boone
Triple Exponential Smoothing
This is also known as the Holt-Winters method.
Process smoothing:
xt
+ (1 āˆ’ Ī±)(Stāˆ’1 + btāˆ’1 )
St = Ī±
Ctāˆ’L
bt = Ī²(St āˆ’ Stāˆ’1 ) + (1 āˆ’ Ī²)btāˆ’1
xt
Ct = Ī³ + (1 āˆ’ Ī³)Ctāˆ’L
st
Starting values:
These are more difļ¬cult to get.
Some use the ļ¬rst few cycles and get means.
Some use regression to get S0 and b0 , then use those to
get the initial Cā€™s.
We will let R do this for us so we donā€™t have to worry about
it.
Edward L. Boone
Example

4000
2000

3000

Sales

5000

6000

Consider the following data: SeasonalSales.csv

0

10

20

30
Time

Edward L. Boone

40
HoltWinters Function in R

Using the HoltWinters function in R we can estimate:
smoothing parameters
ļ¬tted values
the ļ¬tted values also contain the level, trend and seasonal
components

Edward L. Boone
Example

4000
2000

3000

Sales

5000

6000

Consider the following data: SeasonalSales.csv

2

4

6

8
Time

Edward L. Boone

10

12
Example

4000
2000

3000

Sales

5000

6000

A closer look:

8.0

8.5

9.0
Time

Edward L. Boone

9.5

10.0
Example

Sales

2000

3000

4000

5000

6000

7000

Predict into the future.

2

4

6

8
Time

Edward L. Boone

10

12

14
Example

Sales

2000

3000

4000

5000

6000

7000

A closer look.

12.0

12.5

13.0

13.5
Time

Edward L. Boone

14.0

14.5

15.0
Example

2350

2400

2450

Sales

2500

2550

2600

An even closer look.

12.0

12.5

13.0

13.5
Time

Edward L. Boone

14.0

14.5

15.0
Conclusion
Moving average and ā€œsmoothing" methods are ad hoc methods
for analyzing time series data.
MA methods require user input k .
Smoothing methods downweight past observations.
These methods can directly model the level, trend and
season components.
Since they are ad hoc they can produce odd results at
times.
While these methods are useful we need to be careful because
they have no clear theory to back them up.

Edward L. Boone

More Related Content

What's hot

Regression Analysis
Regression AnalysisRegression Analysis
Regression AnalysisMuhammad Fazeel
Ā 
Maximum Likelihood Estimation
Maximum Likelihood EstimationMaximum Likelihood Estimation
Maximum Likelihood Estimationguestfee8698
Ā 
Basic concepts of_econometrics
Basic concepts of_econometricsBasic concepts of_econometrics
Basic concepts of_econometricsSwapnaJahan
Ā 
Numerical analysis kuhn tucker eqn
Numerical analysis  kuhn tucker eqnNumerical analysis  kuhn tucker eqn
Numerical analysis kuhn tucker eqnSHAMJITH KM
Ā 
Forecasting with Vector Autoregression
Forecasting with Vector AutoregressionForecasting with Vector Autoregression
Forecasting with Vector AutoregressionBryan Butler, MBA, MS
Ā 
Multivariate time series
Multivariate time seriesMultivariate time series
Multivariate time seriesLuigi Piva CQF
Ā 
Probability Density Functions
Probability Density FunctionsProbability Density Functions
Probability Density Functionsguestb86588
Ā 
Least square method
Least square methodLeast square method
Least square methodSomya Bagai
Ā 
Presentation on regression analysis
Presentation on regression analysisPresentation on regression analysis
Presentation on regression analysisSujeet Singh
Ā 
Assignment Problem
Assignment ProblemAssignment Problem
Assignment ProblemNakul Bhardwaj
Ā 
Statistics-Correlation and Regression Analysis
Statistics-Correlation and Regression AnalysisStatistics-Correlation and Regression Analysis
Statistics-Correlation and Regression AnalysisRabin BK
Ā 
Lecture: Joint, Conditional and Marginal Probabilities
Lecture: Joint, Conditional and Marginal Probabilities Lecture: Joint, Conditional and Marginal Probabilities
Lecture: Joint, Conditional and Marginal Probabilities Marina Santini
Ā 
Linear regression
Linear regression Linear regression
Linear regression Babasab Patil
Ā 
Probability basics and bayes' theorem
Probability basics and bayes' theoremProbability basics and bayes' theorem
Probability basics and bayes' theoremBalaji P
Ā 

What's hot (20)

Regression Analysis
Regression AnalysisRegression Analysis
Regression Analysis
Ā 
Maximum Likelihood Estimation
Maximum Likelihood EstimationMaximum Likelihood Estimation
Maximum Likelihood Estimation
Ā 
Basic concepts of_econometrics
Basic concepts of_econometricsBasic concepts of_econometrics
Basic concepts of_econometrics
Ā 
Numerical analysis kuhn tucker eqn
Numerical analysis  kuhn tucker eqnNumerical analysis  kuhn tucker eqn
Numerical analysis kuhn tucker eqn
Ā 
Multiple regression
Multiple regressionMultiple regression
Multiple regression
Ā 
Confirmatory Factor Analysis
Confirmatory Factor AnalysisConfirmatory Factor Analysis
Confirmatory Factor Analysis
Ā 
Forecasting with Vector Autoregression
Forecasting with Vector AutoregressionForecasting with Vector Autoregression
Forecasting with Vector Autoregression
Ā 
Multivariate time series
Multivariate time seriesMultivariate time series
Multivariate time series
Ā 
Bayes' theorem
Bayes' theoremBayes' theorem
Bayes' theorem
Ā 
Simple linear regression
Simple linear regressionSimple linear regression
Simple linear regression
Ā 
Probability Density Functions
Probability Density FunctionsProbability Density Functions
Probability Density Functions
Ā 
Least square method
Least square methodLeast square method
Least square method
Ā 
Presentation on regression analysis
Presentation on regression analysisPresentation on regression analysis
Presentation on regression analysis
Ā 
Assignment Problem
Assignment ProblemAssignment Problem
Assignment Problem
Ā 
Statistics-Correlation and Regression Analysis
Statistics-Correlation and Regression AnalysisStatistics-Correlation and Regression Analysis
Statistics-Correlation and Regression Analysis
Ā 
Structural Equation Modelling (SEM) Part 2
Structural Equation Modelling (SEM) Part 2Structural Equation Modelling (SEM) Part 2
Structural Equation Modelling (SEM) Part 2
Ā 
Linear regression
Linear regressionLinear regression
Linear regression
Ā 
Lecture: Joint, Conditional and Marginal Probabilities
Lecture: Joint, Conditional and Marginal Probabilities Lecture: Joint, Conditional and Marginal Probabilities
Lecture: Joint, Conditional and Marginal Probabilities
Ā 
Linear regression
Linear regression Linear regression
Linear regression
Ā 
Probability basics and bayes' theorem
Probability basics and bayes' theoremProbability basics and bayes' theorem
Probability basics and bayes' theorem
Ā 

Viewers also liked

Moving average method maths ppt
Moving average method maths pptMoving average method maths ppt
Moving average method maths pptAbhishek Mahto
Ā 
Chapter 16
Chapter 16Chapter 16
Chapter 16bmcfad01
Ā 
Above and Beyond - The Moving Average
Above and Beyond  - The Moving AverageAbove and Beyond  - The Moving Average
Above and Beyond - The Moving AverageJason Wang
Ā 
Presentation 3
Presentation 3Presentation 3
Presentation 3uliana8
Ā 
time series analysis
time series analysistime series analysis
time series analysisSACHIN AWASTHI
Ā 
Deductor Implementation Results
Deductor Implementation ResultsDeductor Implementation Results
Deductor Implementation ResultsKadimov Mansur
Ā 
Simple moving avg
Simple moving avgSimple moving avg
Simple moving avgAmeenafroz
Ā 
Altavox case study
Altavox case studyAltavox case study
Altavox case studyVILAS ADOLE
Ā 
How to use VWAP as an important technical indicator
How to use VWAP as an important technical indicator How to use VWAP as an important technical indicator
How to use VWAP as an important technical indicator Mike Bellafiore
Ā 
Forecasting Techniques - Data Science SG
Forecasting Techniques - Data Science SG Forecasting Techniques - Data Science SG
Forecasting Techniques - Data Science SG Kai Xin Thia
Ā 
Survey Research Methods
Survey Research MethodsSurvey Research Methods
Survey Research MethodsColin Quinton
Ā 
Lecture2 forecasting f06_604
Lecture2 forecasting f06_604Lecture2 forecasting f06_604
Lecture2 forecasting f06_604datkuki
Ā 
Moving average and Rate of change (ROC)
Moving average and Rate of change (ROC)Moving average and Rate of change (ROC)
Moving average and Rate of change (ROC)Ayush Kansal
Ā 
Statr session 23 and 24
Statr session 23 and 24Statr session 23 and 24
Statr session 23 and 24Ruru Chowdhury
Ā 
Forecasting exponential smoothing
Forecasting exponential smoothingForecasting exponential smoothing
Forecasting exponential smoothingDoiyan
Ā 
Moving average adx derivatives
Moving average adx derivativesMoving average adx derivatives
Moving average adx derivativesKshitij Gupta
Ā 
Simple linear regression analysis
Simple linear  regression analysisSimple linear  regression analysis
Simple linear regression analysisNorma Mingo
Ā 

Viewers also liked (20)

Moving average method maths ppt
Moving average method maths pptMoving average method maths ppt
Moving average method maths ppt
Ā 
Chapter 16
Chapter 16Chapter 16
Chapter 16
Ā 
Above and Beyond - The Moving Average
Above and Beyond  - The Moving AverageAbove and Beyond  - The Moving Average
Above and Beyond - The Moving Average
Ā 
Presentation 3
Presentation 3Presentation 3
Presentation 3
Ā 
time series analysis
time series analysistime series analysis
time series analysis
Ā 
Deductor Implementation Results
Deductor Implementation ResultsDeductor Implementation Results
Deductor Implementation Results
Ā 
Simple moving avg
Simple moving avgSimple moving avg
Simple moving avg
Ā 
Altavox case study
Altavox case studyAltavox case study
Altavox case study
Ā 
Forecasting
ForecastingForecasting
Forecasting
Ā 
Chapter 7
Chapter 7Chapter 7
Chapter 7
Ā 
How to use VWAP as an important technical indicator
How to use VWAP as an important technical indicator How to use VWAP as an important technical indicator
How to use VWAP as an important technical indicator
Ā 
Forecasting Techniques - Data Science SG
Forecasting Techniques - Data Science SG Forecasting Techniques - Data Science SG
Forecasting Techniques - Data Science SG
Ā 
Survey Research Methods
Survey Research MethodsSurvey Research Methods
Survey Research Methods
Ā 
Lecture2 forecasting f06_604
Lecture2 forecasting f06_604Lecture2 forecasting f06_604
Lecture2 forecasting f06_604
Ā 
Chapter 13
Chapter 13Chapter 13
Chapter 13
Ā 
Moving average and Rate of change (ROC)
Moving average and Rate of change (ROC)Moving average and Rate of change (ROC)
Moving average and Rate of change (ROC)
Ā 
Statr session 23 and 24
Statr session 23 and 24Statr session 23 and 24
Statr session 23 and 24
Ā 
Forecasting exponential smoothing
Forecasting exponential smoothingForecasting exponential smoothing
Forecasting exponential smoothing
Ā 
Moving average adx derivatives
Moving average adx derivativesMoving average adx derivatives
Moving average adx derivatives
Ā 
Simple linear regression analysis
Simple linear  regression analysisSimple linear  regression analysis
Simple linear regression analysis
Ā 

Similar to Moving Average

Algebra Trigonometry Problems
Algebra Trigonometry ProblemsAlgebra Trigonometry Problems
Algebra Trigonometry ProblemsDon Dooley
Ā 
Ch02
Ch02Ch02
Ch02swavicky
Ā 
Ch02
Ch02Ch02
Ch02swavicky
Ā 
Fungsi rekursiv
Fungsi rekursivFungsi rekursiv
Fungsi rekursivAhmad Syauqi
Ā 
Predictive Modelling
Predictive ModellingPredictive Modelling
Predictive ModellingRajiv Advani
Ā 
Lecture Notes in Econometrics Arsen Palestini.pdf
Lecture Notes in Econometrics Arsen Palestini.pdfLecture Notes in Econometrics Arsen Palestini.pdf
Lecture Notes in Econometrics Arsen Palestini.pdfMDNomanCh
Ā 
Business forecasting decomposition & exponential smoothing - bhawani nandan...
Business forecasting   decomposition & exponential smoothing - bhawani nandan...Business forecasting   decomposition & exponential smoothing - bhawani nandan...
Business forecasting decomposition & exponential smoothing - bhawani nandan...Bhawani N Prasad
Ā 
PRML Chapter 1
PRML Chapter 1PRML Chapter 1
PRML Chapter 1Sunwoo Kim
Ā 
Lesson 26: Integration by Substitution (handout)
Lesson 26: Integration by Substitution (handout)Lesson 26: Integration by Substitution (handout)
Lesson 26: Integration by Substitution (handout)Matthew Leingang
Ā 
Integration by Parts & by Partial Fractions
Integration by Parts & by Partial FractionsIntegration by Parts & by Partial Fractions
Integration by Parts & by Partial FractionsMuhammadAliSiddique1
Ā 
Class 11 Applied mathematics Formula sheet_c88b01d2-a305-4e82-8384-9a47d968e1...
Class 11 Applied mathematics Formula sheet_c88b01d2-a305-4e82-8384-9a47d968e1...Class 11 Applied mathematics Formula sheet_c88b01d2-a305-4e82-8384-9a47d968e1...
Class 11 Applied mathematics Formula sheet_c88b01d2-a305-4e82-8384-9a47d968e1...rishi820219
Ā 
2006 10 1-2
2006 10 1-22006 10 1-2
2006 10 1-2kvillave
Ā 
2006 10 1
2006 10 12006 10 1
2006 10 1kvillave
Ā 
Interpolation.pptx
Interpolation.pptxInterpolation.pptx
Interpolation.pptxMinaSafwatMSR
Ā 
Curve_Fitting.pdf
Curve_Fitting.pdfCurve_Fitting.pdf
Curve_Fitting.pdfIrfan Khan
Ā 
Math1000 section1.5
Math1000 section1.5Math1000 section1.5
Math1000 section1.5StuartJones92
Ā 
Topic 1 __basic_probability_concepts
Topic 1 __basic_probability_conceptsTopic 1 __basic_probability_concepts
Topic 1 __basic_probability_conceptsMaleakhi Agung Wijaya
Ā 

Similar to Moving Average (20)

Vivek
VivekVivek
Vivek
Ā 
Algebra Trigonometry Problems
Algebra Trigonometry ProblemsAlgebra Trigonometry Problems
Algebra Trigonometry Problems
Ā 
Ch02
Ch02Ch02
Ch02
Ā 
Ch02
Ch02Ch02
Ch02
Ā 
Fungsi rekursiv
Fungsi rekursivFungsi rekursiv
Fungsi rekursiv
Ā 
Binomial
BinomialBinomial
Binomial
Ā 
Predictive Modelling
Predictive ModellingPredictive Modelling
Predictive Modelling
Ā 
Lecture Notes in Econometrics Arsen Palestini.pdf
Lecture Notes in Econometrics Arsen Palestini.pdfLecture Notes in Econometrics Arsen Palestini.pdf
Lecture Notes in Econometrics Arsen Palestini.pdf
Ā 
Business forecasting decomposition & exponential smoothing - bhawani nandan...
Business forecasting   decomposition & exponential smoothing - bhawani nandan...Business forecasting   decomposition & exponential smoothing - bhawani nandan...
Business forecasting decomposition & exponential smoothing - bhawani nandan...
Ā 
PRML Chapter 1
PRML Chapter 1PRML Chapter 1
PRML Chapter 1
Ā 
Recreational mathematics magazine number 3 march 2015
Recreational mathematics magazine  number 3 march  2015Recreational mathematics magazine  number 3 march  2015
Recreational mathematics magazine number 3 march 2015
Ā 
Lesson 26: Integration by Substitution (handout)
Lesson 26: Integration by Substitution (handout)Lesson 26: Integration by Substitution (handout)
Lesson 26: Integration by Substitution (handout)
Ā 
Integration by Parts & by Partial Fractions
Integration by Parts & by Partial FractionsIntegration by Parts & by Partial Fractions
Integration by Parts & by Partial Fractions
Ā 
Class 11 Applied mathematics Formula sheet_c88b01d2-a305-4e82-8384-9a47d968e1...
Class 11 Applied mathematics Formula sheet_c88b01d2-a305-4e82-8384-9a47d968e1...Class 11 Applied mathematics Formula sheet_c88b01d2-a305-4e82-8384-9a47d968e1...
Class 11 Applied mathematics Formula sheet_c88b01d2-a305-4e82-8384-9a47d968e1...
Ā 
2006 10 1-2
2006 10 1-22006 10 1-2
2006 10 1-2
Ā 
2006 10 1
2006 10 12006 10 1
2006 10 1
Ā 
Interpolation.pptx
Interpolation.pptxInterpolation.pptx
Interpolation.pptx
Ā 
Curve_Fitting.pdf
Curve_Fitting.pdfCurve_Fitting.pdf
Curve_Fitting.pdf
Ā 
Math1000 section1.5
Math1000 section1.5Math1000 section1.5
Math1000 section1.5
Ā 
Topic 1 __basic_probability_concepts
Topic 1 __basic_probability_conceptsTopic 1 __basic_probability_concepts
Topic 1 __basic_probability_concepts
Ā 

Recently uploaded

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
Ā 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
Ā 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
Ā 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
Ā 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
Ā 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
Ā 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
Ā 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
Ā 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
Ā 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
Ā 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
Ā 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
Ā 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
Ā 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
Ā 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
Ā 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
Ā 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
Ā 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel AraĆŗjo
Ā 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
Ā 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
Ā 

Recently uploaded (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
Ā 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
Ā 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
Ā 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
Ā 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
Ā 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
Ā 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Ā 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
Ā 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
Ā 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
Ā 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Ā 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
Ā 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
Ā 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
Ā 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
Ā 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Ā 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Ā 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Ā 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
Ā 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Ā 

Moving Average

  • 1. Moving Average Methods Edward L. Boone Department of Statistical Sciences and Operations Research Virginia Commonwealth University November 11, 2013 Edward L. Boone
  • 2. Simple Moving Average We are considering time series data xt where t = 1, 2, ..., T . The order of the observations matter. A simple moving average attempts to ļ¬nd a local mean. This can be done simply by taking the average of the points around the time of interest. For example if we are interested in a window of width k we simply take xt , xtāˆ’1 , xt+1 ,...,xt+k ,xtāˆ’k and compute their average. Edward L. Boone
  • 3. Example Consider the following example: x1 1.2 x2 1.3 x3 1.1 x4 1.2 x5 1.4 x6 1.7 x7 1.6 x8 1.8 x9 1.5 x10 1.6 If we want the moving average at time t = 3 with window 2. ĀÆ x3,2 = x1 + x2 + x3 + x4 + x5 1.2 + 1.3 + 1.1 + 1.2 + 1.4 = = 1.24 5 5 If we want the moving average at time t = 7 with window 2. ĀÆ x7,2 = x5 + x6 + x7 + x8 + x9 1.4 + 1.7 + 1.6 + 1.8 + 1.5 = = 1.6 5 5 Notice that the ā€œlocalā€ means are not similar. Edward L. Boone
  • 4. Trailing Moving Average The problem with a standard moving average is that for the mean at time t we need to know t + 1, t + 2,...,t + k , which is in the future. In many useful cases we donā€™t know the future. We want to just use past values. This leads to the idea of the trailing moving average. Only take the average of xtāˆ’k , xtāˆ’k +1 ,...x1 , xt . ĀÆ xt,k = Edward L. Boone 1 k t xt i=tāˆ’k
  • 5. Example Again consider the following example. x1 1.2 x2 1.3 x3 1.1 x4 1.2 x5 1.4 x6 1.7 x7 1.6 x8 1.8 x9 1.5 Trailing moving average with window k = 2 ĀÆ x3,2 = 1.3 + 1.1 + 1.2 x2 + x3 + x4 = = 1.2 3 3 . . . x5 + x6 + x7 1.4 + 1.7 + 1.6 ĀÆ = = = 1.56 3 3 ĀÆ x4,2 = ĀÆ x7,2 Edward L. Boone x1 + x2 + x3 1.2 + 1.3 + 1.1 = = 1.2 3 3 x10 1.6
  • 6. Simple vs. Trailing Moving Average There are some issues that we will have to confront with all time series methods. How to handle the starting values? Outliers? Gaps? Prediction? Some of these are easier to deal with than others. Edward L. Boone
  • 7. Simple vs. Trailing Moving Average 23 Consider the example to the right. Edward L. Boone 22 x 20 19 18 17 Notice that the red line is ā€œsmootherā€ than the blue line. 21 Red is centered moving average. Blue is trailing moving average. True Center Trail 0 20 40 60 t 80 100
  • 8. Issues with Moving Averages Problems with simple moving average techniques. In the previous methods, all observations in window get the same weight. We may wish to downweight observations as they get farther in the past and always use all observations. Gaps? Prediction? Some of these are easier to deal with than others. Edward L. Boone
  • 9. Exponentially Weighted Moving Average A ā€œsimpleā€ way to address the weighting problem is using a weighted moving average. There are several versions of these. Each attempts to model the components of a time series dataset. If we just want to model the level then the Exponentially Weighted Moving Average may be reasonable. S1 = x1 St = Ī±xt + (1 āˆ’ Ī±)Stāˆ’1 These downweight the previous observations but still use all observations. Edward L. Boone
  • 10. Example Again consider the following example using Ī± = 0.3. x1 1.2 S1 S2 S3 S4 S5 S6 S7 S8 S9 S10 Edward L. Boone = = = = = = = = = = x2 1.3 x3 1.1 x4 1.2 x1 = 1.2 Ī±x2 + (1 āˆ’ Ī±)S1 Ī±x3 + (1 āˆ’ Ī±)S2 Ī±x4 + (1 āˆ’ Ī±)S3 Ī±x5 + (1 āˆ’ Ī±)S4 Ī±x6 + (1 āˆ’ Ī±)S5 Ī±x7 + (1 āˆ’ Ī±)S6 Ī±x8 + (1 āˆ’ Ī±)S7 Ī±x9 + (1 āˆ’ Ī±)S8 ?? x5 1.4 x6 1.7 x7 1.6 x8 1.8 x9 1.5 x10 1.6 = 0.3(1.3) + 0.7(1.2) = 1.23 = 0.3(1.1) + 0.7(1.23) = 1.191 = 0.3(1.2) + 0.7(1.191) = 1.1937 = 0.3(1.4) + 0.7(1.1937) = 1.2559 = 0.3(1.7) + 0.7(1.2559) = 1.3891 = 0.3(1.6) + 0.7(1.3891) = 1.4523 = 0.3(1.8) + 0.7(1.4523) = 1.5566 = 0.3(1.5) + 0.7(1.5566) = 1.5396
  • 11. Example 1.1 1.2 1.3 1.4 x 1.5 1.6 1.7 1.8 A picture of what the calculations give. 2 4 6 time Edward L. Boone 8 10
  • 12. Exponentially Weighted Moving Average What we have looked at so far is only concerned in estimating a level (mean). Only models the level. We want to model the trend. We want to model the Seasonality as well. In order to do this we will need to build the model using these basic components. Edward L. Boone
  • 13. Double Exponential Smoothing Now we can add in a trend term bt . Starting values: S1 = x1 b1 = x2 āˆ’ x1 Process smoothing: St bt Edward L. Boone = Ī±xt + (1 āˆ’ Ī±)(Stāˆ’1 + btāˆ’1 ) = Ī²(St āˆ’ Stāˆ’1 ) + (1 āˆ’ Ī²)btāˆ’1
  • 14. Example Again consider the following example using Ī± = 0.3 and Ī² = 0.2. x1 1.2 x2 1.3 x3 1.1 x4 1.2 x5 1.4 x6 1.7 x7 1.6 x8 1.8 x9 1.5 S1 = x1 = 1.2 b1 = x2 āˆ’ x1 = 1.3 āˆ’ 1.2 = 0.1 S2 = Ī±x2 + (1 āˆ’ Ī±)(S1 + b1 ) = 0.3(1.3) + 0.7(1.2 + 0.1) = 1.3 b2 = Ī²(S1 āˆ’ S2 ) + (1 āˆ’ Ī²)(b1 ) = 0.2(1.3 āˆ’ 1.2) + 0.8(0.1) = 0.1 . . . S10 = 1.7343 b10 = 0.0576 Edward L. Boone x10 1.6
  • 15. Example Again consider the following example using Ī± = 0.3 and Ī² = 0.2. x1 1.2 x2 1.3 x3 1.1 x4 1.2 x5 1.4 x6 1.7 x7 1.6 x8 1.8 Predict x11 and x12 . S10 = 1.7343 b10 = 0.0576 x11 = S10 + b10 = 1.7343 + 0.0567 = 1.7919 x12 = S10 + 2b10 = 1.7343 + 2(0.0567) = 1.8496 Edward L. Boone x9 1.5 x10 1.6
  • 16. Triple Exponential Smoothing To have a level, trend and season can get a bit complicated. We need to know what period the seasonality manifests. Quarterly data the seasonal ā€œlag" L may be 4. Monthly data the seasonal ā€œlag" L may be 12. Weekly data the seasonal ā€œlag" L may be 52. Daily data the seasonal ā€œlag" L may be 365. Think how complicated hourly data would be. For simplicity we will consider Quarterly data with L = 4. Edward L. Boone
  • 17. Triple Exponential Smoothing This is also known as the Holt-Winters method. Process smoothing: xt + (1 āˆ’ Ī±)(Stāˆ’1 + btāˆ’1 ) St = Ī± Ctāˆ’L bt = Ī²(St āˆ’ Stāˆ’1 ) + (1 āˆ’ Ī²)btāˆ’1 xt Ct = Ī³ + (1 āˆ’ Ī³)Ctāˆ’L st Starting values: These are more difļ¬cult to get. Some use the ļ¬rst few cycles and get means. Some use regression to get S0 and b0 , then use those to get the initial Cā€™s. We will let R do this for us so we donā€™t have to worry about it. Edward L. Boone
  • 18. Example 4000 2000 3000 Sales 5000 6000 Consider the following data: SeasonalSales.csv 0 10 20 30 Time Edward L. Boone 40
  • 19. HoltWinters Function in R Using the HoltWinters function in R we can estimate: smoothing parameters ļ¬tted values the ļ¬tted values also contain the level, trend and seasonal components Edward L. Boone
  • 20. Example 4000 2000 3000 Sales 5000 6000 Consider the following data: SeasonalSales.csv 2 4 6 8 Time Edward L. Boone 10 12
  • 22. Example Sales 2000 3000 4000 5000 6000 7000 Predict into the future. 2 4 6 8 Time Edward L. Boone 10 12 14
  • 24. Example 2350 2400 2450 Sales 2500 2550 2600 An even closer look. 12.0 12.5 13.0 13.5 Time Edward L. Boone 14.0 14.5 15.0
  • 25. Conclusion Moving average and ā€œsmoothing" methods are ad hoc methods for analyzing time series data. MA methods require user input k . Smoothing methods downweight past observations. These methods can directly model the level, trend and season components. Since they are ad hoc they can produce odd results at times. While these methods are useful we need to be careful because they have no clear theory to back them up. Edward L. Boone