Docsity

Chapter 10: Regression and Correlation, Exercises of Technology

Toggle sidebar
bg1
Chapter 10: Regression and Correlation
343
Chapter 10: Regression and Correlation
The previous chapter looked at comparing populations to see if there is a difference
between the two. That involved two random variables that are similar measures. This
chapter will look at two random variables that are not similar measures, and see if there is
a relationship between the two variables. To do this, you look at regression, which finds
the linear relationship, and correlation, which measures the strength of a linear
relationship.
Please note: there are many other types of relationships besides linear that can be found
for the data. This book will only explore linear, but realize that there are other
relationships that can be used to describe data.
Section 10.1: Regression
When comparing two different variables, two questions come to mind: “Is there a
relationship between two variables?” and “How strong is that relationship?” These
questions can be answered using regression and correlation. Regression answers
whether there is a relationship (again this book will explore linear only) and correlation
answers how strong the linear relationship is. To introduce both of these concepts, it is
easier to look at a set of data.
Example #10.1.1: Determining If There Is a Relationship
Is there a relationship between the alcohol content and the number of calories in
12-ounce beer? To determine if there is one a random sample was taken of beer’s
alcohol content and calories ("Calories in beer,," 2011), and the data is in table
#10.1.1.
Table #10.1.1: Alcohol and Calorie Content in Beer
Brand
Brewery
Alcohol
Content
Calories
in 12 oz
Big Sky Scape Goat Pale Ale
Big Sky Brewing
4.70%
163
Sierra Nevada Harvest Ale
Sierra Nevada
6.70%
215
Steel Reserve
MillerCoors
8.10%
222
O'Doul's
Anheuser Busch
0.40%
70
Coors Light
MillerCoors
4.15%
104
Genesee Cream Ale
High Falls Brewing
5.10%
162
Sierra Nevada Summerfest Beer
Sierra Nevada
5.00%
158
Michelob Beer
Anheuser Busch
5.00%
155
Flying Dog Doggie Style
Flying Dog Brewery
4.70%
158
Big Sky I.P.A.
Big Sky Brewing
6.20%
195
Solution:
To aid in figuring out if there is a relationship, it helps to draw a scatter plot of the
data. It is helpful to state the random variables, and since in an algebra class the
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32

Partial preview of the text

Download Chapter 10: Regression and Correlation and more Exercises Technology in PDF only on Docsity!

Chapter 10: Regression and Correlation

The previous chapter looked at comparing populations to see if there is a difference

between the two. That involved two random variables that are similar measures. This

chapter will look at two random variables that are not similar measures, and see if there is

a relationship between the two variables. To do this, you look at regression, which finds

the linear relationship, and correlation, which measures the strength of a linear

relationship.

Please note: there are many other types of relationships besides linear that can be found

for the data. This book will only explore linear, but realize that there are other

relationships that can be used to describe data.

Section 10.1: Regression

When comparing two different variables, two questions come to mind: “Is there a

relationship between two variables?” and “How strong is that relationship?” These

questions can be answered using regression and correlation. Regression answers

whether there is a relationship (again this book will explore linear only) and correlation

answers how strong the linear relationship is. To introduce both of these concepts, it is

easier to look at a set of data.

Example #10.1.1: Determining If There Is a Relationship

Is there a relationship between the alcohol content and the number of calories in

12 - ounce beer? To determine if there is one a random sample was taken of beer’s

alcohol content and calories ("Calories in beer,," 2011), and the data is in table

Table #10.1.1: Alcohol and Calorie Content in Beer

Brand Brewery Alcohol

Content

Calories

in 12 oz

Big Sky Scape Goat Pale Ale Big Sky Brewing 4.70% 163

Sierra Nevada Harvest Ale Sierra Nevada 6.70% 215

Steel Reserve MillerCoors 8.10% 222

O'Doul's Anheuser Busch 0.40% 70

Coors Light MillerCoors 4.15% 104

Genesee Cream Ale High Falls Brewing 5.10% 162

Sierra Nevada Summerfest Beer Sierra Nevada 5.00% 158

Michelob Beer Anheuser Busch 5.00% 155

Flying Dog Doggie Style Flying Dog Brewery 4.70% 158

Big Sky I.P.A. Big Sky Brewing 6.20% 195

Solution:

To aid in figuring out if there is a relationship, it helps to draw a scatter plot of the

data. It is helpful to state the random variables, and since in an algebra class the

variables are represented as x and y , those labels will be used here. It helps to

