Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
135 views

Linear Regression

Uploaded by

Kelvin Rufin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
135 views

Linear Regression

Uploaded by

Kelvin Rufin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Linear Regression

MATH 111 – MATH IN THE MODERN WORLD


First Semester, SY 2022-2023

Prepared by: Prof. JEAN D. CENTINA


DAVAO DEL NORTE STATE COLLEGE
OBJECTIVES FOR THE LESSON

1. solve for variables in the equation y = b + mx, given a set of data


2. write the linear regression equation, given the set of data
3. predict the value of a variable given certain conditions
Linear Regression – a statistical tool used to predict the value of a variable given certain conditions
Its simple linear regression equation is y = mx + b.
Given a data set, the constants m and b are determined from the formulas below.
𝑛 𝑛
𝑛 𝑖=1 𝑥𝑖 𝑦𝑖 − 𝑖=1 𝑦𝑖
𝑚= 2
𝑛 2 𝑛
𝑛 𝑖=1 𝑥𝑖 − 𝑥
𝑖=1 𝑖
and

b = 𝑦−𝑚𝑥
Where
𝑚 is the slope;
𝑛 is the sample size;
𝑛
𝑖=1 𝑥𝑖 𝑦𝑖 is the some of all products of x and y;
𝑛
𝑖=1 𝑦𝑖 is the sum of all y;
𝑛 2 2
𝑖=1 𝑥𝑖 is the sum of all X ;
𝑛 2 is the square of the sum of all x;
𝑖=1 𝑥𝑖
b is the y-intercept;
𝑦 is the mean of all y;
𝑥 is the mean of all x.
Substituting the values to the formulas:
Study the given example below and its calculation. 𝑛 𝑛 𝑛
𝑛 𝑖=1 𝑥𝑖 𝑦𝑖 − 𝑖=1 𝑥𝑖 𝑖=1 𝑦𝑖
𝑚= 2
It has been established that there is a positive correlation 𝑛 2 𝑛
𝑛 𝑖=1 𝑥𝑖 − 𝑖=1 𝑥𝑖
between scores in mathematics and English for a group of ten 𝑚=
10 298 −(48)(50)
students. The data are given below. 10 296 − (48)2

𝑚 = 0.884146
Using these data, determine the linear regression equation and If x = 10,
use this equation to predict the score of a student in Engish test, Y= .76 + (.88)(10)
who got a score of 3 in the mathematics quiz. b = 𝑦−𝑚𝑥 Y= 9.56 ~ 10
Student Math Score English Score 𝑥𝑖 𝑦𝑖 𝑥𝑖 2 b = 5 – (0.884146) (4.8)
𝑖 𝑥𝑖 𝑦𝑖 b = 0.756098
1 4 5 20 16
2 5 4 20 25 Substituting in y = mx + b and
3 9 8 72 81
rounding off to two decimal places, the linear regression
4 2 3 6 4
5 8 9 72 64 equation is
6 1 2 2 1
7 2 1 2 4 y = 𝟎. 𝟕𝟔 + 𝟎. 𝟖𝟖 𝒙
8 7 6 42 49 Thus, the student who got 3 score in mathematics quiz will
9 6 7 42 36
have also a score of 3 in English test, as shown below.
10 4 5 20 16
10 10 10 10

𝑥𝑖 = 48 𝑦𝑖 = 50 𝑥𝑖 𝑦𝑖 = 298 𝑥𝑖 2 = 296 y = 0.76 + 0.88 𝑥


𝑛 = 10 𝑖=1 𝑖=1 𝑖=1 𝑖=1 y = 0.76 + 0.88 (3)
48 50
y = 3.41 or 3
𝑥 = = 4.8 𝑦= = 5
10 10
Solving for m Substituting the values to the formulas:
USING THE SCIENTIFIC CALCULATOR:
Solving for b 𝑛 𝑛 𝑛
( 𝑛 𝑖=1 𝑥𝑖 𝑦𝑖 − 𝑖=1 𝑥𝑖 𝑖=1 𝑦𝑖
10 USING THE 𝑚=
𝑛 𝑛 2
SCIENTIFIC 𝑛 2
) 𝑖=1 𝑥𝑖 − 𝑖=1 𝑥𝑖
CALCULATOR: 10 298 −(48)(50)
X 𝑚=
10 296 − (48)2
298 5
) 𝑚 = 0.884146
-
-
( (
48 .884146
X X b = 𝑦−𝑚𝑥
50 4.8 b = 5 - 0.884146 (4.8)
) ) b = 0.756098 or 0.76
) =
Divided by Substituting in y = mx + b or y = b + mx and
.756098
(
rounding off to two decimal places, the linear regression
(
10 equation is
x
296 y = 𝟎. 𝟕𝟔 + 𝟎. 𝟖𝟖 𝒙
) Thus, the student who got 3 score in mathematics quiz will
- have also a score of 3 in English test, as shown below.
(
48
y = 0.76 + 0.88 𝑥
X^2
) y = 0.76 + 0.88 (3)
) y = 3.41 or 3
=
0.884146
Example 2.
Substituting the values to the formulas:
The table below lists the scores of nine students in Chemistry and
Physics tests. 𝑛 𝑛 𝑛
𝑛 𝑖=1 𝑥𝑖 𝑦𝑖 − 𝑖=1 𝑥𝑖 𝑖=1 𝑦𝑖
a. Compute for m and b in the linear regression equation. 𝑚= 2
𝑛 2 𝑛
b. Give the regression equation. 𝑛 𝑖=1 𝑥𝑖 − 𝑖=1 𝑥𝑖
[ 9 255 − 55 43 ]
c. Predict the Physics score of a student when he or she got a score 𝑚= [(9) 369 − 55 2 ]
of 10 in Chemistry.
Student Chemistry Physics Score 𝑥𝑖 𝑦𝑖 𝑥𝑖 2 𝑚 = - 0.2365
𝑖 Score
b = 𝑦−𝑚𝑥
𝑥𝑖 𝑦𝑖
b = 4.8 – (-0.2365)(6.1)
1 3 6 18 9 b = 6.24
2 6 5 30 36
3 5 7 35 25 Rounding off to two decimal places, the linear regression
4 8 6 48 64 equation is
5 9 2 18 81 y = b + mx
6 4 3 12 16
y = 6.24 + (−0.2365) 𝑥
7 5 4 20 25
8 7 6 42 49 Thus, the student who got 10 score in Chemistry will have
9 8 4 32 64 a score of 4 in Physics, as shown below.

