26
Lesson 4 - 4 Nonlinear Regression: Transformations

Lesson 4 - 4

Embed Size (px)

DESCRIPTION

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 - PowerPoint PPT Presentation

Citation preview

Page 1: Lesson 4 - 4

Lesson 4 - 4

Nonlinear Regression:

Transformations

Page 2: Lesson 4 - 4

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

Page 3: Lesson 4 - 4

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)

Page 4: Lesson 4 - 4

Non-linear Scatter Diagrams

Exponential Exponential Power

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

Page 5: Lesson 4 - 4

Exponential Data

● We would like to fit an exponential model

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(a bx) = log(a) + log(bx) = log a + x log b

Page 6: Lesson 4 - 4

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

Page 7: Lesson 4 - 4

Least Squares on Exponential Model

● We started with an exponential model

y = a bx

● 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

Page 8: Lesson 4 - 4

Harley Davidson Dataset

Year (x) Closing Price (y)

• 1990 1.1609• 1991 2.6988• 1992 4.5381• 1993 5.3379• 1994 6.8032• 1995 7.0328• 1996 11.5585

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

Page 9: Lesson 4 - 4

Exponential Example

• The scatter diagram below appears to be exponential (curved) and not linear

• A line is not an appropriate model

Page 10: Lesson 4 - 4

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

Page 11: Lesson 4 - 4

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)

Page 12: Lesson 4 - 4

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

Page 13: Lesson 4 - 4

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

Page 14: Lesson 4 - 4

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

Page 15: Lesson 4 - 4

Part Two

Power Models

Page 16: Lesson 4 - 4

Power Model Data

● We would now like to fit an power model

y = a xb

● 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

Page 17: Lesson 4 - 4

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

Page 18: Lesson 4 - 4

Least Squares on Power Model

● We started with a power model

y = a bx

● We transformed that into a linear model

Y = A + B X

● 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

Page 19: Lesson 4 - 4

Harley Davidson Dataset

Year (x) Closing Price (y)

• 1990 1.1609• 1991 2.6988• 1992 4.5381• 1993 5.3379• 1994 6.8032• 1995 7.0328• 1996 11.5585

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

Page 20: Lesson 4 - 4

Power Function Example

• The scatter diagram below appears to be exponential (curved) and not linear

• A line is not an appropriate model

Page 21: Lesson 4 - 4

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

Page 22: Lesson 4 - 4

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)

Page 23: Lesson 4 - 4

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

Page 24: Lesson 4 - 4

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

Page 25: Lesson 4 - 4

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

Page 26: Lesson 4 - 4

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