You are on page 1of 12

Statistics & graphing in Excel the basics

Statistics & graphing in Excel

Microsoft Excel 2007 Data entry

(scroll down for Excel 2003 instructions)

1. Enter your data into an Excel 2007 worksheet. 2. Type in column headings so its clear what your data are. Sea shell number 1 2 3 4 5 Shell length (mm)
small shells

Shell length (mm)


big shells

10.1 11.5 9.6 13.2 8.2

16.7 19.6 18.4 22.4 20.6

Calculating a mean: place your cursor in the cell where youd like the mean to be, then type: = AVERAGE( ) place your cursor in-between the parentheses, and select the cells with the numbers you would like to calculate the mean of Hit Enter

Calculating a standard deviation place your cursor in the cell where youd like the mean to be, then type: = STDEV( ) place your cursor in-between the parentheses, and select the cells with the numbers you would like to calculate the standard deviation of Hit Enter

Statistics & graphing in Excel the basics

Another option for calculating means and standard deviations 1. Click in an empty cell in the spreadsheet where you would like to put the result of your first calculation (e.g. mean). 2. Choose the Formulas tab at the top of the Excel 2007 window 3. Select More Functions from the top of the page, then select Statistical. 4. This should give you a drop-down menu of statistical calculations you can do. If you want to calculate a mean, select AVERAGE; if you want to calculate a standard deviation, select STDEV. 5. The dialog box that opens up allows you to do calculations on more than one variable at a time. Click in the first box (Number1), then go to the spreadsheet and select the data you would like to do your first calculation on. When youre done, hit OK. (note: dont put anything in the next boxes, such as Number2, unless you want these numbers to be included in your calculation) 6. Hit OK 7. The result of your calculation will be placed in the cell you selected in Step 1. If you wish to do further calculations, repeat these steps, starting with another, empty cell.

Doing a t-test to compare two means 1. Click in an empty cell in the spreadsheet where you would like to put the result of the t-test (given as the p-value). 2. Choose the Formulas tab at the top of the Excel 2007 window 3. Select More Functions from the top of the page, then select Statistical. 4. This should give you a drop-down menu of statistical calculations you can do. To do a t-test, select TTEST. 5. Put the data from one population in the t-test in the box labeled Array 1, and put the other populations data in the box labeled Array 2. 6. Click in the Tails box. Decide whether you want to do a one-tailed (i.e. a directional test, where you expect one populations mean to be higher than the other), or if you want to do a twotailed, non-directional test (done if you have no prediction or expectation that one mean will be higher than the other). Put the appropriate number (1 or 2) in this box depending upon which test you want.

Statistics & graphing in Excel the basics

7. Click in the Type box. Choose the type of t-test you want; paired or two-sample with equal or unequal variances. If your data come in pairs and are not independent of each other, use a paired t-test. If the data in your two populations are independent of each other, then use a two-sample t-test. The default for this test should be to use a two-sample t-test for unequal variances, unless you know that the standard deviations of your two populations are the same (this is rare). 8. Hit OK. This will give you the p-value of the t-test. It will not give you the tstatistic, unfortunately. The p-value should be compared to =0.05; if p < then the two populations you are comparing are statistically significantly different. If p > then the two populations you are comparing are not statistically significantly different.

Doing a chi-square (2) test to compare distributions 1. Chi-square (2) tests are used to compare an observed distribution of data to an expected distribution. As a simple example, heres what we might predict to see if we sampled 100 people for eye color: Eye color
Brown Observed Expected 71 75 Blue 10 8 Green / hazel 19 17 Total 100 100

2. Click in an empty cell in the spreadsheet where you would like to put the result of your first calculation (e.g. mean). 3. Choose the Formulas tab at the top of the Excel 2007 window 4. Select More Functions from the top of the page, then select Statistical. 5. This should give you a drop-down menu of statistical calculations you can do. To do a t-test, select CHITEST. 6. Put your observed data from in the box labeled Actual_range, and put your expected data in the Expected_range box. 7. Hit OK. This will give you the pvalue of the chi-square (2) test. It will not give you the chi-square (2) statistic, unfortunately. The

Statistics & graphing in Excel the basics

p-value should be compared to =0.05; if p < then the observed distribution is statistically significantly different from the expected distribution. If p > then the observed distribution is not statistically significantly different from the expected distribution. Depending upon the hypothesis you are testing, you may predict your observed data are or are not different from the expected distribution (there is no right answer here, but you should predict this before doing the test).

Graphing Make a new chart with means and standard deviations; for example: Shell length (mm)
small shells

Shell length (mm)


big shells

mean SD

10.5200 1.9071

19.5400 2.1606

Making a bar graph (called a Column chart in Excel) 1. Select the two values for the means you want to plot. Note: if you want the levels of the x-axis factor to be shown on the graph, you must also select the cells with the titles (e.g. above: the cells with Shell length (mm) small shells / Shell length (mm)
big shells).