𝑥𝑖 = 55 𝑦𝑖 = 43 𝑥𝑖 𝑦𝑖 = 255 𝑥𝑖 2 = 369 y = 6.24 + (−0.2365) 𝑥


𝑛=9 𝑖=9 𝑖=9 𝑖=9 𝑖=9 y = 6.24 + (−0.2365) (10)

𝑥 = 6.1 𝑦 = 4.8 y = 3.875 or 4


chem scores
phys scores
x y xy x^2
3 6 18 9
6 5 30 36
5 7 35 25
8 6 48 64
9 2 18 81
4 3 12 16
5 4 20 25
7 6 42 49
8 4 32 64
55 43 255 369
sum of x sum of y sum of xy sum of x^2
6.111111 4.777778
x mean y mean

m -0.23649 -0.236486
ACTIVITY 8 - LINEAR REGRESSION
PROBLEM A. The table below indicates the total number of enrolees Substituting the values to the formulas:
of Ezrah Academy and the corresponding profit from 2008 to 2016. 𝑛 𝑛 𝑛
𝑛 𝑖=1 𝑥𝑖 𝑦𝑖 − 𝑖=1 𝑥𝑖 𝑖=1 𝑦𝑖
a. Compute for m and b in the linear regression equation. 𝑚=
𝑛 𝑛 2
𝑛 2
b. Give the regression equation. 𝑖=1 𝑥𝑖 − 𝑖=1 𝑥𝑖
c. Predict the school’s profit in 2017 , the y , 𝒏 −( )( )
𝒎= (𝒏) − ( )𝟐
when the total enrolment is 12,000 (the 𝒙 )
TOTAL PROFIT 𝒎 = ____________
YEAR ENROLMENT (in million
2 b = 𝑦−𝑚𝑥
𝑥𝑖 pesos) 𝑥𝑖 𝑦𝑖 𝑥𝑖
𝑦𝑖 b = ( ) – ( )( )
b = _____________
2008 16,000 250
2009 15,000 200 Rounding off to two decimal places, the linear regression
2010 10,500 150 equation is
2011 11,000 180 y = b + mx
2012 11,800 190
2013 13,400 200 y = _____ + ( )𝒙
2014 13,900 220
Thus, school’s profit in 2017 when the total enrolment is
2015 14,000 240
12,000 is P___________, as shown below.
2016 13,200 180
9 y = ______ + ( )𝒙
9 9 9
𝑖=1 𝑥𝑖 = ___ 𝑖=1 𝑦𝑖 = ___ 𝑖=1 𝑥𝑖 𝑦𝑖 = ___ 𝑥𝑖 2 = _____ y = ______ + ( )( )
𝑛 = _____ 𝑖=1
𝑥 = ___ 𝑦 = ______ y = ______ in million
LINEAR REGRESSION Substituting the values to the formulas:
PROBLEM B
𝑛 𝑛 𝑛
The table below indicates the monthly cost of electricity against 𝑛 𝑖=1 𝑥𝑖 𝑦𝑖 − 𝑖=1 𝑥𝑖 𝑖=1 𝑦𝑖
air-conditioning temperature in a household. 𝑚= 2
𝑛 2 𝑛
𝑛 𝑖=1 𝑥𝑖 − 𝑖=1 𝑥𝑖
a. Fit the data into a linear equation and compute for m and b in −( )( )
the linear regression equation. 𝒎= ( ) − ( )𝟐
b. Give the regression equation.
c. Predict the cost of electricity if the air-conditioner is set at a 𝒎 = ____________
temperature of 16 ⁰C in a month (the y).
b = 𝑦−𝑚𝑥
b = ( ) – ( )( )
b = _____________
Air-con Cost of
Month Temperature Electricity Rounding off to two decimal places, the linear regression
2
in ⁰C in pesos 𝑥𝑖 𝑦𝑖 𝑥𝑖 equation is (y = b + mx):
𝑥𝑖 𝑦𝑖
y = _____ + ( )𝒙
1 25 3000
2 23 3300 Thus, the cost of electricity if the air-conditioner is set at
3 21 3500 a temperature of 16 ⁰C in a month is ________pesos, as
4 19 3800 shown below.
y = ______ + ( )𝒙
5 17 4000
y = ______ + ( )( )
5 5 5
𝑖=1 𝑥𝑖 = __ 𝑖=1 𝑦𝑖 = __ 𝑖=1 𝑥𝑖 𝑦𝑖 = ___ 5

𝑥𝑖 2 = ___ y = ______
𝑛 =5 𝑥 = ___ 𝑦 = ___ 𝑖=1
PROBLEM C.
A real estate agent wishes to examine the relationship between the selling price of a home and its size (measured in square feet).
Predict the price for a house with 2000 square feet.

House Price in Size in


Thousand
Pesos Square Feet
(Y) (X)

245 1400
312 1600
279 1700
308 1875
199 1100
219 1550
405 2350
324 2450
319 1425
255 1700

You might also like