27
Chapter 10 Re-expressing the data

Chapter 10 Re-expressing the data. If the relationship is nonlinear We may re-express the data to straighten the bent relationship so that we can fit

Embed Size (px)

Citation preview

Page 1: Chapter 10 Re-expressing the data. If the relationship is nonlinear We may re-express the data to straighten the bent relationship so that we can fit

Chapter 10 Re-expressing the data

Page 2: Chapter 10 Re-expressing the data. If the relationship is nonlinear We may re-express the data to straighten the bent relationship so that we can fit

If the relationship is nonlinear

• We may re-express the data to straighten the bent relationship so that we can fit and use a simple linear model

• Simple ways to re-express data – Logarithms– square root– reciprocals

Page 3: Chapter 10 Re-expressing the data. If the relationship is nonlinear We may re-express the data to straighten the bent relationship so that we can fit

Straight to the Point (cont.)

• The relationship between fuel efficiency (in miles per gallon) and weight (in pounds) for late model cars looks fairly linear at first

Page 4: Chapter 10 Re-expressing the data. If the relationship is nonlinear We may re-express the data to straighten the bent relationship so that we can fit

Straight to the Point (cont.)

• The relationship between fuel efficiency (in miles per gallon) and weight (in pounds) for late model cars looks fairly linear at first

• Using the linear model, we get the intercept 40.65, slope -0.0057 and R-squared 82%.

Page 5: Chapter 10 Re-expressing the data. If the relationship is nonlinear We may re-express the data to straighten the bent relationship so that we can fit

Straight to the Point (cont.)

• The relationship between fuel efficiency (in miles per gallon) and weight (in pounds) for late model cars looks fairly linear at first

• Using the linear model, we get the intercept 40.65, slope -0.0057 and R-squared 82%.

• This model predicts the fuel efficiency of a Hummer H2 (about 6400 lb) to be 4.2 mpg which is far less than the reported value 11.0 mpg.

Page 6: Chapter 10 Re-expressing the data. If the relationship is nonlinear We may re-express the data to straighten the bent relationship so that we can fit

Straight to the Point (cont.)• A look at the residuals plot shows a problem:

Page 7: Chapter 10 Re-expressing the data. If the relationship is nonlinear We may re-express the data to straighten the bent relationship so that we can fit

Straight to the Point (cont.)• We can re-express fuel efficiency as gallons per mile (a

reciprocal) and eliminate the bend in the original scatterplot:

Page 8: Chapter 10 Re-expressing the data. If the relationship is nonlinear We may re-express the data to straighten the bent relationship so that we can fit

Straight to the Point (cont.)

• A comparison of two scatter plots

Page 9: Chapter 10 Re-expressing the data. If the relationship is nonlinear We may re-express the data to straighten the bent relationship so that we can fit

Straight to the Point (cont.)• A look at the residuals

plot for the new model seems more reasonable

• R-squared of this model is 88%

• This model predicts the fuel efficiency of Hummer H2 to be 11.1 mpg.

Page 10: Chapter 10 Re-expressing the data. If the relationship is nonlinear We may re-express the data to straighten the bent relationship so that we can fit

Comparison on Lincoln Navigator (2000)

• Weight = 7,200 lbs • Predicted mpg is about

-0.32! (before re-expressing the data)

• After re-expressing the data, predicted mpg = 9.8 (reported 11.0)

Page 11: Chapter 10 Re-expressing the data. If the relationship is nonlinear We may re-express the data to straighten the bent relationship so that we can fit

When do we need to re-express data?

1. To make skewed distributions more symmetric

• Why?– Easier to summarize symmetric distributions

• We can use mean and sd

– We can use a normal model

• It does not help to reduce the number of modes!!!

Page 12: Chapter 10 Re-expressing the data. If the relationship is nonlinear We may re-express the data to straighten the bent relationship so that we can fit

Assets of 77 large companies

After log transformation

Page 13: Chapter 10 Re-expressing the data. If the relationship is nonlinear We may re-express the data to straighten the bent relationship so that we can fit

When do we need to re-express data?

2. Make the spread of several groups more alike

• Why?– Easier to compare groups that share a

common spread– Some statistical methods require the

assumption that all groups have a common sd

Page 14: Chapter 10 Re-expressing the data. If the relationship is nonlinear We may re-express the data to straighten the bent relationship so that we can fit

Assets by market sectors

After log transformation

