Appendix 1: Linear Regression (Best

advertisement
Appendix 1:
Linear Regression (Best-Fit Line) Using Excel (2007)
You will be using Microsoft Excel to make several different
graphs this semester. This tutorial is designed to help you
learn some of the more common features of Excel used in
Chemistry and Biochemistry. This is by no means a
comprehensive tutorial for the program. In fact, if you ask the
University Help Desk about what you will be doing, they will
tell you it’s not possible with Excel!
First you should familiarize yourself with the layout of the
Excel spreadsheet. By default, column “A” is x-axis data and
column “B” is y-axis data.
A graph should appear on your page that looks like this:
Now that you know what Excel looks like, let’s dive right in
and get to work. But first, this is college and we do not simply
“connect the dots” when we make a graph—we do linear
regression which generates a line that fits among the points.
Let’s say that you have some XY data and would like to make
a graph and you need a best-fit line. First thing first, enter the
data into the appropriate columns placing your x-axis data first
and y-axis data second.
Now that you have a graph, let’s add some axis labels and
title. Click on “Layout” at the top and then “axis titles” and
the select either vertical or horizontal titles:
Do the same thing for “Chart Title” and you get a nice
finished graph that looks like this:
Now you want to click on the Chart Wizard button to bring up
a list of possible graph types. We will, for the most part, be
using XY scatter plots. The most common mistake made by
students is choosing the Line graph—so don’t do it!!!
Right. Go ahead and click on “Insert” then choose the
“scatter” option and finally the graph with no line on it.
1
It is now time to add the line. Remember we are NOT
connecting the dots, but creating a best-fit line. So, right-click
on any data point on the graph and select “add trendline”.
Ok, let’s say you’re “playing” with the forecast function. In
order to get back to that menu, you now need to right-click on
the trendline itself and select “Format trendline”. Once there
add “2” to the forecast backwards.
Your graph will now look like this. Notice the line has been
extended backwards. To increase the distance it is extended,
increase the value. To decrease the distance it is extended,
decrease the value. If you need the other end extended, use
forecast forward.
The trendline menu has several options. We are interested in a
linear fit for this graph so choose “Linear” and also check the
box at the bottom that says “Display equation on chart”.
There are now other things that you can do to the graph to
make it look nicer such as adding tick-marks or re-scaling the
axes. All of these options are available by right-clicking on
either the x or y axis and selecting the “Format axis” option.
For example, if you right-click the x-axis, you get the
following pop-up menu:
Notice that there is a “Forecast” section in this menu. This is
used if you need to extrapolate your line forwards or
backwards. You simply add a number, such as 1, and then
look to see what happens to the graph. You just have to
“play” with this feature and it is not always necessary. Your
graph should now look like this:
Select the “Format axis” and you get yet another menu that
allows you to adjust the tick marks on the axes. Major tick
marks are the marks where the numbers are. Minor tick marks
are between the numbers and are not necessary but look nice.
2
You can also rescale in this menu and change fonts, sizes
colors and line types and colors.
If you add minor tick marks to both axes you get this graph.
Notice the new minor tick marks:
So, that’s all it is to it. Remember, Excel is powerful and I
have just hit the highlights of a best-fit line XY scatter.
3
Download