Login
📚 Mostly Harmless Statistics
Chapters ▾

12 Correlation and Regression

12.01: Correlation

We are often interested in the relationship between two variables. This chapter determines whether a linear relationship exists between sets of quantitative data and making predictions for a population—for instance, the relationship between the number of hours of study time and an exam score, or smoking and heart disease.

A predictor variable (also called the independent or explanatory variable; usually we use the letter \(x\)) explains or causes changes in the response variable. The predictor variable can be manipulated or changed by the researcher.

A response variable (also called the dependent variable; usually we use the letter \(y\)) measures the outcome of a study. The different outcomes for a dependent variable are measured or observed by the researcher. For instance, suppose we are interested in how much time spent studying affects the scores on an exam. In this study, study time is the predictor variable, and exam score is the response variable.

In data from an experiment, it is much easier to know which variable we should use for the independent and dependent variables. This can be harder to distinguish in observational data. Think of the dependent variable as the variable that you are trying to learn about.

If we were observing the relationship between unemployment rate and economic growth rate, it may not be clear which variable should be \(x\) and \(y\). Do we want to predict the unemployment rate or the economic growth rate? One should never jump to a cause and effect reasoning with observational data. Just because there is a strong relationship between unemployment rate and economic growth rate does not mean that one causes the other to change directly. There may be many other contributing factors to both of these rates changing at the same time, such as retirements or pandemics.

12.01: Scatterplots

A scatterplot shows the relationship between two quantitative variables measured on the same individuals.

  • The predictor variable is labeled on the horizontal or \(x\)-axis.
  • The response variable is labeled on the vertical or \(y\)-axis.

How to Interpret a Scatterplot:

  • Look for the overall pattern and for deviations from that pattern.
  • Look for outliers, individual values that fall outside the overall pattern of the relationship.
  • A positive linear relation results when larger values of one variable are associated with larger values of the other.
  • A negative linear relation results when larger values of one variable are associated with smaller values of the other.
  • A scatterplot has no association if no obvious linear pattern is present.

Use technology to make a scatterplot for the following sample data set:

Hours Studied for Exam 20 16 20 18 17 16 15 17 15 16 15 17 16 17 14 Grade on Exam 89 72 93 84 81 75 70 82 69 83 80 83 81 84 76
Solution

TI-84: On the TI-84 press the [STAT] key and then the [EDIT] function; type the \(x\) values into L1 and the \(y\) values into L2. Press [Y=] and clear any equations that are in the \(y\)-editor. Press [2nd] then [STAT PLOT] (above the [Y=] button.) Press 4 or scroll down to PlotsOff and press enter. Press [ENTER] once more to turn off all of the existing plots.

Entering data for hours studied into L1 and data for grade into L2. Selecting Plot1 on the Stat Plots screen.

Press [2nd], then [STAT PLOT], then press 1 or hit [ENTER] and select Plot1. Select On and press [ENTER] to activate plot 1. For “Type” select the first graph that looks like a scatterplot and press [ENTER]. For “Xlist” enter the list where your explanatory variable data is stored. For our example, enter L1. For “Ylist” enter the list where your response variable data is stored. For our example, enter L2. Press [ZOOM] then press 9 or scroll down to ZoomStat and press [ENTER]. Press Trace and you can use your arrow keys to see the coordinates of each point.

Selecting and activating Plot1. Applying ZoomStat. Shows the finished scatterplot and the use of Trace to identify coordinates of a point on the plot.

TI-89: Press [♦] then [F1] (the Y=) and clear any equations that are in the \(y\)-editor. Open the Stats/List Editor. Enter all \(x\)-values in one list. Enter all corresponding \(y\)-values in a second list. Double check that the data you entered is correct. In the Stats/List Editor select F2 for the Plots menu. Use cursor keys to highlight 1:Plot Setup. Make sure that the other graphs are turned off by pressing F4 button to remove the check marks. Under “Plot 1” press F1 for the Define menu. In the “Plot Type” menu select “Scatter.” In the “x” space type in the name of your list with the x variable without space: for our example, “list1.” In the “y” space type in the name of your list with the y variable without space: for our example, “list2.” Press [ENTER] twice and you will be returned to the Plot Setup menu. Press F5 ZoomData to display the graph. Press F3 Trace and use the arrow keys to scroll along the different points.

Entering study hour data in list1 and score data in list2. Selecting 1:Plot Setup from the F2 Plots menu. Entering the appropriate list variables in the Define Plot 1 window.

Excel: Copy the data over to Excel in either two adjacent rows or columns. Select the data, select the Insert tab, then select Scatter, select the first scatter plot.

Excel sheet containing the given data table, with the filled cells selected and scatter plot option selected to create a scatterplot.

Then add labels for your axis and change the title to produce the completed scatter plot.

Correlation Coefficient

The sample correlation coefficient measures the direction and strength of the linear relationship between two quantitative variables. There are several different types of correlations. We will be using the Pearson Product Moment Correlation Coefficient (PPMCC). The PPMCC is named after biostatistician Karl Pearson. We will just use the lower-case \(r\) for short when we want to find the correlation coefficient, and the Greek letter \(\rho\), pronounced “rho,” (rhymes with sew) when referring to the population correlation coefficient.

Portrait photograph of Karl Pearson.
Karl Pearson

Interpreting the Correlation:

  • A positive \(r\) indicates a positive association (positive linear slope).
  • A negative \(r\) indicates a negative association (negative linear slope).
  • \(r\) is always between \(-1\) and \(1\), inclusive.
  • If \(r\) is close to \(1\) or \(-1\), there is a strong linear relationship between \(x\) and \(y\).
  • If \(r\) is close to \(0\), there is a weak linear relationship between \(x\) and \(y\). There may be a non-linear relation or there may be no relation at all.
  • Like the mean, \(r\) is strongly affected by outliers. Figure 12-1 gives examples of correlations with their corresponding scatterplots.
8 sample scatterplots, with correlation values ranging from -1 to 1. Plots form a straight line when r=-1 or r=1, and become more random as r approaches 0.
Figure 12-1: Sample scatterplots with various values of \(r\).

When you have a correlation that is very close to \(-1\) or \(1\), then the points on the scatter plot will line up in an almost perfect line. The closer \(r\) gets to \(0\), the more scattered your points become.

Take a moment and see if you can guess the approximate value of \(r\) for the scatter plots below.

Three sample scatterplots: A has points concentrated in the 1st and 3rd quadrants, approximating a line. B resembles A but with slightly more spread-out points. C has points similarly spread out to B, but concentrated in the 2nd and 4th quadrants.

Solution

Scatterplot A: \(r = 0.98\), Scatterplot B: \(r = 0.85\), Scatterplot C: \(r = -0.85\).

When \(r\) is equal to \(-1\) or \(1\) all the dots in the scatterplot line up in a straight line. As the points disperse, \(r\) gets closer to zero. The correlation tells the direction of a linear relationship only. It does not tell you what the slope of the line is, nor does it recognize nonlinear relationships. For instance, in Figure 12-2, there are three scatterplots overlaid on the same set of axes. All three data sets would have \(r = 1\) even though they all have different slopes.

A single set of axes contains 3 different linear scaterplots, of slopes 1, 2, and 0.5, all with r=1.
Figure 12-2: Any straight line has \(r=1\).

For the next example in Figure 12-3, \(r = 0\) would indicate no linear relationship; however, there is clearly a non-linear pattern with the data.

A scatterplot whose points are arranged in a parabola. Scatterplot has h=0.
Figure 12-3: A plot of points in a parabola, a non-linear pattern, has \(r=0\).

Figure 12-4 shows a correlation \(r = 0.874\), which is pretty close to one, indicating a strong linear relationship. However, there is an outlier, called a leverage point, which is inflating the value of the slope. If you remove the outlier then \(r = 0\), and there is no up or down trend to the data.

A scatterplot with r=0.874 consists of 12 data points in a 6-by-2 grid, and a 13th point located significantly higher than and to the right of the grid.
Figure 12-4: A single outlier can significantly change the value of \(r\).

Calculating Correlation

To calculate the correlation coefficient by hand we would use the following formula.

Sample Correlation Coefficient

\[r = \frac{\sum \left( \left(x_{i} - \bar{x}\right) \left(y_{i} - \bar{y}\right) \right)}{\sqrt{ \left( \left(\sum \left(x_{i} - \bar{x}\right)^{2}\right) \left(\sum \left(y_{i} - \bar{y}\right)^{2}\right) \right)} } = \frac{SS_{xy}}{\sqrt{ \left(SS_{xx} \cdot SS_{yy}\right) }}\]

Instead of doing all of these sums by hand we can use the output from summary statistics. Recall that the formula for a variance of a sample is \(s_{x}^{2} = \frac{\sum \left(x_{i} - \bar{x}\right)^{2}}{n-1}\). If we were to multiply both sides by the degrees of freedom, we would get \(\sum \left(x_{i} - \bar{x}\right)^{2} = (n-1) s_{x}^{2}\).

We use these sums of squares \(\sum \left(x_{i} - \bar{x}\right)^{2}\) frequently, so for shorthand we will use the notation \(SS_{xx} = \sum \left(x_{i} - \bar{x}\right)^{2}\). The same would hold true for the \(y\) variable; just changing the letter, the variance of \(y\) would be \(s_{y}^{2} = \frac{\sum \left(y_{i} - \bar{y}\right)^{2}}{n-1}\), therefore \(SS_{yy} = (n-1) s_{y}^{2}\).

The numerator of the correlation formula is taking in the horizontal distance of each data point from the mean of the \(x\) values, times the vertical distance of each point from the mean of the \(y\) values. This is time-consuming to find so we will use an algebraically equivalent formula \(\sum \left(\left(x_{i} - \bar{x}\right) \left(y_{i} - \bar{y}\right) \right) = \sum (xy) - n \cdot \bar{x} \bar{y}\), and for short we will use the notation \(SS_{xy} = \sum (xy) - n \cdot \bar{x} \bar{y}\).

To start each problem, use descriptive statistics to find the sum of squares.

\(SS_{xx} = (n-1) s_{x}^{2}\) \(SS_{yy} = (n-1) s_{y}^{2}\) \(SS_{xy} = sum (xy) - n \cdot \bar{x} \bar{y}\)

Use the following data to calculate the correlation coefficient.

Hours Studied for Exam 20 16 20 18 17 16 15 17 15 16 15 17 16 17 14 Grade on Exam 89 72 93 84 81 75 70 82 69 83 80 83 81 84 76
Solution

We could show all the work the long way by hand using the shortcut formula. On the TI-83 press the [STAT] key and then the [EDIT] function, type the \(x\) values into L1 and the y values into L2. Press the [STAT] key again and arrow over to highlight [CALC], select 2-Var Stats, then press [ENTER]. This will return the descriptive stats.

The TI calculator can run descriptive statistics and quickly get everything we need to find the sum of squares. Go to STAT > CALC > 2-Var Stats. For TI-83, you may need to enter your list names separated by a comma, for example 2-Var Stats L1,L2 then hit enter. On the TI-89, open the Stats/List Editor. Enter all \(x\)-values in one list. Enter all corresponding \(y\)-values in a second list. Press F4, then select 2-Var Stats, then press [ENTER]. This will return the descriptive stats. Use the down arrow to see everything.

Selecting 2-Var Stats in the CALC menu of the calculator and selecting the appropriate lists for the x and y variables. Shows the resulting values for the descriptive statistics.

Once you do this the statistics are stored in your calculator so you can use the VARS key, go to Statistics, then select the standard deviation for \(x\), and repeat for the \(y\)-variable. This will reduce rounding errors by using exact values. For the \(SS_{xy}\) you can also use the stored sum of \(xy\) and means.

Performing calculations using the stored values created from the 2-Variable Stat function, accessed through using the VARS key followed by the Statistics option. Calculations include multiplying the standard deviation of each variable by n-1, or 14, and subtracting 15 times the product of the x and y means from the sum of x times y.

This gives the following results:

\(SS_{xx} = (n-1) s_{x}^{2} = (15-1) 1.723783215^{2} = 41.6\)
\(SS_{yy} = (n-1) s_{x}^{2} = (15-1) )6.717425811^{2} = 631.7333\)
\(SS_{xy} = \sum (xy) - n \bar{x} \bar{y} = 20087 – (15 \cdot 16.6 \cdot 80.133333) = 133.8\)

Note that both \(SS_{xx}\) and \(SS_{yy}\) will always be positive, but \(SS_{xy}\) could be negative or positive. For the TI-89, you will see the sum of squares at the very bottom of the descriptive statistics: \(\sum \left(x - \bar{x}\right)^{2} = 41.6\) and \(\sum \left(y - \bar{y}\right)^{2} = 631.7333\).

To find the correlation, substitute the three sums of squares into the formula to get: \(r = \frac{SS_{xy}}{\sqrt{ \left(SS_{xx} \cdot SS_{yy}\right) }}= \frac{133.8}{\sqrt{ \left(41.6 \cdot 631.7333 \right) }} = 0.8524\). Try this now on your calculator to see if you are getting your order of operations correct.

For our example, \(r = 0.8254\) is close to 1; therefore it looks like there is positive linear relationship between the number of hours studying for an exam and the grade on the exam.

Most software has a built-in correlation function.

TI-84: On the TI-83 press the [STAT] key and then the [EDIT] function, type the \(x\) values into L1 and the \(y\) values into L2. Press the [STAT] key again and arrow over to highlight [TEST], select LinRegTTest, then press [ENTER]. The default is Xlist: L1, Ylist: L2, Freq:1, \(\beta\) and \(\rho: \neq 0\). Arrow down to Calculate and press the [ENTER] key. Scroll down to the bottom until see you \(r\).

