In the book we discussed the use of an auxiliary table to calculate variance and standard deviation (Table 4.3). Such a table gives much more insight in the underlying calculations than the simple number coming out of SPSS or Excel (see HERE [hyperlink to 4a]). You may have guessed that it is easy to make such a table in Excel. This allows you to rapidly check that the calculations you have done are correct. Below we describe how to make an Excel sheet for samples up to 20 observations (or whatever larger number you want). We start by defining the columns: Next, we enter the data (taken from p.83 of Basic Statistics for Psychologists): Now we need the sample mean: M. The calculation of this variable is described HERE [hyperlink to 3] Palgrave, 2011 1
First write M = in cell E2. Then goto cell F2 and click on fx. Select Statistical and Average. Define the cells upon which you will calculate M. We take A2:A21. This allows us to enter up to 20 values. Of course, you can always take a larger value. Just make sure that there are no values in cells that are supposed to be empty (e.g., the cells A11:A21 if you only have 9 observations like in the present example). Excel automatically excludes empty cells from its calculations but, of course, includes all cells with values in them. Palgrave, 2011 2
Click on OK to get the value of M. Now we are going to define the cells in column B as the value in column A minus M. One thing must be kept in mind, however. It is that we do not want the value to be calculated for empty cells in column A. Therefore we must start with an IF statement: IF the Cell in A is not empty then. Go in cell B2 and click on fx. Select Logical and IF. Palgrave, 2011 3
This gives you the following screen: First we have to enter the condition. Recall: this requires the cell in A not to be empty. The code for this is A2<> (cell A2 is not empty). Enter this: After the input box you see the word TRUE lighting up. This is because cell A2 is not empty. Now we enter the operation to be done when cell A2 is not empty. This operation is the value of A2 minus the mean value M. The code for this is A2 $F$2. The only surprising part here are the $ signs in $F$2. The reason why we have to include these signs is that the value of M stays in the same cell no matter in which cell of B we are. For cell B2 we want to calculate the value A2 minus M. So, the row of A changes with each row of B. This is done automatically, unless you use the $ signs. If we did not use $F$2, Excel would subtract the value of cell F3 from cell A3 to calculate the value of B3, which would be wrong. Palgrave, 2011 4
Next, we enter the value to be given when cell A2 is empty. This value should be empty as well. So, we enter. Palgrave, 2011 5
Click on OK to get the first value of column B. This will equal 1 (5 4). Also notice that the function panel (the box after f x ) contains the code of the full function calculate in cell B2: =IF(A2<>"",A2 $F$2,""). It is not difficult to decipher this on the basis of what we have covered. You can use it if you want later no longer to have to use the IF function interface. Now, let s copy the calculations done in cell B2 to cell B3. To do this, activate cell B2 (go on it with your cursor and click on the left button). Then either press Ctrl C (i.e., hold the key Ctrl down and press on the key C) or use the copy icon in the top bar: Palgrave, 2011 6
Now activate cell B3 (go with your cursor to it and click on the left button). Then either press Ctrl V or use the Paste the icon in the top panel. If everything went all right, this what you should have: Again, the function panel after fx tells you what operations have been done: This reads =IF(A3<>"",A3 $F$2,""). It means that if cell A3 was not empty, the value A3 F2 was calculated for cell B3. If cell A3 was empty, cell B3 would be left empty as well. Palgrave, 2011 7
Now we can copy the instructions to all cells B2:B21. This is done as follows. First, goto cell B2 with your cursor and activate it by clicking on the left button. Then activate cells B3:B21. This is done by going with your mouse over these cells while keeping the left button pressed. Palgrave, 2011 8
Then press Ctrl V or use the paste icon. If everything went well, this what you should have: For each row with a value in column A we get a value in column B. Otherwise column B remains empty. Palgrave, 2011 9
As a calculation check we can verify that the sum of the values in column B is 0. Write Σ(X M) = in cell E3. Then go to cell F3, click on fx, select All and Sum and define the values B2:B21. (You can also do the latter by simply going over the cells B2 to B21 with your cursor while keeping the left button pressed.) Click on OK to get the outcome. Can you see how your file is starting to look like Table 4.3 in the book (p.83)? Palgrave, 2011 10
Next, we need to define the values in column C. This is rather easy because they are simply the squares of the values in column B. The only complicating factor for us is that we only want those values for which the value in B is nonempty. So, we again will have to work with the IF function. Goto cell C2, click on fx, Logical, IF, and enter the following: This panel simply says that the value of cell C2 equals B2^2 (B2 squared) if B2 is not empty. Otherwise cell C2 remains empty. You can also see this code in the function panel after fx. There it says that cell C2 =IF(B2<>"",B2^2,""). Click on OK to calculate the value. Then copy cell C2 (use Ctrl C or the Copy icon), activate cells C3 to C21 (go over them with the cursor while keeping the left button pressed), and use Ctrl V (or the Paste icon). This is what you should have: Palgrave, 2011 11
We now use calculate the sum of the values in column C. Write Σ(X M)² = in cell E4 and define cell F4 as the sum of the values in column C. You can use the steps described above or simply type =SUM(C2:C21) in the function panel. Cell F4 now tells you that the sum of the squared values is 12 (compare to Table 4.3). Palgrave, 2011 12
We need one more thing to calculate the standard deviation. It is N, the number of observations. To calculate this, we use the Count function in Excel. Either you can use the fx button to search for it yourself or you simply write =COUNT(C2:C21) in cell F5 (also write N = in cell E5). For the sake of completeness, we may also define the degrees of freedom, which equals N 1. So, write df = in cell E6 and =F5 1 in cell F6. Palgrave, 2011 13
Now, we define the sample variance as: ( X M )² SD ² =. N 1 In Excel this translates to cell F4 divided by cell F6 (=F4/F6), as follows: Palgrave, 2011 14
To define SD we simply take the square root of cell F7 [=SQRT(F7)], as shown below. The nice thing is that we now have an Excel file (please save it!) that calculates everything we need for the standard deviation for all possible samples up to 20 observations (or more if you adjust the upper limits of the cells beyond row 21). This means that now you can check each and every exercise or example you are given!! Try it out. For instance with the example given on p. 86 of the book: Palgrave, 2011 15
Or with the example given on p. 89: Or whatever other your example you (or your lecturer) could think of! Enjoy! Palgrave, 2011 16