SlideShare a Scribd company logo
Basics of
Regression Analysis
Presented By
Mahak Vijay
08-02-2017
1
•What is Regression Analysis?
•Population Regression Line
•Why do we use Regression Analysis?
•What are the types of Regression?
•Simple Linear Regression Model
•Least Square Estimation for parameters
•Least Square for Linear Regression
•References
08-02-2017
2
Outlines
 Regression analysis is a form of predictive modelling technique which investigates the
relationship between a dependent (target) and independent variable(s) (predictor).
 This technique is used for forecasting, time series modelling and finding the causal effect
relationship between the variables.
 For example, relationship between rash driving and number of road accidents by a driver is
best studied through regression.
08-02-2017
3
What is Regression Analysis?
x
y
Regression Line
Actual
Estimated
Errors
08-02-2017
4
Population Regression Line
Independent Variables
DependentVariables
Study Time
EstimatedGrades
Population regression function =
𝑦 = 𝑏0+𝑏1x
𝑦 = Estimated Grades
x = Study Time
𝑏0= Intercept
𝑏1= Slope
Example
08-02-2017
5
Population Regression Line
𝑏0= Intercept
𝑏1= Slope
Regression Line
Typically, a regression analysis is used for these purposes:
(1) Prediction of the target variable (forecasting).
(2) Modelling the relationships between the dependent variable and the explanatory variable.
(3) Testing of hypotheses.
Benefits
1. It indicates the strength of impact of multiple independent variables on a dependent variable.
2. It indicates the significant relationships between dependent variable and independent variable.
These benefits help market researchers / data analysts / data scientists to eliminate and evaluate the best set
of variables to be used for building predictive models.
08-02-2017
6
Why we need Regression Analysis?
Types of regression analysis:
Regression analysis is generally classified into two
kinds: simple and multiple.
Simple Regression:
It involves only two variables: dependent variable ,
explanatory (independent) variable.
A regression analysis may involve a linear model or
a nonlinear model.
The term linear can be interpreted in two different
ways:
1. Linear in variable
2. Linearity in the parameter
Regression
Analysis
Simple Multiple
Linear Non Linear
1 Explanatory
variable
2+ Explanatory
variable
08-02-2017
7
Types of Regression Analysis
Simple linear regression model is a model with a single regressor x that has a linear relationship with a
response y.
Simple linear regression model:
y = 𝑏0+𝑏1x + ɛ
Response variable Regressor variable
Intercept Slope Random error component
In this technique, the dependent variable is continuous
and random variable, independent variable(s) can
be continuous or discrete but it is not a random
variable, and nature of regression line is linear.
08-02-2017
8
Simple Linear Regression Model
Some basic assumption on the model:
Simple linear regression model:
yi= 𝑏0+𝑏1xi + ɛi for i=(1,2….n)
 ɛi is a random variable with zero mean and variance σ2,i.e.
 ɛi and ɛj are uncorrelated for i ≠ j, i.e.
 ɛi is a normally distributed random variable with mean zero and variance σ2.