2. Click on the Insert menu at the top of the page, then select Column under the graph types, selecting a 2-D column (dont use 3-D). 3. This will give you a crude bar graph, with nothing labeled. 4. Add axis labels by clicking on the Layout menu at the top of the page, then select Axis Titles. Pick each axis one at a time and type in the appropriate axis title with units!!
5. Use the Layout menu to add whatever other labels you need, such as a Legend. Note: a legend may not be necessary; make sure it adds information someone else could not figure out without the legend to explain the data.
25

Mean shell length (mm)

20
15

10
5

small shells

big shells

Statistics & graphing in Excel the basics

Adding error bars to a graph 1. Make sure your data for SD are entered along with your means, as shown in the data table above for shell length. 2. Click on the graph so it is selected; the border around the graph box will be highlighted. 3. Click on the Layout menu at the top of the page, then select Error Bars. 4. At the bottom of the menu that pulls down, select More Error Bars Options. 5. In the window that opens, click on the radio button that says Custom, then click on Specify Value 6. Click in the box for Positive value and then select the SD data from the spreadsheet. If you want error bars that go down from the mean as well, repeat this for the Negative value box. The same SD data go in both boxes. Note: you may only want or need error bars in one direction, particularly with bar graphs). 7. Click OK. Note that you can double-click on the error bars and change their appearance (color, style, line width). 8. Check the error bars to make sure they look right (i.e. are they the right size, given your values for standard deviations?). If everything looks good, youre done!

Statistics & graphing in Excel the basics

Plotting X-Y Data (Scatterplot) 1. Select the data you want to plot. 2. Click on the Insert menu at the top of the page, then select Scatter under the graph types. If you want lines on your graph, pick the one that says Scatter with straight lines and markers. Do not use the graph type that plots Smooth lines. 3. This will give you a crude scatterplot, with nothing labeled. 4. Add axis labels by clicking on the Layout menu at the top of the page, then select Axis Titles. Pick each axis one at a time and type in the appropriate axis title with units!!
5. Use the Layout menu to add whatever other labels you need, such as a Legend. Note: a legend may not be necessary; make sure it adds information someone else could not figure out without the legend to explain the data.

General note about making graphs in Excel You can change just about anything (size of the chart, font on the axes labels, color of the bars, the background, etc.). Spend some time playing around with the menus, especially whats under the Layout menu when the graph is selected, and see for yourself how you can customize the appearance of your graphs.

Statistics & graphing in Excel the basics

Microsoft Excel 2003 Data entry 1. Enter your data into an Excel 2003 worksheet. 2. Type in column headings so its clear what your data are. Sea shell number 1 2 3 4 5 Shell length (mm)
small shells

Shell length (mm)


big shells

10.1 11.5 9.6 13.2 8.2

16.7 19.6 18.4 22.4 20.6

Calculating a mean: place your cursor in the cell where youd like the mean to be, then type: = AVERAGE( ) place your cursor in-between the parentheses, and select the cells with the numbers you would like to calculate the mean of Hit Enter

Calculating a standard deviation place your cursor in the cell where youd like the mean to be, then type: = STDEV( ) place your cursor in-between the parentheses, and select the cells with the numbers you would like to calculate the standard deviation of Hit Enter

Another option for calculating means and standard deviations 1. Select Data Analysis in the Tools menu at the top of the page
(** for what do to if there is no Data Analysis option, see the end of the Excel 2003 section **)

2. Select Descriptive Statistics in the window that appears

Statistics & graphing in Excel the basics

3. Put your cursor in the Input data range and click, then select the data you want to use to calculate basic statistics on. 4. On the Descriptive Statistics window, click on the button for Output Range, and in the box that appears to its right, click on any box on your Excel worksheet, as long as there are a lot of empty boxes below and to the right. 5. Click on the box to the left of Summary Statistics. 6. Hit OK 7. The output is shown below for the small shell data from above:

Column1 Mean Standard Error Median Mode Standard Deviation Sample Variance Kurtosis Skewness Range Minimum Maximum Sum Count

10.52 0.852877482 10.1 #N/A 1.907092027 3.637 -0.22970087 0.411499631 5 8.2 13.2 52.6 5

Doing a t-test to compare two means Pull down the Tools menu and select Data Analysis Select t-test: Two-sample Assuming Unequal Variances, and hit OK Choose the data from two columns (or rows, depending upon how the data are arranged), placing them into the boxes Variable 1 Range and Variable 2 Range in the t-test window. In the Hypothesized Mean Difference, put your null hypothesis predicted difference between the means. If your null hypothesis states that there is no difference between the means of the two populations, then the number to be placed here would be 0.

Statistics & graphing in Excel the basics