Selecting the LinRegTTest function from the TEST menu under STAT. The default settings for this test. The results from this test.

TI-89: On the TI-89, open the Stats/List Editor. Enter all \(x\)-values in one list. Enter all corresponding \(y\)-values in a second list. Press F6, then select LinRegTTest, then press [ENTER]. Scroll down to the bottom of the output to see \(r\).

Selecting the LinRegTTests option from the F6 Tests menu. The default settings for the test, and the final results.

Excel:

An Excel spreadsheet with the given data table, including labels, entered in rows 1 and 2, columns A through P. Shows the command to calculate correlation: =CORREL(B1:P1,B2:P2)

r = CORREL(array1,array2) = CORREL(B1:P1,B2:P2) = 0.8254

When is a correlation statistically significant? The next subsection shows how to run a hypothesis test for correlations.

12.01: Hypothesis Test for a Correlation

One should perform a hypothesis test to determine if there is a statistically significant correlation between the independent and the dependent variables. The population correlation coefficient \(\rho\) (this is the Greek letter rho, which sounds like “row” and is not a \(p\)) is the correlation among all possible pairs of data values \((x, y)\) taken from a population.

We will only be using the two-tailed test for a population correlation coefficient \(\rho\). The hypotheses are:

\(H_{0}: \rho = 0\)
\(H_{1}: \rho \neq 0\)

The null-hypothesis of a two-tailed test states that there is no correlation (there is not a linear relation) between \(x\) and \(y\). The alternative-hypothesis states that there is a significant correlation (there is a linear relation) between \(x\) and \(y\).

The t-test is a statistical test for the correlation coefficient. It can be used when \(x\) and \(y\) are linearly related, the variables are random variables, and when the population of the variable \(y\) is normally distributed.

The formula for the t-test statistic is \(t = r \sqrt{\left( \dfrac{n-2}{1-r^{2}} \right)}\).

Use the t-distribution with degrees of freedom equal to \(df = n - 2\).

Note the \(df = n - 2\) since we have two variables, \(x\) and \(y\).

Test to see if the correlation for hours studied on the exam and grade on the exam is statistically significant. Use \(\alpha\) = 0.05.

Hours Studied for Exam 20 16 20 18 17 16 15 17 15 16 15 17 16 17 14 Grade on Exam 89 72 93 84 81 75 70 82 69 83 80 83 81 84 76
Solution

The hypotheses are:

\(H_{0}: \rho = 0\)
\(H_{1}: \rho \neq 0\)

Find the critical value using \(df = n -2 = 13\) for a two-tailed test \(\alpha= 0.05\) inverse t-function to get the critical values \(\pm 2.160\). Draw the sampling distribution and label the critical values as shown in Figure 12-5.

Screenshot of using the inverse t-function on a calculator with alpha = 0.05 and df=13 to find the critical values. Graph of the sampling distribution with the critical values of positive and negative 2.160 labeled.
Figure 12-5: Sampling distribution of t-function with critical values labeled.

Next, find the test statistic \(t = r \sqrt{\left( \frac{n-2}{1-r^{2}} \right)} = 0.8254 \sqrt{\left( \frac{13}{1 - 0.8254^{2}} \right)} = 5.271\), which is greater than 2.160 and in the rejection region.

Summary: At the 5% significance level, there is enough evidence to support the claim that there is a statistically significant linear relationship (correlation) between the number of hours studied for an exam and exam scores.

The p-value method could also be used to find the same decision. We will use technology shortcuts for the p-value method. The p-value = \(2 \cdot \text{P}(t \geq 5.271 | H_{0} \text{ is true}) = 0.000151\), which is less than \(\alpha\) = 0.05; therefore we reject \(H_{0}\).

Alternatively, we could test to see if the slope was equal to zero. If the slope is zero then the correlation will also be zero. The setup of a test is a little different, but we get the same results. Most software packages report the test statistic and p-value for a slope. This test is introduced in the next section.

TI-84: Enter the data in L1 and L2. Press the [STAT] key, arrow over to the [TESTS] menu, arrow down to the option [LinRegTTest] and press the [ENTER] key. The default is Xlist: L1, Ylist: L1, Freq:1, \(\beta\) and \(\rho: \neq 0\). Arrow down to Calculate and press the [ENTER] key. The calculator returns the t-test statistic, p-value and the correlation coefficient = \(r\). Note the p-value = 0.0001513, is less than \(\alpha\) = 0.05; therefore reject \(H_{0}\), as there is a significant correlation.

LinRegTTest results.

TI-89: Enter the data in List1 and List2. In the Stats/List Editor select F6 for the Tests menu. Use cursor keys to select A:LinRegTTest and press [Enter]. In the “X List” space type in the name of your list with the \(x\) variable without space, for our example “list1” or use [2nd] [Var-Link] and highlight list1. In the “Y List” space type in the name of your list with the \(y\) variable without space, for our example “list2” or use [2nd] [Var-Link] and highlight list2. Under the “Alternate Hyp” menu select the \(\beta\) and \(\rho: \neq 0\) option, which is the same as the question’s alternative hypothesis statement, then press the [ENTER] key, arrow down to [Calculate] and press the [ENTER] key. The calculator returns the t-test statistic, p-value, and the correlation = \(r\).

Selecting the LinRegTTest option from the F6 Tests menu. Selecting the Alternative Hypothesis option where beta and do not equal to 0. Shows the final results.

Excel: Type the data into two columns in Excel. Select the Data tab, then Data Analysis, then choose Regression and select OK.

Excel spreadsheet with data for hours studied in one column and data for exam score in another column, including data labels. Both columns are selected and the Regression option in the Data Analysis pop-up window is selected.

Be careful here. The second column is the \(y\) range, and the first column is the \(x\) range. Only check the Labels box if you highlight the labels in the input range. The output range is one cell reference where you want the output to start, and then select OK.

Excel Regression pop-up window, with the "Labels" option selected and cell D1 selected for the Output Range option.

Figure 12-6 shows the regression output.

Excel-generated regression output, including regression statistics table, ANOVA table, and a table of coefficients, standard error, t-test statistic and p-value for the intercept and the hours studied.
Figure 12-6: Excel-generated regression output.

When you reject \(H_{0}\), the slope is significantly different from zero. This means there is a significant relationship (correlation) between \(x\) and \(y\), and you can then find a regression line to use for prediction which we explore in the next section, called Simple Linear Regression.

Correlation is Not Causation

Just because two variables are significantly correlated does not imply a cause and effect relationship. There are several relationships that are possible. It could be that \(x\) causes \(y\) to change. You can actually swap \(x\) and \(y\) in the fields and get the same \(r\) value and \(y\) could be causing \(x\) to change. There could be other variables that are affecting the two variables of interest. For instance, you can usually show a high correlation between ice cream sales and home burglaries. Selling more ice cream does not “cause” burglars to rob homes. More home burglaries do not cause more ice cream sales. We would probably notice that the temperature outside may be causing both ice cream sales to increase and more people to leave their windows open. This third variable is called a lurking variable and causes both \(x\) and \(y\) to change, making it look like the relationship is just between \(x\) and \(y\).

There are also highly correlated variables that seemingly have nothing to do with one another. These seemingly unrelated variables are called spurious correlations.

The following website has some examples of spurious correlations (a slight caution that the author has some gloomy examples): http://www.tylervigen.com/spurious-correlations. Figure 12-7 is one of their examples:

Chart from tylervigen.com, showing correlation from 2000 to 2009 between per-capita mozzerella cheese consumption number of civil engineering doctorates awarded.
Figure 12-7: Example of spurious correlations. (6/25/2020) Retrieved from http://tylervigen.com/view_correlation?id=28726.

If we were to take out each pair of measurements by year from the time-series plot in Figure 12-7, we would get the following data.

Year Engineering Doctorates Mozzarella Cheese Consumption
2000 480 9.3
2001 501 9.7
2002 540 9.7
2003 552 9.7
2004 547 9.9
2005 622 10.2
2006 655 10.5
2007 701 11
2008 712 10.6
2009 708 10.6

Using Excel to find a scatterplot and compute a correlation coefficient, we get the scatterplot shown in Figure 12-8 and a correlation of \(r = 0.9586\).

Excel-generated scatterplot of the spurious correlation example, with mozzarella cheese consumption on the x-axis and engineering doctorates on the y-axis.
Figure 12-8: Scatterplot for spurious correlation example.

With \(r = 0.9586\), there is strong correlation between the number of engineering doctorate degrees earned and mozzarella cheese consumption over time, but earning your doctorate degree does not cause one to go eat more cheese. Nor does eating more cheese cause people to earn a doctorate degree. Most likely these items are both increasing over time and therefore show a spurious correlation to one another.

When two variables are correlated, it does not imply that one variable causes the other variable to change.

“Correlation is causation” is an incorrect assumption that because something correlates, there is a causal relationship. Causality is the area of statistics that is most commonly misused, and misinterpreted, by people. Media, advertising, politicians and lobby groups often leap upon a perceived correlation and use it to “prove” their own agenda. They fail to understand that, just because results show a correlation, there is no proof of an underlying causality. Many people assume that because a poll, or a statistic, contains many numbers, it must be scientific, and therefore correct. The human brain is built to try and subconsciously establish links between many pieces of information at once. The brain often tries to construct patterns from randomness, and may jump to conclusions, and assume that a cause and effect relationship exists. Relationships may be accidental or due to other unmeasured variables. Overcoming this tendency to jump to a cause and effect relationship is part of academic training for students and in most fields, from statistics to the arts.

Summary

When looking at correlations, start with a scatterplot to see if there is a linear relationship prior to finding a correlation coefficient. If there is a linear relationship in the scatterplot, then we can find the correlation coefficient to tell the strength and direction of the relationship. Clusters of dots forming a linear uphill pattern from left to right will have a positive correlation. The closer the dots in the scatterplot are to a straight line, the closer \(r\) will be to \(1\). If the cluster of dots in the scatterplots go downhill from left to right in linear pattern, then there is a negative relationship. The closer those dots in the scatterplot are to a straight line going downhill, the closer \(r\) will be to \(-1\). Use a t-test to see if the correlation is statistically significant. As sample sizes get larger, smaller values of \(r\) become statistically significant. Be careful with outliers, which can heavily influence correlations. Most importantly, correlation is not causation. When \(x\) and \(y\) are significantly correlated, this does not mean that \(x\) causes \(y\) to change.

12.02: Simple Linear Regression

A linear regression is a straight line that describes how the values of a response variable \(y\) change as the predictor variable \(x\) changes. The equation of a line, relating \(x\) to \(y\) uses the slope-intercept form of a line, but with different letters than what you may be used to in a math class. We let \(b_{0}\) represent the sample \(y\)-intercept (the value of \(y\) when \(x = 0\)), \(b_{1}\) the sample slope (rise over run), and \(\hat{y}\) the predicted value of \(y\) for a specific value of \(x\). The equation is written as \(\hat{y} = b_{0} + b_{1}x\).

Some textbooks and the TI calculators use the letter \(a\) to represent the \(y\)-intercept and \(b\) to represent the slope, and the equation is written as \(\hat{y} = a + bx\). These letters are just symbols representing the placeholders for the numeric values for the \(y\)-intercept and slope.

If we were to fit the best line that was closest to all the points on the scatterplot we would get what we call the “line of best fit,” also known as the “regression equation” or “least squares regression line.” Figure 12-9 is a scatterplot with just five points.

Figure 12-9: A scatterplot scatter chart with 2 data series 2026-07-23T10:48:17.652423 image/svg+xml Matplotlib v3.11.1, https://matplotlib.org/
Figure 12-10 Figure 12-9: A scatterplot of five points used to illustrate the line of best fit (least-squares regression). x and y both range 0-12. (regenerated with XYZChart for the XYZ Homework web edition.)
Figure 12-9: A scatterplot.

Figure 12-10 shows the least-squares regression line of \(y\) on \(x\), which is the line that minimizes the squared vertical distance from all of the data. If we were to fit the line that best fits through the points, we would get the line pictured below.

The scatterplot, containing an additional line that passes roughly an equal distance from each of the points.
Figure 12-10: Scatterplot with least-squares regression line.

What we want to look for is the minimum of the squared vertical distance between each point and the regression equation, called a residual. This is where the name of the least squares regression line comes from. Figure 12-11 shows the squared residuals.

Figure 12-11: Scatterplot with Least-Squares Regression Line scatter chart with 2 data series 2026-07-23T10:48:17.693086 image/svg+xml Matplotlib v3.11.1, https://matplotlib.org/
Figure 12-11 Figure 12-11: Scatterplot with five points, the least-squares regression line, and squared residuals. (regenerated with XYZChart for the XYZ Homework web edition.)
Figure 12-11: Scatterplot with least-squares regression line and squared residuals.

To find the slope and \(y\)-intercept for the equation of the least-squares regression line \(\hat{y} = b_{0} + b_{1} x\) we use the following formulas: slope \(= b_{1} = \frac{SS_{xy}}{SS_{xx}}\), \(y\)-intercept: \(b_{0} = \bar{y} - b_{1} \bar{x}\).

To compute the least squares regression line, you will need to first find the slope. Then substitute the slope into the following equation of the \(y\)-intercept: \(b_{0} = \bar{y} - b_{1} \bar{x}\), where \(\bar{x}\) = the sample mean of the \(x\)’s and \(\bar{y}\) = the sample mean of the \(y\)’s.