Ɛi ~𝑖𝑛𝑑 N (0, σ2).
E(ɛi )=0 ; V(ɛi )= σ2
cov(ɛi , ɛj )=0
08-02-2017
9
yi= 𝑏0+𝑏1xi + ɛi for i=(1,2….n)
E(yi) = 𝐸(𝑏0+𝑏1xi + ɛi)= 𝑏0+𝑏1xi
V(yi) = 𝑉(𝑏0+𝑏1xi + ɛi)=V(ɛi )=σ2.
=> Ɛi ~𝒊𝒏𝒅 N (0, σ2)
=> Yi ~𝒊𝒏𝒅 N (𝒃 𝟎+𝒃 𝟏xi , σ2)
08-02-2017
10
NOTE : The dataset should satisfy the basic assumption.
E(ɛi )=0
The parameters 𝑏0 and 𝑏1are unknown and must be estimates using sample data:
(𝑥1,𝑦1), (𝑥2,𝑦2),……(𝑥 𝑛,𝑦𝑛)
x
y
𝑦 = 𝑏0+𝑏1x + ɛ
x
y
08-02-2017
11
Least Square Estimation for Parameters
𝑦𝑖 = 𝑏0+ 𝑏1xi + ɛi
The line fitted by least square is the one that makes the sum of squares of all vertical discrepancies
as small as possible.
x
y
We estimate the parameters so that sum of
squares of all the vertical difference between
the observation and fitted line is minimum.
S= 𝑖=1
𝑛
𝑦𝑖 − 𝑏0 − 𝑏1 𝑥𝑖
2
(x1,y1)
(x1, 𝑦1)
(y1- 𝑦1)= ɛ1
08-02-2017
12
𝑦𝑖 = 𝑏0+ 𝑏1xi + ɛi
Minimizing the function requires to calculate the first order condition with respect to alpha and beta and
set them zero:
I:
𝜕𝑠
𝜕𝑏0
= -2 𝑖=1
𝑛
𝑦𝑖 − 𝑏0 − 𝑏1 𝑥𝑖 = 0
II:
𝜕𝑠
𝜕𝑏1
= -2 𝑖=1
𝑛
𝑦𝑖 − 𝑏0 − 𝑏1 𝑥𝑖 𝑥𝑖 = 0
We can mathematically solve for 𝑏0 𝑎𝑛𝑑 𝑏1:
I:
𝜕𝑠
𝜕𝑏0
= -2 𝑖=1
𝑛
𝑦𝑖 − 𝑏0 − 𝑏1 𝑥𝑖 = 0
𝑏0= 𝑖=1
𝑛
𝑦𝑖 − 𝑏1 𝑥𝑖
𝑏0= 𝑦- 𝑏1 𝑥
08-02-2017
13
Where 𝑦 =
𝑦𝑖
𝑛
𝑥 =
𝑥𝑖
𝑛
S= 𝑖=1
𝑛
𝑦𝑖 − 𝑏0 − 𝑏1 𝑥𝑖
2
14
II:
𝜕𝑠
𝜕𝑏1
= -2 𝑖=1
𝑛
𝑦𝑖 − 𝑏0 − 𝑏1 𝑥𝑖 𝑥𝑖 = 0
𝑖=1
𝑛
𝑥𝑖 𝑦𝑖 − 𝑏0 − 𝑏1 𝑥𝑖 = 0
𝑖=1
𝑛
𝑥𝑖 𝑦𝑖 − 𝑦+ 𝑏1 𝑥 − 𝑏1 𝑥𝑖 = 0
𝑖=1
𝑛
𝑥𝑖(𝑦𝑖 − 𝑦) = 𝑏1 𝑖=1
𝑛
(xi− 𝑥) 𝑥𝑖
𝑏1 = 𝑖=1
𝑛
(𝑦𝑖− 𝑦) 𝑥𝑖
𝑖=1
𝑛 (𝑥𝑖
− 𝑥) 𝑥𝑖
𝑏1 = 𝑖=1
𝑛
(𝑦𝑖− 𝑦)( 𝑥𝑖
− 𝑥)
𝑖=1
𝑛 (𝑥𝑖− 𝑥)2
𝑏1 =
𝐶𝑜𝑣(𝑥,𝑦)
𝑉𝑎𝑟(𝑥)
= 𝑋′
𝑋
−1 𝑋′
𝑦
Proof:
= 𝑖=1
𝑛
(𝑦𝑖 − 𝑦) 𝑥
= 𝑥 𝑦𝑖 − 𝑥 𝑦
=𝑛𝑥 𝑦 − 𝑛𝑥 𝑦
=0
𝑏0= 𝑦- 𝑏1 𝑥 ; 𝑏1 = 𝑖=1
𝑛
(𝑦𝑖− 𝑦)( 𝑥𝑖
− 𝑥)
𝑖=1
𝑛 (𝑥𝑖− 𝑥)2
08-02-2017
08-02-2017
15
Example
𝑏1 = 𝑖=1
𝑛
(𝑦𝑖− 𝑦)( 𝑥𝑖
− 𝑥)
𝑖=1
𝑛 (𝑥𝑖− 𝑥)2 =
6
10
= 0.6
𝑏0 = 𝑦- 𝑏1 𝑥 = 2.2
08-02-2017
16
Calculating R2 Using Regression Analysis
 R-squared is a statistical measure of how close the data are to the fitted regression line(For measuring the
goodness of fit ). It is also known as the coefficient of determination.
 Firstly we calculate distance between actual values and mean value and also calculate distance between estimated
value and mean value.
 Then compare both the distances.
