07 Regresi Non Linier
-
Upload
grandhis-gumelar -
Category
Documents
-
view
242 -
download
3
Transcript of 07 Regresi Non Linier
-
8/18/2019 07 Regresi Non Linier
1/38
Nonlinear Regression
SujantokoMathematic Engineering
Ocean Engineering FTK ITS
1
-
8/18/2019 07 Regresi Non Linier
2/38
-
8/18/2019 07 Regresi Non Linier
3/38
Nonlinear Regression
Given n data points ),(,...),,(),,( 2211 nn y x y x y x best fit )( x f y =to the data, where )( x f is a nonlinear function of x .
),(nn
y x
)( x f y =,
22
),(ii
y x−
),(11
y x ii
. .
3
-
8/18/2019 07 Regresi Non Linier
4/38
RegressionExponential Model
4
-
8/18/2019 07 Regresi Non Linier
5/38
Exponential Model
),(,...),,(),,( 2211 nn y x y x y xGiven best fit bx
ae y = to the data.
,nn
),( 22 y xbxae y =),(
ii y x
)(ii
x f y −
Figure. Exponential model of nonlinear regression for y vs. x data
,11
5
-
8/18/2019 07 Regresi Non Linier
6/38
n ng onstants o xponent a o e
( )∑ −= n bxir iae yS 2
e sum o e square o e res ua s s e ne as
=i 1Differentiate with respect to a and b
n
021
=−−=∂ =
ii x
i
xi
r eaea
( )( ) 021
=−−=∂∂ ∑
=
ii bxi
n
i
bxi
r eaxae yb
S
6
-
8/18/2019 07 Regresi Non Linier
7/38
Finding Constants of Exponential Model
Rewriting the equations, we obtain
01
2
1
=∑+∑−== i
bx
i
bxi
ii eae y
02 =∑−∑ n bx
in bx
iiii e xae x y
== ii
7
-
8/18/2019 07 Regresi Non Linier
8/38
Finding constants of Exponential Model
∑n bx
iie y
∑= =
n bx
i
iea 2
1
Substituting a back into the previous equation
=i 1
21∑
− = n bx
bxn
ii
bxn i
i
i
e y
1
1
21 ∑ ==
= i in
i
bxii i ie
he constant b can be found through numerical
methods such bisection method.8
-
8/18/2019 07 Regresi Non Linier
9/38
-Many patients get concerned when a test involves injection of a
few drops of Technetium-99m isotope is used. Half of thetechritium-99m would be gone in about 6 hours. It, however,takes about 24 hours for the radiation levels to reach what weare exposed to in day-to-day activities. Below is given therelative intensity of radiation as a function of time.
t(hrs) 0 1 3 5 7 9
. .
. . . . . .
9
-
8/18/2019 07 Regresi Non Linier
10/38
Example 1-Exponential Model cont.
The relative intensity is related to time by the equationt λ =
Find:
a) The value of the regression constants λ andb) The half-life of Technium-99m
c) Radiation intensity after 24 hours
10
-
8/18/2019 07 Regresi Non Linier
11/38
Plot of data
11
-
8/18/2019 07 Regresi Non Linier
12/38
n n f h M l t Ae λ γ =e va ue o λ is oun y so ving t e non inear equation
n t iλ
( ) 01
2
2
1
1=∑−∑=
=
=
=
n
i
t i
n t
it i
n
ii
i
i
i et et f λ λ
λ γ λ
1=in
==n
ii
i
e A 1
γ
=i
ie1
12
-
8/18/2019 07 Regresi Non Linier
13/38
Setting up the Equation in MATLAB
( ) 01
2
2
1
1=∑
∑−∑=
=
=
=
n
i
t in t
i
t i
t i
n
ii
i
i
i
i et e
et f λ λ
λ γ
γ λ
1=i
rs
γ 1.000 0.891 0.708 0.562 0.447 0.35513
-
8/18/2019 07 Regresi Non Linier
14/38
Settin u the E uation in MATLAB21
∑= n t
n
i
t i
t nie
λ
λ
λ γ
−1
121 ∑
−=
== i
in
it
ii
iie λ
.
t=[0 1 3 5 7 9]amma= 1 0.891 0.708 0.562 0.447 0.355
syms lamdasum1=sum(gamma.*t.*exp(lamda*t));
sum2=sum(gamma.*exp(lamda*t));sum3=sum(exp(2*lamda*t));
= .
f=sum1-sum2/sum3*sum4;14
-
8/18/2019 07 Regresi Non Linier
15/38
Calculating the Other Constant
The value of A can now be calculated
∑6 t i ie λ γ
∑
==6
2 t
i
i
e
Aλ
9998.0=
=1i
The exponential regression model then is
t e 1151.09998.0 −=γ
15
-
8/18/2019 07 Regresi Non Linier
16/38
Plot of data and regression curve
t e 1151.0 9998.0 −=γ
16
-
8/18/2019 07 Regresi Non Linier
17/38
( )241151.09998.0 −×= eγ 2103160.6 −×=
his result implies that only
10316.6 2× −
.9998.0 =
radioactive intensity is left after 24 hours.
17
-
8/18/2019 07 Regresi Non Linier
18/38
H m w rk • What is the half-life of technetium 99m
• Compare the constants of this regressionmo e wit t e one w ere t e ata is
transformed.• Write a program in the language of your
choice to find the constants of the model(fortran, matlab, matchad, maple)
18
-
8/18/2019 07 Regresi Non Linier
19/38
o ynom a o e
),(,...),,(),,( 2211 nn y x y x y xGiven best fitm
m xa... xaa y +++= 10)2( −≤ nm to a given data set.
),(nn
y x
m
m xa xaa y +++= K
10
),(22
y x
),(ii
y x
),(11
y x)( ii x f y −
Figure. Polynomial model for nonlinear regression of y vs. x data
19
-
8/18/2019 07 Regresi Non Linier
20/38
Polynomial Model cont.
The residual at each data point is given bymimiii xa xaa y E −−−−= ...10
T e sum o t e square o t e resi ua s t en is
∑=
=n
iir E S
1
2
( )∑=
−−−−=n
i
mimii xa xaa y
1
2
10 ...
20
-
8/18/2019 07 Regresi Non Linier
21/38
Polynomial Model cont.
To find the constants of the polynomial model, we set the derivativeswith respect to ia where∂ nS
,,1 mi K= equal to zero.
( ) 0)(....2
....
10
110
0
=−−−−−=∂∂
=−−−−−=∂
∑
=
i
nmimii
r
iimii
x xa xaa yaS
xaaa ya
n
MMMM
0)(....2110 =−−−−−=∂ ∑=
mi
i
mimii
m
r
x xa xaa ya
21
-
8/18/2019 07 Regresi Non Linier
22/38
Polynomial Model cont.
These equations in matrix form are given by⎤⎡
⎥
⎤
⎢
⎡
nn
⎥
⎥
⎥
⎥
⎢
⎢
⎢
⎢
=⎥⎥
⎥
⎤
⎢⎢
⎢
⎡
⎥
⎥
⎥
⎢
⎢
⎢
⎟
⎞⎜
⎛ ⎟
⎞⎜
⎛ ⎟
⎞⎜
⎛
⎟
⎠⎜
⎝ ⎟
⎠⎜
⎝
∑
∑
∑∑∑
∑∑=
+
==n
ii
ii
nmi
n
i
n
i
i
mi
ii
y x
y
a
a
x x x
x xn1
1
0
12
11
......
...
⎥
⎥
⎥
⎥
⎦⎢
⎢
⎢
⎢
⎣
⎦⎣
⎥
⎥
⎥
⎥
⎦⎢
⎢
⎢
⎢
⎣
⎟
⎠ ⎞
⎜
⎝ ⎛
⎟
⎠ ⎞
⎜
⎝ ⎛
⎟
⎠ ⎞
⎜
⎝ ⎛ ∑∑∑∑
=
=
==
+
=
===
n
ii
mi
mn
i
mi
n
i
mi
n
i
mi
y x
a
x x x11
2
1
1
1
...
...
...........
The above equations are then solved for maaa ,,, 10 K
22
-
8/18/2019 07 Regresi Non Linier
23/38
Example 2-Polynomial ModelRegress the thermal expansion coefficient vs. temperature data toa second order polynomial.
Temperature, T(oF)
Coefficient ofthermal
expansion, α 5.00E-06
6.00E-06
7.00E-06
o e f
f i c i e n
t , α
. temperature vs α
n n o F)
80 6.47×10 −6
40 6.24×10 −6
−40 5.72×10 −63.00E-06
4.00E-06
a l e x p a n s i o n
( i n
/ i n
/ o F )
−120 5.09×10 −6
−200 4.30×10 −6
−280 3.33×10 −61.00E-06
2.00E-06
-400 -300 -200 -100 0 100 200
o
T h e r
−340 2.45×10 − ,
Figure. Data points for thermal expansion coefficient vstemperature.
23
-
8/18/2019 07 Regresi Non Linier
24/38
Example 2-Polynomial Model cont.
2210 T aT aaα ++=We are to fit the data to the polynomial regression model
210 , , square of the residuals with respect to each variable and setting thevalues equal to zero to obtain
⎥
⎥
⎥
⎤
⎢
⎢
⎢
⎡
⎥
⎤
⎢
⎡⎥
⎥
⎥
⎤
⎢
⎢
⎢
⎡
⎞⎛ ⎞⎛ ⎞⎛
⎟
⎠ ⎞
⎜
⎝ ⎛
⎟
⎠ ⎞
⎜
⎝ ⎛
∑∑∑===
n
n
ii
nnn
n
ii
n
ii
aT T n
10
32
1
2
1α
⎥⎥
⎥
⎦⎢⎢
⎢
⎣
⎥⎦⎢⎣
⎥
⎥⎥
⎦⎢
⎢⎢
⎣
⎟
⎠ ⎞
⎜
⎝ ⎛
⎟
⎠ ⎞
⎜
⎝ ⎛
⎟
⎠ ⎞
⎜
⎝ ⎛ ⎠⎝ ⎠⎝ ⎠⎝ ∑∑∑∑
=
=
===
===n
iii
iii
n
ii
n
ii
n
ii
ii
ii
ii
T a
T T T 1
2
12
1
1
4
1
3
1
2
111
α
24
-
8/18/2019 07 Regresi Non Linier
25/38
Example 2-Polynomial Model cont.
The necessary summations are as followsTable. Data points for temperature vs. α 5
72 105580.2 ×=∑ iT
empera ure,(oF)
oe c en othermal expansion,
α (in/in/ oF)
80 6.47×10 −6
40 6.24×10 −6
1=i
77
1
3 100472.7 ×−=∑=i
iT
−40 5.72×10 −6
−120 5.09×10 −6
−200 4.30×10 −6
10
1
4 101363.2∑=
×=i
iT
57
103600.3 −×=α −280 3.33×10 −6
−340 2.45×10 −61=i
37
1
106978.2 −=
×−=∑i
iiT α
17
1
2 105013.8 −
=
×=∑i
iiT α
25
-
8/18/2019 07 Regresi Non Linier
26/38
Example 2-Polynomial Model cont.
⎤⎡ ×⎤⎡⎤⎡ ××− −5052 103600.3105800.2106000.80000.7 a
Using these summations, we can now calculate 210 , a ,aa
⎥
⎥
⎦⎢
⎢
⎣ ×
×−=⎥
⎥
⎦⎢
⎢
⎣⎥
⎥
⎦⎢
⎢
⎣ ××−×
×−××−−
−
1
3
2
11075
752
105013.8
106978.2
101363.2100472.7105800.2
100472.7105800.210600.8
a
a
Solving the above system of simultaneous linear equations we have
⎥
⎥
⎥
⎤
⎢
⎢
⎢
⎡
×−××
=⎥
⎥
⎤
⎢
⎢
⎡
−
−
−
11
9
6
1
0
102218.1
102782.6
100217.6
a
a
a
The polynomial regression model is then2
210α ++= T aT aa21196 T101.2218T106.2782106.0217 −−− ×−×+×=
26
-
8/18/2019 07 Regresi Non Linier
27/38
Linearization of Data
To find the constants of many nonlinear models, it results in solvingsimultaneous nonlinear equations. For mathematical convenience,some of the data for such models can be linearized. For exam le thedata for an exponential model can be linearized.
As shown in the previous example, many chemical and physical processesare overned b the e uation
bxae y =Taking the natural log of both sides yields,
Let y z ln= and aa ln0 =We now have a linear regression model where xaa z 10 +=(implying) oaea = with ba =1
27
-
8/18/2019 07 Regresi Non Linier
28/38
Linearization of data cont.
Using linear model regression methods, z x z xn
n
i
n n
iii − ∑∑ ∑
1
2
1
2
1
x xn
an
i
n
i
ii ⎟
⎠
⎞⎜
⎝
⎛ −
=
∑ ∑= =
== =
_
1
_
0 xa z a −=
Once 1, aa o are found, the original constants of the model are found as
0
1
aea =
28
-
8/18/2019 07 Regresi Non Linier
29/38
Example 3-Linearization of dataMany patients get concerned when a test involves injection of a radioactive
material. For example for scanning a gallbladder, a few drops of Technetium-99m isotope is used. Half of the technetium-99m would be gone in about 6 hours. It, however, takes about 24 hours for the radiation levels to reach whatwe are exposed to in day-to-day activities. Below is given the relative intensityof radiation as a function of time .
Table. Relative intensity of radiation as a function 1 , γ
t(hrs) 0 1 3 5 7 9
1.000 0.891 0.708 0.562 0.447 0.355γ
of time
0.5
n s i
t y o
f r a d
i a t i o n
0
0 5 10
R e l a t
i v e i n t
,
Figure. Data points of relative radiation intensity
vs. time29
-
8/18/2019 07 Regresi Non Linier
30/38
Example 3-Linearization of data cont.
Find:a) The value of the regression constants A λ and
T e a - i e o Tec nium-99m
c) Radiation intensity after 24 hours
The relative intensity is related to time by the equationt Aeλ γ =
30
-
8/18/2019 07 Regresi Non Linier
31/38
Example 3-Linearization of data cont.
t Ae λ γ =Exponential model given as,
γ += nn Assuming γ ln= z , ( ) Aa o ln= and λ =1a we obtain
t aa z 10 +=This is a linear relationship between z and t
31
-
8/18/2019 07 Regresi Non Linier
32/38
Example 3-Linearization of data cont.
Using this linear relationship, we can calculate 10 , aa∑∑ ∑−n
i
n n
iii z t z t n
where
∑ ∑= =
== =
⎟
⎠
⎞⎜
⎝
⎛ −=
n
i
n
ii
t t n
a
1
2
1
2
1
1
t a z a 10 −=
1a=λ
0a
e=
32
-
8/18/2019 07 Regresi Non Linier
33/38
Example 3-Linearization of Data cont.
Summations for data linearization are as followsTable. Summation data for linearization of data model With 6=n
1 0 1 0.00000− 0.0000− 0.0000
i it iγ ii z γ ln= ii z t 2
it 000.25
1
∑=
=i
it
−=6
8778.2 z 3456
3579
.0.7080.5620.4470.355
.−0.34531−0.57625−0.80520−1.0356
.−1.0359−2.8813−5.6364−9.3207
.9.000025.00049.00081.000
=1ii
∑=
−=6
1
990.18i
ii z t
25.000 −2.8778 −18.990 165.00∑ 00.1656
1
2 =∑=i it
33
-
8/18/2019 07 Regresi Non Linier
34/38
Example 3-Linearization of Data cont.
Calculating 10, aa
( ) ( )( )218778.225990.186 −−−=a 11505.0−=
. −
( )25
11505.08778.2
0 −−−
=a 4
106150.2 −
×−=
Since( ) Aa ln0 =
e=4106150.2 −×−= e 99974.0=
also11505.01 −== aλ
34
-
8/18/2019 07 Regresi Non Linier
35/38
Example 3-Linearization of Data cont.Resulting model is t e 11505.099974.0
−×=γ
1t 11505.0−
0.5
Relative
Intensity
e .. ×=γ
oRadiation,
0
0 5 10
Time, t (hrs)
Figure. Relative intensity of radiation as a function oftemperature using linearization of data model.
35
-
8/18/2019 07 Regresi Non Linier
36/38
Example 3-Linearization of Data cont.
The regression formula is thent e 11505.099974.0 −×=γ 1=
02 =t
( ) ( )e.e. .t . 9997402
1999740 0115050115050 =× −−
( )hours.t
.t .
.e .
02486
50ln115050
50
==−
=−
36
-
8/18/2019 07 Regresi Non Linier
37/38
Example 3-Linearization of Data cont.c) The relative intensity of radiation after 24 hours is then
( )2411505.099974.0 −= eγ .=
This implies that only %3216.610099983.0
103200.6 2 =×× −
of the radioactive
material is left after 24 hours.
37
-
8/18/2019 07 Regresi Non Linier
38/38
Comparison
Table. Comparison for exponential model with and without datalinearization.
With data linearization(Example 3)
Without data linearization(Example 1)
A 0.99974 0.99983
− . − .
Half-Life (hrs) 6.0248 6.0232
Relative intensityafter 24 hrs.
6.3200×10 −2 6.3160×10 −2
The values are very similar so data linearization was suitable tofind the constants of the nonlinear exponential model in this
.
38