state which variable is x and which is y.

State random variables

x = alcohol content in the beer

y = calories in 12 ounce beer

Figure #10.1.1: Scatter Plot of Beer Data

This scatter plot looks fairly linear. However, notice that there is one beer in the

list that is actually considered a non-alcoholic beer. That value is probably an

outlier since it is a non-alcoholic beer. The rest of the analysis will not include

O’Doul’s. You cannot just remove data points, but in this case it makes more

sense to, since all the other beers have a fairly large alcohol content.

To find the equation for the linear relationship, the process of regression is used to find

the line that best fits the data (sometimes called the best fitting line). The process is to

draw the line through the data and then find the distances from a point to the line, which

are called the residuals. The regression line is the line that makes the square of the

residuals as small as possible, so the regression line is also sometimes called the least

squares line. The regression line and the residuals are displayed in figure #10.1.2.

2 4 6 8

0

50

100

150

200

250

Calories vs Alcohol Content

Alcohol Content (%)

Calories in 12 in Beer

The independent variable , also called the explanatory variable or predictor variable ,

is the x - value in the equation. The independent variable is the one that you use to predict

what the other variable is. The dependent variable depends on what independent value

you pick. It also responds to the explanatory variable and is sometimes called the

response variable. In the alcohol content and calorie example, it makes slightly more

sense to say that you would use the alcohol content on a beer to predict the number of

calories in the beer.

The population equation looks like:

y = β

o

  • β

1

x

β

o

= slope

β

1

= y-intercept

y is used to predict y.

Assumptions of the regression line:

a. The set ( x , y ) of ordered pairs is a random sample from the population of all such

possible x , y

pairs.

b. For each fixed value of x , the y - values have a normal distribution. All of the y

distributions have the same variance, and for a given x - value, the distribution of y -

values has a mean that lies on the least squares line. You also assume that for a

fixed y , each x has its own normal distribution. This is difficult to figure out, so

you can use the following to determine if you have a normal distribution.

i. Look to see if the scatter plot has a linear pattern.

ii. Examine the residuals to see if there is randomness in the residuals. If

there is a pattern to the residuals, then there is an issue in the data.

Example #10.1.2: Find the Equation of the Regression Line

a.) Is there a positive relationship between the alcohol content and the number of

calories in 12-ounce beer? To determine if there is a positive linear

relationship, a random sample was taken of beer’s alcohol content and calories

for several different beers ("Calories in beer,," 2011), and the data are in table

Table #10.1.2: Alcohol and Calorie Content in Beer without Outlier

Brand Brewery Alcohol

Content

Calories

in 12 oz

Big Sky Scape Goat Pale Ale Big Sky Brewing 4.70% 163

Sierra Nevada Harvest Ale Sierra Nevada 6.70% 215

Steel Reserve MillerCoors 8.10% 222

Coors Light MillerCoors 4.15% 104

Genesee Cream Ale High Falls Brewing 5.10% 162

Sierra Nevada Summerfest Beer Sierra Nevada 5.00% 158

Michelob Beer Anheuser Busch 5.00% 155

Flying Dog Doggie Style Flying Dog Brewery 4.70% 158

Big Sky I.P.A. Big Sky Brewing 6.20% 195

Solution:

State random variables

x = alcohol content in the beer

y = calories in 12 ounce beer

Assumptions check:

a. A random sample was taken as stated in the problem.

b. The distribution for each calorie value is normally distributed for every value

of alcohol content in the beer.

i. From Example #10.2.1, the scatter plot looks fairly linear.

ii. The residual versus the x- values plot looks fairly random. (See figure

It appears that the distribution for calories is a normal distribution.

To find the regression equation on the TI-83/84 calculator, put the x ’s in L1 and

the y ’s in L2. Then go to STAT, over to TESTS, and choose LinRegTTest. The

setup is in figure #10.1.3. The reason that >0 was chosen is because the question

was asked if there was a positive relationship. If you are asked if there is a

negative relationship, then pick <0. If you are just asked if there is a relationship,

then pick ≠ 0. Right now the choice will not make a different, but it will be

important later.

Figure #10.1.3: Setup for Linear Regression Test on TI-83/

b.) Use the regression equation to find the number of calories when the alcohol

content is 6.50%.

Solution:

x

o

y = 25.0 + 26.3 6.

= 196 calories

If you are drinking a beer that is 6.50% alcohol content, then it is probably close

to 196 calories. Notice, the mean number of calories is 170 calories. This value