Once we find the equation for the regression line, we can use it to estimate the response variable \(y\) for a specific value of the predictor variable \(x\).

Note: we would only want to use the regression equation for prediction if we reject \(H_{0}\) and find that there is a significant correlation between \(x\) and \(y\). Alternatively, we could start with the regression equation and then test to see if the slope is significantly different from zero.

Use the following data to find the line of best fit.

Hours Studied for Exam 20 16 20 18 17 16 15 17 15 16 15 17 16 17 14 Grade on Exam 89 72 93 84 81 75 70 82 69 83 80 83 81 84 76
Solution

Start with finding the 2-Var Stats and sum of squares as shown in the steps for correlation.

\(SS_{xx} = (n-1) s_{x}^{2} = (15-1) 1.723783215^{2} = 41.6\)

\(SS_{yy} = (n-1) s_{y}^{2} = (15-1) 6.717425811^{2} = 631.7333\)

\(SS_{xy} = \sum (xy) - n \cdot \bar{x} \cdot \bar{y} = 20087 – (15 \cdot 16.6 \cdot 80.133333) = 133.8\)

Calculate the slope: \(b_{1} = \frac{SS_{xy}}{SS_{xx}} = \frac{133.8}{41.6} = 3.216346\).

Calculate the \(y\)-intercept: \(b_{0} = \bar{y} - b_{1} \cdot \bar{x} = 80.133333 - 3.216346 \cdot 16.6 = 26.742\).

Put these numbers back into the regression equation and write your answer as: \(\hat{y} = 26.742 + 3.216346 x\).

Interpreting the \(y\)-intercept coefficient: When \(x = 0\), note that \(\hat{y} = 26.742\). This means that we would expect a failing midterm score of 26.742 for students who had studied zero hours.

Interpreting the slope coefficient: For each additional hour studied for the exam, we would expect an increase in the midterm grade of 3.2163 points.

In general, when interpreting the slope coefficient, for each additional 1 unit increase in \(x\), the predicted \(\hat{y}\) value will change by \(b_{1}\) units.

Adding the Regression Line to the Scatterplot

TI-84: Make a scatterplot using the directions from the previous section. Turn your STAT scatter plot on. Press [Y=] and clear any equations that are in the \(y\)-editor. Into Y1, enter the least-squares regression equation manually as found above. Or, press the VARS key, go to option 5: Statistics, arrow over to EQ for equation, then choose the first option RegEQ. This will bring the equation over to the Y= menu without rounding error. Press [GRAPH]. You can press [TRACE] and use the arrow keys to scroll left or right. Pressing up or down on the arrow keys will change between tracing the scatterplot and the regression line. You can use the regression line to predict values of the response variable for a given value of the explanatory variable. While tracing the regression line type the value of the explanatory variable and press [ENTER]. For example, for \(x = 19\) the value of \(\hat{y} = 87.8526\).

Setting up the scatterplot with regression line in a TI-84 calculator.
Tracing the scatterplot and the regression line with a TI-84 calculator.

TI-89: Make a scatterplot and find the regression line using the directions in the previous section. If you press [♦] then [F1] (Y=) you will notice the regression equation has been stored into y1 in the y-editor. Press [F2] Trace and use the left and right arrow keys to trace along the plot. Use the up and down arrow keys to toggle between the regression line and the scatterplot. You can use the regression line to predict values of the response variable for a given value of the explanatory variable. While tracing the regression line type the value of the explanatory variable and press [ENTER]. For example, for \(x = 19\) the value of \(y = 87.8526\).

Tracing a scatterplot and regression line using a TI-89 calculator.

12.02: Hypothesis Test for Linear Regression

To test to see if the slope is significant we will be doing a two-tailed test with hypotheses. The population least squares regression line would be \(y = \beta_{0} + \beta_{1} + \varepsilon\) where \(\beta_{0}\) (pronounced “beta-naught”) is the population \(y\)-intercept, \(\beta_{1}\) (pronounced “beta-one”) is the population slope and \(\varepsilon\) is called the error term.

If the slope were horizontal (equal to zero), the regression line would give the same \(y\)-value for every input of \(x\) and would be of no use. If there is a statistically significant linear relationship then the slope needs to be different from zero. We will only do the two-tailed test, but the same rules for hypothesis testing apply for a one-tailed test.

We will only be using the two-tailed test for a population slope.

The hypotheses are:

\(H_{0}: \beta_{1} = 0\)
\(H_{1}: \beta_{1} \neq 0\)

The null hypothesis of a two-tailed test states that there is not a linear relationship between \(x\) and \(y\). The alternative hypothesis of a two-tailed test states that there is a significant linear relationship between \(x\) and \(y\).

Either a t-test or an F-test may be used to see if the slope is significantly different from zero. The population of the variable \(y\) must be normally distributed.

F-Test for Regression

An F-test can be used instead of a t-test. Both tests will yield the same results, so it is a matter of preference and what technology is available. Figure 12-12 is a template for a regression ANOVA table,

Template for a regression table, containing equations for the sum of squares, degrees of freedom and mean square for regression and for error, as well as the F value of the data.
Figure 12-12: Regression ANOVA table template.

where \(n\) is the number of pairs in the sample and \(p\) is the number of predictor (independent) variables; for now this is just \(p = 1\). Use the F-distribution with degrees of freedom for regression = \(df_{R} = p\), and degrees of freedom for error = \(df_{E} = n - p - 1\). This F-test is always a right-tailed test since ANOVA is testing the variation in the regression model is larger than the variation in the error.

Use an F-test to see if there is a significant relationship between hours studied and grade on the exam. Use \(\alpha\) = 0.05.

Hours Studied for Exam 20 16 20 18 17 16 15 17 15 16 15 17 16 17 14 Grade on Exam 89 72 93 84 81 75 70 82 69 83 80 83 81 84 76
Solution

The hypotheses are:

\(H_{0}: \beta_{1} = 0\)
\(H_{1}: \beta_{1} \neq 0\)

Compute the sum of squares.

\(SS_{xx} = 41.6\), \(SS_{yy} = 631.7333\), \(SS_{xy} = 133.8\), \(n = 15\) and \(p = 1\)

\(SSR = \frac{\left(SS_{xy}\right)^{2}}{SS_{xx}} = \frac{(133.8)^{2}}{41.6} = 430.3471154\)

\(SSE = SST - SSR = 631.7333 - 430.3471154 = 201.3862\)

\(SST = SS_{yy} = 631.7333\)

Compute the degrees freedom.

\(df_{T} = n - 1 = 14 \quad\quad df_{E} = n - p - 1 = 15 - 1 - 1 = 13\)

Compute the mean squares.

\(MSR = \frac{SSR}{p} = \frac{430.3471154}{1} = 430.3471154 \quad\quad MSE = \frac{SSE}{n-p-1} = \frac{201.3862}{13} = 15.4912\)

Compute the Test Statistic

\(F = \frac{MSR}{MSE} = \frac{430.3471154}{15.4912} = 27.7801\)

Substitute the numbers into the ANOVA table:

Regression ANOVA table containing the values calculated above.

This is a right-tailed F-test with \(df = 1, 13\) and \(\alpha\) = 0.05, which gives a critical value of 4.667.

In Excel we can find the critical value by using the function =F.INV.RT(0.05,1,13) = 4.667.

Graph of the F-distribution with right tail, starting at the critical value of 4.667, shaded in.

Or use the online calculator at https://homepage.divms.uiowa.edu/~mbognar/applets/f.html to visualize the critical value, as shown in Figure 12-13. It is hard to see the shaded tail in the following picture above the test statistic since the F-distribution is so close to the \(x\)-axis after 3, but it has the right-tail shaded from 4.667 and greater.

F-distribution generated by an online calculator with inputs of a df_1 value of 1, a df_2 value of 13, a critical value of 4.66719, and an alpha of 0.05.
Figure 12-13: F-distribution graph generated by online calculator, with the input values displayed.

The test statistic 27.78 is even further out in the tail than the critical value, so we would reject \(H_{0}\). At the 5% level of significance, there is a statistically significant relationship between hours studied and grade on a student’s final exam.

The p-value could also be used to make the decision. The p-value method would use the function =F.DIST.RT(27.78,1,13) = 0.00015 in Excel. The p-value is less than \(\alpha\) = 0.05, which also verifies that we reject \(H_{0}\).

The following is the output from Excel and SPSS. Note the same ANOVA table information is shown but the columns are in a different order.

Excel
Regression ANOVA table generated by Excel.

SPSS
Regression ANOVA table generated by SPSS.

T-Test for Regression

If the regression equation has a slope of zero, then every \(x\) value will give the same \(y\) value and the regression equation would be useless for prediction. We should perform a t-test to see if the slope is significantly different from zero before using the regression equation for prediction. The numeric value of t will be the same as the t-test for a correlation. The two test statistic formulas are algebraically equal; however, the formulas are different and we use a different parameter in the hypotheses.

The formula for the t-test statistic is \(t = \frac{b_{1}}{\sqrt{ \left(\frac{MSE}{SS_{xx}}\right) }}\)

Use the t-distribution with degrees of freedom equal to \(n - p - 1\).

The t-test for slope has the same hypotheses as the F-test:

\(H_{0}: \beta_{1} = 0\)
\(H_{1}: \beta_{1} \neq 0\)

Use a t-test to see if there is a significant relationship between hours studied and grade on the exam, use \(\alpha\) = 0.05.

Hours Studied for Exam 20 16 20 18 17 16 15 17 15 16 15 17 16 17 14 Grade on Exam 89 72 93 84 81 75 70 82 69 83 80 83 81 84 76
Solution

The hypotheses are:

\(H_{0}: \beta_{1} = 0\)
\(H_{1}: \beta_{1} \neq 0\)

Find the critical value using \(df_{E} = n - p - 1 = 13\) for a two-tailed test \(\alpha\) = 0.05 inverse t-distribution to get the critical values \(\pm 2.160\).

Draw the sampling distribution and label the critical values, as shown in Figure 12-14.

Graph of the t-distribution with both tails shaded in, starting at the critical values of positive and negative 2.160.
Figure 12-14: Graph of t-distribution with labeled critical values.

The critical value is the same as we found using the t-test for correlation.

Next, find the test statistic \(t = \frac{b_{1}}{\sqrt{ \left(\frac{MSE}{SS_{xx}}\right) }} = \frac{3.216346}{\sqrt{ \left(\frac{15.4912}{41.6}\right) }}\) = 5.271\).

The test statistic value is the same value of the t-test for correlation even though they used different formulas. We look in the same place using technology as the correlation test.

Using a calculator to conduct a LinRegTTest and find the value for t.

The test statistic is greater than the critical value of 2.160 and in the rejection region. The decision is to reject \(H_{0}\).

Summary: At the 5% significance level, there is enough evidence to support the claim that there is a significant linear relationship (correlation) between the number of hours studied for an exam and exam scores. The p-value method could also be used to find the same decision.

The p-value = 0.00015, the same as the previous tests. We will use technology for the p-value method. In the SPSS output, they use Sig. for the p-value.

Excel
Excel-generated table of coefficients, standard error, t-statistic and p-value for the intercept and hours studied.

SPSS
SPSS-generated table of coefficients, standard error, t-statistic, and Sig. for the intercept and hours studied.

12.02: Residuals

When we overlay the regression equation on a scatterplot, most of the time, the points do not lie on the line itself. The vertical distance between the actual value of \(y\) and the predicted value of \(\hat{y}\) is called the residual. The numeric value of the residual is found by subtracting the predicted value of \(y\) from the actual value of \(y\): \(y - \hat{y}\). When we find the line of best fit using least squares regression, this finds the regression equation with the smallest sum of the residuals \(\sum y - \hat{y}\).

When your residual is positive, then your data point is above the regression line, when the residual is negative, your data point is below the regression line. If you were to find the residuals for all the sample points and add them up you would get zero. The expected value of the residuals will always be zero. The regression equation is found so that there is just as much distance for the residuals above the line as there is below the line.

Find the residual for the point \((15, 80)\) for the exam data.

Hours Studied for Exam 20 16 20 18 17 16 15 17 15 16 15 17 16 17 14 Grade on Exam 89 72 93 84 81 75 70 82 69 83 80 83 81 84 76
Solution

Figure 12-15 is a scatterplot with the regression equation \(\hat{y} = 26.742 + 3.216346 x\) from the exam data.

Figure 12-15: Exam Grade vs. Hours Studied with Regression Line scatter chart with 2 data series 2026-07-23T10:48:17.737810 image/svg+xml Matplotlib v3.11.1, https://matplotlib.org/
Figure 12-15 Scatterplot of exam grade versus hours studied for the 15-student exam dataset, overlaid with the least-squares regression line y-hat = 26.742 + 3.216346x. (regenerated with XYZChart for the XYZ Homework web edition.)
Figure 12-15: Scatterplot showing the linear prediction of grades and the distance from point (15, 80) to the predicted grade for \(x = 15\).

The blue diamonds represent the sample data points. The orange squares are the predicted \(y\) for each value of \(x\). If we connect the orange squares, we get the linear regression equation. The vertical distance between each data point and the regression equation is called the residual. The numeric value can be found by subtracting the observed \(y\) with its corresponding predicted value, \(y - \hat{y}\). We use \(e_{i}\) to represent the \(i^{th}\) residual where \(e_{i} = y_{i} - \hat{y}_{i}\). The residual for the point \((15, 80)\) is drawn on the scatterplot vertically as a yellow double-sided arrow to visually show the size of the residual.