Make sure that the box labeled Alpha () has 0.05, unless you have some reason to adjust the alpha value. This is the typical default value used by most statisticians. Decide where youd like the output from the t-test to be displayed. Putting a location (cell in the Excel spreadsheet) into Output Range will place the output results on the same worksheet page as your data or wherever you tell it to put the output. Hit OK. This should give you the t-value and p-value associated with a one-tailed (directional) and two-tailed (non-directional) test. In the output, you are given the t-statistic from the t-test (named t-Stat), and two options for t-critical values and their associated p-values to compare your test statistic to. If you had no prediction of which mean would be higher than the other, use the two-tailed results (P(T<=t) two-tail), t Critical two-tail). If you expected one mean to be higher than the other, select the one-tailed results (P(T<=t) one-tail), t Critical one-tail). If the p-value associated with the t-test results is less than alpha (=0.05), then the means of the two populations are statistically significantly different. If p > then the means of the two populations are not statistically significantly different.

Doing a chi-square (2) test to compare distributions Excel does not give you the test statistic (2) resulting from a chi-square test, so if you wish to do this test, youre probably better off using another program such as JMP (available on most machines on Rowans campus) or Excel 2007. If having the probability of having the value of chi-square (which youre not told) is enough, then heres how to do it in Excel 2003 (below). Find an open cell where youd like this result, and type =CHITEST(observed data, expected data), and hit Enter. Where this syntax says observed data, go select the data in columns or rows that you collected, and where it says expected data, go select the data from the distribution you expected. This probability can be compared to =0.05; if p < a then the observed distribution is statistically significantly different from the expected distribution. If p > then the observed and expected distributions are not statistically significantly different (i.e. they are statistically the same).

Statistics & graphing in Excel the basics

10

Graphing Make a new chart with means and standard deviations; for example: Shell length (mm) small shells 10.5200 1.9071 Shell length (mm) big shells 19.5400 2.1606

mean SD

Making a bar graph (called a column chart in Excel) 1. Select the two values for the means 2. Click on the Chart Wizard at the top of the Excel screen (it looks like a bar chart with a red, a yellow, and a blue bar) 3. Choose the Column chart on the left; dont worry about the chart sub-types on the right 4. Hit Next 5. Click on the tab for Series at the top of the next window 6. Name your data (type in the Name box) 7. Click in the box to the right of Category (X) axis labels 8. Select the boxes in the Excel worksheet where you typed in the names for each column (grey boxes below): Shell length (mm) small shells 10.5200 1.9071 Shell length (mm) big shells 19.5400 2.1606

mean SD

9. Hit Next. 10. On the next page, you can name the graph (chart), put titles on axes, and do many other things. Try out all the tabs on this page to see what you can do. 11. Click Finish. 12. Choose whether you want the graph to end up inside your current Excel worksheet (As object in), or if you want it to be in a new worksheet (As new sheet). 13. Click Finish.

Statistics & graphing in Excel the basics

11

Adding error bars to a graph 1. To add standard deviation error bars to your graph, double click on the bars in the graph (a small square should appear in each bar as you do this). 2. Under the Format menu, choose Selected Data Series. 3. Click on the tab for Y error bars. 4. Choose what kinds of error bars you want (both +/-, only +, only -). 5. Click on Custom at the bottom of the window. 6. Click inside one of the boxes to the right (+ for plus error bars, - for minus error bars). 7. Select your standard deviation data in the Excel worksheet (grey boxes below): Shell length (mm) small shells 10.5200 1.9071 Shell length (mm) big shells 19.5400 2.1606

mean SD

8. If you chose to make Both (plus and minus) error bars, be sure to fill in both Custom boxes (+ and -) 9. Check the error bars to make sure they look right (i.e. are they the right size, given your values for standard deviations?). If everything looks good, youre done!

Plotting X-Y Data 1. Enter your data in columns with your labels in the top row and your x-axis values (the independent variable in column A). Your y-axis values should be in columns B, etc. 2. Highlight the data by dragging the mouse around all the data including the labels. 3. Click on the Chart Wizard icon (which looks like a bar graph) on the top toolbar 4. Click on the XY (scatter) type under the Standard types menu and choose whether or not you want the points to be connected by lines. Click Next.

Statistics & graphing in Excel the basics

12

5. Click Next again if the chart is laid out properly. If not, click Back to change the chart type. 6. Fill in the chart title, and the labels for your x- and y-axes in the appropriate boxes. Click Next. 7. Click Finish to see the final graph. You can still change many aspects of how the graph looks at this point by double clicking on the axes, legend, etc. Ask me for help with these changes.

General note about making graphs in Excel You can change just about anything (size of the chart, font on the axes labels, color of the bars, the background, etc.) by clicking on parts of the chart. Try this out and play around with changing things to make the graph look the way youd like it to.

What to do if the Data Analysis tool is not installed on your computer (Excel 2003)
(If Data Analysis is not n the Tools menu)

1.

Pull down the Tools menu and select Add-Ins.

2. In the window that opens up, click in the boxes to the left of Analysis ToolPak and Analysis ToolPak - VBA. 3. Hit OK. 4. You should now see the Data Analysis tool in the Tools pull-down menu.

CER updated 9.5.11