08-02-2017
17
Example
18
Performance of Model
08-02-2017
The standard error of the estimate is a measure of the accuracy of predictions.
Note: The regression line is the line that minimizes the sum of squared deviations of prediction
(also called the sum of squares error).
The standard error of the estimate is closely related to this quantity and is defined below:
Where Y = actual value
Y’= Estimated Value
N = No. of observations
Standard error of the Estimate (Mean square error)
08-02-2017
19
X Y Y' Y-Y' (Y-Y')2
1.00 1.00 1.210 -0.210 0.044
2.00 2.00 1.635 0.365 0.133
3.00 1.30 2.060 -0.760 0.578
4.00 3.75 2.485 1.265 1.600
5.00 2.25 2.910 -0.660 0.436
Sum 15.00 10.30 10.30 0.000 2.791
Example
08-02-2017
20
08-02-2017
21
Difference
Solve : Ax=b
The columns of A define a vector space range(A).
2a
1a
Ax 2211 aa xx
Ax is an arbitrary vector in range(A).
b is a vector in Rn and also in the column space of A so this has a solution.
b
08-02-2017
22
Least Square for Linear Regression
The columns of A define a vector space range(A).
2a
1a
Ax 2211 aa xx
Ax is an arbitrary vector in range(A).
b is a vector in Rn but not in the column space of A then it doesn’t has a solution.
b
Try to find out 𝒙 that makes A𝒙 as close to 𝒃 as possible and this is called least square solution of
our problem.
xAb ˆ
08-02-2017
23
08-02-2017
24
b
2a
1a
xA ˆ
xAb ˆ
A 𝑥 is the orthogonal projection of b onto range(A)
  bAxAAxAbA TTT
 ˆˆ 0
25
26
Matlab Implementation (Linear_Regression3.m)
27
Matlab Implementation (Linear_Regression3.m)
[1] Sykes, Alan O. "An introduction to regression analysis." (1993).
[2] Chatterjee, Samprit, and Ali S. Hadi. Regression analysis by example. John Wiley & Sons,
2015.
[3] Draper, Norman Richard, Harry Smith, and Elizabeth Pownell. Applied regression analysis.
Vol. 3. New York: Wiley, 1966.
[4] Montgomery, Douglas C., Elizabeth A. Peck, and G. Geoffrey Vining. Introduction to linear
regression analysis. John Wiley & Sons, 2015.
[5] Seber, George AF, and Alan J. Lee. Linear regression analysis. Vol. 936. John Wiley & Sons,
2012.
08-02-2017
28
Reference
THANK YOU
08-02-2017
29
Ad

More Related Content

What's hot (20)

Regression Analysis
Regression AnalysisRegression Analysis
Regression Analysis
Salim Azad
 
Regression analysis
Regression analysisRegression analysis
Regression analysis
Ravi shankar
 
Regression analysis.
Regression analysis.Regression analysis.
Regression analysis.
sonia gupta
 
Multiple linear regression
Multiple linear regressionMultiple linear regression
Multiple linear regression
James Neill
 
Statistics-Regression analysis
Statistics-Regression analysisStatistics-Regression analysis
Statistics-Regression analysis
Rabin BK
 
Simple linear regression
Simple linear regressionSimple linear regression
Simple linear regression
Avjinder (Avi) Kaler
 
Linear regression
Linear regressionLinear regression
Linear regression
vermaumeshverma
 
Regression
RegressionRegression
Regression
ICFAI Business School
 
Presentation On Regression
Presentation On RegressionPresentation On Regression
Presentation On Regression
alok tiwari
 
Regression Analysis
Regression AnalysisRegression Analysis
Regression Analysis
Shiela Vinarao
 
Regression analysis
Regression analysisRegression analysis
Regression analysis
Shameer P Hamsa
 
Multiple Regression Analysis (MRA)
Multiple Regression Analysis (MRA)Multiple Regression Analysis (MRA)
Multiple Regression Analysis (MRA)
Naveen Kumar Medapalli
 
Multiple regression
Multiple regressionMultiple regression
Multiple regression
Venkata Reddy Konasani
 
Regression analysis
Regression analysisRegression analysis
Regression analysis
Sohag Babu
 
Simple & Multiple Regression Analysis
Simple & Multiple Regression AnalysisSimple & Multiple Regression Analysis
Simple & Multiple Regression Analysis
Shailendra Tomar
 
Non Linear Equation
Non Linear EquationNon Linear Equation
Non Linear Equation
MdAlAmin187
 
Linear regression
Linear regressionLinear regression
Linear regression
Tech_MX
 
Regression analysis ppt
Regression analysis pptRegression analysis ppt
Regression analysis ppt
Elkana Rorio
 
Regression analysis in R
Regression analysis in RRegression analysis in R
Regression analysis in R
Alichy Sowmya
 
Regression analysis
Regression analysisRegression analysis
Regression analysis
Srikant001p
 
Regression Analysis
Regression AnalysisRegression Analysis
Regression Analysis
Salim Azad
 
Regression analysis
Regression analysisRegression analysis
Regression analysis
Ravi shankar
 
Regression analysis.
Regression analysis.Regression analysis.
Regression analysis.
sonia gupta
 
Multiple linear regression
Multiple linear regressionMultiple linear regression
Multiple linear regression
James Neill
 
Statistics-Regression analysis
Statistics-Regression analysisStatistics-Regression analysis
Statistics-Regression analysis
Rabin BK
 
Presentation On Regression
Presentation On RegressionPresentation On Regression
Presentation On Regression
alok tiwari
 
Regression analysis
Regression analysisRegression analysis
Regression analysis
Sohag Babu
 
Simple & Multiple Regression Analysis
Simple & Multiple Regression AnalysisSimple & Multiple Regression Analysis
Simple & Multiple Regression Analysis
Shailendra Tomar
 
Non Linear Equation
Non Linear EquationNon Linear Equation
Non Linear Equation
MdAlAmin187
 
Linear regression
Linear regressionLinear regression
Linear regression
Tech_MX
 
Regression analysis ppt
Regression analysis pptRegression analysis ppt
Regression analysis ppt
Elkana Rorio
 
Regression analysis in R
Regression analysis in RRegression analysis in R
Regression analysis in R
Alichy Sowmya
 
Regression analysis
Regression analysisRegression analysis
Regression analysis
Srikant001p
 

Viewers also liked (19)

Regression Analysis
Regression AnalysisRegression Analysis
Regression Analysis
nadiazaheer
 
Simple linear regression
Simple linear regressionSimple linear regression
Simple linear regression
Maria Theresa
 
Simple Linear Regression (simplified)
Simple Linear Regression (simplified)Simple Linear Regression (simplified)
Simple Linear Regression (simplified)
Haoran Zhang
 
Simple linear regression (final)
Simple linear regression (final)Simple linear regression (final)
Simple linear regression (final)
Harsh Upadhyay
 
Correlation and Simple Regression
Correlation  and Simple RegressionCorrelation  and Simple Regression
Correlation and Simple Regression
Venkata Reddy Konasani
 
Regression analysis
Regression analysisRegression analysis
Regression analysis
Dr.ammara khakwani
 
Introduction to correlation and regression analysis
Introduction to correlation and regression analysisIntroduction to correlation and regression analysis
Introduction to correlation and regression analysis
Farzad Javidanrad
 
C2.1 intro
C2.1 introC2.1 intro
C2.1 intro
Daniel LIAO
 
Chapter13
Chapter13Chapter13
Chapter13
Richard Ferreria
 
Simple linear regression analysis
Simple linear  regression analysisSimple linear  regression analysis
Simple linear regression analysis
Norma Mingo
 
Time series
Time seriesTime series
Time series
Haitham Ahmed
 
Timeseries forecasting
Timeseries forecastingTimeseries forecasting
Timeseries forecasting
Venkata Reddy Konasani
 
Simple Linier Regression
Simple Linier RegressionSimple Linier Regression
Simple Linier Regression
dessybudiyanti
 
Regression
RegressionRegression
Regression
mandrewmartin
 
Simple (and Simplistic) Introduction to Econometrics and Linear Regression
Simple (and Simplistic) Introduction to Econometrics and Linear RegressionSimple (and Simplistic) Introduction to Econometrics and Linear Regression
Simple (and Simplistic) Introduction to Econometrics and Linear Regression
Philip Tiongson
 
Lesson 8 Linear Correlation And Regression
Lesson 8 Linear Correlation And RegressionLesson 8 Linear Correlation And Regression
Lesson 8 Linear Correlation And Regression
Sumit Prajapati
 
time series analysis
time series analysistime series analysis
time series analysis
SACHIN AWASTHI
 
Correlation and regression
Correlation and regressionCorrelation and regression
Correlation and regression
Khalid Aziz
 
Data Science - Part IV - Regression Analysis & ANOVA
Data Science - Part IV - Regression Analysis & ANOVAData Science - Part IV - Regression Analysis & ANOVA
Data Science - Part IV - Regression Analysis & ANOVA
Derek Kane
 
Regression Analysis
Regression AnalysisRegression Analysis
Regression Analysis
nadiazaheer
 
Simple linear regression
Simple linear regressionSimple linear regression
Simple linear regression
Maria Theresa
 
Simple Linear Regression (simplified)
Simple Linear Regression (simplified)Simple Linear Regression (simplified)
Simple Linear Regression (simplified)
Haoran Zhang
 
Simple linear regression (final)
Simple linear regression (final)Simple linear regression (final)
Simple linear regression (final)
Harsh Upadhyay
 
Introduction to correlation and regression analysis
Introduction to correlation and regression analysisIntroduction to correlation and regression analysis
Introduction to correlation and regression analysis
Farzad Javidanrad
 
Simple linear regression analysis
Simple linear  regression analysisSimple linear  regression analysis
Simple linear regression analysis
Norma Mingo
 
Simple Linier Regression
Simple Linier RegressionSimple Linier Regression
Simple Linier Regression
dessybudiyanti
 
Simple (and Simplistic) Introduction to Econometrics and Linear Regression
Simple (and Simplistic) Introduction to Econometrics and Linear RegressionSimple (and Simplistic) Introduction to Econometrics and Linear Regression
Simple (and Simplistic) Introduction to Econometrics and Linear Regression
Philip Tiongson
 
Lesson 8 Linear Correlation And Regression
Lesson 8 Linear Correlation And RegressionLesson 8 Linear Correlation And Regression
Lesson 8 Linear Correlation And Regression
Sumit Prajapati
 
Correlation and regression
Correlation and regressionCorrelation and regression
Correlation and regression
Khalid Aziz
 
Data Science - Part IV - Regression Analysis & ANOVA
Data Science - Part IV - Regression Analysis & ANOVAData Science - Part IV - Regression Analysis & ANOVA
Data Science - Part IV - Regression Analysis & ANOVA
Derek Kane
 
Ad

Similar to Basics of Regression analysis (20)

Regression Analysis.pptx
Regression Analysis.pptxRegression Analysis.pptx
Regression Analysis.pptx
MdRokonMia1
 
Nonparametric approach to multiple regression
Nonparametric approach to multiple regressionNonparametric approach to multiple regression
Nonparametric approach to multiple regression
Alexander Decker
 
Curve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods RegressionCurve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods Regression
Nada Hikmah
 
Regression
RegressionRegression
Regression
Long Beach City College
 
An econometric model for Linear Regression using Statistics
An econometric model for Linear Regression using StatisticsAn econometric model for Linear Regression using Statistics
An econometric model for Linear Regression using Statistics
IRJET Journal
 
Regression analysis: Simple Linear Regression Multiple Linear Regression
Regression analysis:  Simple Linear Regression Multiple Linear RegressionRegression analysis:  Simple Linear Regression Multiple Linear Regression
Regression analysis: Simple Linear Regression Multiple Linear Regression
Ravindra Nath Shukla
 
一比一原版(Otago毕业证书)新西兰奥塔哥大学毕业证成绩单
一比一原版(Otago毕业证书)新西兰奥塔哥大学毕业证成绩单一比一原版(Otago毕业证书)新西兰奥塔哥大学毕业证成绩单
一比一原版(Otago毕业证书)新西兰奥塔哥大学毕业证成绩单
ynlsmv4ja
 
一比一原版(RoyalVeterinary毕业证书)皇家兽医学院毕业证成绩单
一比一原版(RoyalVeterinary毕业证书)皇家兽医学院毕业证成绩单一比一原版(RoyalVeterinary毕业证书)皇家兽医学院毕业证成绩单
一比一原版(RoyalVeterinary毕业证书)皇家兽医学院毕业证成绩单
ynlsmv4ja
 
一比一原版(UCD毕业证书)爱尔兰都柏林大学毕业证成绩单
一比一原版(UCD毕业证书)爱尔兰都柏林大学毕业证成绩单一比一原版(UCD毕业证书)爱尔兰都柏林大学毕业证成绩单
一比一原版(UCD毕业证书)爱尔兰都柏林大学毕业证成绩单
ynlsmv4ja
 
一比一原版(UM毕业证书)马来亚大学毕业证成绩单
一比一原版(UM毕业证书)马来亚大学毕业证成绩单一比一原版(UM毕业证书)马来亚大学毕业证成绩单
一比一原版(UM毕业证书)马来亚大学毕业证成绩单
ynlsmv4ja
 
一比一原版(UPM毕业证书)马来西亚博特拉大学毕业证成绩单
一比一原版(UPM毕业证书)马来西亚博特拉大学毕业证成绩单一比一原版(UPM毕业证书)马来西亚博特拉大学毕业证成绩单
一比一原版(UPM毕业证书)马来西亚博特拉大学毕业证成绩单
ynlsmv4ja
 
一比一原版(KHU毕业证书)韩国庆熙大学毕业证成绩单
一比一原版(KHU毕业证书)韩国庆熙大学毕业证成绩单一比一原版(KHU毕业证书)韩国庆熙大学毕业证成绩单
一比一原版(KHU毕业证书)韩国庆熙大学毕业证成绩单
ynlsmv4ja
 
一比一原版(TheAuckland毕业证书)新西兰奥克兰大学毕业证成绩单
一比一原版(TheAuckland毕业证书)新西兰奥克兰大学毕业证成绩单一比一原版(TheAuckland毕业证书)新西兰奥克兰大学毕业证成绩单
一比一原版(TheAuckland毕业证书)新西兰奥克兰大学毕业证成绩单
ynlsmv4ja
 
一比一原版(SEGi毕业证书)马来西亚世纪大学毕业证成绩单
一比一原版(SEGi毕业证书)马来西亚世纪大学毕业证成绩单一比一原版(SEGi毕业证书)马来西亚世纪大学毕业证成绩单
一比一原版(SEGi毕业证书)马来西亚世纪大学毕业证成绩单
ynlsmv4ja
 
Linear regression: introduction and method
Linear regression: introduction and methodLinear regression: introduction and method
Linear regression: introduction and method
ThomasWong104635
 
Bba 3274 qm week 6 part 1 regression models
Bba 3274 qm week 6 part 1 regression modelsBba 3274 qm week 6 part 1 regression models
Bba 3274 qm week 6 part 1 regression models
Stephen Ong
 
Simple Linear Regression
Simple Linear RegressionSimple Linear Regression
Simple Linear Regression
Sindhu Rumesh Kumar
 
Regression
Regression Regression
Regression
Ali Raza
 
Regression Analysis.pptx
Regression Analysis.pptxRegression Analysis.pptx
Regression Analysis.pptx
ShivankAggatwal
 
simple linear regression - brief introduction
simple linear regression - brief introductionsimple linear regression - brief introduction
simple linear regression - brief introduction
edinyoka
 
Regression Analysis.pptx
Regression Analysis.pptxRegression Analysis.pptx
Regression Analysis.pptx
MdRokonMia1
 
Nonparametric approach to multiple regression
Nonparametric approach to multiple regressionNonparametric approach to multiple regression
Nonparametric approach to multiple regression
Alexander Decker
 
Curve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods RegressionCurve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods Regression
Nada Hikmah
 
An econometric model for Linear Regression using Statistics
An econometric model for Linear Regression using StatisticsAn econometric model for Linear Regression using Statistics
An econometric model for Linear Regression using Statistics
IRJET Journal
 
Regression analysis: Simple Linear Regression Multiple Linear Regression
Regression analysis:  Simple Linear Regression Multiple Linear RegressionRegression analysis:  Simple Linear Regression Multiple Linear Regression
Regression analysis: Simple Linear Regression Multiple Linear Regression
Ravindra Nath Shukla
 
一比一原版(Otago毕业证书)新西兰奥塔哥大学毕业证成绩单
一比一原版(Otago毕业证书)新西兰奥塔哥大学毕业证成绩单一比一原版(Otago毕业证书)新西兰奥塔哥大学毕业证成绩单
一比一原版(Otago毕业证书)新西兰奥塔哥大学毕业证成绩单
ynlsmv4ja
 
一比一原版(RoyalVeterinary毕业证书)皇家兽医学院毕业证成绩单
一比一原版(RoyalVeterinary毕业证书)皇家兽医学院毕业证成绩单一比一原版(RoyalVeterinary毕业证书)皇家兽医学院毕业证成绩单
一比一原版(RoyalVeterinary毕业证书)皇家兽医学院毕业证成绩单
ynlsmv4ja
 
一比一原版(UCD毕业证书)爱尔兰都柏林大学毕业证成绩单
一比一原版(UCD毕业证书)爱尔兰都柏林大学毕业证成绩单一比一原版(UCD毕业证书)爱尔兰都柏林大学毕业证成绩单
一比一原版(UCD毕业证书)爱尔兰都柏林大学毕业证成绩单
ynlsmv4ja
 
一比一原版(UM毕业证书)马来亚大学毕业证成绩单
一比一原版(UM毕业证书)马来亚大学毕业证成绩单一比一原版(UM毕业证书)马来亚大学毕业证成绩单
一比一原版(UM毕业证书)马来亚大学毕业证成绩单
ynlsmv4ja
 
一比一原版(UPM毕业证书)马来西亚博特拉大学毕业证成绩单
一比一原版(UPM毕业证书)马来西亚博特拉大学毕业证成绩单一比一原版(UPM毕业证书)马来西亚博特拉大学毕业证成绩单
一比一原版(UPM毕业证书)马来西亚博特拉大学毕业证成绩单
ynlsmv4ja
 
一比一原版(KHU毕业证书)韩国庆熙大学毕业证成绩单
一比一原版(KHU毕业证书)韩国庆熙大学毕业证成绩单一比一原版(KHU毕业证书)韩国庆熙大学毕业证成绩单
一比一原版(KHU毕业证书)韩国庆熙大学毕业证成绩单
ynlsmv4ja
 
一比一原版(TheAuckland毕业证书)新西兰奥克兰大学毕业证成绩单
一比一原版(TheAuckland毕业证书)新西兰奥克兰大学毕业证成绩单一比一原版(TheAuckland毕业证书)新西兰奥克兰大学毕业证成绩单
一比一原版(TheAuckland毕业证书)新西兰奥克兰大学毕业证成绩单
ynlsmv4ja
 
一比一原版(SEGi毕业证书)马来西亚世纪大学毕业证成绩单
一比一原版(SEGi毕业证书)马来西亚世纪大学毕业证成绩单一比一原版(SEGi毕业证书)马来西亚世纪大学毕业证成绩单
一比一原版(SEGi毕业证书)马来西亚世纪大学毕业证成绩单
ynlsmv4ja
 
Linear regression: introduction and method
Linear regression: introduction and methodLinear regression: introduction and method
Linear regression: introduction and method
ThomasWong104635
 
Bba 3274 qm week 6 part 1 regression models
Bba 3274 qm week 6 part 1 regression modelsBba 3274 qm week 6 part 1 regression models
Bba 3274 qm week 6 part 1 regression models
Stephen Ong
 
Regression
Regression Regression
Regression
Ali Raza
 
Regression Analysis.pptx
Regression Analysis.pptxRegression Analysis.pptx
Regression Analysis.pptx
ShivankAggatwal
 
simple linear regression - brief introduction
simple linear regression - brief introductionsimple linear regression - brief introduction
simple linear regression - brief introduction
edinyoka
 
Ad

Recently uploaded (20)

ELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdfELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdf
Shiju Jacob
 
railway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forgingrailway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forging
Javad Kadkhodapour
 
Fort night presentation new0903 pdf.pdf.
Fort night presentation new0903 pdf.pdf.Fort night presentation new0903 pdf.pdf.
Fort night presentation new0903 pdf.pdf.
anuragmk56
 
introduction to machine learining for beginers
introduction to machine learining for beginersintroduction to machine learining for beginers
introduction to machine learining for beginers
JoydebSheet
 
Oil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdfOil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdf
M7md3li2
 
DSP and MV the Color image processing.ppt
DSP and MV the  Color image processing.pptDSP and MV the  Color image processing.ppt
DSP and MV the Color image processing.ppt
HafizAhamed8
 
211421893-M-Tech-CIVIL-Structural-Engineering-pdf.pdf
211421893-M-Tech-CIVIL-Structural-Engineering-pdf.pdf211421893-M-Tech-CIVIL-Structural-Engineering-pdf.pdf
211421893-M-Tech-CIVIL-Structural-Engineering-pdf.pdf
inmishra17121973
 
Avnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights FlyerAvnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights Flyer
WillDavies22
 
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdfRICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
MohamedAbdelkader115
 
QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)
rccbatchplant
 
