You are on page 1of 23

1 Linear Regression Analysis in Excel 2007 Below are step by step instructions on how to do a regression analysis.

The sample data that is used in this example is that of the pigeon data used in the lab you can find this Excel file on Blackboard it is called MATCHINGtemplate. To do the treasure hunt analysis, you will need to use the data from labs that we have provided you with on Blackboard. Open up the MATCHINGtemplate file and go to the Enter data here tab and it will look like this...

Enter in the data (when you do your assignment this data will be entered for you you will just have to calculate the log ratio info)...

2 Next you will need to do the ratio calculations and log the data. Start with the number of individuals data i.e. the N1 and N2 data go to the cell that you want the data to appear in and enter in an equals sign (this tells Excel that you want it to calculate something). You can then type in LOG10 (this tells Excel that you want it to log the data) and then open a bracket and click on the cell that contains the N1 information which in this case is cell B2. You would then enter a divide by symbol (/) and then click on the cell that contains the N2 data which in this case is C2. Enter a close bracket symbol and hit enter.

Excel will now enter the result of this calculation in this cell...

3 To calculate the rest of the data click on the cell that had already contains the calculated information and hover over the bottom right hand corner when the cursor changes to a black cross click and holding the mouse button drag the cursor down the remaining cells that you want to calculate and then let go.... the rest of log ratio information for N1 and N2 will now be calculated...

Now perform the same steps for the reinforcer data i.e. the R1 and R2 data... this time you will want to make sure that the cells containing the R1 and R2 data are selected...

So the first calculation will look like this then calculate the rest of the log ratio data for the reinforcers the same as before, hover over the right hand corner of this cell until the cursor changes to a black cross and then drag it down the rest of the cells...

So now all the log ratio data should be calculated and we can do the actual regression analysis...

5 To do a linear regression you plot X and Y coordinates on a graph (i.e. points on a graph) and then put a line of best fit through the data (in a linear regression this is a straight line). It is useful to label the data in terms of X and Y coordinates remember the log(N1/N2) data is the y coordinate information and the log(R1/R2) data is the x coordinate...

To perform the regression analysis go to the Data menu tab at the top of the page and then click on the Data Analysis icon on the far right hand corner of the screen (if this is not visible you will need to activate it see the Other Important Excel Skills folder on Blackboard for how to do this).

6 Up will pop the Data Analysis box scroll down till you find Regression and then hit the OK button...

