Docsity

Linear Regression - Numerical Methods - Lecture Slides, Slides of Mathematical Methods for Numerical Analysis and Optimization

Partial preview of the text

Download Linear Regression - Numerical Methods - Lecture Slides and more Slides Mathematical Methods for Numerical Analysis and Optimization in PDF only on Docsity!

Linear Regression

What is Regression?

What is regression? Given n data points (^ x^1 ,^ y^1 ),( x^2 , y^2 ),...,( xn ,^ yn )

best fit y^  f ( x ) to the data. The best fit is generally based on

minimizing the sum of the square of the residuals, Sr

Residual at a point is

 i  yi  f ( xi )

 

n
i

Sr yi f xi

( ( ))^2 (^ x^1 ,^ y^1 )

( xn , yn )

yf ( x )

Figure. Basic model for regression
Sum of the square of the residuals

Example for Criterion#

x y
Example: Given the data points (2,4), (3,6), (2,6) and (3,8), best fit
the data to a straight line using Criterion#
Figure. Data points for y vs. x data.
Table. Data Points

0

2

4

6

8

10

(^0 1) x 2 3 4

y

Linear Regression-Criteria#

i^4  1  i^ ^0

x y ypredicted ε = y - ypredicted 2.0 4.0 4.0 0. 3.0 6.0 8.0 -2. 2.0 6.0 4.0 2. 3.0 8.0 8.0 0.

Table. regression model y = 4x Residuals at each point for – 4.
Figure. Regression curve for y=4x-4, y vs. x data

0

2

4

6

8

10

0 1 2 3 4

x

y

Using y=4x-4 as the regression curve

Linear Regression – Criterion

0

4  i  1  i^ ^ for both regression models of y=4x-4 and y=6.

The sum of the residuals is as small as possible, that is zero,
but the regression model is not unique.
Hence the above criterion of minimizing the sum of the
residuals is a bad criterion.

Linear Regression-Criterion#

x

x 1 , y 1  iyi^  a 0  a 1 xi

x 2 , y 2 x 3 , y 3
xn , yn

xi , yi

 i  yi  a 0  a 1 xi

y

Figure. Linear regression of y vs. x data showing residuals at a typical point,xi.

Will minimizing 

n i 1 i

 work any better?

Linear Regression-Criteria#

x y ypredicted |ε| = |y ypredicted – | 2.0 4.0 6.0 2. 3.0 6.0 6.0 0. 2.0 6.0 6.0 0. 3.0 8.0 6.0 2.  i^4  1  i^ ^4

Table. the y=6 model Absolute residuals employing
x

y

Figure. Regression curve for y=6, y vs. x data

Using y=6 as a regression curve

Linear Regression-Criterion#

Can you find a regression line for which^4

4

regression coefficients?^  i ^1  i^  and has unique

for both regression models of y=4x-4 and y=6.
The sum of the errors has been made as small as possible, that
is 4, but the regression model is not unique.
Hence the above criterion of minimizing the sum of the absolute
value of the residuals is also a bad criterion.

i^4  1  i^ ^4

Finding Constants of Linear Model

 

2 1 1 0 1  2 

n i i i

n Minimize the sum of the square of the residuals: To find Sr (^) ii y a ax

^ aS 0 r^ ^2  i ^ n 1 ^ yia^0  a^1 xi ^ ^1 ^ ^0  Sa 1 r (^)  (^2)  i ^ n 1  yia 0  a 1 xi   xi   0

giving

i

n i i i

n i i

nia^ x ^  ax^  1 y^ x 2 1 0 1 1

a (^0) and a (^1) we minimize Sr with respect to a (^1) and a (^0).

 ^ 

n i i i

n i

n i 1 a^^01 a^1 x 1^ y ( ) a 0 (^)  ya 1 x

Finding Constants of Linear Model

Solving for a^0

2 1 1

2 1 1 1 1  

   

  

 

  ni i

n i i

n i i

n i i

n i i i n x x

n x y x y a

and

2 1 1

2

1 1 1 1

2 0  

   

   

 

   ni i

n i i

n i i i

n i i

n i i

n i i n x x

x y x x y a

and a^1 directly yields,

( a 0 (^)  ya 1 x )

Example 1 cont.

a 1

The following table shows the summations needed for the calculations of
the constants in the regression model.

 ^2 TRadians N-m Radians^2 N-m-Radians 0.698132 0.188224 0.487388 0. 0.959931 0.209138 0.921468 0. 1.134464 0.230052 1.2870 0. 1.570796 0.250965 2.4674 0. 1.919862 0.313707 3.6859 0. 6.2831 1.1921 8.8491 1.

Table. Tabulation of data for calculation of important

^ 

5 i 1

n  5
Using equations described for

5 2 1

5 1

2

5 1

5 1

5 2 1  

 

 

   i i i i

i i i i ii i n

n T T k  

 

5  8 8491   62831 ^2

 9_._ 6091  10 ^2 N-m/rad

summations

T a 0 and with

Example 1 cont.

n

T T i

 i

5 _ 1

Use the average torque and average angle to calculate k^1

_ 2

_ k 1  Tk

n  ^ ii

5 _^1 

^1.^1921

 2. 3842  10 ^1

^6.^2831

 1. 2566

Using,

 2. 3842  10 ^1 ( 9. 6091  10 ^2 )( 1. 2566 )  1. 1767  10 ^1 N-m

Example 2

Strain Stress (%) (MPa) 0 0 0.183 306 0.36 612 0.5324 917 0.702 1223 0.867 1529 1.0244 1835 1.1774 2140 1.329 2446 1.479 2752 1.5 2767 1.56 2896

To find the longitudinal modulus of composite, the following data is
collected. Find the longitudinal modulus,
Table. Stress vs. Strain data   E  and the sum of the square of the E^ using the regression model

0.0E+

1.0E+

2.0E+

3.0E+

0 0.005 0.01 0.015 0. Strain, ε (m/m)

Stress, σ (Pa)

residuals.
Figure. Data points for Stress vs. Strain data Docsity.com

Example 2 cont.

 (^) i  iEi

Residual at each point is given by
The sum of the square of the residuals then is

 n S (^) r i 1 i

^2

 i ^ n 1  (^) iEi ^2

 SEr (^)  in 12  (^) iEi (   i )  0

Differentiate with respect to E

  n

i i

n

E i i i

1

2

1 

 

Therefore