new ppt artificial intelligence historyyy
new ppt artificial intelligence historyyynew ppt artificial intelligence historyyy
new ppt artificial intelligence historyyy
PianoPianist
 
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
charlesdick1345
 
Smart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptxSmart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptx
rushikeshnavghare94
 
Level 1-Safety.pptx Presentation of Electrical Safety
Level 1-Safety.pptx Presentation of Electrical SafetyLevel 1-Safety.pptx Presentation of Electrical Safety
Level 1-Safety.pptx Presentation of Electrical Safety
JoseAlbertoCariasDel
 
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdfMAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
ssuser562df4
 
Compiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptxCompiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptx
RushaliDeshmukh2
 
The Gaussian Process Modeling Module in UQLab
The Gaussian Process Modeling Module in UQLabThe Gaussian Process Modeling Module in UQLab
The Gaussian Process Modeling Module in UQLab
Journal of Soft Computing in Civil Engineering
 
Machine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptxMachine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptx
rajeswari89780
 
theory-slides-for react for beginners.pptx
theory-slides-for react for beginners.pptxtheory-slides-for react for beginners.pptx
theory-slides-for react for beginners.pptx
sanchezvanessa7896
 
Raish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdfRaish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdf
RaishKhanji
 
ELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdfELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdf
Shiju Jacob
 