If you were to predict a student’s exam grade when they studied 15 hours, you would get a predicted grade of \(\hat{y} = 26.742 + 3.216346 \cdot 15 = 74.9865\). The residual for the point \((15, 80)\) then would be \(y - \hat{y} = 80 - 74.9865 = 5.0135\). This is the length of the vertical yellow arrow connecting the point \((15, 80)\) to the point \((15, 74.9865)\).

Standard Error of Estimate

The standard deviation of the residuals is called the standard error of estimate or \(s\). Some texts will use a subscript \(s_{e}\) or \(s_{est}\) to distinguish the different standard deviations from one another. When all of your data points line up in a perfectly straight line, \(s = 0\) since none of your points deviate from the regression line. As your data points get more scattered away from a regression line, \(s\) gets larger. When you are analyzing a regression model, you want \(s\) to be as small as possible.

Standard Error of Estimate

\[s_{est} = s = \sqrt{\frac{\sum \left(y_{i} - \hat{y}_{i}\right)^{2}}{n-2}} = \sqrt{MSE} \nonumber\]

The standard error of estimate is the standard deviation of the residuals. The standard error of estimate measures the deviation in the vertical distance from data points to the regression equation. The units of \(s\) are the same as the units of \(y\).

Use the exam data to find the standard error of estimate.

Solution

To find the \(\sum \left(y_{i} - \hat{y}_{i}\right)^{2}\) you would need to find the residual for every data point, square the residuals, and sum them up. This is a lot of math. Recall the regression ANOVA table found earlier. The MSE = 15.4912.

Regression ANOVA table for exam data.

The mean square error is the variance of the residuals, if we take the square root of the MSE we find the standard deviation of the residuals, which is the standard error of estimate.

\(s = \sqrt{MSE} = \sqrt{15.4912} = 3.9359\)

You can also use the technology to find \(s\).

Screenshots of Excel and SPSS regression statistics outputs, and TI-84 and TI-89 linear regression t-test outputs, all showing values of 3.93589 for s, the standard error.

12.02: Coefficient of Determination

The coefficient of determination \(R^{2}\) (or \(r^{2}\)) is the fraction (or percent) of the variation in the values of \(y\) that is explained by the least-squares regression of \(y\) on \(x\). \(R^{2}\) is a measure of how well the values of \(y\) are explained by \(x\).

For example, there is some variability in the dependent variable values, such as grade. Some of the variation in student’s grades is due to hours studied and some is due to other factors. How much of the variation in a student’s grade is due to hours studied?

When considering this question, you want to look at how much of the variation in a student’s grade is explained by the number of hours they studied and how much is explained by other variables. Realize that some of the changes in grades have to do with other factors. You can have two students who study the same number of hours, but one student may have a higher grade. Some variability is explained by the model and some variability is not explained. Together, both of these give the total variability.

\[\begin{aligned} \text{(Total Variation)} &= \text{(Explained Variation)} & + \quad \text{(Unexplained Variation)} \\ \quad \sum \left(y - \bar{y}\right)^{2} &= \quad \sum \left(\hat{y} - \bar{y}\right)^{2} & + \sum \left(y - \bar{y}\right)^{2} \end{aligned}\]

Coefficient of Determination

The proportion of the variation that is explained by the model is \[R^{2} = \frac{\text{Explained Variation}}{\text{Total Variation}} = \frac{SSR}{SST} \nonumber\]

Find and interpret the coefficient of determination for the hours studied and exam grade data.

Hours Studied for Exam 20 16 20 18 17 16 15 17 15 16 15 17 16 17 14 Grade on Exam 89 72 93 84 81 75 70 82 69 83 80 83 81 84 76
Solution

The coefficient of determination is this correlation coefficient squared. Note: when \(r\) is negative, then when you square \(r\) the answer becomes positive. For the hours studied and exam grade \(r = 0.825358\), so \(r^{2} = R^{2} = 0.825358^{2} = 0.6812\).

Approximately 68% of the variation in a student’s exam grade is explained by the least square regression equation and the number of hours a student studied.

TI-84: Press the [STAT] key, arrow over to the [TESTS] menu, arrow down to the option [LinRegTTest] and press the [ENTER] key. The default is Xlist:L1, Ylist:L2, Freq:1, \(\beta\) and \(\rho: \neq 0\). Arrow down to Calculate and press the [ENTER] key. The calculator returns the \(y\)-intercept = \(a = b_{0}\), slope = \(b = b_{1}\), the standard error of estimate = \(s\), the coefficient of determination = \(r^{2} = R^{2}\), and the correlation coefficient = \(r\).

Selecting and setting up the LinRegTTest from the Tests menu on the TI-84 calculator, and scrolling through the output to find the values of r and r^2.

TI-89: In the Stats/List Editor select F6 for the Tests menu. Use cursor keys to select A:LinRegTTest and press [Enter]. In the “X List” space type in the name of your list with the \(x\) variable without spaces: for our example, “list1.” In the “Y List” space type in the name of your list with the \(y\) variable without spaces: for our example, “list2.” Under the “Alternate Hyp” menu, select the \(\neq\) sign that is the same as the problem’s alternative hypothesis statement then press the [ENTER] key, arrow down to [Calculate] and press the [ENTER] key. The calculator returns the \(y-\)intercept of the regression line = \(a = b_{0}\), the slope of the regression line = \(b = b_{1}\), the correlation = \(r\), and the coefficient of determination = \(r^{2} = R^{2}\).

Selecting and setting up the LinRegTTest on the TI-89 calculator, and scrolling through the output to view the values of r and r^2.

Regression statistics output tables in Excel and SPSS, as well as the LinRegTTest output in both the TI-84 and TI-89 calculators, all display the same value of 0.681 for the coefficient of determination r^2 in for this data set.

The coefficient of determination can take on any value between 0 and 1, or 0% to 100%. The closer \(R^{2}\) is to 100%, the better the regression equation models the data. Unlike \(r\), which can only be used for simple linear regression, we can use \(R^{2}\) for different types of regression. In more advanced courses, if we were to do non-linear or multiple linear regression we could compare different models and pick the one that has the highest \(R^{2}\).

For instance, if we ran a linear regression the scatterplot that showed an obvious curve pattern we would get a regression equation with a zero slope and \(R^{2} = 0\). See Figure 12-16.

If we were to fit a parabola through the data we get a perfect fit and \(R^{2} = 1\). See Figure 12-17.

Scatterploint of data points in a parabolic format, whose linear regression line is horizontal with equation y=22 and R^2 = 0.
Figure 12-16: Linear regression on parabolic scatterplot.
Scatterplot of data points in a parabolic format, whose nonlinear regression line is a perfect fit of formula y =-0.2x^2 + 50 and R^2 = 1.
Figure 12-17: Nonlinear regression on parabolic scatterplot.

12.02: Prediction

We can now use the least squares regression equation for prediction.

Use the regression equation to predict the grade for a student who has studied for 18 hours for their exam using the previous data.

Hours Studied for Exam 20 16 20 18 17 16 15 17 15 16 15 17 16 17 14 Grade on Exam 89 72 93 84 81 75 70 82 69 83 80 83 81 84 76
Solution

We found the regression equation \(\hat{y} = 26.742 + 3.216346 x\). The \(x\)-variable is the hours studied so let \(x = 18\) hours. \(\hat{y}\) is the symbol for the predicted \(y\).

Substitute \(x = 18\) into the regression equation and you get: \(\hat{y} = 26.742 + 3.216346 \cdot 18 = 84.636228\). We would estimate the student’s grade to be 84.6 when they studied 18 hours. This is a point estimate for the grade on the exam for a student that studied 18 hours.

Prediction Interval

We can find a special type of confidence interval to estimate the true value of \(y\) called the prediction interval.

The prediction interval is the confidence interval for the actual value of \(y\): \[\hat{y} \pm t_{\alpha / 2} \cdot s \sqrt{\left( 1 + \frac{1}{n} + \frac{(x - \bar{x})^{2}}{SS_{xx}}\right)} \nonumber\]

where \(\hat{y}\) is the predicted value of \(y\) for the given value of \(x\).

Using the previous data, find and interpret the 95% prediction interval for a student who studies 18 hours.

Solution

From the question, \(x = 18\). From previous examples we found that \(\hat{y} = 26.742 + 3.216346 \cdot 18 = 84.636228\) and \(s = 3.935892\). Find the critical value from the invT using \(df = n - 2 = 13\); we get \(t_{\alpha / 2} = 2.160369\). Make sure to go out at least 6 decimal places in between steps. Ideally, never round between steps. Use the 2-Var Stats from your calculator to find the sums and then substitute values back into the equation to get

\[\begin{aligned} & 84.636228 \pm 2.1600369 \cdot 3.935892 \sqrt{\left( 1 + \frac{1}{15} + \frac{(18 - 16.6)^{2}}{41.6} \right)} \\ & \Rightarrow \quad 84.636228 \pm 8.9723 \\ & \Rightarrow \quad 75.6639 < y < 93.6085 \end{aligned}\]

We are 95% confident that the predicted exam grade for a student that studies 18 hours is between 75.6639 and 93.6085.

A confidence interval can be more accurate (narrower) when you increase the sample size. Note that in the last example, the predicted grade for an individual student could have been anywhere from a C to an A grade. If you wanted to predict \(y\) with more accuracy, then you would want to sample more than 15 students to get a smaller margin of error. The confidence interval for a mean will have a smaller margin of error than for an individual’s predicted value.

Excel, the TI-83 and 84 do not have built in prediction intervals.

TI-89: Enter the \(x\)-values in list1 and the \(y\)-values in list2, select [F7] Intervals, then select option 7:LinRegTInt… Use the Var-Link button to enter in list1 and list2 for the X List and Y List. Select Response in the drop-down menu for Interval. Enter in the \(x\)-value given in the question. Change the confidence level (C-Level) to match what was in the question, the [Enter]. Scroll down to Pred Int for the prediction interval. The calculator does not round between steps so if you rounded \(b_{0}\) and \(b_{1}\), for instance, when doing hand calculations, your answer may be slightly different than the calculator results.

Entering confidence levels in the Response interval type in the TI-89 Linear Regression T Test setup.

Extrapolation is the use of a regression line for prediction far outside the range of values of the independent variable \(x\). As a general rule, one should not use linear regression to estimate values too far from the given data values. The further away you move from the center of the data set, the more variable results become. For instance, we would not want to estimate a student’s grade for someone that studied way less than 14 hours or more than 20 hours.

12.02: Outliers

A scatter plot should be checked for outliers. An outlier is a point that seems out of place when compared with the other points. Some of these points can affect the equation of the regression line.

Should linear regression be used with this data set?

\(x\) 1 3 8 2 1 3 2 2 3 1 \(y\) 2 3 8 2 3 1 3 1 2 1
Solution

A regression analysis for the data set was run on Excel.

Excel-generated table of regression statistics for the given data.

If we test for a significant correlation:

\(H_{0}: \rho = 0\)
\(H_{1}: \rho \neq 0\)

The correlation is \(r = 0.844\) and the p-value is 0.002, which is less than \(\alpha\) = 0.05, so we would reject \(H_{0}\) and conclude there is a significant relationship between \(x\) and \(y\).

However, if look at the scatterplot in Figure 12-18, with the regression equation we can clearly see that the point \((8,8)\) is an outlier. The outlier is pulling the slope up towards the point \((8,8)\).

Figure 12-18: Scatterplot of data with an outlier scatter chart with 2 data series 2026-07-23T10:48:17.784224 image/svg+xml Matplotlib v3.11.1, https://matplotlib.org/
Figure 12-18 Figure 12-18: Scatterplot of the data with a fitted linear regression line (y = 0.8438x + 0.4063, R^2 = 0.7119). The point (8,8) is a leverage-point outlier that pulls th (regenerated with XYZChart for the XYZ Homework web edition.)
Figure 12-18: Scatterplot of data with an outlier.

If we were to take out the outlier point \((8,8)\) and run the regression analysis again on the modified data set we get the following Excel output.

Excel-generated regression statistics table of the given data with the (8, 8) outlier removed.

See Figure 12-19: note the correlation is now 0 and the p-value is 1, so there is no relationship at all between \(x\) and \(y\).

Scatterplot of the given data with the outlier point (8, 8) removed. Plot now takes the form of a 3-by-3 grid of points bounded by x and y values of 1 and 3, with the linear regression line equation now being y=2 and the R-squared value being 0.
Figure 12-19: Scatterplot of the same data as above with outlier removed.

This type of outlier is called a leverage point. Leverage points are positioned far away from the main cluster of data points on the \(x\)-axis.

There is another type of outlier called an influential point. Influential points are positioned far away from the main cluster of data points on the \(y\)-axis. There is an option in most software packages to get the “standardized” residuals. Standardized residuals are z-scores of the residuals. Any standardized residual that is not between \(-2\) and \(2\) may be an outlier. If it is not between \(-3\) and \(3\) then the point is an outlier. When this happens, the points are called influential points or influential observations.

Use technology to compute the standardized residuals. Should linear regression be used with this data set?

\(x\) 1 3 2 2 4 5 7 9 6 8 \(y\) 1 3 10 2 4 5 7 9 6 8
Solution

A regression analysis for the given data set was run on Excel, producing the following results:

Regression analysis table for the given data. Observation 3, the data point (2, 10), has a standard residual of 2.671, which is highlighted. All other observations have standard residual values between -1 and 1.

The point \((2, 10)\) shown in Figure 12-20 is pulling the left side of the line up and away from the points that form a line. This influential point changes the \(y\)-intercept and slope.

