Graphing Calculator Exercise 2-5B & Hand Calculation of Least Squares Linear Regression
The graphing calculator exercise 2-5B (pages 101-102) does not work as written with a TI-83. It also hides a lot
of the math so while you end up doing a linear regression, you really do not get a feel for what is being done.

In this exercise, we will do Problem 2 (page 102) on the TI-83 & duplicate the linear regression
calculation.
Lets use the graphing calculator to recreate this scatter plot, then we will use its built in linear regression features to find the least squares fit to this data.

First we need to store this x-y data in a list. Since the linear regression is part of the TI's statistics package we'll enter the list in the statistics editor.

1. [STAT] 1 to display the stat editor.
2. scroll to select L1 heading.
3. [CLEAR] clear any old lists in L1. Note: after you press [CLEAR] the lists do not seem to go
away until you scroll down into the lists.
4. repeat repeat prior 2 steps to clear L2 (list 2).
5. scroll to first entry position in L1.
6. .2[ENTER]1[ENTER]3[ENTER]4[ENTER]5[ENTER]8 [ENTER] puts x values in L1
7. .11[ENTER].31[ENTER].9 [ENTER]...you have the idea puts y values in L2
Now that our x-y data is in the statistics list editor, lets see what it looks like as a scatter plot on the calculator.
1. [2nd][STAT PLOT]1[ENTER] selects plot 1
2. >[ENTER] turns plot 1 ON
3. >[ENTER] selects scatter plot (the first little picture)
4. down scroll [ENTER] selects L1 as the "x list"
5. > [ENTER][GRAPH] selects the little square as the marker for the points on the scatter plot.
6. [WINDOW] set (xmin,xmax),(ymin,ymax) to (0,10),(0,5) both scales to 1. You
should see a nice scatter plot of the x-y data.
Now lets find the equation of the best fit line (the linear regression):

1. [STAT]> to open the "calc" menu.
2. 4 to pick the linear regression option "LinReg(ax+b)"
3. [2nd]L1[,]
[2nd]L2[ENTER] just after the command "LinReg(ax+b)" your need to specify the lists that the program
will use as its list of ordered pairs to find the best fit line through, remember that our
x values are in L1 and our y values are in L2. That's what this step does.
You should now see:
y=ax+b
a=.2938039867 (this is the slope of the best fit line)
b=.0652259136 (this is the y intercept of the best fit line)
We can now easily graph the best fit line on the same graph as the scatter plot as follows:

1. [Y=] to select the y editor, clear anything after the equals sign.
2. [VARS] to select the variables menu.
3. 5 to select the "statistics" variables menu option.
4. >> to select the "EQuation" related variables since "LinReg (ax+b)"
is one of the statistics equations.
5. 1 to select "RegEq" - the Regression equation. Now the best fit equation has
been conveniently placed in the "Y=" line, do you recognize the previously calculated slope
and Y intercept?
6. [GRAPH] Your best fit line is now shown superimposed on your scatter plot points. Play with the
[TRACE] option, you should be able to trace both the scatter plot points and the
best fit line (not at the same time, play with the scroll buttons).
Your scatter plot with the best fit line should look like this:
Now lets see if we can do a best fit ourselves, that is , find the a and b coefficients of the least squares
best fit line y=ax+b. This will give you a much better understanding of what the calculator is doing
"behind the scenes."

To do the least squares fit by hand you will find that a five column table greatly simplifies the
calculation. The first two columns are the x and y values that are given in the original problem
(the scatter plot points). The next column (column 3) is the x values squared, column 4 is x and
y multiplied together, and the last column, column 5, is the y values squared. You will see in a minute
how we use these but for now just make this table. When finished, take the sum of each column
and also find the mean of the x and y's (column 1 and 2). Be careful not to round, the least
squares calculation is very sensitive to rounding errors.

Here is the finished table.
Most of the work to find the slope and y-intercept of our best fit line is now done. Remember
in the best fit equation y=ax+b that a is the slope and b is the y-intercept. The next step will
involve manipulating the data we just put into the table. To make it easy from now on the data
in the table will just be referenced as col1, col2, etc. (column 1, column 2, etc.).

The formulas we will use below are ones that you will be able to derive easily in Calculus,
for now we are just going to use them to duplicate the linear regression you did using your
calculator.

This method of creating a five column table and using the following formulas to calculate the
best fit slope and y-intercept will work with any list of ordered pairs. As your lists get bigger
you will see why it is nice to let your calculator do most of the work.

Let N be the number of ordered pairs (x-y values). N=6 for this problem.
The next formula will give us the slope (a) of our best fit line. We will do it in two parts such that
a=part2/part1. Look at the table we made to see where these numbers come from.
Do you recognize a?
Do you recognize b?
Therefore: y = .2938039867x + .0652259234