0% found this document useful (0 votes)
6 views27 pages

Sta101 Lec 14

The document outlines a course on Introduction to Statistics (STA101) taught by Farzana Zaman at BRAC University, focusing on moving averages and linear trend analysis. It explains the concept of moving averages for smoothing time series data and provides examples and exercises for calculating moving averages and linear trends using regression analysis. The document includes detailed calculations and examples for both odd and even periods in trend estimation.

Uploaded by

fahmidrahman3675
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)
6 views27 pages

Sta101 Lec 14

The document outlines a course on Introduction to Statistics (STA101) taught by Farzana Zaman at BRAC University, focusing on moving averages and linear trend analysis. It explains the concept of moving averages for smoothing time series data and provides examples and exercises for calculating moving averages and linear trends using regression analysis. The document includes detailed calculations and examples for both odd and even periods in trend estimation.

Uploaded by

fahmidrahman3675
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
You are on page 1/ 27

Course: STA101

Introduction to Statistics

Farzana Zaman
Adjunct Faculty (Statistics)
Department of Mathematics and Natural Sciences (MNS)
BRAC University

STA101 - Spring ’25 Prepared by Farzana Zaman (FZZ) 1/18


Outline

Lecture 14

❖ Moving Average
❖ Linear Trend Analysis

STA101 - Spring ’25 Prepared by Farzana Zaman (FZZ) 2/18


A Moving Average

A moving average is useful in smoothing a time series to see its trend.


It is also the basic method used in measuring seasonal fluctuation
The moving-average method merely smooths the fluctuations in the
data. This is accomplished by “moving” the arithmetic mean values
through the time series.
In mathematical notation,
xi + xi+1 + · · · + xi+(n−1)
nMAi =
n

STA101 - Spring ’25 Prepared by Farzana Zaman (FZZ) 3/18


Example
The following table shows three-year and five-year moving averages for a
series of production data.

STA101 - Spring ’25 Prepared by Farzana Zaman (FZZ) 4/18


Examples

Time Series Plot of Production, Three-Year Moving Average, and


Five-Year Moving Average

STA101 - Spring ’25 Prepared by Farzana Zaman (FZZ) 5/18


Examples

Calculations of a Four-Year Moving Average:

STA101 - Spring ’25 Prepared by Farzana Zaman (FZZ) 6/18


Example

Q. A sensor in a weather station record hourly temperature over a day.


To smooth fluctuations and identify trend, a three-point moving average is
applied. The station collected the following hourly temperature data:

Hour (t) 1 2 3 4 5 6 7 8 9
Temperature (Yt ) 22 24 23 25 26 28 27 29 30

a. Calculate trend using three-point moving average method.


b. Visualize the trend value using appropriate graphical method.

STA101 - Spring ’25 Prepared by Farzana Zaman (FZZ) 7/18


Example: Solution

Hour (t) Temperature (Yt ) 3-point average


1 22 -
2 24 (22 + 24 + 23)/3 = 23
3 23 (24 + 23 + 25)/3 = 24
4 25 (23 + 25 + 26)/3 = 24.67
5 26 (25 + 26 + 28)/3 = 26.33
6 28 (26 + 28 + 27)/3 = 27
7 27 (28 + 27 + 29)/3 = 28
8 29 (27 + 29 + 30)/3 = 28.67
9 30 -
Table: Hourly Temperature Data with 3-Point Moving Average

STA101 - Spring ’25 Prepared by Farzana Zaman (FZZ) 8/18


Example: Solution

3-Point Moving Average Trend Line


30
3-Point Moving Average

29 3-Point Moving Average


28
27
26
25
24
23
22
0 1 2 3 4 5 6 7 8 9 10
Hour (t)

STA101 - Spring ’25 Prepared by Farzana Zaman (FZZ) 9/18


Exercise

Q. The following table shows the sales of Waccamaw Machine Tool Inc.

a. Determine a three-year moving average for the sales of Waccamaw


Machine Tool Inc.
b. Plot both the original data and the moving average.

STA101 - Spring ’25 Prepared by Farzana Zaman (FZZ) 10/18


Linear Trend

