SlideShare a Scribd company logo
Data Approximation in Mathematical
Modelling: Regression Analysis and
Curve Fitting
DR. SUMMIYA PARVEEN
Department of Mathematics
COLLEGE OF ENGINEERING ROORKE (COER)
ROORKEE
summiyaparveen82@gmail.com
Dr. Summiya Parveen 1
Outline of the lecture:
Introduction of Regression
Application of Regression
Regression Techniques
Types of Regression
Goodness of fit
MATLAB/MATHEMATICA
implementation with some example
Dr. Summiya Parveen 2
Regression
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 casual effect
relationship between the variables.
Regression analysis is an important tool for modelling and analysing data. Here, we fit a
curve / line to the data points in such a manner that the differences between the distances of
data points from the curve or line is minimized.
Independent variable (x)
Dependentvariable(y)
Year Research &
development
Investment
(millions)
Annual Profit
(millions)
2011 2 20
2012 3 25
2013 5 34
2014 4 30
2015 11 40
2016 5 31
2017 6 25
2019 15 ?
2020 ? 50
Dr. Summiya Parveen 3
Applications of Regression Analysis
Agricultural Science
Industrial Production
Environment Science
Business
Health Care
Dr. Summiya Parveen 4
Regression Techniques
There are various types of regression techniques available
to make predictions. These techniques are mostly driven
by three metrics (number of independent variables, type of
dependent variables and shape of regression line).
Dr. Summiya Parveen 5
Commonly used Types of Regression
Linear Regression
Non - Linear Regression
Polynomial Regression
Multiple Regression
Dr. Summiya Parveen 6
Linear Regression
The output of a simple
regression is the coefficient a1
and the constant a0. The
equation is then:
y = a0 + a1 x + e
where
e is the residual error.
a1 is the per unit change in the
dependent variable for each unit
change in the independent
variable. Mathematically:
Dr. Summiya Parveen 7
Non-linear Regression
Non-linear functions can also be fitted as regressions.
For examples Power function , Logarithmic function and
Exponential functions.
Dr. Summiya Parveen 8
Polynomial Regression
Polynomial equation in m degree
may be taken as :
y = a0 + a1x + a2x2 +....amxm+ e
Here a0 , a1, ……. am
are constant and
e = residual error
Dr. Summiya Parveen 9
Multiple Linear Regression
A useful extension of linear regression is the case where
dependent variable y is a linear function of two or more
independent variables
e.g
y = ao + a1x1 + a2x2
We follow the same procedure
y = ao + a1x1 + a2x2 + e
where
e= residual error .
Dr. Summiya Parveen 10
Linear Regression
Independent variable (x)
Dependentvariable(y)
The output of a regression is a function that predicts the
dependent variable based upon values of the independent
variable.
Linear regression fits a straight line to the data.
y = a0 + a1 x + e
a0 (y intercept)
a1 = slope
= ∆y/ ∆x
e
Dr. Summiya Parveen 11
12
Fitting a straight line to a
set of paired observations:
(x1, y1), (x2, y2),…,(xn, yn)
yi = a0 + a1 xi + ei
ei = yi - a0 - a1 xi
Here
yi : measured value
ei : error
a1 : slope
a0 : intercept
Linear Regression
e Error
Line equation
y = a0 + a1 x
Dr. Summiya Parveen
Best strategy is to minimize the sum of the squares of the residual errors
between the measured-y and the y calculated with the linear model:
Here we need to compute a0 and a1 such that Sr is minimized.