of 196 seems like a better estimate than the mean when looking at the original

data. The regression equation is a better estimate than just the mean.

c.) Use the regression equation to find the number of calories when the alcohol

content is 2.00%.

Solution:

x

o

y = 25.0 + 26.3 2.

= 78 calories

If you are drinking a beer that is 2.00% alcohol content, then it has probably close

to 78 calories. This doesn’t seem like a very good estimate. This estimate is what

is called extrapolation. It is not a good idea to predict values that are far outside

the range of the original data. This is because you can never be sure that the

regression equation is valid for data outside the original data.

d.) Find the residuals and then plot the residuals versus the x - values.

Solution:

To find the residuals, find

y for each x - value. Then subtract each

y from the

given y value to find the residuals. Realize that these are sample residuals

since they are calculated from sample values. It is best to do this in a

spreadsheet.

Table #10.1.3: Residuals for Beer Calories

x y

y = 25.0 + 26.3 x y −

y

Notice the residuals add up to close to 0. They don’t add up to exactly 0 in

this example because of rounding error. Normally the residuals add up to 0.

You can use R to get the residuals. The command is

lm.out = lm(dependent variable ~ independent variable) – this defines the

linear model with a name so you can use it later. Then

residual(lm.out) – produces the residuals.

For this example, the command would be

lm(calories~alcohol)

Call:

lm(formula = calories ~ alcohol)

Coefficients:

(Intercept) alcohol

residuals(lm.out)

So the first residual is 14.271307 and it belongs to the first x value. The

residual 13.634092 belongs to the second x value, and so forth.

You can then graph the residuals versus the independent variable using the

plot command. For this example, the command would be plot(alcohol,

residuals(lm.out), main="Residuals for Beer Calories versus Alcohol Content",

xlab="Alcohol Content", ylab="Residuals"). Sometimes it is useful to see the

x-axis on the graph, so after creating the plot, type the command abline(0,0).

The graph of the residuals versus the x - values is in figure #10.1.5. They

appear to be somewhat random.

The calories increase 26.3 calories for every 1% increase in alcohol content.

The y - intercept in many cases is meaningless. In this case, it means that if a drink has 0

alcohol content, then it would have 25.0 calories. This may be reasonable, but remember

this value is an extrapolation so it may be wrong.

Consider the residuals again. According to the data, a beer with 6.7% alcohol has 215

calories. The predicted value is 201 calories.

Residual = actual − predicted

This deviation means that the actual value was 14 above the predicted value. That isn’t

that far off. Some of the actual values differ by a large amount from the predicted value.

This is due to variability in the dependent variable. The larger the residuals the less the

model explains the variability in the dependent variable. There needs to be a way to

calculate how well the model explains the variability in the dependent variable. This will

be explored in the next section.

The following example demonstrates the process to go through when using the formulas

for finding the regression equation, though it is better to use technology. This is because

if the linear model doesn’t fit the data well, then you could try some of the other models

that are available through technology.

Example #10.1.3: Calculating the Regression Equation with the Formula

Is there a relationship between the alcohol content and the number of calories in

12 - ounce beer? To determine if there is one a random sample was taken of beer’s

alcohol content and calories ("Calories in beer,," 2011), and the data are in table

#10.1.2. Find the regression equation from the formula.

Solution:

State random variables

x = alcohol content in the beer

y = calories in 12 ounce beer

Table #10.1.4: Calculations for Regression Equation

Alcohol Content Calories x − x

y − y

( x − x )

2

( y − y )

2

( x − x ) ( y − y )

= x

= y

= SS

x

= SS

y

= SS

xy

slope: b =

SS

xy

SS

x

y - intercept: a = y − bx = 170.222 − 26.3 (5.516667 ) ≈ 25.

Regression equation:

y = 25.0 + 26.3 x

Section 10.1: Homework

For each problem, state the random variables. Also, look to see if there are any outliers

that need to be removed. Do the regression analysis with and without the suspected

outlier points to determine if their removal affects the regression. The data sets in this

section are used in the homework for sections 10.2 and 10.3 also.

3.) The World Bank collects information on the life expectancy of a person in each

country ("Life expectancy at," 2013) and the fertility rate per woman in the

country ("Fertility rate," 2013). The data for 24 randomly selected countries for

the year 2011 are in table #10.1.7. Create a scatter plot of the data and find a

linear regression equation between fertility rate and life expectancy. Then use the

regression equation to find the life expectancy for a country that has a fertility rate

