# Nonlinear Regression Quiz Solution

advertisement ```Multiple-Choice Test
Nonlinear Regression
Regression
COMPLETE SOLUTION SET
1. When using the transformed data model to find the constants of the regression model y  ae bx
to best fit x1 , y1 , x2 , y 2 ,........xn , y n , the sum of the square of the residuals that is minimized is
n

(A)  y i  aebxi

2
i 1
n
(B)
 ln( y )  ln a   bx 
2
i
i 1
i
n
(C)
  y  ln a   bx 
i 1
2
i
i
n
(D)  ln( y i )  ln a   b ln( xi ) 
2
i 1
Solution
The correct answer is (B).
Taking the natural log of both sides of the regression model
y  ae bx
gives
ln  y   ln a   bx
The residual at each data point xi is
Ei  ln  yi   ln a   bxi
The sum of the square of the residuals for the transformed data is
n
S r   Ei2
i 1
n
  ln  y i   ln a   bxi 
i 1
2
2. It is suspected from theoretical considerations that the rate of water flow from a firehouse is
proportional to some power of the nozzle pressure. Assume pressure data is more accurate. You
are transforming the data.
Flow rate, F (gallons/min) 96 129 135 145 168 235
Pressure, p (psi)
11 17
20
25
40
55
The exponent of the nozzle pressure in the regression model F  ap most nearly is
(A) 0.49721
(B) 0.55625
(C) 0.57821
(D) 0.67876
b
Solution
The correct answer is (A).
The transforming of the above data is done as follows.
F  ap b
ln( F )  ln( a )  b ln( p )
z  a 0  bx
where
z  ln F 
x  ln( p )
a0  ln a 
implying
a  ea0
There is a linear relationship between z and x.
Linear regression constants are given by
n
b
n
n
n xi zi  xi  zi
i 1
i 1
i 1


n x    xi 
i 1
 i 1 
n
n
2
2
i
n
a0 
Since
n
n
n
i 1
i 1
 xi2  zi   xi  xi zi
i 1
i 1
2


n xi2    xi 
i 1
 i 1 
n
n
n6
6
x z
i 1
i i
 ln( 11)  ln( 96)  ln( 17)  ln( 129)  ln( 20)  ln( 135)
 ln( 25)  ln( 145)  ln( 40)  ln( 168)  ln( 55)  ln( 235)
 96.208
6
x
i 1
i
 ln( 11)  ln( 17)  ln( 20)  ln( 25)  ln( 40)  ln( 55)  19.142
i
 ln( 96)  ln( 129)  ln( 135)  ln( 145)  ln( 168)  ln( 235)  29.890
6
z
i 1
6
x
i 1
then
2
i
 (ln( 11)) 2  (ln( 17)) 2  (ln( 20)) 2  (ln( 25)) 2  (ln( 40)) 2  (ln( 55)) 2  62.779
6  96.208  19.142  29.890
6  62.779  19.1422
577.25  572.15

376.67  366.41
 0.49721
Can you now find what a is?
b
3. The transformed data model for the stress-strain curve   k1e  k2 for concrete in
compression, where  is the stress and  is the strain, is
(A) ln    ln k1   ln    k2
 
(B) ln    ln k1   k2
 
 
(C) ln    ln k1   k2
 
(D) ln    ln( k1 )  k2
Solution
The correct answer is (B)
  k1e  k 
2
The model can be rewritten as

 k1 e  k 2 

To transform the data, we take the natural log of both sides
 
ln    ln k1e  k 2
 
 ln k1   ln e  k 2



 ln k1   k 2 

4. In nonlinear regression, finding the constants of the model requires solving simultaneous
nonlinear equations. However in the exponential model y  ae bx that is best fit
to x1 , y1 , x2 , y2 ,........, xn , yn , the value of b can be found as a solution of a single nonlinear
equation. That nonlinear equation is given by
n
n
n
i 1
i 1
i 1
(A)  y i xi e bxi   y i e bxi  xi  0
n
n
(B)
 yi xi e bxi 
i 1
ye
bxi
i
i 1
n
e
n
x e
i 1
2 bxi
2 bxi
i
0
i 1
n
n
(C)
 yi xi e bxi 
i 1
ye
bxi
i
i 1
n
e
n
e
bxi
0
i 1
2 bxi
i 1
n
n
(D)  y i e bxi 
ye
i 1
i 1
n
bxi
i
e
2 bxi
n
x e
i 1
i
2 bxi
0
i 1
Solution
The correct answer is (B).
Given x1 , y1 , x2 , y2 ,........, xn , yn , best fit y  ae bx to the data. The variables a and b are the
constants of the exponential model. The residual at each data point xi is
Ei  yi  ae bxi
(1)
The sum of the square of the residuals is
n
S r   Ei2
i 1
n

  yi  aebxi

2
(2)
i 1
To find the constants a and b of the exponential model, we find where S r is a local minimum or
maximum by differentiating with respect to a and b and equating the resulting equations to
zero.
n
S r
  2 y i  ae bxi  e bxi  0
a
i 1
n
S r
  2 y i  ae bxi  axi e bxi  0
b
i 1






(3a,b)
or
n
n
i 1
i 1
  yi ebxi  a  e 2bxi  0
n
n
i 1
i 1
 yi xiebxi  a xie2bxi  0
(4a,b)
Equations (4a) and (4b) are simultaneous nonlinear equations with constants a and b . This is
unlike linear regression where the equations to find the constants of the model are simultaneous
but linear. In general, iterative methods (such as the Gauss-Newton iteration method, Method of
Steepest Descent, Marquardt's Method, Direct search, etc) must be used to find values of a and
b.
However, in this case, from Equation (4a), a can be written explicitly in terms of b as
n
a
ye
i 1
n
bxi
i
e
(5)
2 bxi
i 1
Substituting Equation (5) in (4b) gives
n
n
 yi xiebxi 
i 1
ye
i 1
n
bxi
i
e
2 bxi
n
xe
i 1
i
2 bxi
0
i 1
This equation is still a nonlinear equation in terms of b , and can be solved best by numerical
methods such as the bisection method or the secant method.
You can now show that these values of of a and b, correspond to a local minimum, and since the
above nonlinear equation has only one real solution, it corresponds to an absolute minimum.
5. There is a functional relationship between the mass density p of air and the altitude h above
the sea level.
Altitude above sea level, h (km) 0.32 0.64 1.28 1.60
1.15 1.10 1.05 0.95
Mass Density,  (kg/m3)
In the regression model   k1e  k2h , the constant k 2 is found as k 2  0.1315 . Assuming the
mass density of air at the top of the atmosphere is 1 / 1000th of the mass density of air at sea level.
The altitude in kilometers of the top of the atmosphere most nearly is
(A) 46.2
(B) 46.6
(C) 49.7
(D) 52.5
Solution
The correct answer is (D).
Note to the student: See the alternative answer given later as that is quite a bit shorter.
Since
k 2  0.1315
is given, the sum of the square of the residual is
n

S r    i  k1e 0.1315hi

2
i 1
First we need to find the value of the constant k1 .



n
Sr
  2 i  k1e 0.1315hi  e 0.1315hi  0
k1 i 1
n
n
i 1
i 1
  i e  0.1315hi  k1  e  20.1315hi  0
Thus,
n
k1 
 e
i 1
n
 0.1315hi
i
e
 0.263hi
i 1
Since
n4
n
 e
i 1
i
 0.1315hi
 1.15e  0.13150.32  1.10e  0.13150.64  1.05e  0.13151.28  0.95e  0.13151.60
 1.15  0.95879  1.10  0.91928  1.05  0.84508  0.95  0.81026
 3.7709
n
e
 0.263hi
 e  0.2630.32  e  0.2630.64  e  0.2631.28  e  0.2631.60
i 1
 0.91928  0.84508  0.71417  0.65652
 3.1351
the value of the constant k1 is
3.7709
k1 
3.1351
 1.2028
Hence
  k1e k 2 h
 1.2028e 0.1315h kg m3
sea  level 1.2028e0.13150
 1.2028 kg m3
1
 top 
sea  level
1000
1

 1.2028
1000
 0.0012028 kg m 3
 top  k1e
0.1315 htop
0.0012028
1.2028
ln 0.001
htop 
 0.1315
 52.530 km
e
 0.1315 htop

Alternative Answer:
Note to the student: Do we really need to find k1 for this problem?
  k1e 0.1315h
 sea level  k1e 0.13150
 k1
 top  k1e
 0.1315htop
 sea level
k1

 0.1315h
 top
k1e
top
sealevel

1
sealevel e
1000
 1 
ln 

1000 
htop  
 0.1315
 52.530 km
1
0.1315htop
6. A steel cylinder at 80&deg; F of length 12&quot; is placed in a commercially available liquid nitrogen
bath (315 F) . If the thermal expansion coefficient of steel behaves as a second order
polynomial function of temperature and the polynomial is found by regressing the data below,
Temperature,
T (&deg;F)
 320
 240
 160
 80
0
80
Thermal expansion
Coefficient, 
(  in/in/&deg;F)
2.76
3.83
4.72
5.43
6.00
6.47
the reduction in the length of the cylinder in inches most nearly is
(A) 0.0219
(B) 0.0231
(C) 0.0235
(D) 0.0307
Solution
The correct answer is (C).
We are fitting the above data to the following polynomial.
  a0  a1T  a2T 2

Sr   i  a0  a1Ti  a2Ti 2

2
There is a quadratic relationship between the thermal expansion coefficient and the temperature,
and the coefficients a0 , a1 , and a2 are found as follows
n
S r
  2 i  a0  a1Ti  a 2Ti 2  1  0
a0 i 1
n
S r
  2 i  a0  a1Ti  a 2Ti 2  Ti   0
a1 i 1
n
S r
  2 i  a0  a1Ti  a 2Ti 2  Ti 2   0
a 2 i 1
which gives

 n


 n
  Ti 
 i n1 
 T 2 
i
 
 i 1 
 n

  Ti 
 i 1 
 n 2
  Ti 
 i 1 
 n 3
  Ti 
 i 1 
 n 2 
 n
  Ti  
 i
 i 1   a   i 1
0
 n 3     n
  Ti   a1    Ti  i
 i 1      i 1
a
n
 n 4    2   T 2
  Ti  
i i
 i 1
 i 1  








Table 1 Summations for calculating constants of model.
 (in/in/oF)
T (oF)
1
80
6.4700  10–6
T2
6.4000  103
2
0
6.0000  10–6
0.0000
3
 80
4
i
T3
5.1200  105
0.0000
5.4300  10
6.4000  10
3
–5.1200  105
 160
4.7200  10–6
2.5600  104
–4.0960  106
5
 240
3.8300  10–6
5.7600  104
–1.3824  107
6
 320
2.7600  10–6
1.0240  105
–3.2768  107
1.9840  105
 5.0688  107
–6
6

i 1
2.9210  10–5
 7.2000  102
Table 1 (cont)
T 
T 2 
5.1760  10–4
4.1408  10–2
1
T4
4.0960  107
2
0.0000
0.0000
0.0000
3
4.0960  107
–4.3440  10–4
3.4752  10–2
4
6.5536  108
–7.5520  10–4
1.2083  10–1
5
3.3178  109
–9.1920  10–4
2.2061  10–1
6
1.0486  1010 –8.8320  10–4
2.8262  10–1
1.4541  1010 –2.4744  10–3
7.0022  10–1
i
6

i 1
We have

6

2
 7.2000  10
 1.9840  105

 7.2000  102
1.9840  105
 5.0688  107
1.9840  105  a0   2.9210 10 5 



 5.0688  107  a1    2.4744  103 
1.4541 1010  a2   7.0022 10 1 
Solving the above system of simultaneous linear equations, we get
6
a 0   6.0238  10 
 a    6.3319  10 9 

 1 
a 2   1.1965  10 11 
The polynomial regression model is
α  a0  a1T  a2T 2
 6.0237 106  6.3375 109 T  1.1942 1011T 2
Since
L  L0 
Tfluid
  dT
Troom
315
 12 
 6.0237 10
6

 6.3375  109 T  1.1942 1011T 2 dT
80
315

6.3375  109 2 1.1942  1011 3 
 12  6.0237  106 T 
T 
T 
2
3

 80


 12  6.0237  10  315  3.1687 10  315   3.9807  10  315 
 12  6.0237  10 80  3.1687  10 80   3.9807  10 80 
 12   1.4586  10  5.0014  10 
315
 12  6.0237  106 T  3.1687  109 T 2  3.9807 1012 T 3 80
6
9
6
3
 0.023505&quot;
9
4
12
2
2
12
3
3
```