railway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forgingrailway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forging
Javad Kadkhodapour
 
Fort night presentation new0903 pdf.pdf.
Fort night presentation new0903 pdf.pdf.Fort night presentation new0903 pdf.pdf.
Fort night presentation new0903 pdf.pdf.
anuragmk56
 
introduction to machine learining for beginers
introduction to machine learining for beginersintroduction to machine learining for beginers
introduction to machine learining for beginers
JoydebSheet
 
Oil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdfOil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdf
M7md3li2
 
DSP and MV the Color image processing.ppt
DSP and MV the  Color image processing.pptDSP and MV the  Color image processing.ppt
DSP and MV the Color image processing.ppt
HafizAhamed8
 
211421893-M-Tech-CIVIL-Structural-Engineering-pdf.pdf
211421893-M-Tech-CIVIL-Structural-Engineering-pdf.pdf211421893-M-Tech-CIVIL-Structural-Engineering-pdf.pdf
211421893-M-Tech-CIVIL-Structural-Engineering-pdf.pdf
inmishra17121973
 
Avnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights FlyerAvnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights Flyer
WillDavies22
 
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdfRICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
MohamedAbdelkader115
 
QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)
rccbatchplant
 
new ppt artificial intelligence historyyy
new ppt artificial intelligence historyyynew ppt artificial intelligence historyyy
new ppt artificial intelligence historyyy
PianoPianist
 
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
charlesdick1345
 
