Dr. Mark Gardener 


Statistics for Ecologists Using R and Excel. Edition 2 is on the way. Statistics for Ecologists Using R and Excel: Original Edition 1 Available now from Get a 20% discount on "Statistics for Ecologists" when you buy direct from the publisher! Enter the voucher code S4E20 in the shopping basket at Pelagic Publishing. 
Writer's BlocOn this page you can find out about my latest writing project. I'll post updates on progress, tables of contents and also some of the R scripts (and possibly Excel spreadsheets) I am developing in support of the new book. I'll try to keep the material reasonably up to date. The Writer's Bloc homepage contains a table of contents and an index of the pages that contain custom R commands and R scripts.
I am working on a new edition of my book Statistics for Ecologists Using R and Excel. I am currently revising the chapter on exploring differences. These notes are about presenting the results/data of matched pairs data graphically. Using graphs to display matched pairs dataIntroductionUsually you'll use a bar chart or boxwhisker plot to display data when looking at differences between samples. When you have a matched pairs situation however, these sorts of graph may not always be the best way to summarize your data/results. An alternative is to use a scatter plot, where you plot one sample against the other. If you add an isocline (a straight line with slope 1 and intercept 0) you can see more clearly how the pairs of observations match up with one another. These notes show you how to prepare such a scatter plot. 

Use Insert > Scatter to plot one sample against the other for matched pairs. Add an isocline by plotting two points, one at the origin and one at the max data value. Remove the points but add a joining line to create the isocline. The isocline has slope = 1 and intercept = 0 e.g. coordinates: Use the Add Data button to add the isocline data. 
Make a scatter plotWhen you have matched pair data you obviously have matched pairs. These data could be plotted as a scatter graph with one sample against the other. You can do this easily in Excel or in R. In ExcelIn Excel you can simply select the two samples and then click the Insert > Scatter button. The chart really comes into its own if you add an isocline (a line of parity). To do this you need to add a straight line with a slope of 1 and an intercept of 0. To add an isocline you need two values:
To add the isocline you:
Once you've formatted the chart and tidied up a bit you'll have a scatter plot and isocline.


Use abline() for the isocline. Set a = 0, b = 1 to get intercept 0 and slope 1 
In RIn R you can use the plot() command to chart one sample against the other. The isocline can be added using the abline() command, set a = 0, b = 1 to get an intercept of 0 and a slope of 1. > a;b This produces a simple scatter with an isocline. There are many additional graphical parameters you can add to these basic commands, to alter the plotting character, colors and the style of the isocline for example. 

Boxbplot and scatter plot with isocline give different emphasis to your data/results. Choose what seems best for your purpose. 
Compare to a boxplotThe scatter plot shows your matched pairs data in a different way to a boxwhisker plot or a bar chart. The isocline is the key to the plot. The further from the isocline the points are the more "different" the pairs of data are. If all the point lay on the line then there would be no difference between the pairs. If all the points were to one side then one sample would be different from the other. The further from the line, the more different. Sometimes a basic bar or boxplot is all you need, at other times you may decide that the scatter plot and isocline is the way to go.


Plot a single point at a coordinate which is hte average for one sample and the average for the other. Add horizontal and vertical error bars to show variability. 
Show the IQRWith a little bit of tinkering you can show the averages and variability for your matched pairs data right on the scatter plot. What you need to do is to plot an additional point with coordinates that take the average for one sample vs. the average for the other. Then add error bars to the vertical and horizontal. In Excel the error bars are calculated as an amount, so you need to determine the "deflection" from the average. In R you add error bars by drawing on the plot so you need the coordinates of the extremes of the variability. For example if you wanted to show median and interquartile range in Excel you'd need to work out how far "above" the median the upper quartile was, and how far "below" the median the lower quartile was. In R you simply calculate the quartiles and use the appropriate values to draw the error bars. With a bit of tinkering you can get a plot something like this (in Excel):
It is easy to get Excel error bars: click the chart then the Design menu and the Add Chart Element button. Choose the More Error Bars Options and then select the values for the vertical bars. You should also see horizontal error bars appear in the chart, click them to activate the Horizontal Error Bars options. If you don't see the horizontal erorr bars try the Chart Tools > Format menu and select the error bars from the dropdown menu on the left in the Current Selection section. In R you can use the lines() or arrows() command to draw the error bars in place, once you have the appropriate values, such as from the quantile() command. 

Top 


Providing training for:

My Publications See my personal pages at GardenersOwn 

Follow me... 

Top  Contact  DataAnalytics Homepage 