Professional Documents
Culture Documents
Part 5
1
Describes techniques to fit curves (curve fitting) to
discrete data to obtain intermediate estimates.
y
y i
, i 1, , n
n
St
Sy , St ( yi y ) 2
n 1
Mathematical Background (cont’d)
i y y
2 2
( y y ) 2
/n
S
2
or S 2
i i
n 1
y
n 1
y
7
Chapter 17
Least-Squares Regression
8
Linear Regression
n n
min e (y
i 1
i
i 1
i a0 a1 xi )
e1 e1= -e2
e2
Linear Regression:
Criteria for a “Best” Fit
n n
min | e | | y
i 1
i
i 1
i a0 a1 xi |
Linear Regression:
Criteria for a “Best” Fit
n
min max | ei || yi a0 a1 xi |
i 1
Linear Regression:
Least Squares Fit
n n n
S r e ( yi , measured yi , model ) ( yi a0 a1 xi ) 2
2
i
2
i 1 i 1 i 1
n n
min S r ei
2
( yi a0 a1 xi ) 2
i 1 i 1
S r
a 0
0
S r 0
a1
Linear Regression:
Determination of ao and a1
S r
2 ( yi ao a1 xi ) 0
ao
S r
2 ( yi ao a1 xi ) xi 0
a1
0 yi a 0 a1 xi
0 yi xi a 0 xi a1 xi2
a 0 na0
na0 xi a1 yi 2 equations with 2
unknowns, can be solved
ii 0i 1i
y x a x a x 2
simultaneously
Linear Regression:
Determination of ao and a1
y = a0+ a1 x
a1 - slope
a0 - intercept
n xi yi xi yi
a1
n x xi
2 2
i
a0 y a1 x
Error of Linear Regression
Error of Linear Regression
n n
S r e ( yi a0 a1 xi ) 2
2
i
Analog to
i 1 i 1 Standard deviation
Standard error of the estimates:
21
Error of Linear Regression
22
Error Quantification of Linear
Regression
St S r
r
2
St
r2: coefficient of determination
r : correlation coefficient
For a perfect fit:
• Sr= 0 and r = r2 =1, signifying that the line explains 100
percent of the variability of the data.
• For r = r2 = 0, Sr = St, the fit represents no improvement.
Least Squares Fit of a Straight Line:
Example
Fit a straight line to the x and y values in the following
Table:
xi yi xiyi xi2
xi 28 yi 24.0
1 0.5 0.5 1
2 2.5 5 4 xi 140
2
xi yi 119 .5
3 2 6 9
28 24
4 4 16 16 x 4 y 3.42857
5 3.5 17.5 25 7 7
6 6 36 36
28 24
7 5.5 38.5 x 49 4 y 3.428571
7 7
28 24 119.5 140
Least Squares Fit of a Straight Line:
Example (cont’d)
n xi yi xi yi
a1
n x ( xi )
2 2
i
7 119.5 28 24
0.8392857
7 140 28 2
a0 y a1 x
3.428571 0.8392857 4 0.07142857
Y = 0.07142857 + 0.8392857 x
Least Squares Fit of a Straight Line:
Example (Error Analysis)
y a1eb1x
ln y ln a1 b1 x
Linearization of Nonlinear Relationships
2. The power equation
y a2 xb2
x
y a3
b3 x
1 1 b3 1
y a3 a3 x
Example
Fit the following Equation:
y a2 x b2
xi yi X = log xi Y = log yi
log y log a2 b2 log x
1 0.5 0 -0.301 let Y log y, X log x,
2 1.7 0.301 0.226 a0 log a2 , a1 b2
3 3.4 0.477 0.534
4 5.7 0.602 0.753 Y a0 a1 X
5 8.4 0.699 0.922
15 19.7 2.079 2.141
Example
Xi Yi X*i=Log(X) Y*i=Log(Y) X*Y* X*^2
1 0.5 0.0000 -0.3010 0.0000 0.0000
2 1.7 0.3010 0.2304 0.0694 0.0906
3 3.4 0.4771 0.5315 0.2536 0.2276
4 5.7 0.6021 0.7559 0.4551 0.3625
5 8.4 0.6990 0.9243 0.6460 0.4886
Sum 15 19.700 2.079 2.141 1.424 1.169
a0 y a1x 0.4282 1.75 0.41584 0.334
Example
A parabola is preferable
Polynomial Regression (cont’d)
ei yi ao a1 xi a2 xi
2
Sr ei yi ao a1 xi a2 xi
2
2 2
Polynomial Regression (cont’d)
S r
2 ( yi ao a1 xi a2 xi2 ) 0
ao
S r
2 ( yi ao a1 xi a2 xi2 ) xi 0
a1
S r
2 ( yi ao a1 xi a2 xi2 ) xi2 0
a2
i
y n a o a1 i
x a 2 i
x 2
3 linear equations
i i o i 1 i 2 i
with 3 unknowns
x y a x a x 2
a x 3
(ao,a1,a2), can be
i i o i 1 i 2 i
solved
x 2
y a x 2
a x 3
a x 4
Polynomial Regression (cont’d)
• A system of 3x3 equations needs to be solved to
determine the coefficients of the polynomial.
n
x x
i
2
i
a0 y i
xi x x a1 xi yi
2 3
i i
xi2 x x
3 4 a2 xi2 yi
i i
Sr St S r
sy / x r
2
n3 St
Polynomial Regression (cont’d)
General:
The mth-order polynomial:
y ao a1 x a2 x 2 ..... am x m e
• A system of (m+1)x(m+1) linear equations must be solved for
determining the coefficients of the mth-order polynomial.
• The standard error:
Sr
sy / x
n m 1
St S r
• The coefficient of determination: r
2
St
Polynomial Regression- Example
Fit a second order polynomial to data:
xi
0
yi
2.1
xi2
0
Xi3
0
xi4
0
xiyi xi2yi
0 0
x i 15
4
5
40.9
61.1
16
25
64
125
256
625
163.6 654.4
305.5 1527.5
i 225
x 3
15 152.6 x y i i 585.6
x 2.5, y 25.433 xi yi 2488.8
2
6 6
Polynomial Regression- Example
(cont’d)
St yi y 2513.39 S r ei 3.74657
2 2
Polynomial Regression- Example
(cont’d)
xi yi ymodel e i2 (yi-y`)2
0 2.1 2.4786 0.14332 544.42889
1 7.7 6.6986 1.00286 314.45929
2 13.6 14.64 1.08158 140.01989
3 27.2 26.303 0.80491 3.12229
4 40.9 41.687 0.61951 239.22809
5 61.1 60.793 0.09439 1272.13489
15 152.6 3.74657 2513.39333
•The standard error of estimate:
3.74657
sy / x 1.12
63
•The coefficient of determination:
2513.39 3.74657
r
2
0.99851, r r 2 0.99925
2513.39
Other Regression Techniques