Smart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptxSmart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptx
rushikeshnavghare94
 
Level 1-Safety.pptx Presentation of Electrical Safety
Level 1-Safety.pptx Presentation of Electrical SafetyLevel 1-Safety.pptx Presentation of Electrical Safety
Level 1-Safety.pptx Presentation of Electrical Safety
JoseAlbertoCariasDel
 
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdfMAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
ssuser562df4
 
Compiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptxCompiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptx
RushaliDeshmukh2
 
Machine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptxMachine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptx
rajeswari89780
 
theory-slides-for react for beginners.pptx
theory-slides-for react for beginners.pptxtheory-slides-for react for beginners.pptx
theory-slides-for react for beginners.pptx
sanchezvanessa7896
 
Raish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdfRaish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdf
RaishKhanji
 

Basics of Regression analysis

  • 1. Basics of Regression Analysis Presented By Mahak Vijay 08-02-2017 1
  • 2. •What is Regression Analysis? •Population Regression Line •Why do we use Regression Analysis? •What are the types of Regression? •Simple Linear Regression Model •Least Square Estimation for parameters •Least Square for Linear Regression •References 08-02-2017 2 Outlines
  • 3.  Regression analysis is a form of predictive modelling technique which investigates the relationship between a dependent (target) and independent variable(s) (predictor).  This technique is used for forecasting, time series modelling and finding the causal effect relationship between the variables.  For example, relationship between rash driving and number of road accidents by a driver is best studied through regression. 08-02-2017 3 What is Regression Analysis?
  • 5. Study Time EstimatedGrades Population regression function = 𝑦 = 𝑏0+𝑏1x 𝑦 = Estimated Grades x = Study Time 𝑏0= Intercept 𝑏1= Slope Example 08-02-2017 5 Population Regression Line 𝑏0= Intercept 𝑏1= Slope Regression Line
  • 6. Typically, a regression analysis is used for these purposes: (1) Prediction of the target variable (forecasting). (2) Modelling the relationships between the dependent variable and the explanatory variable. (3) Testing of hypotheses. Benefits 1. It indicates the strength of impact of multiple independent variables on a dependent variable. 2. It indicates the significant relationships between dependent variable and independent variable. These benefits help market researchers / data analysts / data scientists to eliminate and evaluate the best set of variables to be used for building predictive models. 08-02-2017 6 Why we need Regression Analysis?
  • 7. Types of regression analysis: Regression analysis is generally classified into two kinds: simple and multiple. Simple Regression: It involves only two variables: dependent variable , explanatory (independent) variable. A regression analysis may involve a linear model or a nonlinear model. The term linear can be interpreted in two different ways: 1. Linear in variable 2. Linearity in the parameter Regression Analysis Simple Multiple Linear Non Linear 1 Explanatory variable 2+ Explanatory variable 08-02-2017 7 Types of Regression Analysis
  • 8. Simple linear regression model is a model with a single regressor x that has a linear relationship with a response y. Simple linear regression model: y = 𝑏0+𝑏1x + ɛ Response variable Regressor variable Intercept Slope Random error component In this technique, the dependent variable is continuous and random variable, independent variable(s) can be continuous or discrete but it is not a random variable, and nature of regression line is linear. 08-02-2017 8 Simple Linear Regression Model
  • 9. Some basic assumption on the model: Simple linear regression model: yi= 𝑏0+𝑏1xi + ɛi for i=(1,2….n)  ɛi is a random variable with zero mean and variance σ2,i.e.  ɛi and ɛj are uncorrelated for i ≠ j, i.e.  ɛi is a normally distributed random variable with mean zero and variance σ2. Ɛi ~𝑖𝑛𝑑 N (0, σ2). E(ɛi )=0 ; V(ɛi )= σ2 cov(ɛi , ɛj )=0 08-02-2017 9
  • 10. yi= 𝑏0+𝑏1xi + ɛi for i=(1,2….n) E(yi) = 𝐸(𝑏0+𝑏1xi + ɛi)= 𝑏0+𝑏1xi V(yi) = 𝑉(𝑏0+𝑏1xi + ɛi)=V(ɛi )=σ2. => Ɛi ~𝒊𝒏𝒅 N (0, σ2) => Yi ~𝒊𝒏𝒅 N (𝒃 𝟎+𝒃 𝟏xi , σ2) 08-02-2017 10 NOTE : The dataset should satisfy the basic assumption. E(ɛi )=0
  • 11. The parameters 𝑏0 and 𝑏1are unknown and must be estimates using sample data: (𝑥1,𝑦1), (𝑥2,𝑦2),……(𝑥 𝑛,𝑦𝑛) x y 𝑦 = 𝑏0+𝑏1x + ɛ x y 08-02-2017 11 Least Square Estimation for Parameters 𝑦𝑖 = 𝑏0+ 𝑏1xi + ɛi
  • 12. The line fitted by least square is the one that makes the sum of squares of all vertical discrepancies as small as possible. x y We estimate the parameters so that sum of squares of all the vertical difference between the observation and fitted line is minimum. S= 𝑖=1 𝑛 𝑦𝑖 − 𝑏0 − 𝑏1 𝑥𝑖 2 (x1,y1) (x1, 𝑦1) (y1- 𝑦1)= ɛ1 08-02-2017 12 𝑦𝑖 = 𝑏0+ 𝑏1xi + ɛi
  • 13. Minimizing the function requires to calculate the first order condition with respect to alpha and beta and set them zero: I: 𝜕𝑠 𝜕𝑏0 = -2 𝑖=1 𝑛 𝑦𝑖 − 𝑏0 − 𝑏1 𝑥𝑖 = 0 II: 𝜕𝑠 𝜕𝑏1 = -2 𝑖=1 𝑛 𝑦𝑖 − 𝑏0 − 𝑏1 𝑥𝑖 𝑥𝑖 = 0 We can mathematically solve for 𝑏0 𝑎𝑛𝑑 𝑏1: I: 𝜕𝑠 𝜕𝑏0 = -2 𝑖=1 𝑛 𝑦𝑖 − 𝑏0 − 𝑏1 𝑥𝑖 = 0 𝑏0= 𝑖=1 𝑛 𝑦𝑖 − 𝑏1 𝑥𝑖 𝑏0= 𝑦- 𝑏1 𝑥 08-02-2017 13 Where 𝑦 = 𝑦𝑖 𝑛 𝑥 = 𝑥𝑖 𝑛 S= 𝑖=1 𝑛 𝑦𝑖 − 𝑏0 − 𝑏1 𝑥𝑖 2
  • 14. 14 II: 𝜕𝑠 𝜕𝑏1 = -2 𝑖=1 𝑛 𝑦𝑖 − 𝑏0 − 𝑏1 𝑥𝑖 𝑥𝑖 = 0 𝑖=1 𝑛 𝑥𝑖 𝑦𝑖 − 𝑏0 − 𝑏1 𝑥𝑖 = 0 𝑖=1 𝑛 𝑥𝑖 𝑦𝑖 − 𝑦+ 𝑏1 𝑥 − 𝑏1 𝑥𝑖 = 0 𝑖=1 𝑛 𝑥𝑖(𝑦𝑖 − 𝑦) = 𝑏1 𝑖=1 𝑛 (xi− 𝑥) 𝑥𝑖 𝑏1 = 𝑖=1 𝑛 (𝑦𝑖− 𝑦) 𝑥𝑖 𝑖=1 𝑛 (𝑥𝑖 − 𝑥) 𝑥𝑖 𝑏1 = 𝑖=1 𝑛 (𝑦𝑖− 𝑦)( 𝑥𝑖 − 𝑥) 𝑖=1 𝑛 (𝑥𝑖− 𝑥)2 𝑏1 = 𝐶𝑜𝑣(𝑥,𝑦) 𝑉𝑎𝑟(𝑥) = 𝑋′ 𝑋 −1 𝑋′ 𝑦 Proof: = 𝑖=1 𝑛 (𝑦𝑖 − 𝑦) 𝑥 = 𝑥 𝑦𝑖 − 𝑥 𝑦 =𝑛𝑥 𝑦 − 𝑛𝑥 𝑦 =0 𝑏0= 𝑦- 𝑏1 𝑥 ; 𝑏1 = 𝑖=1 𝑛 (𝑦𝑖− 𝑦)( 𝑥𝑖 − 𝑥) 𝑖=1 𝑛 (𝑥𝑖− 𝑥)2 08-02-2017
  • 15. 08-02-2017 15 Example 𝑏1 = 𝑖=1 𝑛 (𝑦𝑖− 𝑦)( 𝑥𝑖 − 𝑥) 𝑖=1 𝑛 (𝑥𝑖− 𝑥)2 = 6 10 = 0.6 𝑏0 = 𝑦- 𝑏1 𝑥 = 2.2
  • 16. 08-02-2017 16 Calculating R2 Using Regression Analysis  R-squared is a statistical measure of how close the data are to the fitted regression line(For measuring the goodness of fit ). It is also known as the coefficient of determination.  Firstly we calculate distance between actual values and mean value and also calculate distance between estimated value and mean value.  Then compare both the distances.
  • 19. The standard error of the estimate is a measure of the accuracy of predictions. Note: The regression line is the line that minimizes the sum of squared deviations of prediction (also called the sum of squares error). The standard error of the estimate is closely related to this quantity and is defined below: Where Y = actual value Y’= Estimated Value N = No. of observations Standard error of the Estimate (Mean square error) 08-02-2017 19
  • 20. X Y Y' Y-Y' (Y-Y')2 1.00 1.00 1.210 -0.210 0.044 2.00 2.00 1.635 0.365 0.133 3.00 1.30 2.060 -0.760 0.578 4.00 3.75 2.485 1.265 1.600 5.00 2.25 2.910 -0.660 0.436 Sum 15.00 10.30 10.30 0.000 2.791 Example 08-02-2017 20
  • 22. Solve : Ax=b The columns of A define a vector space range(A). 2a 1a Ax 2211 aa xx Ax is an arbitrary vector in range(A). b is a vector in Rn and also in the column space of A so this has a solution. b 08-02-2017 22 Least Square for Linear Regression
  • 23. The columns of A define a vector space range(A). 2a 1a Ax 2211 aa xx Ax is an arbitrary vector in range(A). b is a vector in Rn but not in the column space of A then it doesn’t has a solution. b Try to find out 𝒙 that makes A𝒙 as close to 𝒃 as possible and this is called least square solution of our problem. xAb ˆ 08-02-2017 23
  • 24. 08-02-2017 24 b 2a 1a xA ˆ xAb ˆ A 𝑥 is the orthogonal projection of b onto range(A)   bAxAAxAbA TTT  ˆˆ 0
  • 25. 25
  • 28. [1] Sykes, Alan O. "An introduction to regression analysis." (1993). [2] Chatterjee, Samprit, and Ali S. Hadi. Regression analysis by example. John Wiley & Sons, 2015. [3] Draper, Norman Richard, Harry Smith, and Elizabeth Pownell. Applied regression analysis. Vol. 3. New York: Wiley, 1966. [4] Montgomery, Douglas C., Elizabeth A. Peck, and G. Geoffrey Vining. Introduction to linear regression analysis. John Wiley & Sons, 2015. [5] Seber, George AF, and Alan J. Lee. Linear regression analysis. Vol. 936. John Wiley & Sons, 2012. 08-02-2017 28 Reference

Editor's Notes

  • #4: The dependent variable is variously known as explained variables, predictand, response and endogenous variables. While the independent variable is known as explanatory, regressor and exogenous variable.
  • #27: load accidents x = hwydata(:,14); %Population of states y = hwydata(:,4); %Accidents per state format long b1 = x\y; yCalc1 = b1*x; scatter(x,y) hold on plot(x,yCalc1) xlabel('Population of state') ylabel('Fatal traffic accidents per state') title('Linear Regression Relation Between Accidents & Population') grid on X = [ones(length(x),1) x]; b = X\y; yCalc2 = X*b; plot(x,yCalc2,'--') legend('Data','Slope','Slope & Intercept','Location','best'); Rsq1 = 1 - sum((y - yCalc1).^2)/sum((y - mean(y)).^2); Rsq2 = 1 - sum((y - yCalc2).^2)/sum((y - mean(y)).^2);