Nbm Reg Sim Nonlinearwith-١
Nbm Reg Sim Nonlinearwith-١
Nbm Reg Sim Nonlinearwith-١
nb 1
Introduction
This worksheet illustrates finding the constants of nonlinear regression models with data linearization. Three common
nonlinear models are illustrated - 1) Exponential 2) Power 3) Saturation Growth.
Given n data points ( x1 , y1 ), ( x2 , y2 ), ( x3 , y3 ), .... , ( xn , yn ), best fit one of the following models to the data.
Exponential: y = aebx
Power: y = axb
ax
Saturation: y = ÅÅÅÅ
ÅÅÅÅÅÅ
b+x
To learn more about Nonlinear Regression with data linearization, see the Nonlinear Regression worksheet.
Below are the input parameters to begin the simulation. This is the only section that requires user input. The user can
change the values below and Mathematica will calculate the nonlinear regression model using data linearization for the
corresponding model that the user chooses.
Input Parameters:
nbm_reg_sim_nonlinearwith.nb 2
n=5
è Array of x values, x
è Array of y values, y
modeltype = "exponential"
exponential
The following manipulation must first be made to each model in order to linearize the data:
Exponential: ln(y) = ln(a) + bx (taking the natural log of both sides) (2.1)
Power: ln(y) = ln(a) + bln(x) (taking the natural log of both sides) (2.2)
1 b 1 1
Growth: ÅÅÅÅy = ÅÅÅÅa ÅÅÅÅx + ÅÅÅÅa (taking the reciprocal of both sides then rearranging) (2.3)
Once the data is linearized, substitutions are made so as to apply a direct solution approach using least squares regression
method for a straight line. In this section, a procedure is written for each model. Once a specific nonlinear model is called
for with the modeltype variable, the proper procedure will calculate the coefficients for that model using data linearization.
Note: See Nonlinear Regression notes for explanation of the model.
nbm_reg_sim_nonlinearwith.nb 3
After data linearization, the following substitutions are made to Equation 2.1
let z = ln(y)
a0 = ln (a), implying a = ea0
a1 = b
The data z versus x now takes the form of a linear model:
z = a0 + a1 x (2.4)
In the exponential model procedure, least squares linear regression method is used to solve for the a0 and a1 coefficients
which are then used to determine the original constants of the exponential model, a and b, where y = aebx .
Off@General::spellD
E;
sumz sumx
a0 = NA − a1 ∗
n n
a = E ^ a0;
b = a1;
a; bE;
After data linearization, the following substitutions are made to Equation 2.2
let z = ln(y)
w = ln(x)
a0 = lnHaL, implying a = ea0
a1 = b
The data z versus w now takes the form of a linear model:
z = a0 + a1 w (2.5)
In the power model procedure, least squares linear regression method is used to solve for the a0 and a1 coefficients which
are then used to determine the originial constants of the power model, a and b, where y = axb .
nbm_reg_sim_nonlinearwith.nb 4
z = Array@0, 81, n<D; w = Array@0, 81, n<D; sumz = 0; sumw = 0; sumwz = 0; sumww = 0;
PowerModel@x_, y_, n_D := ModuleA8z, w, sumz, sumw, sumwz, sumww<,
After data linearization, the following substitutions are made to Equation 2.3
let z = 1/y
a0 = 1 ê a, implying a = 1 ê a0
q = 1/x
a1 = b/a, implying b = a1 ê a0
The data z versus q now takes the form of a linear model:
z = a0 + a1 q (2.6)
In the saturation growth model procedure, least squares linear regression method is used to solve for the a0 and a1 coeffi-
ax
cients which are then used to determine the original constants of the growth model, a and b, where y = ÅÅÅÅ
ÅÅÅÅÅÅ .
b+x
z = Array@0, 81, n<D; q = Array@0, 81, n<D; sumq = 0; sumz = 0; sumqz = 0; sumqq = 0;
GrowthModel@x_, y_, n_D := ModuleA8z, q, sumq, sumz, sumqz, sumqq, a1, a0<,
b = N@a1 ê a0D;E;
nbm_reg_sim_nonlinearwith.nb 5
The proper regression model is assigned below, returning the constants of the model that was chosen with the modeltype
variable.
240
220
200
180
160
140
120
100
10 20 30 40 50 60
nbm_reg_sim_nonlinearwith.nb 6
Conclusion
Mathematica helped us apply our knowledge of linear regression method to regress a given data set to a nonlinear model
Question 1: You are working for Valdez SpillProof Oil Company as a petroleum engineer. Your boss is asking you to
estimate the future life of an oil well. The analysis used in the industry is called the decline curve analysis where the
barrels of oil produced per unit time are plotted against time, and the curve is extrapolated. One of the standard curves used
is harmonic decline model, that is
q= b
1 + at
a) Find the constants of the regression model. Hint: You are allowed to linearize the data if possible.
b) Find the total life of an oil field if 5 barrels per day is considered the production at which the field needs to be aban-
doned for further production.
c) What does b stand for?
Question 2: It is desired to obtain a functional relationship between the mass density ρ of air and the altitude h above the
sea level for the dynamic analysis of bodies moving within earth's atmosphere. Use the approximation ρ = k1 e-k2 h to fit
the data given below by regression analysis. Find the constants k1 and k2. You are allowed to linearize the data.
HkilometersL Hkg ê m3 L
Altitude Mass Density
0.32 1.15
0.64 1.10
1.28 1.05
1.60 0.95
Question 3: It is suspected from theoretical considerations that the rate of flow from a fire hose is proportional to some
power of the nozzle pressure. Determine whether the speculation is true. What is the exponent of the data. Assume
pressure data is more accurate. You are allowed to linearize the data.
References