Transforming to achieve linearity

Slides:



Advertisements
Similar presentations
Copyright © 2010 Pearson Education, Inc. Slide A least squares regression line was fitted to the weights (in pounds) versus age (in months) of a.
Advertisements

Chapter 12: More About Regression
Chapter 4 Review: More About Relationship Between Two Variables
4.1: Linearizing Data.
Chapter 10: Re-Expressing Data: Get it Straight
Chapter 10 Re-Expressing data: Get it Straight
Get it Straight!! Chapter 10
Chapter Four: More on Two- Variable Data 4.1: Transforming to Achieve Linearity 4.2: Relationships between Categorical Variables 4.3: Establishing Causation.
Lesson Quiz: Part I 1. Change 6 4 = 1296 to logarithmic form. log = 4 2. Change log 27 9 = to exponential form = log 100,000 4.
Copyright © 2010, 2007, 2004 Pearson Education, Inc. Chapter 10 Re-expressing Data: Get it Straight!
Chapter 10 Re-expressing the data
Re-expressing the Data: Get It Straight!
S ECTION 4.1 – T RANSFORMING R ELATIONSHIPS Linear regression using the LSRL is not the only model for describing data. Some data are not best described.
Lectures 4a,4b: Exponential & Logarithmic Functions 1.(4.1) Exponential & Logarithmic Functions in Biology 2.(4.2) Exponential & Logarithmic Functions:
+ Hw: pg 788: 37, 39, 41, Chapter 12: More About Regression Section 12.2b Transforming using Logarithms.
More about Relationships Between Two Variables
CHAPTER 12 More About Regression
Chapter 4: More on Two-Variable (Bivariate) Data.
The Practice of Statistics
Transforming Relationships
Bivariate Data When two variables are measured on a single experimental unit, the resulting data are called bivariate data. You can describe each variable.
Chapter 10: Re-Expressing Data: Get it Straight AP Statistics.
M25- Growth & Transformations 1  Department of ISM, University of Alabama, Lesson Objectives: Recognize exponential growth or decay. Use log(Y.
Relationships If we are doing a study which involves more than one variable, how can we tell if there is a relationship between two (or more) of the.
DO NOW Read Pages 222 – 224 Read Pages 222 – 224 Stop before “Goals of Re-expression” Stop before “Goals of Re-expression” Answer the following questions:
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Chapter 10 Re-expressing Data: Get It Straight!. Slide Straight to the Point We cannot use a linear model unless the relationship between the two.
Lecture 6 Re-expressing Data: It’s Easier Than You Think.
Copyright © 2010 Pearson Education, Inc. Slide A least squares regression line was fitted to the weights (in pounds) versus age (in months) of a.
Bivariate Data Analysis Bivariate Data analysis 4.
Chapter 8 Linear Regression HOW CAN A MODEL BE CREATED WHICH REPRESENTS THE LINEAR RELATIONSHIP BETWEEN TWO QUANTITATIVE VARIABLES?
Reexpressing Data. Re-express data – is that cheating? Not at all. Sometimes data that may look linear at first is actually not linear at all. Straight.
If the scatter is curved, we can straighten it Then use a linear model Types of transformations for x, y, or both: 1.Square 2.Square root 3.Log 4.Negative.
Chapter 5 Lesson 5.4 Summarizing Bivariate Data 5.4: Nonlinear Relationships and Transformations.
Re-Expressing Data. Scatter Plot of: Weight of Vehicle vs. Fuel Efficiency Residual Plot of: Weight of Vehicle vs. Fuel Efficiency.
Copyright © 2010 Pearson Education, Inc. Chapter 10 Re-expressing Data: Get it Straight!
Copyright © 2010, 2007, 2004 Pearson Education, Inc. Chapter 10 Re-expressing Data: Get it Straight!
Chapter 10 Notes AP Statistics. Re-expressing Data We cannot use a linear model unless the relationship between the two variables is linear. If the relationship.
Chapter 4 More on Two-Variable Data. Four Corners Play a game of four corners, selecting the corner each time by rolling a die Collect the data in a table.
Statistics 10 Re-Expressing Data Get it Straight.
Copyright © 2010, 2007, 2004 Pearson Education, Inc. Chapter 10 Re-expressing Data: Get it Straight!
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
The Practice of Statistics, 5th Edition Starnes, Tabor, Yates, Moore Bedford Freeman Worth Publishers CHAPTER 12 More About Regression 12.2 Transforming.
Chapter 12.2A More About Regression—Transforming to Achieve Linearity
Chapter 12: More About Regression
Let’s Get It Straight! Re-expressing Data Curvilinear Regression
Transforming Relationships
Is this data truly linear?
Re-expressing the Data: Get It Straight!
Chapter 12: More About Regression
Chapter 10 Re-Expressing data: Get it Straight
Re-expressing Data: Get it Straight!
Re-expressing the Data: Get It Straight!
Re-expressing the Data: Get It Straight!
Chapter 12: More About Regression
Re-expressing Data:Get it Straight!
CHAPTER 12 More About Regression
Transforming Relationships
Chapter 12: More About Regression
Chapter 12: More About Regression
Lecture 6 Re-expressing Data: It’s Easier Than You Think
Chapter 12: More About Regression
CHAPTER 12 More About Regression
Chapter 12: More About Regression
Chapter 12: More About Regression
Chapter 12: More About Regression
Chapters Important Concepts and Terms
CHAPTER 12 More About Regression
Re-expressing Data: Get it Straight!
Presentation transcript:

Transforming to achieve linearity

Body and brain weight of 96 species of mammals For this data, r = 0.86, but why might we not trust the given correlation? If we remove the elephant, the correlation changes to r = 0.5!

Body and brain weight of 96 species of mammals Here is a close up of the blob in the lower-left corner. Is the data linear? The data is not exactly linear- notice the data bends to the right as body weight increases.

How does our data look now? Biologists know that data on sizes often behave better if we take logarithms before doing more analysis. This plot graphs the logarithm of brain weight against the logarithm of body weight for all 96 species. How does our data look now?

Applying a function such as the logarithm or square root to a quantitative variable is called transforming or re-expressing the data.

In this chapter, we'll focus on the third reason. Why transform? To make the distribution of a single variable (as seen in a histogram, for example) more symmetric. To make the spread of several groups (as seen in side-by-side boxplots) more alike. To make the form of a scatterplot more nearly linear (as seen in the previous example). Make the scatter in a scatterplot spread out evenly rather than following a fan shape. In this chapter, we'll focus on the third reason.

Common Transformations Transformations we may use include raising our data to a power (like squared or cubed), square rooting our data, taking the logarithm of our data, or taking the reciprocal of our data.

Common transformations The situation may help us know which transformations will best achieve linearity. For example... A problem dealing with area might benefit from squaring the data (power of 2) since area involves square units. A problem dealing with weight or volume might benefit from cubing or cube-rooting (a power of 3 or one-third) the data since volume involves cubic units. Data involving a ratio (like miles per gallon) might benefit from a reciprocal transformation (power of -1).

Example 4.2 This example has data comparing the lengths and weights of fish, and asks us to find a model that helps us predict the weight of a fish given its length.

Weight versus length of fish Here's a graph of the data. Describe the form of the data. Since the data is not linear, we want to try a transformation that will make it linear.

Common transformations Which transformation should we try? A problem dealing with area might benefit from squaring the data (power of 2) since area involves square units. A problem dealing with weight or volume might benefit from cubing or cube-rooting (a power of 3 or one-third) the data since volume involves cubic units. Data involving a ratio (like miles per gallon) might benefit from a reciprocal transformation (power of -1).

Weight versus length3 Notice what happens to our graph when we cube all our lengths. Our form is now linear.

Weight versus length3 The least-squares regression line is weight = 4.066 + 0.0147length3 with r2 = 0.995 Notice our explanatory variable is length3, because we cubed all our lengths. Would you feel comfortable using this model for prediction?

Weight versus length3 What can you say about the residual plot? Despite the slight pattern in the residual plot, the residuals themselves are quite small compared to the hundreds of grams we were measuring our fish in. We should be safe using our LSRL for prediction.

Prediction So to predict the weight of a fish with a length of 36 centimeters, plug 36 into our LSRL weight = 4.066 + 0.0147length3 weight = 4.066 + 0.0147(36)3 weight = 689.9 grams

The ladder of powers A review of functions When transforming with powers (like in the last example), a general understanding of different power functions can sometimes help, since we could use any of these powers in transforming our data.

The ladder of powers A review of functions The power of 1 graph is a straight line

The ladder of powers A review of functions Powers greater than one (like 2 and 4) give graphs that bend upward.

The ladder of powers A review of functions Powers less than 1 but greater than 0 (like 0.5 or the square root) give graphs that bend downward.

The ladder of powers A review of functions Powers less than zero (like -1 or the reciprocal transformation) give graphs that decrease as x increases.

The ladder of powers A review of functions The zero power in the ladder is replaced by the graph of logx.

A country's GDP & life expectancy So let's say we were looking at a graph such as this, which compares a country's gross domestic product and life expectancy, and we wanted to linearize the data.

A country's GDP & life expectancy There isn't an obvious relationship between GDP and life expectancy like there was between length & weight, so just start somewhere on the ladder and move down.

A country's GDP & life expectancy Here's our data to the power of 0.5, or in other words square rooted. Compare our new r value to the old. How linear is the data?

A country's GDP & life expectancy We could do better, so let's go down the ladder another step to see what happens.

A country's GDP & life expectancy Here's the log of our data (which takes the power of 0 on the ladder). Compare our new r value to the old. How linear is the data? Let's go one more step on the ladder.

A country's GDP & life expectancy Here's our data to the power of -0.5, or in other words the reciprocal square rooted. Compare our new r value to the old. How linear is the data?

A country's GDP & life expectancy I'm sure you noticed that as we moved down the ladder of powers, the scatterplots became straighter. This final plot has a fairly linear form apart from the outliers.

Also note that not all data will become linear with a transformation. Although this guess and check method ultimately accomplished the goal of achieving linearity, the ladder of powers is rarely used in practice. It is much more satisfactory to begin with a theory or mathematical model that we expect to describe a relationship, (as in the length and weight of fish example.)‏ Also note that not all data will become linear with a transformation.

Modeling Nonlinear Data Nonlinear growth can often be modeled by exponential or power functions. When transformation of the data reveals a linear form on a scatterplot, we can find an LSRL. Using the rules of logs and exponents, we can then perform an inverse transformation which gives us a curve that fits the original data.

Review of Log Properties Rules of Logs

An exponential function is a function with the form: y = abx Note that a is the y-intercept and b is the rate of growth or decay. When a is positive, b > 1 indicates growth. When a is positive, b < 1 indicates decay.

Exponential Growth Remember that linear growth increases by a fixed amount in each equal time period. Exponential growth occurs when a variable increases by a fixed multiple (b) in each equal time period. Or another way to say it is that exponential growth increases by a fixed percent of the previous total in each equal time period.

Exponential Decay Exponential decay occurs when a variable decreases by a fixed multiple (b) in each equal time period. Or another way to say it is that exponential decay decreases by a fixed percent of the previous total in each equal time period.

Common Ratio The rate of increase or decrease for exponential data is called the common ratio. It is the ratio of the y values for equal-interval x values. (yn/yn-1) By determining if there is a common ratio, we can determine if data are exponential. Note that real data will not have a perfect common ratio. We are looking to see if the ratio is approximately the same.

Common Ratio Determine if the following data sets represent exponential growth, exponential decay or neither. If it is exponential, what is the common ratio? Dataset A Dataset B x y 2 270 3 92 4 31 5 10 6 7 1 x Y 1 10 2 34 3 51 4 66 5 83 6 97

More on Moore's law You may recall last time talking about Moore's law, which predicted in 1965 that the number of transistors on an integrated circuit chip would double every 18 months

Construct a scatterplot of the data. More on Moore's law Construct a scatterplot of the data.

Your plot should have looked like this We will answer two questions 1. What transformation will linearize the data? 2. Is the data exponential?

Verifying exponential growth The answer to question 1: Taking the log of the response variable will linearize the data The answer to questions 2: the data is exponential The log (or ln) of the response variable plotted vs the explanatory variable will always produce a linear relationship if the data is exponential!

Verifying exponential growth In other words, if our data are growing exponentially and we plot the logarithm (base 10 or base e) of y against x, we should observe a straight line for the transformed data. Perform the transformation and graph ln y vs. x.

Verifying exponential growth Your graph should look like this. It's fairly linear. Let's perform a regression to see how linear.

Verifying exponential growth Perform a linear regression and record your regression equation, correlation, and r2 values. Check your residual plot. How does the model fit?

Verifying Exponential Growth The residual plot is shown on page 274 of your text Once again, there is a slight pattern to our residuals, but they are so small that we can justify using our model to make predictions.

Residuals Again When calculating residuals by hand, remember: For linear data: Residual = observed – predicted value When using transformed data be sure to use the transformed values for the observations: log y vs. x ln y vs. x

Predictions using our LSRL With our regression equation, we can now use it to make predictions. To predict the number of transistors on Intel’s Itanium 2 chip, which was released in 2003, we substitute 33 for “years since 1970” in the regression equation. Ln(transistors) = 7.41 + 0.332(years since 1970) Ln(transistors) = 7.41 + 0.332(33) = 18.366 Then change to exponential form (remember ln is base e)

Inverse Transformation (Used to obtain a model to fit the original data) For an exponential model that has been transformed, by taking the ln of the response variable, the inverse transformation is

Use the correct inverse transformation to obtain a model that will fit our original transistor data. Make a scatterplot of the original data and this model. How does it look?