Page 15: Chapter 10 Re-expressing the data. If the relationship is nonlinear We may re-express the data to straighten the bent relationship so that we can fit

When do we need to re-expressing data?

3. Make the relationship more linear

• Why?– To apply linear regression

It does not help if the scatterplot turns around (go up and then down or down then up)

Page 16: Chapter 10 Re-expressing the data. If the relationship is nonlinear We may re-express the data to straighten the bent relationship so that we can fit

After log transformation

Assets vs. Sales

Page 17: Chapter 10 Re-expressing the data. If the relationship is nonlinear We may re-express the data to straighten the bent relationship so that we can fit

Ratios of two quantities (e.g., mph) often benefit from a reciprocal.

The reciprocal of the data-1

An uncommon re-expression, but sometimes useful.

Reciprocal square root-1/2

Measurements that cannot be negative often benefit from a log re-expression. Good start point.

We’ll use logarithms here“0”

Counts often benefit from a square root re-expression. For counted data, start here.

Square root of data values½

Data with positive and negative values and no bounds are less likely to benefit from re-expression.

Raw data1

Try with unimodal distributions that are skewed to the left.

Square of data values2

CommentNamePower

Page 18: Chapter 10 Re-expressing the data. If the relationship is nonlinear We may re-express the data to straighten the bent relationship so that we can fit
Page 19: Chapter 10 Re-expressing the data. If the relationship is nonlinear We may re-express the data to straighten the bent relationship so that we can fit
Page 20: Chapter 10 Re-expressing the data. If the relationship is nonlinear We may re-express the data to straighten the bent relationship so that we can fit

Multiple Benefits

• We often choose a re-expression for one reason and then discover that it has helped other aspects of an analysis.

• For example, a re-expression that makes a histogram more symmetric might also straighten a scatterplot or stabilize variance.

Page 21: Chapter 10 Re-expressing the data. If the relationship is nonlinear We may re-express the data to straighten the bent relationship so that we can fit

Why Not Just a Curve?

• If there’s a curve in the scatterplot, why not just fit a curve to the data?

-Computationally more difficult

-Straight lines are easy to understand and interpret

Page 22: Chapter 10 Re-expressing the data. If the relationship is nonlinear We may re-express the data to straighten the bent relationship so that we can fit

A general principle

• Occam’s Razor

entia non sunt multiplicanda praeter necessitatem

entities should not be multiplied beyond necessity.

When multiple competing theories are equal in other respects, the principle recommends selecting the theory that introduces the fewest assumptions and postulates the fewest hypothetical entities

Page 23: Chapter 10 Re-expressing the data. If the relationship is nonlinear We may re-express the data to straighten the bent relationship so that we can fit

What Can Go Wrong?

• Don’t expect your model to be perfect.

• Don’t choose a model based on R2 alone:– Example: large R2, but

residual plot shows curvature

Page 24: Chapter 10 Re-expressing the data. If the relationship is nonlinear We may re-express the data to straighten the bent relationship so that we can fit

What Can Go Wrong? (cont.)

• Beware of multiple modes.– Re-expression cannot pull separate modes together.

• Watch out for scatterplots that turn around.– Re-expression can straighten many bent

relationships, but not those that go up and down.

Page 25: Chapter 10 Re-expressing the data. If the relationship is nonlinear We may re-express the data to straighten the bent relationship so that we can fit

What Can Go Wrong? (cont.)

• Watch out for negative data values.– Can NOT use log or square root transformations

• Watch for data far from 1.– Data values that are all very far from 1 may not be

much affected by re-expression unless the range is very large. If all the data values are large (e.g., years), consider subtracting a constant to bring them back near 1.

• Don’t stray too far from the ladder– Too difficult to interpret

Page 26: Chapter 10 Re-expressing the data. If the relationship is nonlinear We may re-express the data to straighten the bent relationship so that we can fit

What have we learned?

• When the conditions for regression are not met, a simple re-expression of the data may help.

• A re-expression may make the:– Distribution of a variable more symmetric.– Spread across different groups more similar.– Form of a scatterplot straighter.– Scatter around the line in a scatterplot more

consistent.

Page 27: Chapter 10 Re-expressing the data. If the relationship is nonlinear We may re-express the data to straighten the bent relationship so that we can fit

What have we learned? (cont.)

• Taking logs is often a good, simple starting point.– To search further, the Ladder of Powers or

the log-log approach can help us find a good re-expression.

• Our models won’t be perfect, but re-expression can lead us to a useful model.