Scatterplot of the given data points. All points except for (2, 10) appear to line up; the regression line does not pass evenly through these points, but is tilted towards the (2, 10) point.
Figure 12-20:

12.02: Conclusion - Simple Linear Regression

A lurking variable is a variable other than the independent or dependent variables that may influence the regression line. For instance, the highly correlated ice cream sales and home burglary rates probably have to do with the season. Hence, linear regression does not imply cause and effect.

Two variables are confounded when their effects on the dependent variable cannot be distinguished from each other. For instance, if we are looking at diet predicting weight, a confounding variable would be age. As a person gets older, they can gain more weight with fewer calories compared to when they were younger. Another example would be predicting someone’s midterm score from hours studied for the exam. Some confounding variables would be GPA, IQ score, and teacher’s difficultly level.

Assumptions for Linear Regression

There are assumptions that need to be met when running simple linear regression. If these assumptions are not met, then one should use more advanced regression techniques.

The assumptions for simple linear regression are:

  • The data need to follow a linear pattern.
  • The observations of the dependent variable y are independent of one another.
  • Residuals are approximately normally distributed.
  • The variance of the residuals is constant.

Most software packages will plot the residuals for each \(x\) on the \(y\)-axis against either the \(x\)-variable or \(\hat{y}\) along the \(x\)-axis. This plot is called a residual plot. Residual plots help determine some of these assumptions.

Use technology to compute the residuals and make a residual plot for the hours studied and exam grade data.

Hours Studied for Exam 20 16 20 18 17 16 15 17 15 16 15 17 16 17 14 Grade on Exam 89 72 93 84 81 75 70 82 69 83 80 83 81 84 76
Solution

Plot the residuals.

TI-84: Find the least-squares regression line as described in the previous section. Press [Y=] and clear any equations that are in the \(y\)-editor. Press [2nd] then [STAT PLOT] then press 1 or hit [ENTER] to select Plot1. Select On and press [ENTER] to activate plot 1. For “Type” select the first graph that looks like a scatterplot and press [ENTER]. For “Xlist” enter whichever list where your explanatory variable data is stored. For our example, enter L1. For “Ylist” press [2nd] [LIST] then scroll down to RESID and press [ENTER]. The calculator automatically computes the residuals and stores them in a list called RESID. Press [ZOOM] then press 9 or scroll down to ZoomStat and press [ENTER].

Using the TI-84 to activate Plot 1, select ZoomStat from the Zoom menu, and view the plotted residuals.

TI-89: Find the least-squares regression line as described in the previous section. Press [♦] then [F1] (Y=) and clear any equations that are in the \(y\)-editor. In the Stats/List Editor select F2 for the Plots menu. Use cursor keys to highlight 1:Plot Setup. Make sure that the other graphs are turned off by pressing F4 button to remove the check marks. Under “Plot 2” press F1 for the Define menu. In the “Plot Type” menu select “Scatter.” In the “x” space type in the name of your list with the x variable without space, for our example “list1.” In the “y” space press [2ND] [-] for the VAR-LINK menu. Scroll down the list and find “resid” in the “STATVARS” menu. Press [ENTER] twice and you will be returned to the Plot Setup menu. Press F5 ZoomData to display the graph. Press F3 Trace and use the arrow keys to scroll along the different points.

Using the TI-89 calculator to enter the PlotSetup menu and select Plot 2 to plot the residuals. Viewing the plotted residuals.

Excel: Run the regression the same as in the last section when testing to see if there is a significant correlation. Type the data into two columns in Excel. Select the Data tab, then Data Analysis, then choose Regression and select OK.

Entering the given data in two adjacent columns in Excel, and selecting the "Regression" option from the Data Analysis menu.

Be careful here, the second column is the \(y\) range, and the first column is the \(x\) range.

Only check the Labels box if you highlight the labels in the input range. The output range is one cell reference where you want the output to start. Check the residuals, residual plots and normal probability plots, then select OK.

Regression pop-up window in Excel, with an input Y range of B1 to B16, an input X range of A1 to A16, the Labels option checked, and the Residuals, Residual Plots, and Normal Probability Plots options checked.

Figure 12-21 shows the Excel Output.

Excel-generated output for the regression, consisting of a regression statistics table, ANOVA table, and a table of coefficients, standard error, the t-statistic, and the P-value for the intercept and the hours studied for the exam.
Figure 12-21: Output for running a regression in Excel.

Additional output from Excel gives the residuals, residual plot, and normal probability plot; see below.

Excel-generated Residual Output table, consisting of columns for observation, predicted grade on exam, and residuals.

Excel-generated scatterplot of residuals vs hours studied for the exam, and the normal probability plot for the given data.

With this additional output, you can check the assumptions about the residuals. The residual plot is random and the normal probability plot forms an approximately straight line.

Putting It All Together

High levels of hydrogen sulfide \((\mathrm{H}_{2} \mathrm{S})\) in the ocean can be harmful to animal life. It is expensive to run tests to detect these levels. A scientist would like to see if there is a relationship between sulfate \((\mathrm{SO}_{4})\) and \(\mathrm{H}_{2} \mathrm{S}\) levels, since \(\mathrm{SO}_{4}\) is much easier and less expensive to test in ocean water. A sample of \(\mathrm{SO}_{4}\) and \(\mathrm{H}_{2} \mathrm{S}\) were recorded together at different depths in the ocean. The sample is reported below in millimolar (mM). If there were a significant relationship, the scientist would like to predict the \(\mathrm{H}_{2} \mathrm{S}\) level when the ocean has an \(\mathrm{SO}_{4}\) level of 25 mM. Run a complete regression analysis and check the assumptions. If the model is significant, then find the 95% prediction interval to predict the sulfide level in the ocean when the sulfate level is 25 mM.

Sulfate 22.5 27.5 24.6 27.3 23.1 24 24.5 28.4 25.1 24.4 Sulfide 0.6 0.3 0.6 0.4 0.7 0.5 0.7 0.2 0.3 0.7
Solution

Start with a scatterplot to see if a linear relation exists.

Figure 12-22: Scatterplot of sulfide and sulfate level data scatter chart with 2 data series 2026-07-23T10:48:17.826534 image/svg+xml Matplotlib v3.11.1, https://matplotlib.org/
Figure 12-22 Scatterplot of hydrogen sulfide level (mM, y-axis) versus sulfate level (mM, x-axis) for 10 ocean-water samples, showing a negative linear relationship. Reproduces Figure (regenerated with XYZChart for the XYZ Homework web edition.)
Figure 12-22: Scatterplot of sulfide and sulfate level data.

The scatterplot in Figure 12-22 shows a negative linear relationship. Test to see if the linear relationship is statistically significant. Use \(\alpha\) = 0.05. You could use an F- or a t-test. I would recommend the t-test if you are using a TI calculator and an F-test if you are using a computer program like Excel or SPSS. We will do the F-test for the following example.

The hypotheses are:

\(H_{0}: \beta_{1} = 0\)
\(H_{1}: \beta_{1} \neq 0\)

Compute the sum of squares.

\(SS_{xx} = (n-1) s_{x}^{2} = (10 - 1)1.959138^{2} = 34.544\)
\(SS_{yy} = (n-1) s_{y}^{2} = (10 - 1)0.188561^{2} = 0.32\)
\(SS_{xy} = \sum (xy) - n \cdot \bar{x} \cdot \bar{y} = 123.04 - 10 \cdot 25.14 \cdot \cdot 0.5 = -2.66\)

Next, compute the test statistic.

\(\begin{array}{l} & SSR = \frac{\left(SS_{xy}\right)^{2}}{SS_{xx}} = \frac{-2.66^{2}}{34.544} = 0.2048286 \quad\quad\quad\quad & SST = SS_{yy} = 0.32 \\ & SSE = SST - SSR = 0.32 - 0.2048286 = 0.1151714 \\ & df_{T} = n - 1 = 9 & df_{E} = n - p - 1 = 10 - 1 - 1 = 8 \\ & MSR = \frac{SSR}{p} = \frac{0.24829}{1} = = 0.204829 & SE = \frac{SSE}{n-p-1} = \frac{0.115171}{8} = 0.014396 \\ & F = \frac{MSR}{MSE} = \frac{0.204829}{0.014396} = 14.228 \end{array} \)

ANOVA table filled in with the values calculated above.

Compute the p-value. This is a right-tailed F-test with \(df = 1, 8\), which gives a p-value of =F.DIST.RT(14.2277,1,8) = 0.00545.

We could also use Excel to generate the p-value.

Excel-generated ANOVA table for the given data, showing a p-value of 0.00545.

The p-value = 0.00545 < \(\alpha\) = 0.05; therefore, reject \(H_{0}\). There is a statistically significant linear relationship between hydrogen sulfide and sulfate levels in the ocean.

From the linear regression, check the assumptions and make sure there are no outliers.

The standardized residuals are between \(-2\) and \(2\), and the scatterplot does not indicate any outliers.

Standard Residuals bar chart with 1 data series 2026-07-23T10:48:46.508897 image/svg+xml Matplotlib v3.11.1, https://matplotlib.org/
Figure 12-23 Standardized residuals for the 10 sulfate/sulfide observations (all between -2 and 2, indicating no outliers). (regenerated with XYZChart for the XYZ Homework web edition.)

The Normal Probability Plot in Figure 12-23 forms an approximately straight line. This indicates that the residuals are approximately normally distributed.

Normal Probability Plot scatter chart with 2 data series 2026-07-23T10:48:17.907137 image/svg+xml Matplotlib v3.11.1, https://matplotlib.org/
Figure 12-24 Figure 12-23: Normal probability plot for the sulfate/sulfide regression example — the 10 sulfide readings (mM), sorted ascending, plotted against Excel sample percentile (regenerated with XYZChart for the XYZ Homework web edition.)
Figure 12-23: Normal probability plot.

The residual plot in Figure 12-24 has no unusual pattern. This indicates that a linear model would work well for this data.

Excel-generated sulfate residual plot. Points are clustered around x=25, with y-values ranging from 0.15 to -0.2.
Figure 12-24: Sulfate residual plot.

Now find and use the regression equation to calculate the 95% prediction interval to predict the sulfide level in the ocean when the sulfate level is 25 mM.

Find the regression equation. Calculate the slope: \(b_{1} = \frac{SS_{xy}}{SS_{xx}} = \frac{-2.66}{34.544} = -0.077\).

Then calculate the \(y\)-intercept: \(b_{0} = \bar{y} - b_{1} \cdot \bar{x} = 0.5 - (-0.077) \cdot 25.14 = 2.43586\).

Put the numbers back into the regression equation and write your answer as: \(\hat{y} = 2.4359 + (-0.077)x\) or as \(\hat{y} = 2.4359 - 0.077x\).

We can use technology to get the regression equation. Coefficients are found in the first column in the computer output.

Excel-generated regression analysis table.

We would expect variation in our predicted value every time a new sample is used. Find the 95% prediction interval to estimate the sulfide level when the sulfate level is 25 mM.

Use the prediction interval equation \(\hat{y} \pm t_{\alpha / 2} \cdot s \sqrt{\left(1 + \frac{1}{n} + \frac{\left(x - \bar{x}\right)^{2}}{SS_{xx}}\right)}\).

Substitute \(x = 25\) into the equation to get \(\hat{y} = 2.43586 - 0.0770032 \cdot 25 = 0.51078\).

To find \(t_{\alpha/2}\) use your calculator's invT with \(df_{E} = n - 2 = 8\) and left-tail area \(\frac{\alpha}{2} = \frac{0.05}{2} = 0.025\), gives \(t_{0.025} = \pm 2.306004\).

Finding the linear regression t-interval using a TI-89 calculator.

The standard error of estimate \(s = \sqrt{MSE} = \sqrt{0.014396} = 0.11998\), which can also be found using technology.

Excel-generated table of regression statistics for the given data, including standard error of 0.119985.

From the earlier descriptive statistics, we have \(n = 10\), \(\bar{x}= 25.14\), \(SS_{xx} = 34.544\). Substitute each of these values into the prediction interval to get the following:

\(0.51078 \pm 2.306004 \cdot 0.119985 \sqrt{\left(1 + \frac{1}{10} + \frac{(25 - 25.14)^{2}}{34.544}\right)}\)

\(0.51078 \pm 0.290265\)

\(0.2205 < y < 0.8010\)

We can be 95% confident that the true sulfide level in the ocean will be between 0.2205 and 0.801 mM when the sulfate level is 25 mM.

Summary

A simple linear regression should only be performed if you observe visually that there is a linear pattern in the scatterplot and that there is a statistically significant correlation between the independent and dependent variables. Use technology to find the numeric values for the \(y\)-intercept = \(a = b_{0}\) and slope = \(b = b_{1}\), then make sure to use the correct notation when substituting your numbers back in the regression equation \(\hat{y} = b_{0} + b_{1} x\). Another measure of how well the line fits the data is called the coefficient of determination \(R^{2}\). When \(R^{2}\) is close to 1 (or 100%), then the line fits the data very closely. The advantage over using \(R^{2}\) over \(r\) is that we can use \(R^{2}\) for nonlinear regression, whereas \(r\) is only for linear regression.

One should always check the assumptions for regression before using the regression equation for prediction. Make sure that the residual plots have a completely random horizontal band around zero. There should be no patterns in the residual plots such as a sideways V that may indicate a non-constant variance. A pattern like a slanted line, a U, or an upside-down U shape would suggest a non-linear model. Check that the residuals are normally distributed; this is not the same as the population being normally distributed. Check to make sure that there are no outliers. Be careful with lurking and confounding variables.

