This lesson will introduce using a CAS to perform analysis in bivariate statistics for us. You could also use a graphics calculator or statistical program to work through the exercise. We will look at how to use technology to:
In a previous lesson we found the approximate line of best fit by eye. Using our judgement to find the line that best fits the points in a scatter plot. The images below show some examples of a line of best fit. The line of best fit does not necessarily go through the data points. It is positioned so that it minimises the overall distance from the points.
Constructing a line of best fit in this way can be very useful because the line summarises all of the data points in a way that allows us to predict the value of the response (dependent) variable that corresponds to a given value of the explanatory (independent) variable, or vice-versa. However, it takes a certain amount of judgement to choose the position and angle of the line. Constructing the line by eye is not very reliable, especially if the scatter plot does not show a strong relationship.
Fortunately, there are mathematical calculations that we can use to determine a line of best fit with more consistency. In this lesson, we will learn to find the line of best fit called the least-squares regression line using technology.
The best way to understand it is through a demonstration. Try moving the points to see how the least-squares regression line follows the data.
The least-squares regression line is a straight line, so it can be represented by a linear function, in gradient-intercept form:
$y$y$=mx+c$=mx+c
$y$y is the predicted value of the response (dependent) variable
$x$x is our explanatory (independent) variable
$m$m is the gradient of our line
$c$c is the vertical intercept (or $y$y-intercept) of our line.
It is common practice to use the symbol $\hat{y}$^y (which is pronounced "y-hat"), instead of $y$y, as the variable for the predicted value of the response variable.
Unless we are working with a very small data set, the calculations to determine the least-squares regression line are too tedious to do by hand.
Select the brand of calculator you use below to work through an example of using a calculator to generate a scatter plot and find the equation of the least squares regression line.
Casio Classpad
How to use the CASIO Classpad to complete the following tasks regarding scatterplots and linear regression.
The average number of pages read to a child each day and the child’s growing vocabulary are measured. Consider the data set given below:
Pages read per day ($x$x) | $25$25 | $27$27 | $29$29 | $3$3 | $13$13 | $31$31 | $18$18 | $29$29 | $29$29 | $5$5 |
---|---|---|---|---|---|---|---|---|---|---|
Total vocabulary ($y$y) | $402$402 | $440$440 | $467$467 | $76$76 | $220$220 | $487$487 | $295$295 | $457$457 | $460$460 | $106$106 |
Use your calculator to generate a scatterplot of the data.
Using your calculator, find an equation for the least squares regression line of $y$y on $x$x.
Give your answer in the form $y=ax+b$y=ax+b. Give all values to two decimal places.
TI Nspire
How to use the TI Nspire to complete the following tasks regarding scatterplots and linear regression.
The average number of pages read to a child each day and the child’s growing vocabulary are measured. Consider the data set given below:
Pages read per day ($x$x) | $25$25 | $27$27 | $29$29 | $3$3 | $13$13 | $31$31 | $18$18 | $29$29 | $29$29 | $5$5 |
---|---|---|---|---|---|---|---|---|---|---|
Total vocabulary ($y$y) | $402$402 | $440$440 | $467$467 | $76$76 | $220$220 | $487$487 | $295$295 | $457$457 | $460$460 | $106$106 |
Use your calculator to generate a scatterplot of the data.
Using your calculator, find an equation for the least squares regression line of $y$y on $x$x.
Give your answer in the form $y=ax+b$y=ax+b. Give all values to two decimal places.
Note: Depending on your calculator the line of best fit shown may use different variables for the gradient, $m$m, and $y$y-intercept, $c$c. The gradient will always be the coefficient of $x$x and the $y$y-intercept will be the constant term in the equation.
Use technology to find the line of best fit for the data below. Write the equation with the coefficient and constant term to the nearest two decimal places.
$x$x | $24$24 | $37$37 | $19$19 | $31$31 | $32$32 | $22$22 | $14$14 | $30$30 | $23$23 | $40$40 |
---|---|---|---|---|---|---|---|---|---|---|
$y$y | $-7$−7 | $-8$−8 | $-3$−3 | $-6$−6 | $-9$−9 | $-8$−8 | $-2$−2 | $-8$−8 | $-8$−8 | $-12$−12 |
The price of various second-hand Mitsubishi Lancers are shown below.
Age | $1$1 | $2$2 | $0$0 | $5$5 | $7$7 | $4$4 | $3$3 | $4$4 | $8$8 | $2$2 |
---|---|---|---|---|---|---|---|---|---|---|
Value (dollars) | $16000$16000 | $13000$13000 | $21990$21990 | $10000$10000 | $8600$8600 | $12500$12500 | $11000$11000 | $11000$11000 | $4500$4500 | $14500$14500 |
Find the equation of the Least Squares Regression Line for the price ($y$y) in terms of age ($x$x).
Round all values to the nearest integer.
State the value of the $y$y-intercept.
The value of the $y$y-intercept indicates that when a Mitsubishi Lancer is brand new, its value is, on average, $\editable{}$ dollars.
Does the interpretation in the previous part make sense in this context?
Yes, when the explanatory variable has a value of zero, this is still within the data range and the value of the dependent variable makes sense.
No, when the explanatory variable has a value of zero, this is outside the data range and the value of the dependent variable does not make sense.
State the gradient of the line.
Which of the following is true?
If the explanatory variable increases by $1$1 unit, then the dependent variable increases by $1694$1694 units.
If the explanatory variable increases by $1$1 unit, then the dependent variable increases by $18407$18407 units.
If the explanatory variable increases by $1$1 unit, then the dependent variable decreases by $18407$18407 units.
If the explanatory variable increases by $1$1 unit, then the dependent variable decreases by $1694$1694 units.
The correlation coefficient was introduced in the previous lesson as a measure that tells us the strength of a relationship between two variables. It is denoted by the letter $r$r. The sign of $r$r also tells us the direction of the relationship.
Some key aspects of the correlation coefficient are summarised below, followed by examples that show how we can calculate the correlation coefficient with our CAS calculator.
The strength of correlation depends on the size of the r value, so we can ignore the positive or negative sign:
Even when two variables have a strong relationship and $r$r is close to $1$1 or $-1$−1 we cannot say that one variable causes change in the other variable.
Select the brand of calculator you use below to work through an example of using a calculator to find the correlation coefficient.
Casio Classpad
How to use the CASIO Classpad to complete the following task to find the correlation coefficient.
A café records the temperature and number of hot chocolates sold on the same day of the week for 10 weeks. Consider the data set given below:
Temperature ($x\ ^\circ C$x °C) | $14$14 | $25$25 | $18$18 | $19$19 | $27$27 | $24$24 | $16$16 | $12$12 | $26$26 | $22$22 |
---|---|---|---|---|---|---|---|---|---|---|
Hot chocolates sold ($y$y) | $35$35 | $8$8 | $20$20 | $22$22 | $5$5 | $23$23 | $32$32 | $34$34 | $8$8 | $14$14 |
Calculate the value of the correlation coefficient ($r$r).
Give your answer to three decimal places.
TI Nspire
How to use the TI Nspire to complete the following task to find the correlation coefficient.
A café records the temperature and number of hot chocolates sold on the same day of the week for 10 weeks. Consider the data set given below:
Temperature ($x\ ^\circ C$x °C) | $14$14 | $25$25 | $18$18 | $19$19 | $27$27 | $24$24 | $16$16 | $12$12 | $26$26 | $22$22 |
---|---|---|---|---|---|---|---|---|---|---|
Hot chocolates sold ($y$y) | $35$35 | $8$8 | $20$20 | $22$22 | $5$5 | $23$23 | $32$32 | $34$34 | $8$8 | $14$14 |
Calculate the value of the correlation coefficient ($r$r).
Give your answer to three decimal places.
Given the following data:
x | $1$1 | $4$4 | $7$7 | $10$10 | $13$13 | $16$16 | $19$19 |
---|---|---|---|---|---|---|---|
y | $4$4 | $4.25$4.25 | $4.55$4.55 | $4.4$4.4 | $4.45$4.45 | $4.75$4.75 | $4.2$4.2 |
Calculate the correlation coefficient and give your answer to two decimal places.
Choose the best description of this correlation.
Moderate negative
Strong positive
Weak negative
Moderate positive
Strong negative
Weak positive
Once we have determined the least-squares regression line, we can use it as a model to predict the likely value of the response variable based on a given value of the explanatory variable. Let's look at some examples to see how we can make a prediction efficiently using CAS once we've input our data and calculated the least-squares regression line. Select the brand of calculator you use below to work through an example.
Casio Classpad
How to use the CASIO Classpad to complete the following tasks regarding linear regression and making predictions.
Consider the data obtained from a chemical process where the yield of the process is thought to be linearly related to the reaction temperature.
Temperature ($x,^\circ C$x,°C) | $50$50 | $53$53 | $54$54 | $56$56 | $59$59 | $62$62 | $65$65 | $67$67 | $71$71 | $74$74 |
---|---|---|---|---|---|---|---|---|---|---|
Yield ($y,g$y,g) | $122$122 | $118$118 | $128$128 | $125$125 | $136$136 | $144$144 | $142$142 | $149$149 | $161$161 | $168$168 |
Using your calculator, find an equation for the least squares regression line of $y$y on $x$x.
Give your answer in the form $y=ax+b$y=ax+b. Give all values to two decimal places.
What yield is predicted at a reaction temperature of $60$60$^\circ$°C?
Give your answer to the nearest gram.
What yield is predicted at a reaction temperature of $85$85$^\circ$°C?
Give your answer to the nearest gram.
What temperature gives a predicted yield of $155$155 g?
Give your answer to one decimal place.
TI Nspire
How to use the TI Nspire to complete the following tasks regarding linear regression and making predictions.
Consider the data obtained from a chemical process where the yield of the process is thought to be linearly related to the reaction temperature.
Temperature ($x,^\circ C$x,°C) | $50$50 | $53$53 | $54$54 | $56$56 | $59$59 | $62$62 | $65$65 | $67$67 | $71$71 | $74$74 |
---|---|---|---|---|---|---|---|---|---|---|
Yield ($y,g$y,g) | $122$122 | $118$118 | $128$128 | $125$125 | $136$136 | $144$144 | $142$142 | $149$149 | $161$161 | $168$168 |
Using your calculator, find an equation for the least squares regression line of $y$y on $x$x.
Give your answer in the form $y=ax+b$y=ax+b. Give all values to two decimal places.
What yield is predicted at a reaction temperature of $60$60$^\circ$°C?
Give your answer to the nearest gram.
What yield is predicted at a reaction temperature of $85$85$^\circ$°C?
Give your answer to the nearest gram.
What temperature gives a predicted yield of $155$155 g?
Give your answer to one decimal place.
Research on the number of cigarettes smoked during pregnancy and the birth weights of the newborn babies was conducted.
Average number of cigarettes per day ($x$x) | $46.30$46.30 | $13.00$13.00 | $21.40$21.40 | $25.00$25.00 | $8.60$8.60 | $36.50$36.50 | $1.00$1.00 | $17.90$17.90 | $10.60$10.60 | $13.40$13.40 | $37.30$37.30 | $18.50$18.50 |
---|---|---|---|---|---|---|---|---|---|---|---|---|
Birth weight in kilograms ($y$y) | $3.90$3.90 | $5.80$5.80 | $5.00$5.00 | $4.80$4.80 | $5.50$5.50 | $4.50$4.50 | $7.00$7.00 | $5.10$5.10 | $5.50$5.50 | $5.10$5.10 | $3.80$3.80 | $5.70$5.70 |
Using a graphics calculator (or other technology), calculate the correlation coefficient between the average number of cigarettes per day and birth weight.
Give your answer to three decimal places.
Choose the description which best describes the statistical relationship between these two variables.
Strong negative linear relationship
Moderate positive linear relationship
Weak relationship
Strong positive linear relationship
Moderate negative linear relationship
Use your graphing calculator to form an equation for the least squares regression line of $y$y on $x$x.
Give all values to two decimal places. Give the equation of the line in the form $y=mx+b$y=mx+b.
Use your regression line to predict the birth weight of a newborn whose mother smoked on average $5$5 cigarettes per day.
Give your answer to two decimal places.
Choose the description which best describes the validity of the prediction in part (d).
Despite an interpolated prediction, unreliable due to a moderate to weak correlation.
Reliable due to interpolation and a strong correlation.
Very unreliable due to extrapolation and a moderate to weak correlation.
Despite a strong correlation, unreliable due to extrapolation.
Research on the number of cigarettes smoked during pregnancy and the birth weights of the newborn babies was conducted.
Average number of cigarettes per day ($x$x) | $46.30$46.30 | $13.00$13.00 | $21.40$21.40 | $25.00$25.00 | $8.60$8.60 | $36.50$36.50 | $1.00$1.00 | $17.90$17.90 | $10.60$10.60 | $13.40$13.40 | $37.30$37.30 | $18.50$18.50 |
---|---|---|---|---|---|---|---|---|---|---|---|---|
Birth weight in kilograms ($y$y) | $3.90$3.90 | $5.80$5.80 | $5.00$5.00 | $4.80$4.80 | $5.50$5.50 | $4.50$4.50 | $7.00$7.00 | $5.10$5.10 | $5.50$5.50 | $5.10$5.10 | $3.80$3.80 | $5.70$5.70 |
Using a graphics calculator (or other technology), calculate the correlation coefficient between the average number of cigarettes per day and birth weight.
Give your answer to three decimal places.
Choose the description which best describes the statistical relationship between these two variables.
Strong negative linear relationship
Moderate positive linear relationship
Weak relationship
Strong positive linear relationship
Moderate negative linear relationship
Use your graphing calculator to form an equation for the least squares regression line of $y$y on $x$x.
Give all values to two decimal places. Give the equation of the line in the form $y=mx+b$y=mx+b.
Use your regression line to predict the birth weight of a newborn whose mother smoked on average $5$5 cigarettes per day.
Give your answer to two decimal places.
Choose the description which best describes the validity of the prediction in part (d).
Despite an interpolated prediction, unreliable due to a moderate to weak correlation.
Reliable due to interpolation and a strong correlation.
Very unreliable due to extrapolation and a moderate to weak correlation.
Despite a strong correlation, unreliable due to extrapolation.