260 likes | 435 Views
Lesson 4 - 4. Nonlinear Regression: Transformations. Objectives. Change exponential expressions to logarithmic expressions and logarithmic expressions to exponential expressions Simplify expressions containing logarithms Use logarithmic transformations to linearize exponential relations
E N D
Lesson 4 - 4 Nonlinear Regression: Transformations
Objectives • Change exponential expressions to logarithmic expressions and logarithmic expressions to exponential expressions • Simplify expressions containing logarithms • Use logarithmic transformations to linearize exponential relations • Use logarithmic transformations to linearize power relations
Vocabulary • Response Variable – variable whose value can be explained by the value of the explanatory or predictor variable • Predictor Variable – independent variable; explains the response variable variability • Lurking Variable – variable that may affect the response variable, but is excluded from the analysis • Positively Associated – if predictor variable goes up, then the response variable goes up (or vice versa) • Negatively Associated – if predictor variable goes up, then the response variable goes down (or vice versa)
Non-linear Scatter Diagrams • Some relationships that are nonlinear can be modeled with exponential or power models • y = a bx (with b > 1) • y = a bx (with b < 1) • y = a xb Exponential Exponential Power
Exponential Data • We would like to fit an exponentialmodel y = a bx • We would still like to use our least-squares linear regression techniques on this model • If we take the logarithms of both sides, we get log y = log a + x log b because log(abx) = log(a) + log(bx) = log a + x log b
Exponential to Linear Transform • We modify this transformed equation log y = log a + x log b • Define these new variables • Y = log y • A = log a • B = log b • X = x • Then this equation becomes Y = A + B X
Least Squares on Exponential Model • We started with an exponential model y = abx • We transformed that into a linear model Y = A + B X • After we solve the linear model, we match up • b = 10B • a = 10A • In this way, we are able to use the method of least-squares to find an exponential model
Harley Davidson Dataset Year (x) Closing Price (y) Year (x) Closing Price (y) 1997 13.4799 1998 23.5424 1999 31.9342 2000 39.7277 2001 54.31 2002 46.20 2003 47.53 2004 60.75 • 1990 1.1609 • 1991 2.6988 • 1992 4.5381 • 1993 5.3379 • 1994 6.8032 • 1995 7.0328 • 1996 11.5585
Exponential Example • The scatter diagram below appears to be exponential (curved) and not linear • A line is not an appropriate model
Fitting an Exponential Model We use Y = log y and X = x • The first observation is x = 1 and y = 1.1609, thus the first observation of the transformed data is X = 1 and Y = log 1.1609 = 0.0648 • The second observation is x = 2 and y = 2.6988, thus the second observation of the transformed data is X = 2 and Y = log 2.6988 = 0.4312 • We continue and take logs of all of the y values
Using your Calculator • To get the scatter plot we inputted x-values into L1 and the y-values into L2 • To change the y-values into logs we go to the top of L3 and hit LOG(L2) ENTER and then use LINREG to find a and b (first part of the slide after next) • Or a simpler way yet, use the ExpReg calculation under STAT and CALC and get it directly without having to convert back (last line of the slide after next)
Transformed Line • The scatter diagram of the transformed data (Y and X) is more linear • We now calculate least-squares regression line for this data
Least Squares to Exponential • The least squares line is Y = 0.1161 X + 0.2107 • B = 0.1161 • A = 0.2107 • This is transformed back to • b = 10B = 100.1161 = 1.3064 and • a = 10A = 100.2107 = 1.6244, so y = 1.6244 (1.3064)x
Exponential Model • We now plot y = 1.624 (1.306)x, our exponential model, on the original scatter diagram • This is a better fit to the data, but we need to be careful if we try to extrapolate
Part Two Power Models
Power Model Data • We would now like to fit an powermodel y = axb • We would still like to use our least-squares linear regression techniques on this model • If we take the logarithms of both sides, we get log y = log a + b log x because log(a xb) = log(a) + log(xb) = log a + b log x
Power Function to Linear Transform • We modify this transformed equation log y = log a + x log b • Define these new variables • Y = log y • A = log a • B = log b • X = x • Then this equation becomes Y = A + B X
Least Squares on Power Model • We started with a power model y = a bx • We transformed that into a linear model Y = A + BX • After we solve the linear model, we find that • b = B • a = 10A • In this way, we are able to use the method of least-squares to find a power model
Harley Davidson Dataset Year (x) Closing Price (y) Year (x) Closing Price (y) 1997 13.4799 1998 23.5424 1999 31.9342 2000 39.7277 2001 54.31 2002 46.20 2003 47.53 2004 60.75 • 1990 1.1609 • 1991 2.6988 • 1992 4.5381 • 1993 5.3379 • 1994 6.8032 • 1995 7.0328 • 1996 11.5585
Power Function Example • The scatter diagram below appears to be exponential (curved) and not linear • A line is not an appropriate model
Fitting a Power Function Model We use Y = log y and X = log x • The first observation is x = 1 and y = 1.1609, thus the first observation of the transformed data isX = log 1 = 0 and Y = log 1.1609 = 0.0648 • The second observation is x = 2 and y = 2.6988, thus the second observation of the transformed data is X = log 2 = .3010 and Y = log 2.6988 = 0.4312 • We continue and take logs of all of the x values and all the y values
Using your Calculator • To get the scatter plot we inputted x-values into L1 and the y-values into L2 • To change the x-values into logs we go to the top of L3 and hit LOG(L1) ENTER and then repeat using L4 and the y-values (L2). Then use LINREG to find a and b (first part of the slide after next) • Or a simpler way yet, use the PwrReg calculation under STAT and CALC and get it directly without having to convert back (last line of the slide after next)
Transformed Line • The scatter diagram of the transformed data (Y and X) is more linear • We now calculate least-squares regression line for this data
Least Squares to Power • The least squares line is Y = 1.5252 X – 0.0928 • B = 1.5252 • A = –0.0928 • This is transformed back to • b = B = 1.5252 and • a = 10A = 0.8076, so y = 0.8076 x1.5252
Power Model • We now plot y = 0.8076 x1.5252, our power model, on the original scatter diagram • This is a better fit to the data, but we need to be careful if we try to extrapolate
Summary and Homework • Summary • Transformations can enable us to construct certain nonlinear models • Exponential models, or y = a bx, can be created using least-squares techniques after taking logarithms of both sides • Power models, or y = a xb, can also be created using least-squares techniques after taking logarithms of both sides • Homework