12.03: Multiple Linear Regression

A multiple linear regression line describes how two or more predictor variables affect the response variable \(y\). An equation of a line relating \(p\) independent variables to \(y\) is of the form for the population as: \(y = \beta_{0} + \beta_{1} x_{1} + \beta_{2} x_{2} + \cdots + \beta_{p} x_{p} + \varepsilon\), where \(\beta_{1}, \beta_{2}, \ldots, \beta_{p}\) are the slopes, \(\beta_{0}\) is the \(y\)-intercept and \(\varepsilon\) is called the error term.

We use sample data to estimate this equation using the predicted value of \(y\) as \(\hat{y}\) with the regression equation (also called the line of best fit or least squares regression line) as: \[y = b_{0} + b_{1} x_{1} + b_{2} x_{2} + \cdots + b_{p} x_{p} \nonumber\]

where \(b_{1}, b_{2}, \ldots, b_{p}\) are the slopes, and \(b_{0}\) is the \(y\)-intercept

For example, if we had two independent variables, we would have a 3-dimensional space as in Figure 12-25 where the red dots represent the sample data points and the equation would be a plane in the space represented by \(y = b_{0} + b_{1} x_{1} + b_{2} x_{2}\).

A three-dimensional coordinate system with axes for x1 and x2 forming the "floor" and the y-axis running vertically, containing a number of data points in red. A diagonal plane represents the "best fit" of these data points, with a vertical line connecting each point to the plane.
Figure 12-25: Multiple linear regression with 2 independent variables. This photo by unknown author is licensed under CC BY-SA-NC.

The calculations use matrix algebra, which is not a prerequisite for this course. We will instead rely on a computer to calculate the multiple regression model.

If all the population slopes were equal to zero, the model \(y = \beta_{0} + \beta_{1} x_{1} + \beta_{2} x_{2} + \cdots + \beta_{p} x_{p} + \varepsilon\) would not be significant and should not be used for prediction. If one or more of the population slopes are not equal to zero then the model will be significant, meaning there is a significant relationship between the independent variables and the dependent variable and we may want to use this model for prediction. There are other statistics to look at to decide if this would be the best model to use. Those methods are discussed in more advanced courses.

The hypotheses will always have an equal sign in the null hypotheses.

The hypotheses are:

\(H_{0}: \beta_{1} = \beta_{2} = \cdots = \beta_{p} = 0\)
\(H_{1}:\) At least one slope is not zero.

Note that the alternative hypothesis is not written as \(H_{1}: \beta_{1} \neq \beta_{2} \neq \cdots \neq \beta_{p} \neq 0\). This is because we just want one or more of the independent variables to be significantly different from zero, not necessarily all the slopes unequal to zero.

Use the F-distribution with degrees of freedom for regression = \(df_{R} = p\), where \(p\) = the number of independent variables (predictors), and degrees of freedom for error = \(df_{E} = n - p - 1\), where \(n\) is the number of pairs. This is always a right-tailed ANOVA test, since we are testing if the variation in the regression model is larger than the variation in the error.

The test statistic and p-value are the last two values on the right in the ANOVA table. The p-value rule is easiest to use since the p-value is part of the outcome, but a critical value can be found using the invF program on your calculator or in Excel using =F.INV.RT(\(\alpha, df_{R}, df_{E}\)) We can also single out one independent variable at a time and use a t-test to see if the variable is significant by itself in predicting \(y\).

This would have hypotheses:

\(H_{0}: \beta_{i} = 0\)
\(H_{1}: \beta_{i} \neq 0\)
where \(i\) is a placeholder for whichever independent variable is being tested.

This t-test is found in the same row as the coefficient that you are testing.

Assumptions for Multiple Linear Regression

When doing multiple regression, the following assumptions need to be met:

  1. The residuals of the model are approximately normally distributed.
  2. The residuals of the model are independent (not autocorrelated) and have a constant variance (homoscedasticity).
  3. There is a liner relationship between the dependent variable and each independent variable.
  4. Independent variables are uncorrelated with each other (no multicollinearity).

The following is a schematic for the regression output for Microsoft Excel. Other software usually has a similar output but may have numbers in slightly different places. The blue spaces have the descriptions of the corresponding numbers.

Excel-generated regression statistics table, ANOVA table, and table of coefficients, standard error, t-stat and p-value for the y-intercept, first x variable, second x variable, and third x variable.
Figure 12-26: Excel output for multiple linear regression.

The coefficients column gives the numeric values to find the regression equation \(y = b_{0} + b_{1} x_{1} + b_{2} x_{2} + \cdots + b_{p} x_{p}\). The p-values for \(b_{i}\) should be investigated to see if the variable is statistically significant. One should also be careful that the independent variables are not significantly correlated amongst themselves. Correlated independent variables may give unexpected outcomes in the overall regression model and actually flip the sign on a coefficient.

A sample of 30 homes that were recently on the market were selected. The listing price in $1,000’s of the home, the livable square feet of the home, the lot size in 1,000’s of square feet and the number of bathrooms in the home were recorded. A multiple linear regression was done in Excel with the following output. Test to see if there is a significant relationship between the listing price of a home with the livable square feet, lot size, and number of bathrooms. If there is a relationship, then use the regression model to predict the listing price for a home that has 2,350 square feet, 3 bathrooms and has a 5,000 square foot lot. Use \(\alpha\) = 0.05.

 excel-generated=

Solution

First, we need to test to see if the overall model is significant.

The hypotheses are:

\(H_{0}: \beta_{1} = \beta_{2} = \beta_{3} = 0\)
\(H_{1}:\) At least one slope is not zero.

The test statistic is \(F = 187.9217\) and the p-value = \(9.74E-18 \sim 0\)

Isolated view of the ANOVA table from the given data, with the F-value of 187.9217 and the p-value of 9.74E-18 highlighted.

We reject \(H_{0}\), since the p-value is less than \(\alpha\) = 0.05. There is enough evidence to support the claim that there is a significant relationship between the number of bathrooms and lot size of a home with its listing price. Since we reject \(H_{0}\), we can use the regression model for prediction.

The question asked to predict the listing price for a home that has 2,350 square feet, 3 bathrooms and has a 5,000 square foot lot. This gives us \(x_{1} = 2350\), \(x_{2} = 5\) (5,000 square feet), and \(x_{3} = 3\).

The coefficients column has the values that correspond to the y-intercept and slopes gives the regression equation: \(\hat{y} = -28.8477 + 0.170908 \cdot x_{1} + 6.7705 \cdot x_{2} + 15.5347 \cdot x_{3}\).

Coefficients table from the given output, with highlighted values of -28.8477 for intercept, 0.170908 for square feet, 6.777705 for lot size, and 15.5347 for bathrooms.

Substitute the three given x values into the equation in the correct order and you get \(\hat{y} = -28.8477 + 0.170908 \cdot 2350 + 6.7705 \cdot 5 + 15.5347 \cdot 3 = 453.2787\).

This then gives a predicted listing price of $453,278.

Note that our sample size is very small and we really need to check assumptions in order to use this predicted value with any reliability.

Is this the best model to use? Note that not all the p-values for each of the individual slope coefficients are significant. The number of bathrooms has a t-test statistic = 1.687038 and p-value = 0.10356, which is not statistically significant at the 5% level of significance.

The given coefficients table with the t-stat of 1.687038 and the P-value of 0.10356 for the bathrooms variable highlighted.

We may want to rerun the regression model without the number of bathroom variables and see if we get a higher \(R^{2}\) and a lower standard error of estimate. Ideally, we would try all the different combinations of independent variables and see which combination gives the best model. This is a lot of work to do if you have many independent variables. Most statistical software packages have built in functions that find the best fit.

Adjusted Coefficient of Determination

When we add more predictor variables into the model, this inflates the coefficient of variation, \(R^{2}\). In multiple regression, we adjust for this inflation using the following formula for adjusted coefficient of variation.

Adjusted Coefficient of Determination

\[R_{adj}^{2} = 1 - \left( \frac{\left(1 - R^{2}\right) (n-1)}{(n - p - 1)} \right) \nonumber\]

Use the previous example to verify the value of the adjusted coefficient of determination starting with the regular coefficient of determination \(R^{2} = 0.955915\).

Solution

First identify in the Excel output \(R^{2} = 0.955915\), \(n - 1 = df_{T} = 29\), and \(n - p - 1 = df_{E} = 26\).

 the=

Substitute these values in and we get \(R_{adj}^{2} = 1 - \left(\frac{(1-0.955915)(29)}{(26)}\right) = 0.950828\). This is the same value as the adjusted \(R^{2}\) reported in the Excel output.

The regression statistics table previously shown, with the adjusted R-square value of 0.950828 highlighted.

The Excel output has both the adjusted coefficient of determination and the regular coefficient of determination. However, you may need the equation for the adjusted coefficient of determination depending on what information is given in a problem.

There are more types of regression models and more that should be done for a complete regression analysis. Ideally, you would find several models and pick the one with no outliers, the smallest standard error of estimate, a good residual plot, and the highest adjusted \(R^{2}\) and check the assumptions behind each model before using for prediction. More advanced techniques are discussed in a regression course.

“Well, I was in fact, I was moving backwards in time. Hmmm. Well, I think we've sorted all that out now. If you'd like to know, I can tell you that in your universe you move freely in three dimensions that you call space. You move in a straight line in a fourth, which you call time, and stay rooted to one place in a fifth, which is the first fundamental of probability. After that it gets a bit complicated, and there's all sorts of stuff going on in dimensions 13 to 22 that you really wouldn't want to know about. All you really need to know for the moment is that the universe is a lot more complicated than you might think…”

(Adams, 2002)

12.04: Chapter 12 Formulas

\(SS_{xx} = (n-1) s_{rx}^{2}\)
\(SS_{yy} = (n-1) s_{y}^{2}\)
\(SS_{xy} = \sum (xy) - n \cdot \bar{x} \cdot \bar{y}\)
Correlation Coefficient
\(r = \frac{SS_{xy}}{\sqrt{\left(SS_{xx} \cdot SS_{yy}\right)}}\)
Correlation t-test
\(H_{0}: \rho = 0\)
\(H_{1}: \rho \neq 0\)
\(t = r \sqrt{\left( \frac{n-2}{1-r^{2}} \right)}\)
\(df = n-2\)
Regression Equation (Line of Best Fit)
\(\hat{y} = b_{0} + b_{1}x\)
Slope
\(b_{1} = \frac{SS_{xy}}{SS_{xx}}\)
y-Intercept
\(b_{0} = \bar{y} - b_{1} \bar{x}\)
Slope t-test
\(H_{0}: \beta_{1} = 0\)
\(H_{1}: \beta_{1} \neq 0\)
\(t = \frac{b_{1}}{\sqrt{ \left( \frac{MSE}{SS_{xx}} \right)}}\)
\(df = n - p - 1 = n - 2\)
Slope/Model F-test
\(H_{0}: \beta_{1} = 0\)
\(H_{1}: \beta_{1} \neq 0\)
Standard Error of Estimate
\(s_{est} = \sqrt{ \frac{\sum \left(y_{i} - \hat{y}_{i}\right)^{2}}{n-2}} = \sqrt{MSE}\)
Residual
\(e_{i} = y_{i} - \hat{y}_{i}\)
Prediction Interval
\(\hat{y} \pm t_{\alpha / 2} \cdot s_{est} \sqrt{\left( 1 + \frac{1}{n} + \frac{\left(x - \bar{x}\right)^{2}}{SS_{xx}} \right)}\)
Coefficient of Determination
\(R^{2} = (r)^{2} = \frac{SSR}{SST}\)
Multiple Linear Regression Equation
\(\hat{y} = b_{0} + b_{1} x_{1} + b_{2} x_{2} + \cdot + b_{p} x_{p}\)
Model F-Test for Multiple Regression
\(H_{0}: \beta_{1} = \beta_{2} = \cdots = \beta_{p} = 0\)
\(H_{1}:\) At least one slope is not zero.
Adjusted Coefficient of Determination
\(R_{adj}^{2} = 1 - \left( \frac{\left(1 - R^{2}\right) (n-1)}{(n - p - 1)} \right)\)
 

Regression ANOVA table with equations.

12.05: Chapter 12 Exercises

Chapter 12 Exercises

1. The correlation coefficient, \(r\), is a number between _______________.

a) -1 and 1
b) -10 and 10
c) 0 and 10
d) 0 and \(\infty\)
e) 0 and 1
f) \(-\infty\) and \(\infty\)

2. To test the significance of the correlation coefficient, we use the t-distribution with how many degrees of freedom?

a) \(n - 1\)
b) \(n\)
c) \(n + 1\)
d) \(n - 2\)
e) \(n_{1} + n_{2} - 2\)

3. What are the hypotheses for testing to see if a correlation is statistically significant?

a) \(H_{0}: r = 0 \quad \ \ \ H_{1}: r \neq 0\)
b) \(H_{0}: \rho = 0 \quad \ \ \ H_{1}: \rho \neq 0\)
c) \(H_{0}: \rho = \pm 1 \quad H_{1}: \rho \neq \pm 1\)
d) \(H_{0}: r = \pm 1 \quad H_{1}: r \neq \pm 1\)
e) \(H_{0}: \rho = 0 \quad \ \ \ H_{1}: \rho = 1\)

4. The coefficient of determination is a number between _______________.