Secular trend represents the long-term change / direction of the


series.
The long-term trend of many business series, such as sales, exports,
and production, often approximates a straight line.
The secular trend often approximates a straight line.
Regression analysis can be used to fit a linear trend line to a time
series.
The trend line can be expressed as:

LINEAR TREND EQUATION: Ŷ = â + b̂X

where,
Ŷ is the projected value of the y variable for a selected value of t,
â is the y-intercept,
b̂ is the slope of the line.
STA101 - Spring ’25 Prepared by Farzana Zaman (FZZ) 11/18
Least Squares Method

Following from linear regression, the least squares estimate is


expressed by:
Ŷ = â + b̂X
Where:
∑ XY − nX̄ Ȳ
b̂ = , â = Ȳ − b̂ X̄
∑ X 2 − nX̄ 2
However, when using the Least Squares Method for time series, we
often translate X such that ∑ X = 0, simplifying:

∑ XY
b̂ = , â = Ȳ
∑X2

STA101 - Spring ’25 Prepared by Farzana Zaman (FZZ) 12/18


Odd Number of Periods

Least Squares Method: Odd Number of Period

Steps for Odd Number of Periods


1 Calculate the mean value of time:
∑T
T̄ =
n
2 Code the time values:
X = T − T̄

STA101 - Spring ’25 Prepared by Farzana Zaman (FZZ) 13/18


Odd Number of Periods

Example 1
The close price of Alphabet Inc. (GOOG) shares on the last trading day of
each year is represented by the following time series.
Q. Find the linear equation that describes the trend and estimate the
close price for 2014.

Year (T) Close (Y)


2004 96
2005 207
2006 229
2007 344
2008 153
2009 309
2010 296
2011 322
2012 352
STA101 - Spring ’25 Prepared by Farzana Zaman (FZZ) 14/18
Odd Number of Periods

Solution: Trend Line Calculation

Calculation table:

Year (T) X = T − T̄ Close (Y) XY X2


2004 -4 96 -384 16
2005 -3 207 -621 9
2006 -2 229 -458 4
2007 -1 344 -344 1
2008 0 153 0 0
2009 1 309 309 1
2010 2 296 592 4
2011 3 322 966 9
2012 4 352 1408 16
ΣX = 0 ΣY = 2308 ΣXY = 1468 ΣX 2 = 60

STA101 - Spring ’25 Prepared by Farzana Zaman (FZZ) 15/18


Odd Number of Periods

Solution

Compute â and b̂:


2308 ΣXY 1468
â = Ȳ = = 256.44, b̂ = 2
= = 24.47
9 ΣX 60
Therefore, the trend line equation:

Ŷ = 256.44 + 24.47X

For T = 2014, X = 2014 − 2008 = 6:

Ŷ = 256.44 + (24.47 × 6) = 403.26

STA101 - Spring ’25 Prepared by Farzana Zaman (FZZ) 16/18


Even Number of Periods

Least Squares Method: Even Number of Period

Steps for Even Number of Periods


1 Calculate the mean value of time:
∑T
T̄ =
n
2 Code the time values:
X = 2 × (T − T̄ )

STA101 - Spring ’25 Prepared by Farzana Zaman (FZZ) 17/18


Even Number of Periods

Example 2
The close price of Alphabet Inc. (GOOG) shares on the last trading day of
each year is represented by the following time series.
Q. Find the linear equation that describes the trend and estimate the
close price for 2014.
Year (T) Close (Y)
2004 96
2005 207
2006 229
2007 344
2008 153
2009 309
2010 296
2011 322
2012 352
2013 558
STA101 - Spring ’25 Prepared by Farzana Zaman (FZZ) 18/18
Even Number of Periods

Solution: Trend Line Calculation

Calculation table:

Year (T) X = 2(T − T̄ ) Close (Y) XY X2


2004 -9 96 -864.32 81
2005 -7 207 -1445.59 49
2006 -5 229 -1146.09 25
2007 -3 344 -1033.35 9
2008 -1 153 -152.01 1
2009 1 309 308.83 1
2010 3 296 887.76 9
2011 5 322 1608.72 25
2012 7 352 2466.58 49
2013 9 558 5024.76 81
ΣX = 0 ΣY = 2867 ΣXY = 5651.73 ΣX 2 = 330