n
i
iir
n
i
modelimeasuredi
n
i
ir
xaayS
yy
eS
1
2
10
1
2
,,
1
2
)(
)(
e Error
Dr. Summiya Parveen 13
Least-Square Fit of a Straight Line
  00)(2
00)(2
2
101
1
101






 
 
iiiiiioi
r
iiioi
o
r
xaxaxyxxaay
a
S
xaayxaay
a
S
Normal equations which can
be solved simultaneously
 
    iiii
ii
xyaxax
yaxna
naa






1
2
0
10
00
(2)
(1)
Since
 

n
i
ii
n
i
ir xaayeS
1
2
10
1
2
)(:errorMinimize
Dr. Summiya Parveen 14
 
xayaa
xxn
yxyxn
a
ii
iiii
100
221
asexpressedbecan 



 
  
Solving equations (1) and (2) we get
Mean values
Dr. Summiya Parveen 15
To understand how well the X predicts the Y, we evaluate
Variability in the Y
variable
SSR –> Regression
Variability that is
explained by the
relationship b/w X & Y
+
SSE –> Unexplained
Variability, due to
factors then the
regression
-------------------------------
SST –> Total variability
about the mean
Correlation
Coefficient
r – Strength of the
Relationship
between Y and X
variables
Standard
Error
St Deviation of
error around
the Regression
Line
Residual
Analysis
Validation of
Model
Coefficient of Determination
R Sq - Proportion of explained
variation
Test for Linearity
Significance of the
Regression Model
i.e. Linear Regression
Model
“Goodness” of fit
Dr. Summiya Parveen 16
Independent variable (x)
Dependentvariable(y) Population mean: y
y
X
SSE
SSR
SST
Y
^Variability
Regression Line
Dr. Summiya Parveen 17
The Coefficient of Determination
The coefficient of determination (R ) is the proportion of the
variability in Y that is explained by the regression equation.
The value of R can range between 0 and 1, and the higher its
value the more accurate the regression model is. It is often
referred to as a percentage.
2
2
Dr. Summiya Parveen 18
Correlation Coefficient
The correlation coefficient (r) measures the
strength of the linear relationship
Note: -1 < r < 1
Dr. Summiya Parveen 19
Standard Error of Regression
The Standard Error of a regression is a measure of its
variability. It can be used in a similar manner to standard
deviation, allowing for prediction intervals.
Standard Error is calculated by taking the square root of the
average prediction error.
Standard Error/Deviation =
where n is the number of observations in the sample and k is
the total number of variables in the model.
If Standard error is low then less number are away from the
mean and if Standard error is high then more number are
away from the mean.
SSE
n - k√
Dr. Summiya Parveen 20
Least Squares Fit of a Straight Line:
Example
Fitting a straight line y = a0 + a1 x to the x and y
values given in the following table:
5.119 ii yx
,28 ix 0.24 iy
,1402
 ix
4285.3
7
24
4
7
28
 yx
428571.3
7
24
4
7
28
 yx
xi yi xiyi xi
2
1 0.5 0.5 1
2 2.5 5 4
3 2 6 9
4 4 16 16
5 3.5 17.5 25
6 6 36 36
7 5.5 38.5 49
28 24 119.5 140
Dr. Summiya Parveen 21
1 22
2
0 1
( )
7 119.5 28 24
0.8392857
7 140 28
3.428571 0.8392857 4 0.07142857
i i i i
i i
n x y x y
a
n x x
a y a x



  
 
 
 
   
  
 
y* = 0.07142857 + 0.8392857 x
Dr. Summiya Parveen 22
Error Analysis
9911.2
2
  ir eS
932.0868.02
 Rr
xi yi
1 0.5
2 2.5
3 2.0
4 4.0
5 3.5
6 6.0
7 5.5
8.5765 0.1687
0.8622 0.5625
2.0408 0.3473
0.3265 0.3265
0.0051 0.5896
6.6122 0.7972
4.2908 0.1993
222
*)( yye)y(y iii 
28 24.0 22.7143 2.9911
868.02



t
rt
S
SS
R
  7143.22
2
  yyS it
Dr. Summiya Parveen 23
9457.1
17
7143.22
1





n
S
s t
y
7735.0
27
9911.2
2
/ 




n
S
s r
xy
yxy SS /
•The standard deviation (quantifies the spread around the mean):
•The standard error of estimate (quantifies the spread around the
regression line)
Because the linear regression model has good fitness.
Dr. Summiya Parveen 24
MATLAB Session on
Regression
and
Curve Fitting
Dr. Summiya Parveen 25
Required Toolboxes :
A. Curve Fitting Toolbox
B. Statistics Toolbox
C. Spline Toolbox
Dr. Summiya Parveen 26
Curve Fitting using inbuilt functions
polyfit(x,y,n)
finds the coefficients of a polynomial P(x) of degree n that fits
the data
It uses least-square minimization
n = 1 (linear fit)
[P] = polyfit(X,Y,N)
returns P, a matrix containing the slope and the x intercept for a
linear fit
[Y] = polyval(P,X)
calculates the Y values for every X point on the line of best fit
Dr. Summiya Parveen 27
Curve Fitting Example
• 2nd Order Polynomial Fit:
%read data
[var1, var2] = textread(‘week8_testdata2.txt','%f%f','headerlines',1)
% Calculate 2nd order polynomial fit
P2 = polyfit(var1,var2,2);
Y2 = polyval(P2,var1);
%Plot fit
close all
figure(1)
hold on
plot(var1,var2,'ro')
[sortedvar1, sortind] = sort(var1)
plot(sortedvar1,Y2(sortind),'b*-')Dr. Summiya Parveen 28
2nd Order Polynomial Fit:
-2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5
-3
-2
-1
0
1
2
3
Dr. Summiya Parveen 29
Curve Fitting Example
• Add 3rd Order Polynomial Fit:
% Calculate 3rd order polynomial fit
P3 = polyfit(var1,var2,3);
Y3 = polyval(P3,var1);
%Add fit to figure
figure(1)
plot(sortedvar1,Y3(sortind),’g*-')
Dr. Summiya Parveen 30
-2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5
-3
-2
-1
0
1
2
3
2nd Order Polynomial Fit:
3rd Order Polynomial Fit:
Dr. Summiya Parveen 31
Curve Fitting Example
• Add 4th Order Polynomial Fit:
% Calculate 4th order polynomial fit
P4 = polyfit(var1,var2,4);
Y4 = polyval(P4,var1);
%Add fit to figure
figure(1)
plot(sortedvar1,Y4(sortind),’k*-')
Dr. Summiya Parveen 32
-2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5
-3
-2
-1
0
1
2
3
2nd Order Polynomial Fit:
3rd Order Polynomial Fit:
4th Order Polynomial Fit:
Dr. Summiya Parveen 33
-2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5
-3
-2
-1
0
1
2
3
Assessing Goodness of Fit
Example Solution
% recall var1 contains x values and var2 contains y values of data points
ypred = polyval(P2,var1);
dev = var2 - mean(2);
SST = sum(dev.^2);
resid = var2 - ypred;
SSE = sum(resid.^2);
normr = sqrt(SSE); % residual norm
Rsq = 1 - SSE/SST; % R2 Error
Normr = 5.7436
Rsq = 0.8533
• The residual norm and R2 error indicate goodness of fit
2nd Order Polynomial Fit:
Dr. Summiya Parveen 34
Limitations of Polyfit
• Only finds a least squares best polynomial
function fit
• Cannot be used to interpolate curves or fit other
standard functions
• Requires several lines of code and the polyval()
function
Dr. Summiya Parveen 35
THANK YOU
Dr. Summiya Parveen 36

More Related Content

What's hot

L8 fuzzy relations contd.
L8 fuzzy relations contd.L8 fuzzy relations contd.
L8 fuzzy relations contd.
Mohammad Umar Rehman
 
General Quadrature Equation
General Quadrature EquationGeneral Quadrature Equation
General Quadrature Equation
MrinalDev1
 
Curve Fitting
Curve FittingCurve Fitting
Curve Fitting
Sachin Kumar
 
Curve fitting
Curve fitting Curve fitting
Curve fitting
shopnohinami
 
Numerical solution of system of linear equations
Numerical solution of system of linear equationsNumerical solution of system of linear equations
Numerical solution of system of linear equations
reach2arkaELECTRICAL
 
Least square method
Least square methodLeast square method
Least square methodSomya Bagai
 
Newton's forward difference
Newton's forward differenceNewton's forward difference
Newton's forward difference
Raj Parekh
 
Derivation of Simpson's 1/3 rule
Derivation of Simpson's 1/3 ruleDerivation of Simpson's 1/3 rule
Derivation of Simpson's 1/3 rule
HapPy SumOn
 
Application of fourier series
Application of fourier seriesApplication of fourier series
Application of fourier seriesGirish Dhareshwar
 
Spline interpolation numerical methods presentation
Spline interpolation numerical methods presentationSpline interpolation numerical methods presentation
Spline interpolation numerical methods presentation
Shohanur Nishad
 
B.tech ii unit-2 material beta gamma function
B.tech ii unit-2 material beta gamma functionB.tech ii unit-2 material beta gamma function
B.tech ii unit-2 material beta gamma function
Rai University
 
Succesive differntiation
Succesive differntiationSuccesive differntiation
Succesive differntiation
JaydevVadachhak
 
Eigen value , eigen vectors, caley hamilton theorem
Eigen value , eigen vectors, caley hamilton theoremEigen value , eigen vectors, caley hamilton theorem
Eigen value , eigen vectors, caley hamilton theorem
gidc engineering college
 
Lesson 9: Gaussian Elimination
Lesson 9: Gaussian EliminationLesson 9: Gaussian Elimination
Lesson 9: Gaussian EliminationMatthew Leingang
 
A NEW METHOD OF CENTRAL DIFFERENCE INTERPOLATION
A NEW METHOD OF CENTRAL DIFFERENCE INTERPOLATIONA NEW METHOD OF CENTRAL DIFFERENCE INTERPOLATION
A NEW METHOD OF CENTRAL DIFFERENCE INTERPOLATION
mathsjournal
 
Partial differential equations
Partial differential equationsPartial differential equations
Partial differential equations
muhammadabullah
 
Numerical solution of ordinary differential equations GTU CVNM PPT
Numerical solution of ordinary differential equations GTU CVNM PPTNumerical solution of ordinary differential equations GTU CVNM PPT
Numerical solution of ordinary differential equations GTU CVNM PPT
Panchal Anand
 
Aoa amortized analysis
Aoa amortized analysisAoa amortized analysis
Aoa amortized analysis
Salabat Khan
 
Elementary linear algebra
Elementary linear algebraElementary linear algebra
Elementary linear algebra
Ayupratiwi Geophysics
 

What's hot (20)

L8 fuzzy relations contd.
L8 fuzzy relations contd.L8 fuzzy relations contd.
L8 fuzzy relations contd.
 
General Quadrature Equation
General Quadrature EquationGeneral Quadrature Equation
General Quadrature Equation
 
Curve Fitting
Curve FittingCurve Fitting
Curve Fitting
 
Curve fitting
Curve fitting Curve fitting
Curve fitting
 
Numerical solution of system of linear equations
Numerical solution of system of linear equationsNumerical solution of system of linear equations
Numerical solution of system of linear equations
 
Least square method
Least square methodLeast square method
Least square method
 
Newton's forward difference
Newton's forward differenceNewton's forward difference
Newton's forward difference
 
Derivation of Simpson's 1/3 rule
Derivation of Simpson's 1/3 ruleDerivation of Simpson's 1/3 rule
Derivation of Simpson's 1/3 rule
 
Application of fourier series
Application of fourier seriesApplication of fourier series
Application of fourier series
 
Spline interpolation numerical methods presentation
Spline interpolation numerical methods presentationSpline interpolation numerical methods presentation
Spline interpolation numerical methods presentation
 
B.tech ii unit-2 material beta gamma function
B.tech ii unit-2 material beta gamma functionB.tech ii unit-2 material beta gamma function
B.tech ii unit-2 material beta gamma function
 
Succesive differntiation
Succesive differntiationSuccesive differntiation
Succesive differntiation
 
Eigen value , eigen vectors, caley hamilton theorem
Eigen value , eigen vectors, caley hamilton theoremEigen value , eigen vectors, caley hamilton theorem
Eigen value , eigen vectors, caley hamilton theorem
 
Lesson 9: Gaussian Elimination
Lesson 9: Gaussian EliminationLesson 9: Gaussian Elimination
Lesson 9: Gaussian Elimination
 
A NEW METHOD OF CENTRAL DIFFERENCE INTERPOLATION
A NEW METHOD OF CENTRAL DIFFERENCE INTERPOLATIONA NEW METHOD OF CENTRAL DIFFERENCE INTERPOLATION
A NEW METHOD OF CENTRAL DIFFERENCE INTERPOLATION
 
Knapsack Problem
Knapsack ProblemKnapsack Problem
Knapsack Problem
 
Partial differential equations
Partial differential equationsPartial differential equations
Partial differential equations
 
Numerical solution of ordinary differential equations GTU CVNM PPT
Numerical solution of ordinary differential equations GTU CVNM PPTNumerical solution of ordinary differential equations GTU CVNM PPT
Numerical solution of ordinary differential equations GTU CVNM PPT
 
Aoa amortized analysis
Aoa amortized analysisAoa amortized analysis
Aoa amortized analysis
 
Elementary linear algebra
Elementary linear algebraElementary linear algebra
Elementary linear algebra
 

Similar to Data Approximation in Mathematical Modelling Regression Analysis and Curve Fitting

ML Module 3.pdf
ML Module 3.pdfML Module 3.pdf
ML Module 3.pdf
Shiwani Gupta
 
Course pack unit 5
Course pack unit 5Course pack unit 5
Course pack unit 5
Rai University
 
simple linear regression - brief introduction
simple linear regression - brief introductionsimple linear regression - brief introduction
simple linear regression - brief introduction
edinyoka
 
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
 
Statistics-Regression analysis
Statistics-Regression analysisStatistics-Regression analysis
Statistics-Regression analysis
Rabin BK
 
Regression analysis by Muthama JM
Regression analysis by Muthama JMRegression analysis by Muthama JM
Regression analysis by Muthama JM
Japheth Muthama
 
Regression Analysis by Muthama JM
Regression Analysis by Muthama JM Regression Analysis by Muthama JM
Regression Analysis by Muthama JM
Japheth Muthama
 
Regression analysis
Regression analysisRegression analysis
Regression analysis
Awais Salman
 
Rsh qam11 ch04 ge
Rsh qam11 ch04 geRsh qam11 ch04 ge
Rsh qam11 ch04 ge
Firas Husseini
 
Correlation by Neeraj Bhandari ( Surkhet.Nepal )
Correlation by Neeraj Bhandari ( Surkhet.Nepal )Correlation by Neeraj Bhandari ( Surkhet.Nepal )
Correlation by Neeraj Bhandari ( Surkhet.Nepal )Neeraj Bhandari
 
Linear Regression
Linear RegressionLinear Regression
Linear Regression
VARUN KUMAR
 
一比一原版(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
 
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
 

Similar to Data Approximation in Mathematical Modelling Regression Analysis and Curve Fitting (20)

ML Module 3.pdf
ML Module 3.pdfML Module 3.pdf
ML Module 3.pdf
 
Course pack unit 5
Course pack unit 5Course pack unit 5
Course pack unit 5
 
simple linear regression - brief introduction
simple linear regression - brief introductionsimple linear regression - brief introduction
simple linear regression - brief introduction
 
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
 
Statistics-Regression analysis
Statistics-Regression analysisStatistics-Regression analysis
Statistics-Regression analysis
 
Regression analysis by Muthama JM
Regression analysis by Muthama JMRegression analysis by Muthama JM
Regression analysis by Muthama JM
 
Regression Analysis by Muthama JM
Regression Analysis by Muthama JM Regression Analysis by Muthama JM
Regression Analysis by Muthama JM
 
Regression analysis
Regression analysisRegression analysis
Regression analysis
 
Rsh qam11 ch04 ge
Rsh qam11 ch04 geRsh qam11 ch04 ge
Rsh qam11 ch04 ge
 
Correlation by Neeraj Bhandari ( Surkhet.Nepal )
Correlation by Neeraj Bhandari ( Surkhet.Nepal )Correlation by Neeraj Bhandari ( Surkhet.Nepal )
Correlation by Neeraj Bhandari ( Surkhet.Nepal )
 
Linear Regression
Linear RegressionLinear Regression
Linear Regression
 
一比一原版(Otago毕业证书)新西兰奥塔哥大学毕业证成绩单
一比一原版(Otago毕业证书)新西兰奥塔哥大学毕业证成绩单一比一原版(Otago毕业证书)新西兰奥塔哥大学毕业证成绩单
一比一原版(Otago毕业证书)新西兰奥塔哥大学毕业证成绩单
 
一比一原版(RoyalVeterinary毕业证书)皇家兽医学院毕业证成绩单
一比一原版(RoyalVeterinary毕业证书)皇家兽医学院毕业证成绩单一比一原版(RoyalVeterinary毕业证书)皇家兽医学院毕业证成绩单
一比一原版(RoyalVeterinary毕业证书)皇家兽医学院毕业证成绩单
 
一比一原版(UCD毕业证书)爱尔兰都柏林大学毕业证成绩单
一比一原版(UCD毕业证书)爱尔兰都柏林大学毕业证成绩单一比一原版(UCD毕业证书)爱尔兰都柏林大学毕业证成绩单
一比一原版(UCD毕业证书)爱尔兰都柏林大学毕业证成绩单
 
一比一原版(UM毕业证书)马来亚大学毕业证成绩单
一比一原版(UM毕业证书)马来亚大学毕业证成绩单一比一原版(UM毕业证书)马来亚大学毕业证成绩单
一比一原版(UM毕业证书)马来亚大学毕业证成绩单
 
一比一原版(UPM毕业证书)马来西亚博特拉大学毕业证成绩单
一比一原版(UPM毕业证书)马来西亚博特拉大学毕业证成绩单一比一原版(UPM毕业证书)马来西亚博特拉大学毕业证成绩单
一比一原版(UPM毕业证书)马来西亚博特拉大学毕业证成绩单
 
一比一原版(KHU毕业证书)韩国庆熙大学毕业证成绩单
一比一原版(KHU毕业证书)韩国庆熙大学毕业证成绩单一比一原版(KHU毕业证书)韩国庆熙大学毕业证成绩单
一比一原版(KHU毕业证书)韩国庆熙大学毕业证成绩单
 
一比一原版(TheAuckland毕业证书)新西兰奥克兰大学毕业证成绩单
一比一原版(TheAuckland毕业证书)新西兰奥克兰大学毕业证成绩单一比一原版(TheAuckland毕业证书)新西兰奥克兰大学毕业证成绩单
一比一原版(TheAuckland毕业证书)新西兰奥克兰大学毕业证成绩单
 
一比一原版(SEGi毕业证书)马来西亚世纪大学毕业证成绩单
一比一原版(SEGi毕业证书)马来西亚世纪大学毕业证成绩单一比一原版(SEGi毕业证书)马来西亚世纪大学毕业证成绩单
一比一原版(SEGi毕业证书)马来西亚世纪大学毕业证成绩单
 
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
 

Recently uploaded

Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
heavyhaig
 
Building Electrical System Design & Installation
Building Electrical System Design & InstallationBuilding Electrical System Design & Installation
Building Electrical System Design & Installation
symbo111
 
Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
ChristineTorrepenida1
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
SyedAbiiAzazi1
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
aqil azizi
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
DESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABS
DESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABSDESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABS
DESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABS
itech2017
 
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
ssuser7dcef0
 
Water billing management system project report.pdf
Water billing management system project report.pdfWater billing management system project report.pdf
Water billing management system project report.pdf
Kamal Acharya
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Christina Lin
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
gestioneergodomus
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
manasideore6
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
drwaing
 
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
dxobcob
 
Online aptitude test management system project report.pdf
Online aptitude test management system project report.pdfOnline aptitude test management system project report.pdf
Online aptitude test management system project report.pdf
Kamal Acharya
 

Recently uploaded (20)

Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
 
Building Electrical System Design & Installation
Building Electrical System Design & InstallationBuilding Electrical System Design & Installation
Building Electrical System Design & Installation
 
Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
DESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABS
DESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABSDESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABS
DESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABS
 
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
 
Water billing management system project report.pdf
Water billing management system project report.pdfWater billing management system project report.pdf
Water billing management system project report.pdf
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
 
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
 
Online aptitude test management system project report.pdf
Online aptitude test management system project report.pdfOnline aptitude test management system project report.pdf
Online aptitude test management system project report.pdf
 

Data Approximation in Mathematical Modelling Regression Analysis and Curve Fitting

  • 1. Data Approximation in Mathematical Modelling: Regression Analysis and Curve Fitting DR. SUMMIYA PARVEEN Department of Mathematics COLLEGE OF ENGINEERING ROORKE (COER) ROORKEE summiyaparveen82@gmail.com Dr. Summiya Parveen 1
  • 2. Outline of the lecture: Introduction of Regression Application of Regression Regression Techniques Types of Regression Goodness of fit MATLAB/MATHEMATICA implementation with some example Dr. Summiya Parveen 2
  • 3. Regression 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 casual effect relationship between the variables. Regression analysis is an important tool for modelling and analysing data. Here, we fit a curve / line to the data points in such a manner that the differences between the distances of data points from the curve or line is minimized. Independent variable (x) Dependentvariable(y) Year Research & development Investment (millions) Annual Profit (millions) 2011 2 20 2012 3 25 2013 5 34 2014 4 30 2015 11 40 2016 5 31 2017 6 25 2019 15 ? 2020 ? 50 Dr. Summiya Parveen 3
  • 4. Applications of Regression Analysis Agricultural Science Industrial Production Environment Science Business Health Care Dr. Summiya Parveen 4
  • 5. Regression Techniques There are various types of regression techniques available to make predictions. These techniques are mostly driven by three metrics (number of independent variables, type of dependent variables and shape of regression line). Dr. Summiya Parveen 5
  • 6. Commonly used Types of Regression Linear Regression Non - Linear Regression Polynomial Regression Multiple Regression Dr. Summiya Parveen 6
  • 7. Linear Regression The output of a simple regression is the coefficient a1 and the constant a0. The equation is then: y = a0 + a1 x + e where e is the residual error. a1 is the per unit change in the dependent variable for each unit change in the independent variable. Mathematically: Dr. Summiya Parveen 7
  • 8. Non-linear Regression Non-linear functions can also be fitted as regressions. For examples Power function , Logarithmic function and Exponential functions. Dr. Summiya Parveen 8
  • 9. Polynomial Regression Polynomial equation in m degree may be taken as : y = a0 + a1x + a2x2 +....amxm+ e Here a0 , a1, ……. am are constant and e = residual error Dr. Summiya Parveen 9
  • 10. Multiple Linear Regression A useful extension of linear regression is the case where dependent variable y is a linear function of two or more independent variables e.g y = ao + a1x1 + a2x2 We follow the same procedure y = ao + a1x1 + a2x2 + e where e= residual error . Dr. Summiya Parveen 10
  • 11. Linear Regression Independent variable (x) Dependentvariable(y) The output of a regression is a function that predicts the dependent variable based upon values of the independent variable. Linear regression fits a straight line to the data. y = a0 + a1 x + e a0 (y intercept) a1 = slope = ∆y/ ∆x e Dr. Summiya Parveen 11
  • 12. 12 Fitting a straight line to a set of paired observations: (x1, y1), (x2, y2),…,(xn, yn) yi = a0 + a1 xi + ei ei = yi - a0 - a1 xi Here yi : measured value ei : error a1 : slope a0 : intercept Linear Regression e Error Line equation y = a0 + a1 x Dr. Summiya Parveen
  • 13. Best strategy is to minimize the sum of the squares of the residual errors between the measured-y and the y calculated with the linear model: Here we need to compute a0 and a1 such that Sr is minimized.          n i iir n i modelimeasuredi n i ir xaayS yy eS 1 2 10 1 2 ,, 1 2 )( )( e Error Dr. Summiya Parveen 13
  • 14. Least-Square Fit of a Straight Line   00)(2 00)(2 2 101 1 101           iiiiiioi r iiioi o r xaxaxyxxaay a S xaayxaay a S Normal equations which can be solved simultaneously       iiii ii xyaxax yaxna naa       1 2 0 10 00 (2) (1) Since    n i ii n i ir xaayeS 1 2 10 1 2 )(:errorMinimize Dr. Summiya Parveen 14
  • 15.   xayaa xxn yxyxn a ii iiii 100 221 asexpressedbecan          Solving equations (1) and (2) we get Mean values Dr. Summiya Parveen 15
  • 16. To understand how well the X predicts the Y, we evaluate Variability in the Y variable SSR –> Regression Variability that is explained by the relationship b/w X & Y + SSE –> Unexplained Variability, due to factors then the regression ------------------------------- SST –> Total variability about the mean Correlation Coefficient r – Strength of the Relationship between Y and X variables Standard Error St Deviation of error around the Regression Line Residual Analysis Validation of Model Coefficient of Determination R Sq - Proportion of explained variation Test for Linearity Significance of the Regression Model i.e. Linear Regression Model “Goodness” of fit Dr. Summiya Parveen 16
  • 17. Independent variable (x) Dependentvariable(y) Population mean: y y X SSE SSR SST Y ^Variability Regression Line Dr. Summiya Parveen 17
  • 18. The Coefficient of Determination The coefficient of determination (R ) is the proportion of the variability in Y that is explained by the regression equation. The value of R can range between 0 and 1, and the higher its value the more accurate the regression model is. It is often referred to as a percentage. 2 2 Dr. Summiya Parveen 18
  • 19. Correlation Coefficient The correlation coefficient (r) measures the strength of the linear relationship Note: -1 < r < 1 Dr. Summiya Parveen 19
  • 20. Standard Error of Regression The Standard Error of a regression is a measure of its variability. It can be used in a similar manner to standard deviation, allowing for prediction intervals. Standard Error is calculated by taking the square root of the average prediction error. Standard Error/Deviation = where n is the number of observations in the sample and k is the total number of variables in the model. If Standard error is low then less number are away from the mean and if Standard error is high then more number are away from the mean. SSE n - k√ Dr. Summiya Parveen 20
  • 21. Least Squares Fit of a Straight Line: Example Fitting a straight line y = a0 + a1 x to the x and y values given in the following table: 5.119 ii yx ,28 ix 0.24 iy ,1402  ix 4285.3 7 24 4 7 28  yx 428571.3 7 24 4 7 28  yx xi yi xiyi xi 2 1 0.5 0.5 1 2 2.5 5 4 3 2 6 9 4 4 16 16 5 3.5 17.5 25 6 6 36 36 7 5.5 38.5 49 28 24 119.5 140 Dr. Summiya Parveen 21
  • 22. 1 22 2 0 1 ( ) 7 119.5 28 24 0.8392857 7 140 28 3.428571 0.8392857 4 0.07142857 i i i i i i n x y x y a n x x a y a x                      y* = 0.07142857 + 0.8392857 x Dr. Summiya Parveen 22
  • 23. Error Analysis 9911.2 2   ir eS 932.0868.02  Rr xi yi 1 0.5 2 2.5 3 2.0 4 4.0 5 3.5 6 6.0 7 5.5 8.5765 0.1687 0.8622 0.5625 2.0408 0.3473 0.3265 0.3265 0.0051 0.5896 6.6122 0.7972 4.2908 0.1993 222 *)( yye)y(y iii  28 24.0 22.7143 2.9911 868.02    t rt S SS R   7143.22 2   yyS it Dr. Summiya Parveen 23
  • 24. 9457.1 17 7143.22 1      n S s t y 7735.0 27 9911.2 2 /      n S s r xy yxy SS / •The standard deviation (quantifies the spread around the mean): •The standard error of estimate (quantifies the spread around the regression line) Because the linear regression model has good fitness. Dr. Summiya Parveen 24
  • 25. MATLAB Session on Regression and Curve Fitting Dr. Summiya Parveen 25
  • 26. Required Toolboxes : A. Curve Fitting Toolbox B. Statistics Toolbox C. Spline Toolbox Dr. Summiya Parveen 26
  • 27. Curve Fitting using inbuilt functions polyfit(x,y,n) finds the coefficients of a polynomial P(x) of degree n that fits the data It uses least-square minimization n = 1 (linear fit) [P] = polyfit(X,Y,N) returns P, a matrix containing the slope and the x intercept for a linear fit [Y] = polyval(P,X) calculates the Y values for every X point on the line of best fit Dr. Summiya Parveen 27
  • 28. Curve Fitting Example • 2nd Order Polynomial Fit: %read data [var1, var2] = textread(‘week8_testdata2.txt','%f%f','headerlines',1) % Calculate 2nd order polynomial fit P2 = polyfit(var1,var2,2); Y2 = polyval(P2,var1); %Plot fit close all figure(1) hold on plot(var1,var2,'ro') [sortedvar1, sortind] = sort(var1) plot(sortedvar1,Y2(sortind),'b*-')Dr. Summiya Parveen 28
  • 29. 2nd Order Polynomial Fit: -2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 -3 -2 -1 0 1 2 3 Dr. Summiya Parveen 29
  • 30. Curve Fitting Example • Add 3rd Order Polynomial Fit: % Calculate 3rd order polynomial fit P3 = polyfit(var1,var2,3); Y3 = polyval(P3,var1); %Add fit to figure figure(1) plot(sortedvar1,Y3(sortind),’g*-') Dr. Summiya Parveen 30
  • 31. -2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 -3 -2 -1 0 1 2 3 2nd Order Polynomial Fit: 3rd Order Polynomial Fit: Dr. Summiya Parveen 31
  • 32. Curve Fitting Example • Add 4th Order Polynomial Fit: % Calculate 4th order polynomial fit P4 = polyfit(var1,var2,4); Y4 = polyval(P4,var1); %Add fit to figure figure(1) plot(sortedvar1,Y4(sortind),’k*-') Dr. Summiya Parveen 32
  • 33. -2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 -3 -2 -1 0 1 2 3 2nd Order Polynomial Fit: 3rd Order Polynomial Fit: 4th Order Polynomial Fit: Dr. Summiya Parveen 33
  • 34. -2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 -3 -2 -1 0 1 2 3 Assessing Goodness of Fit Example Solution % recall var1 contains x values and var2 contains y values of data points ypred = polyval(P2,var1); dev = var2 - mean(2); SST = sum(dev.^2); resid = var2 - ypred; SSE = sum(resid.^2); normr = sqrt(SSE); % residual norm Rsq = 1 - SSE/SST; % R2 Error Normr = 5.7436 Rsq = 0.8533 • The residual norm and R2 error indicate goodness of fit 2nd Order Polynomial Fit: Dr. Summiya Parveen 34
  • 35. Limitations of Polyfit • Only finds a least squares best polynomial function fit • Cannot be used to interpolate curves or fit other standard functions • Requires several lines of code and the polyval() function Dr. Summiya Parveen 35
  • 36. THANK YOU Dr. Summiya Parveen 36