a) -1 and 1
b) -10 and 10
c) 0 and 10
d) 0 and \(\infty\)
e) 0 and 1
f) \(-\infty\) and \(\infty\)

5. Which of the following is not a valid linear regression equation?

a) \(\hat{y} = -5 + \frac{2}{9} x\)
b) \(\hat{y} = 3x + 2\)
c) \(\hat{y} = \frac{2}{9} - 5x\)
d) \(\hat{y} = 5 + 0.4 x\)

6. Body frame size is determined by a person's wrist circumference in relation to height. A researcher measures the wrist circumference and height of a random sample of individuals. The data is displayed below. Use \(\alpha\) = 0.05.

Regression statistic table with a multiple-R value of 0.7938, R-square value of 0.6301, adjusted R-square value of 0.6182, standard error of 3.8648, and observations value of 33.
Coefficient values of 31.6304 for intercept and 5.4496 for circumference, standard error values of 5.2538 for intercept and 0.7499 for circumference, t-stat values of 6.0205 for intercept and 7.2673 for circumference, and p-values of 1.16 E-06 for intercept and 3.55 E-08 for circumference.

a) What is the value of the test statistic to see if the correlation is statistically significant?

i. 6.0205
ii. 1.16E-06
iii. 3.55E-08
iv. 5.2538
v. 7.2673
vi. 0.7499
vii. 0.7938

b) What is the correct p-value and conclusion for testing if there is a significant correlation?

i. 1.16E-06; there is a significant correlation.
ii. 3.55E-08; there is a significant correlation.
iii. 1.16E-06; There is not a significant correlation.
iv. 3.55E-08, There is not a significant correlation.
v. 0.7938, There is a significant correlation.
vi. 0.7938, There is not a significant correlation.

7. Bone mineral density and cola consumption have been recorded for a sample of patients. Let \(x\) represent the number of colas consumed per week and \(y\) the bone mineral density in grams per cubic centimeter. Assume the data is normally distributed. Calculate the correlation coefficient.

\(x\) 1 2 3 4 5 6 7 8 9 10 11
\(y\) 0.883 0.8734 0.8898 0.8852 0.8816 0.863 0.8634 0.8648 0.8552 0.8546 0.862

8. A teacher believes that the third homework assignment is a key predictor of how well students will do on the midterm. Let \(x\) represent the third homework score and y the midterm exam score. A random sample of last term’s students were selected and their grades are shown below. Assume scores are normally distributed. Use \(\alpha\) = 0.05.

HW3 Midterm HW3 Midterm HW3 Midterm
13.1 59   6.4 43   20 86
21.9 87   20.2 79   15.4 73
8.8 53   21.8 84   25 93
24.3 95   23.1 92   9.7 52
5.4 39   22 87   15.1 70
13.2 66   11.4 54   15 65
20.9 89   14.9 71   16.8 77
18.5 78   18.4 76   20.1 78

a) State the hypotheses to test for a significant correlation.
b) Compute the correlation coefficient.
c) Compute the p-value to see if there is a significant correlation.
d) State the correct decision.
e) Is there a significant correlation?
f) Compute the coefficient of determination.
g) Write a sentence interpreting \(R^{2}\).
h) Does doing poorly on homework 3 cause a student to do poorly on the midterm exam? Explain.
i) Find the standard error of estimate.

9. The sum of the residuals should be ________.

a) a
b) b
c) 0
d) 1
e) \(r\)

10. An object is thrown from the top of a building. The following data measure the height of the object from the ground for a five-second period. Calculate the correlation coefficient.

Seconds 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
Height 112.5 110.875 106.8 100.275 91.3 79.875 70.083 59.83 30.65 0

11. A teacher believes that the third homework assignment is a key predictor of how well students will do on the midterm. Let \(x\) represent the third homework score and \(y\) the midterm exam score. A random sample of last term’s students were selected and their grades are shown below. Assume scores are normally distributed. Use \(\alpha\) = 0.05.

HW3 Midterm HW3 Midterm HW3 Midterm
13.1 59   6.4 43   20 86
21.9 87   20.2 79   15.4 73
8.8 53   21.8 84   25 93
24.3 95   23.1 92   9.7 52
5.4 39   22 87   15.1 70
13.2 66   11.4 54   15 65
20.9 89   14.9 71   16.8 77
18.5 78   18.4 76   20.1 78

a) Compute the regression equation.
b) Compute the predicted midterm score when the homework 3 score is 15.
c) Compute the residual for the point \((15, 65)\).
d) Find the 95% prediction interval for the midterm score when the homework 3 score is 15.

12. Body frame size is determined by a person's wrist circumference in relation to height. A researcher measures the wrist circumference and height of a random sample of individuals. The data is displayed below.

Regression statistic table with a multiple-R value of 0.7938, R-square value of 0.6301, adjusted R-square value of 0.6182, standard error of 3.8648, and observations value of 33.
Coefficient values of 31.6304 for intercept and 5.4496 for circumference, standard error values of 5.2538 for intercept and 0.7499 for circumference, t-stat values of 6.0205 for intercept and 7.2673 for circumference, and p-values of 1.16 E-06 for intercept and 3.55 E-08 for circumference. Scatterplot of the given height vs wrist circumference data.

a) Which is the correct regression equation?

i. \(\hat{y} = 31.6304 + 5.4496\)
ii. \(\hat{y} = 31.6304 + 5.4496 x\)
iii. \(\hat{y} = 5.4496 + 31.6304 x\)
iv. \(\hat{y} = 31.6304 + 5.2538 x\)
v. \(y = 31.6304 + 5.4496 x\)


b) What is the predicted height (in inches) for a person with a wrist circumference of 7 inches?
c) Which number is the standard error of estimate?
d) Which number is the coefficient of determination?
e) Compute the correlation coefficient.
f) What is the correct test statistic for testing if the slope is significant \(H_{1}: \beta_{1} \neq 0\)?
g) What is the correct p-value for testing if the slope is significant \(H_{1}: \beta_{1} \neq 0\)?
h) At the 5% level of significance, is there a significant relationship between wrist circumference and height?

13. Bone mineral density and cola consumption have been recorded for a sample of patients. Let \(x\) represent the number of colas consumed per week and \(y\) the bone mineral density in grams per cubic centimeter. Assume the data is normally distributed. Calculate the coefficient of determination.

\(x\) 1 2 3 4 5 6 7 8 9 10 11
\(y\) 0.883 0.8734 0.8898 0.8852 0.8816 0.863 0.8634 0.8648 0.8552 0.8546 0.862

14. Bone mineral density and cola consumption have been recorded for a sample of patients. Let \(x\) represent the number of colas consumed per week and \(y\) the bone mineral density in grams per cubic centimeter. Assume the data is normally distributed. A regression equation for the following data is \(\hat{y} = 0.8893 - 0.0031x\). Which is the best interpretation of the slope coefficient?

\(x\) 1 2 3 4 5 6 7 8 9 10 11
\(y\) 0.883 0.8734 0.8898 0.8852 0.8816 0.863 0.8634 0.8648 0.8552 0.8546 0.862

a) For every additional average weekly soda consumption, a person’s bone density increases by 0.0031 grams per cubic centimeter.
b) For every additional average weekly soda consumption, a person’s bone density decreases by 0.0031 grams per cubic centimeter.
c) For an increase of 0.8893 in the average weekly soda consumption, a person’s bone density decreases by 0.0031 grams per cubic centimeter.
d) For every additional average weekly soda consumption, a person’s bone density decreases by 0.8893 grams per cubic centimeter.

15. Which residual plot has the best linear regression model?

Six different scatterplots, each with a horizontal regression line.

a) a
b) b
c) c
d) d
e) e
f) f

16. An object is thrown from the top of a building. The following data measure the height of the object from the ground for a five-second period.

Seconds 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
Height 112.5 110.875 106.8 100.275 91.3 79.875 70.083 59.83 30.65 0

The following four plots were part of the regression analysis.

A seconds residual plot, seconds line fit plot, scatterplot, and normal probability plot for the given data.

There is a statistically significant correlation between time and height, \(r = -0.942\), p-value = 0.0000454. Should linear regression be used for this data? Why or why not? Choose the correct answer.

a) Yes, the p-value indicates that there is a significant correlation so we can use linear regression.
b) Yes, the normal probability plot has a nice curve to it.
c) Yes, there is a nice straight line in the line fit plot.
d) No, there is a curve in the residual plot, normal plot and the scatterplot.

17. The following data represent the leaching rates (percent of lead extracted vs. time in minutes) for lead in solutions of magnesium chloride \((\mathrm{MgCl}_{2})\). Use \(\alpha = 0.05\).

Time \((x)\) 4 8 16 30 60 120
Percent Extracted \((y)\) 1.2 1.6 2.3 2.8 3.6 4.4

a) State the hypotheses to test for a significant correlation.
b) Compute the correlation coefficient.
c) Compute the p-value to see if there is a significant correlation.
d) State the correct decision.
e) Is there a significant correlation?
f) Compute the coefficient of determination.
g) Compute the regression equation.
h) Compute the 95% prediction interval for 100 minutes.
i) Write a sentence interpreting this interval using units and context.

18. Bone mineral density and cola consumption have been recorded for a sample of patients. Let x represent the number of colas consumed per week and y the bone mineral density in grams per cubic centimeter. Assume the data is normally distributed. What is the residual for the observed point \((7, 0.8634)\).

\(x\) 1 2 3 4 5 6 7 8 9 10 11
\(y\) 0.883 0.8734 0.8898 0.8852 0.8816 0.863 0.8634 0.8648 0.8552 0.8546 0.862

19. A study was conducted to determine if there was a linear relationship between a person's age and their peak heart rate. Use \(\alpha = 0.05\).

Age \((x)\) 16 26 32 37 42 53 48 21
Peak Heart Rate \((y)\) 220 194 193 178 172 160 174 214

a) What is the estimated regression equation that relates number of hours worked and test scores for high school students.
b) Interpret the slope coefficient for this problem.
c) Compute and interpret the coefficient of determination.
d) Compute the coefficient of nondetermination.
e) Compute the standard error of estimate.
f) Compute the correlation coefficient.
g) Compute the 95% Prediction Interval for peak heart rate for someone who is 25 years old.

20. The following data represent the weight of a person riding a bike and the rolling distance achieved after going down a hill without pedaling.

Weight (lbs) 59 84 97 56 103 87 88 92 53 66 71 100
Rolling distance (m) 26 43 48 20 59 44 48 46 28 32 39 49

a) Can it be concluded at a 0.05 level of significance that there is a linear correlation between the two variables?
b) Using the regression line for this problem, find the predicted bike rolling distance for a person that weighs 110 lbs.
c) Find the 99% prediction interval for bike rolling distance for a person that weighs 110 lbs.

21. Body frame size is determined by a person's wrist circumference in relation to height. A researcher measures the wrist circumference and height of a random sample of individuals. The Excel output and scatterplot are displayed below. Find the regression equation and predict the height (in inches) for a person with a wrist circumference of 7 inches. Then, compute the residual for the point \((7, 75)\).

Coefficient values of 31.6304 for intercept and 5.4496 for circumference, standard error values of 5.2538 for intercept and 0.7499 for circumference, t-stat values of 6.0205 for intercept and 7.2673 for circumference, and p-values of 1.16 E-06 for intercept and 3.55 E-08 for circumference.

22. It has long been thought that the length of one’s femur is positively correlated to the length of one’s tibia. The following are data for a classroom of students who measured each (approximately) in inches. A significant linear correlation was found between the two variables. Find the 90% prediction interval for the length of someone’s tibia when it is known that their femur is 23 inches long.

Femur Length 18.7 20.5 16.2 15.0 19.0 21.3 21.0 14.3 15.8 18.8 18.7
Tibia Length 14.2 15.9 13.1 12.4 16.2 15.8 16.2 12.1 13.0 14.3 13.8

23. The data below represent the driving speed (mph) of a vehicle and the corresponding gas mileage (mpg) for several recorded instances.

Driving Speed Gas Mileage Driving Speed Gas Mileage
57 21.8   62 21.5
66 20.9   66 20.5
42 25.0   67 23.0
34 26.2   52 19.4
44 24.3   49 25.3
44 26.3   48 24.3
25 26.1   41 28.4
20 27.2   38 29.6
24 23.5   26 32.5
42 22.6   24 30.8
52 19.4   21 28.8
54 23.9   19 33.5
60 24.8   24 25.1

a) Do a hypothesis test to see if there is a significant correlation. Use \(\alpha = 0.10\).
b) Compute the standard error of estimate.
c) Compute the regression equation and use it to find the predicted gas mileage when a vehicle is driving at 77 mph.
d) Compute the 90% prediction interval for gas mileage when a vehicle is driving at 77 mph.

24. The following data represent the age of a car and the average monthly cost for repairs. A significant linear correlation is found between the two variables. Use the data to find a 95% prediction interval for the monthly cost of repairs for a vehicle that is 15 years old.

Age of Car (yrs) 1 2 3 4 5 6 7 8 9 10
Monthly Cost ($) 25 34 42 45 55 71 82 88 87 90

25. In a sample of 20 football players for a college team, their weight and 40-yard-dash time in minutes were recorded.

Weight (lbs) 40-Yard Dash (min) Weight (lbs) 40-Yard Dash (min)
285 5.95   195 4.85
185 4.99   254 5.12
165 4.92   140 4.87
188 4.77   212 5.05
160 4.52   158 4.75
156 4.67   188 4.87
256 5.22   134 4.53
169 4.95   205 4.92
210 5.06   178 4.88
165 4.83   159 4.79