STA101 - Spring ’25 Prepared by Farzana Zaman (FZZ) 19/18


Even Number of Periods

Solution

Compute â and b̂:


2867 ΣXY 5651.73
â = Ȳ = = 286.7, b̂ = 2
= = 17.13
10 ΣX 330
Therefore, the trend line equation:

Ŷ = 286.7 + 17.13X

For T = 2014, X = 2 × (2014 − 2008.5) = 11:

Ŷ = 286.7 + (17.13 × 11) = 475.13

STA101 - Spring ’25 Prepared by Farzana Zaman (FZZ) 20/18


Even Number of Periods

Problem 3: Sales Trend Estimation

The annual sales of a product (in thousands) for the years 2010 to 2018
are given below:

Year (T) 2010 2011 2012 2013 2014 2015 2016 2017 2018
Sales (Y) 120 135 140 155 170 180 195 205 220

Find the linear equation describing the trend and estimate the sales for the
year 2020.

STA101 - Spring ’25 Prepared by Farzana Zaman (FZZ) 21/18


Even Number of Periods

Problem 3 Solution

Calculation Table:

Year (T) X = T − T̄ Sales (Y) XY X2


2010 −4 120 −480 16
2011 −3 135 −405 9
2012 −2 140 −280 4
2013 −1 155 −155 1
2014 0 170 0 0
2015 1 180 180 1
2016 2 195 390 4
2017 3 205 615 9
2018 4 220 880 16
ΣX = 0 ΣY = 1520 ΣXY = 745 ΣX 2 = 60

STA101 - Spring ’25 Prepared by Farzana Zaman (FZZ) 22/18


Even Number of Periods

Problem 3 Solution

Trend Line Calculation:


ΣY 1520 ΣXY 745
â = Ȳ = = = 168.89, b̂ = 2
= = 12.42
n 9 ΣX 60

Ŷ = 168.89 + 12.42X
For 2020 (X = 6):

Ŷ = 168.89 + (12.42 × 6) = 243.41 (thousands)

STA101 - Spring ’25 Prepared by Farzana Zaman (FZZ) 23/18


Even Number of Periods

Problem 4: Revenue Projection

The annual revenue (in million dollars) for a company from 2011 to 2020
is as follows:
Year (T) 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020
Revenue (Y) 50 55 60 70 75 85 95 100 110 120

Find the linear equation describing the trend and estimate the revenue for
the year 2023.

STA101 - Spring ’25 Prepared by Farzana Zaman (FZZ) 24/18


Even Number of Periods

Problem 4 Solution

Calculation Table:

Year (T) X = 2(T − T̄ ) Revenue (Y) XY X2


2011 −9 50 −450 81
2012 −7 55 −385 49
2013 −5 60 −300 25
2014 −3 70 −210 9
2015 −1 75 −75 1
2016 1 85 85 1
2017 3 95 285 9
2018 5 100 500 25
2019 7 110 770 49
2020 9 120 1080 81
ΣX = 0 2
ΣY = 820 ΣXY = 1300 ΣX = 330

STA101 - Spring ’25 Prepared by Farzana Zaman (FZZ) 25/18


Even Number of Periods

Problem 4 Solution

Trend Line Calculation:


ΣY 820 ΣXY 1300
â = Ȳ = = = 82, b̂ = 2
= = 3.94
n 10 ΣX 330

Ŷ = 82 + 3.94X
For 2023 (X = 15):

Ŷ = 82 + (3.94 × 15) = 140.1 (million dollars)

STA101 - Spring ’25 Prepared by Farzana Zaman (FZZ) 26/18


References

❑ Statistical Techniques in Business and Economics- Douglas A Lind,


William G. Marchal & Samuel A. Wathen.
❑ Introductory Statistics- Neil A. Weiss.
❑ Introductory Statistics- PREM S. MANN

STA101 - Spring ’25 Prepared by Farzana Zaman (FZZ) 27/18

You might also like