of 2.7 and for a country with fertility rate of 8.1. Which life expectancy that you

calculated do you think is closer to the true life expectancy? Why?

Table #10.1.7: Data of Fertility Rates versus Life Expectancy

Fertility

Rate

Life

Expectancy

4.) The World Bank collected data on the percentage of GDP that a country spends

on health expenditures ("Health expenditure," 2013) and also the percentage of

women receiving prenatal care ("Pregnant woman receiving," 2013). The data for

the countries where this information are available for the year 2011 is in table

#10.1.8. Create a scatter plot of the data and find a regression equation between

percentage spent on health expenditure and the percentage of women receiving

prenatal care. Then use the regression equation to find the percent of women

receiving prenatal care for a country that spends 5.0% of GDP on health

expenditure and for a country that spends 12.0% of GDP. Which prenatal care

percentage that you calculated do you think is closer to the true percentage?

Why?

Table #10.1.8: Data of Health Expenditure versus Prenatal Care

Health

Expenditure

(% of GDP)

Prenatal

Care (%)

6.) Different species have different body weights and brain weights are in table

#10.1.10. ("Brain2bodyweight," 2013). Create a scatter plot and find a regression equation between body weights and brain weights. Then use the regression equation to find the brain weight for a species that has a body weight of 62 kg and for a species that has a body weight of 180,000 kg. Which brain weight that you calculated do you think is closer to the true brain weight? Why? Table #10.1.10: Body Weights and Brain Weights of Species

  • Newborn Human 3.20 0. Species Body Weight (kg) Brain Weight (kg)
  • Adult Human 73.00 1.
  • Pithecanthropus Man 70.00 0.
  • Squirrel 0.80 0.
  • Hamster 0.15 0.
  • Chimpanzee 50.00 0.
  • Rabbit 1.40 0.
  • Dog_(Beagle) 10.00 0.
  • Cat 4.50 0.
  • Rat 0.40 0.
  • Bottle-Nosed Dolphin 400.00 1.
  • Beaver 24.00 0.
  • Gorilla 320.00 0.
  • Tiger 170.00 0.
  • Owl 1.50 0.
  • Camel 550.00 0.
  • Elephant 4600.00 6.
  • Lion 187.00 0.
  • Sheep 120.00 0.
  • Walrus 800.00 0.
  • Horse 450.00 0.
  • Cow 700.00 0.
  • Giraffe 950.00 0.
  • Green Lizard 0.20 0.
  • Sperm Whale 35000.00 7.
  • Turtle 3.00 0.
  • Alligator 270.00 0.

7.) A random sample of beef hotdogs was taken and the amount of sodium (in mg)

and calories were measured. ("Data hotdogs," 2013) The data are in table

#10.1.11. Create a scatter plot and find a regression equation between amount of

calories and amount of sodium. Then use the regression equation to find the

amount of sodium a beef hotdog has if it is 170 calories and if it is 120 calories.

Which sodium level that you calculated do you think is closer to the true sodium

level? Why?

Table #10.1.11: Calories and Sodium Levels in Beef Hotdogs

Calories Sodium

9.) Cigarette smoking and cancer have been linked. The number of deaths per one

hundred thousand from bladder cancer and the number of cigarettes sold per

capita in 1960 are in table #10.1.13 ("Smoking and cancer," 2013). Create a

scatter plot and find a regression equation between cigarette smoking and deaths

of bladder cancer. Then use the regression equation to find the number of deaths

from bladder cancer when the cigarette sales were 20 per capita and when the

cigarette sales were 6 per capita. Which number of deaths that you calculated do

you think is closer to the true number? Why?

Table #10.1.13: Number of Cigarettes and Number of Bladder Cancer

Deaths in 1960

Cigarette

Sales (per

Capita)

Bladder Cancer

Deaths (per 100

Thousand)

Cigarette Sales

(per Capita)

Bladder Cancer

Deaths (per 100

Thousand)

10.) The weight of a car can influence the mileage that the car can obtain. A random

sample of cars’ weights and mileage was collected and are in table #10.1.

("Passenger car mileage," 2013). Create a scatter plot and find a regression

equation between weight of cars and mileage. Then use the regression equation to

find the mileage on a car that weighs 3800 pounds and on a car that weighs 2000

pounds. Which mileage that you calculated do you think is closer to the true

mileage? Why?

Table #10.1.14: Weights and Mileages of Cars

Weight

pounds)

Mileage

(mpg)