a) Do a hypothesis test to see if there is a significant correlation. Use \(\alpha = 0.01\).
b) Compute the standard error of estimate.
c) Compute the regression equation and use it to find the predicted 40-yard-dash time for a football player that is 200 lbs.
d) Compute the 99% prediction interval for a football player that is 200 lbs.
e) Write a sentence interpreting the prediction interval.

26. The following data represent the enrollment at a small college during its first ten years of existence. A significant linear relationship is found between the two variables. Find a 90% prediction interval for the enrollment after the college has been open for 14 years.

Years 1 2 3 4 5 6 7 8 9 10
Enrollment 856 842 923 956 940 981 1025 996 1057 1088

27. A new fad diet called Trim-to-the-MAX is running some tests that they can use in advertisements. They sample 25 of their users and record the number of days each has been on the diet along with how much weight they have lost in pounds. The data is below. A significant linear correlation was found between the two variables. Find the 95% prediction interval for the weight lost when a person has been on the diet for 60 days.

Days on Diet 7 12 16 19 25 34 39 43 44 49
Weight Loss 5 7 12 15 20 25 24 29 33 35

28. An elementary school uses the same system to test math skills at their school throughout the course of the 5 grades at their school. The age and score (out of 100) of several students is displayed below. A significant linear relationship is found between the student’s age and their math score. Find a 90% prediction interval for the score a student would earn given that they are 5 years old.

Student Age 6 6 7 8 8 9 10 11 11
Math Score 54 42 50 61 67 65 71 72 79

29. The intensity (in candelas) of a 100-watt light bulb was measured by a sensing device at various distances (in meters) from the light source. A linear regression was run and the following residual plot was found.

Regression statistics table with multipler R value of 0.9536, R-square value of 0.920371, adjusted R-square of 0.911523, standard error of 0.021636, and 11 observations. Table showing coefficient = 0.468618, standard error = 0.031624, t-stat = 14.81856, and p-value of 125 E-07 for intercept, and coefficient = -0.2104, standard error = 0.020629, t-stat = -10.1992, and p-value = 3.04 E-06 for distance. Residual plot for the data.

a) Is linear regression a good model to use?
b) Write a sentence explaining your answer.

30. The table below shows the percentage of adults in the United States who were married before age 24 for the years shown. A significant linear relationship was found between the two variables.

Year 1960 1965 1970 1975 1980 1985 1990 1995 2000 2005
% Married Before 24 Years Old 52.1 51.3 45.9 46.3 40.8 38.1 34.0 32.6 28.1 25.5

a) Compute the regression equation.
b) Predict the percentage of adults who married before age 24 in the United States in 2015.
c) Compute the 95% prediction interval for the percentage of adults who married before age 24 in the United States in 2015.

31. A nutritionist feels that what mothers eat during the months they are nursing their babies is important for healthy weight gain of their babies. She samples several of her clients and records their average daily caloric intake for the first three months of their babies’ lives and also records the amount of weight the babies gained in those three months. The data are below.

Daily Calories 1523 1649 1677 1780 1852 2065 2096 2145 2378
Baby's Weight Gain (lbs) 4.62 4.77 4.62 5.12 5.81 5.34 5.89 5.96 6.05

a) Compute the regression equation.
b) Test to see if the slope is significantly different from zero, using \(\alpha = 0.05\).
c) Predict the weight gain of a baby whose mother gets 2,500 calories per day.
d) Compute the 95% prediction interval for the weight gain of a baby whose mother gets 2,500 calories per day.

32. The data below show the predicted average high temperature \(({}^{\circ} \mathrm{F})\) per month by the Farmer’s Almanac in Portland, Oregon alongside the actual high temperature per month that occurred.

Farmer's Almanac 45 50 57 62 69 72 81 90 78 64 51 48
Actual High 46 52 60 61 72 78 82 95 85 68 52 49

a) Compute the regression equation.
b) Test to see if the slope is significantly different from zero, using \(\alpha = 0.01\).
c) Predict the high temperature in the coming year, given that the Farmer’s Almanac is predicting the high to be \(58^{\circ} \mathrm{F}\).
d) Compute the 99% prediction interval for the actual high temperature in the coming year, given that the Farmer’s Almanac is predicting the high to be \(58^{\circ} \mathrm{F}\).

33. In a multiple linear regression problem, p represents:

a) The number of dependent variables in the problem.
b) The probability of success.
c) The number of independent variables in the problem.
d) The probability of failure.
e) The population proportion.

34. The manager of a warehouse found a significant relationship exists between the number of weekly hours clocked \((x_{1}\)), the age of the employee \((x_{2})\), and the productivity of the employee \((y)\) (measured in weekly orders assembled). A multiple regression was run and the following line of best fit was found: \(\hat{y} = 66.238 + 2.7048 x_{1} - 0.7275 x_{2}\). Approximate the productivity level of an employee who clocked 61 hours in a given week and is 59 years old.

35. A multiple regression test concludes that there is a linear relationship and finds the following line of best fit: \(\hat{y} = -53.247 + 12.594 x_{1} - 0.648 x_{2} + 4.677 x_{3}\). Use the line of best fit to approximate \(y\) when \(x_{1} = 5\), \(x_{2} = 12\), \(x_{3} = 2\).

36. A career counselor feels that the strongest predictors of a student’s success after college are class attendance \((x_{1})\) (recorded as a percent) and GPA \((x_{2})\). To test this, she samples clients after they have found a job and lets the dependent variable be the number of weeks it took them to find a job. A multiple regression was run and the following line of best fit was found \(\hat{y} = 38.6609 - 0.3345 x_{1} - 1.0743 x_{2}\). Predict the number of weeks it will take a client to find a job, given that she had a 94% \((x_{1} = 94)\) attendance rate in college and a 3.82 GPA.

37. A study conducted by the American Heart Association provided data on how age, blood pressure and smoking relate to the risk of strokes. The following data is the SPSS output with Age in years \((x_{1})\), Blood Pressure in mmHg \((x_{2})\), Smoker (0 = Nonsmoker, 1 = Smoker) \((x_{3})\) and the Risk of a Stroke as a percent \((y)\).

Regression statistics table with R-square = 0.873, standard error = 5.75657, and 20 observations.
ANOVA table with regression df=3, SS=3660.740, and MS=120.247; residual df=16, SS=530.210, and MS=33.138; F=36.823 and significance F = 2.04E-07. Intercept has coefficient -91.759, standard error 15.223, t-stat -6.028, and p-value 1.7568E-05; age has coefficient 1.077, standard error 0.166, t-stat 6.488, and p-value 7.4848E-07; blood pressure has coefficient 0.252, standard error 0.045, t-stat 5.568, and p-value 4.2433E-05; smoker status has coefficient 8.740, standard error 3.001, t-stat 2.912, and p-value 0.0102.

a) Use \(\alpha = 0.05\) to test the claim that the regression model is significant. State the hypotheses, test statistic, p-value, decision and summary.
b) Use the estimated regression equation to predict the stroke risk for a 70-year-old smoker with a blood pressure of 180.
c) Interpret the slope coefficient for age.
d) Find the adjusted coefficient of determination.

38. Use technology to run a multiple linear regression with a dependent variable of annual salary for adults with full-time jobs in San Francisco and independent variables of years of education completed and age. The data for the sample used is below.

Annual Salary Years of Education Age
82,640 17 34
95,854 18 42
152,320 21 39
49,165 13 25
31,120 12 31
67,500 16 32
42,590 12 28
57,245 14 55
58,940 16 45
67,250 18 40
56,120 16 39
38,955 12 34
74,650 16 33
53,495 16 29
67,210 16 30
79,365 16 50
96,045 18 51
78,472 14 60
124,975 21 52
43,125 12 36

a) Test to see if the overall model is significant using \(\alpha = 0.05\).
b) Compute the predicted salary for a 35-year-old with 16 years of education.
c) Compute the adjusted coefficient of determination.
d) Are all the independent variables statistically significant? Explain.

39. A study was conducted to determine if there was a linear relationship between a person's weight in pounds with their gender, height and activity level. A person’s gender was recorded as a 0 for anyone who identified as male and 1 for those who did not identify as male. Height was measured in inches. Activity level was coded as 1, 2, or 3; the more active the person was, the higher the value.

Regression statistics showing R-square value 0.667, standard error of 13.9353, and 92 observations. ANOVA table showing regression values of df=3, SS=34195, and MS=11398.33; residual values of df=88, SS=17089, and MS=194.1932; F-value of 58.6958; and significance F of 6.2026 E-21. Intercept has coefficient -81.5, standard error 43.96, t-stat -1.854, and p-value 0.0671. Gender has coefficient -15.1, standard error 4.286, t-stat -3.5231, and p-value 0.0007. Height has coefficient 3.7, standard error 0.5704, t-stat 6.4867, and p-value 4.97 E-09. Activity level has coefficient -3.08, standard error 2.443, t-stat -1.2607, and p-value 0.2107.

a) Interpret the slope coefficient for height.
b) Predict the weight for a male who is 70 inches tall and has an activity level of 2.
c) Calculate the adjusted coefficient of determination.

40. A professor claims that the number of hours a student studies for their final paired with the number of homework assignments completed throughout the semester (out of 20 total assignment opportunities) is a good predictor of a student’s final exam grade. She collects a sample of students and records the following data.

Final Exam Score # Hours Studied HW Completed
85 5.2 19
74 5.1 18
79 4.9 16
62 3.7 12
96 9 17
52 1 12
73 2 15
81 2 16
90 7.25 18
79 4.5 14
83 3 20
76 3.2 17
92 6.8 20
84 6.2 18
50 4.1 10

a) Test the professor’s claim using \(\alpha = 0.05\).
b) Compute the multiple correlation coefficient.
c) Interpret the slope coefficient for number of hours studied.
d) Compute the adjusted coefficient of determination.

Solutions to Odd-Numbered Exercises

1. a

3. b

5. d

7. \(r = 0.8241\)

9. c

11. a) \(\hat{y} = 25.6472 + 2.8212 x\)
b) \(67.9657\)
c) \(-2.9657\)
d) \(61.3248 < y < 74.6065\)

13. \(R^{2} = 0.679\)

15. a

17. a) \(H_{0}: \rho = 0; H_{1}: \rho \neq 0\)
b) \(r = 0.9403\)
c) \(0.0052\)
d) Reject \(H_{0}\)
e) Yes
f) \(R^{2} = 0.8842\)
g) \(\hat{y} = 1.6307 - 0.0257x\)
h) \(2.6154 < y < 5.7852\)
i) We can be 95% confident that the predicted percent of lead extracted in solutions of magnesium chloride at 100 minutes is anywhere between 2.6154 and 5.7852.

19. a) \(\hat{y} = 241.8127 - 1.5618x\)
b) Every year a person ages, their peak heart rate decreases by an average of 1.5618.
c) \(R^{2} = 0.93722\)
d) \(0.06278\)
e) \(5.6924\)
f) \(r = -0.9681\)

21. 5.2224

23. a) \(H_{0}: \rho = 0; H_{1}: \rho \neq 0; t = -5.2514;\) p-value = \(0.000022\).
Reject \(H_{0}\). There is a significant correlation between driving speed of a vehicle and the corresponding gas mileage.
b) 2.49433
c) \(\hat{y} = 32.40313 - 0.1662x\)
d) \(14.8697 < y < 24.3424\)

25. a) \(H_{0}: \rho = 0; H_{1}: \rho \neq 0; t = 6.9083;\) p-value = \(0.000007\).
Reject \(H_{0}\). There is a significant correlation between a football player’s weight and 40-yard-dash time.
b) \(s = 0.160595\)
c) \(\hat{y} = 3.722331 - 0.006396x; 5.0016\)
d) \(4.527 < y < 5.476\)
e) We can be 99% confident that the predicted time for all 200-pound football player’s running time for the 40-yard-dash is between 4.527 and 5.476 minutes.

27. \(36.605 < y < 47.740\)

29. a) No
b) The p-value = 0.00000304 suggests that there is a significant linear relationship between intensity (in candelas) of a 100-watt light bulb was measured by a sensing device at various distances (in meters) from the light source. However, the residual plot clearly shows a nonlinear relationship. Even though we can fit a straight line through the points, we would get a better fit with a curve.

31. a) \(\hat{y} = 1.76267 - 0.001883x\)
b) \(H_{0}: \beta_{1} = 0; H_{1}: \beta_{1} \neq 0; t = 5.0668;\) p-value = \(0.0015\)
Reject \(H_{0}\). There is significant linear relationship between a nursing baby’s weight gain and the calorie intake of the mother.
c) \(6.4693 \mathrm{~lbs}\)
d) \(5.571 < y < 7.368\)

33. c

35. 11.301

37. a) \(H_{0}: \beta_{1} = \beta_{2} = \beta_{3} = 0; H_{1}:\) At least one slope is not zero\(; F = 36.823;\) p-value = \(0.000000204\)
Reject \(H_{0}\). There is a significant relationship between a person’s age, blood pressure and smoking status and the risk of a stroke.
b) \(37.731%\)
c) For each year a person ages, their chance of a stroke increases by 1.077%.
d) \(84.9%\)

39. a) For each additional inch in height, the predicted weight would increase 3.7 pounds.
b) \(171.34 \mathrm{~lbs}\)
c) \(65.56%\)

From Mostly Harmless Statistics by Rachel L. Webb, adapted from LibreTexts. Licensed CC BY-SA 4.0. XYZ Homework OER web edition, adapted with 7 verified corrections (see errata).