Then the Regression box will pop up and you need to tell Excel which data you want analysed... place the cursor in the Input Y Range box and then highlight the cells on the worksheet that correspond to this data (remember the Y coordinate is the log(N1/N2 data) which in this case are the cells F2 to F4. You then need to move the cursor to the Input X Range box and highlight the cells for this data (remember the X coordinate is the log(R1/R2 data) which in this case are the cells G2 to G4. You then want to make sure that the Line Fit Plots button is selected click on the box to the left of it so that a tick appears in the box and then hit the OK button.

7 Excel will put the Regression Analysis data in a new worksheet (i.e. a new tab will appear at the bottom of the screen) it will consist of several tables and a small graph. We will work on the graph to start with...

You will want to enlarge the graph so you can see what you are doing to do this click on it and when it is highlighted, then go to one of the corners and when the cursor is a double headed arrow click (cursor will change to a cross) and drag the mouse outwards diagonally. So now it should look something like this...

8 The graph is a bit of a mess it contains the predicted Y value (what the model would predict the square data points) and the actual data (our actual data that we calculated the diamond points). You want to get rid of the predicted data as we only want to display the actual data. To do this you need to click on one of the predicted data points when they are highlighted you can hit the delete key on the keyboard (or once the data points are highlighted you can right mouse click and then select Delete Series this will do the same thing).

So now the graph should look like this...

9 You now want to delete the legend click on it and when it is highlighted hit the delete key on the keyboard.

So now it should look like this...

You now want to add a trend line (the point of a linear regression is to make a straight line so this is how you get Excel to do this). Click on one of the data points and then right mouse click select Add Trendline... (see the next page for how this should look).

10

The Format Trendline box will pop up select the Linear option (gives a straight line). Then select Display Equation on chart and Display R-squared on chart. Then hit the Close button.

11 This will put a line on the graph and put the actual line equation and R-squared value on the graph (makes it easy for people to interpret)...

You now want to make the graph black and white to do this click on the graph and then go up to the Design menu tab and click on the icon that has the greyscale points...

12 You now want to get rid of the title (remember we use figure captions that go at the bottom of the figure instead of titles). To do this click on the title, when it is highlighted hit the delete key on the keyboard...

So now you should have a black and white graph with no title like this...

13 You now want to change the labels on the axes... to do this click on one of them (lets start with the one at the bottom which is currently labelled X Variable 1 remember the X data is the log(R1/R2 data) and then place your cursor inside the text box and type in the label you wish to use, in this case log(R1/R2) and then delete the old label. When you are done simply click the mouse somewhere outside of the textbox.

You now want to repeat this process with the next axis label this axis should be labelled log(N1/N2)... (okay so the picture doesnt have the brackets on the axis labels but it should)...

14 You now need to change the scale on the axes (if they are not even it will distort the data) so the scale needs to be the same on both axes. To do this click on the graph and then go up to the Layout menu tab at the top of the page and click on the Axes icon. You then want to select Primary Horizontal Axis and then choose More Primary Horizontal Axis Options...

Up will pop the Format Axis box you want to select Fixed option for the minimum (lowest point on the scale) and then enter -1.0 for this value. You then want to select Fixed option for the maximum (highest point on the scale) and then enter 1.0 for this value. You then want to select the Fixed option for the major unit (this is the interval that the scale goes up by) and then enter 0.5 for this value. When you do your assignment these values will need to be different you need to look at what your highest value is and then make sure that you use this for both axes... When you are done click on the close button see next page for how this should look...

15

So now your graph should look like this...

16 You now want to repeat this process for the other axis. This time you will select Primary Vertical axis and More Primary Vertical Axis Options...

When the Format Axis box pops up you want to make sure that you choose the same values as you did for the other axis...

17 Now your graph should look like this note the gradient of the line looks like it has changed (this is why you need to make sure that the axes are equal)...

You now want to do the standard things to make it APA formatted such as removing the borders and the backgrounds. To remove the border and background from the graph area (the plot area) click on the graph and then go up to the Layout menu tab at the top of the page and select Plot Area and the choose More Plot Area Options...

18 When the Format Plot Area box comes up you want to select No fill (gets rid of the background)...

You then want to click on Border Colour and then select No line (this gets rid of the border)...

19 You then to get rid of the border and background on the chart area (area around the graph) to do this click on the outer area of the graph and then right mouse click and select Format Chart Area...

When the Format Chart Area box pops up select No fill...

20 Then select Border Colour and select No line...

Now your graph should look like this. You might then like to move the line equation and Rsquared information to a place that is less in the way. To do this simply click on it and drag it to where you want it to go...

21 You may want to change the size of the Font of information on the graph so that it is easier to read to do this simply click on the information you want to change and highlight it, then right mouse click and select Font...

Up will pop the font box you can change the size and style however you wish. In general you want to your information to be in a size 12 font. When you are done hit the OK button...

22 You should then be done (should look like this below except without the colour squares)... you need to know how to interpret the data...

The four important numbers that you need to find on this sheet are: The yellow cell which is the R squared value The orange cell which is the Standard Error The red cell which is the y intercept (bias measure) The pink cell which is the gradient (sensitivity/matching measure)

There are two measures that provide an indication of how well the equation describes the behaviour (i.e. how well does your data fit the model which is a straight line so how well do your points fit on the straight line). These are the R Square value (want this value to be as close to 1 as possible) and the Standard Error (want this value to be as close to 0 as possible). If your gradient is very shallow (that is close to 0) then the standard error may be a better measure of how well the equation describes the data. The y intercept is your measure of bias - so if the graph does not cut through the y axis at zero you have bias. A number that is positive (cuts above 0 on the y axis) means a bias to site 1 and if it is negative (cuts below 0 on the y axis) it means a bias to site 2 (also the bigger the number the more bias you have). The gradient (slope of the line) information is your measure of sensitivity or matching a gradient of 1 means that you have strict matching, a number less than 1 (flatter) is undermatching and a number greater than 1 (steeper) is overmatching... You can now copy and paste your figure into Microsoft Word...

23

0.5

log (N1/N2)

0 -0.5 0 0.5 1

-1

-0.5

y = 0.8649x + 0.0629 R = 0.9959

-1 log (R1/R2)

Figure 1. Blah blah blah (remember it needs to be detailed).....

You might also like