Linear Regression and Time Series Analysis
Lesson Objectives: At the end of the module, each student should be able to
1) define and explain the concept of linear regression
2) determine linear equation and regression line
3) interpret values of regression coefficient
4) understand the use of time series analysis
--------------------------------------------------------------------------------------------------------------------
Linear Regression
Regression analysis helps us determine the probable form of the relationships between
variables. The objective of this method of analysis is usually to predict or estimate the value
of one variable corresponding to the value of another variable A two-variable regression model
species one dependent variable Y (sometimes called the response) and one independent
variable X (sometimes called the predictor). A linear regression model is a mathematical
equation that describes a straight – line relationship between two variables x and y.
Equation of a regression line
y̅ = a + bx
where b = n∑ xy −∑ x ∑ y and = a = y̅ - bx̅
n∑ x 2 - (∑ x ¿¿ 2
In the regression line equation, b is the slope of the regression line and a is its vertical
intercept.
Example:
The table below gives the monthly incomes and expenditures on food for seven households.
Income X (in PhP1,000) Expenditure Y (in PhP1,000)
35 9
49 15
21 7
39 11
15 5
28 8
25 9
a) Find the equation of the regression line.
Solution:
We let x represent the income and y the food expenditure for each household.
Computing for each of the entries needed in the equation, we have
Page 1 of 7
n = 7, ∑ x = 212, ∑ y = 64, ∑ x y = 2150, ∑ x 2 = 7222
y̅ = ∑ y /n = 64 / 7 = 9.14, x̅ = ∑ x /n = 212 / 7 = 30.29
Substituting these in the equations:
b = [ 7(2150) – (212)(64) ] / [ 7(7222) – (212¿2 = +0.26
a = 9.14 – 0.26(30.29) = 1.26
Hence, the equation of the regression line is:
y˜ = 1.26 + 0.26x
Interpretation:
Income and food expenditure are directly related. This is indicated by the positive sign of the
value of b. (Remember that b is the slope of the regression line). An increase in income
increases also food spending. A family with no source of income (i.e., income = 0) still spends
around Php1,260 on food monthly. For every Php1,000 increase in its income, food
expenditure rises by Php260.
b) Predict the amount of food spending for a household whose monthly income is Php20,000.
Solution:
We let x = 20. Substituting this in the equation of the regression line, we get
y˜ = 6.46. This means that a family that receives a monthly income of Php20,000 is predicted
to spend around Php6,460 on food
Scatter Diagram (or the Scatter Plot)
The scatter diagram provides a visual display of each observed data pair (x, y) as a dot on an
X-Y grid. This diagram provides a visual indication of the strength of the relationship or
associated between the two random variables.
Example:
The scatter diagram of the preceding example of income-food expenditure distribution is
shown below. This is done by plotting the paired observations. (You don’t connect the plotted
points). A trend can be seen from the position of these points. Here, we see a positive
relationship income and food spending.
Page 2 of 7
Y
Expenditure (in P1000)
16
14
12
10 Y= 1.26 + 0.26X
85
2 X
5 10 15 20 25 30 35 40 45 50 Income (in 1000)
The straight line drawn is the graph of the regression equation found above. This can be
used to read the predicted food expenditure for a chosen income level. (Remember that such
food expenditure is simply a prediction, not necessarily what may actually be the food
spending of that family with that given income level).
--------------------------------------------------------------------------------------------------------------------
Time-Series Analysis
A time-series variable (denoted by Y) consists of data observed n periods of time. Time-series
data may be measured at a point in time or over an interval of time. Your GPA is measured at
a point in time while your monthly pay is measured over an interval of time. The periodicity is
the time interval over which data are collected (decade, year, quarter, month, week, day, hour).
Time series or linear trend model is a special case of linear regression. It has the form
ỹ = a + bt where t is an index denoting time period (t=1,2,..,n)
The symbol t replaces the independent variable x in our linear regression model.
Thus, for the value of b and a, we have the following formulas:
b = n∑ ty - ∑ t ∑ y
n∑ t 2 – (∑ t ¿ ¿ 2
Page 3 of 7
a = y̅ - bt̅
This trend-line model is useful for a time-series that grows or declines by the same amount (b)
in each period. It is a simple model for short-run forecasting. The rend-line equation or any
regression line should not be used to predict values much outside the range in the sample
because we do not know whether the linear pattern observed in th scatte diagram continues
outside this range. This is sometimes reffered to as the danger of extrapolation.
Example.
PMA Applications for Cadetship, 2012-2021 (hypothetical data)
Year t Number of Applications (in 1000s)
2012 1 10.0
2013 2 9.0
2014 3 10.0
2015 4 9.5
2016 5 7.0
2017 6 7.7
2018 7 8.2
2019 8 8.0
2020 9 6.0
a) Find the equatiion of the trend line.
b) Forecast the number of applicants for 2021
c) Plot the scatter diagram and the graph of the trend line.
Solution:
a) We use the same formula as in the regression line for the computation of the slope
b and the intercept a (t will just replcace x in the formula) of the trend line equation.
∑t = 45; ∑y = 75.4; ∑t y = 352.6; ∑ t2 = 285; t = 5
y = 8.38
Page 4 of 7
b = 9 (352.6) – (45) (75.4) = -0.41
9(285) – (45 ¿2
a = 8.38 – (-0.41) (5) = 10.43
Hence, the equation of the trend line is
ỹ = 10.43 – 0.41 t
Do we forecast a decreasing number of applicants in the coming years. Why do yoou think so?
b) Year 2021 indicates t = 11. Using the trend line equation with t = 11, we have ỹ
= 10.43 – 0.41 (11) = 5.92
This means that the forecast number of applications for 2021 is about 5,920
c) Scatter diagram and trend line graph
. y (in 1000)
A 10
p 9
p
l 8
i
c 7 y=10.43-0.41t
a
t 6
i
o 5
n
s 4
3 t
1 2 3 4 5 6 7 8 9 10
Page 5 of 7
Activity
1. For the following information obtained from a sample data set, find the regression
equation.
Σx = 66, x = 5.5, Σy = 588, Σxy = 2244, Σx 2 = 396
n = Σx / x ______________ y̅ = ________________
b = n∑ xy - ∑ x ∑ y
n∑ x 2 – (∑ x ¿¿ 2
= _________________
a = y̅ - bx̅
a = _____________________
y̅ = a + bx
Regression Equation: _____________________
2. A researcher took a sample of 10 years and found the following relationship between x and
y where x is the number of major natural calamities that occurred during a year and y
represents the total profits (in millions of pesos) of local hotels in Baguio City.
y = 10.6 - 0.2x
________(a) Assuming that there were no calamities in a selected year, how much were the
total profits of these hotels during that year?
(b) For every natural calamity that occurred, total profits (rose , fell ) ________ by
______________.
_________(c) A randomly selected year had 7 major calamities. What were the expected
total profits of these hotels for that year?
_________ (d) If total profits of these hotels were Php 9.8M for a certain year, how many
calamities had hit Baguio City during that year?
x = ________________
3. Consider the ff data below: (from [Link]/coronavirus/country/Philippines)
Year (t) May (1) June(2) July (3) Aug(4) Sept(5) Oct(6)
# of Positive cases (y) 17,224 37,514 89,291 217,373 311,664 376,927
Of Covid-19 in the Phil
t y ty t2
1 17,224 1
2 37,514 4
3 89,291 9
Page 6 of 7
4 217,373 16
5 311,664 25
6 376,927 36
1,049,99
∑ 21 3 91
t = 21 / 6 = 3.5
a) Find the trend line equation. ________________________________ Show solution
below.
b = n∑ ty - ∑ t ∑ y
n∑ t 2 – (∑ t ¿ ¿ 2
=
b = _______________
b = ______________
a = y̅ - bt
a = _____________
y̅ = a + bt
y̅ = ___________________
b) Draw the scatter diagram and the graph of the trend line equation below.
400,000
350,000
300,000
# of Positive Cases
250,000
200,000
150,000
100,000
50,000
0
0 1 2 3 4 5 6
Month
c) Predict the number of corona virus positive for the December 2020 ___________
If May = 1; December = 8 then t = 8
y̅ = ______________________
y̅ = ______________________
y̅ = ______________________
Page 7 of 7
II.. Shown below is the graph of a hypothetical time-series set of data for y and t where t =
time period in months and y = number of clearing-out students for a certain year.
y
16 --
14 --
12 --
10 --
8 --
6 --
4 --
2 --
t (months)
0 1 2 3 4 5 6 7 8 9
t y ty t2
0 16 0
1 14 1
2 12 4
3 10 9
4 8 16
5 6 25
6 4 36
7 2 49
8 0 64
∑ 36 72 204
n = ______ t = __________ y = _________
a) Find: a = _______, b = _________, Trend line equation:_______________________
b = n∑ ty - ∑ t ∑ y
n∑ t 2 – (∑ t ¿ ¿ 2
=
b = ____________
a = y̅ - bt a = _______
y̅ = a + bt
y̅ = ________________
If t = 0 represents the month of June 2022,
Page 8 of 7
b) forecast the number of students who shall be clearing out because of resignation,
discharge or being turned-back in December of this year. _____________________
If June = 0; December = 6 then t = 6
y̅ =
y̅ =
y̅ = _________
b) in what month will there be no students clearing out? _____________________
Page 9 of 7