In R: As a side point, to do it in R, just use the score.multiple.choice() function from the psych package.
In SPSS: The following example is based on a class example that I teach. The raw data were the response options (1 to 4) for 53 four-choice multiple test items. the name of each variable was ability1, ability2, and so on, to ability53. The questions are not a serious set of questions. The correct responses were known. I learnt how to use DO REPEAT from Richard Bell.
Run the following syntax:
The SPSS syntax explained:
DO REPEAT xraw = ability1 to ability53/ xkey = 3, 2, 4, 1, 2, 2, 1, 1, 1, 3, 4, 4, 1, 2, 4, 2, 4, 1, 2, 4, 1, 4, 2, 1, 2, 1, 2, 2, 4, 2, 1, 2, 4, 3, 4, 1, 2, 1, 2, 2, 1, 4, 3, 2, 1, 4, 4, 1, 3, 2, 1, 2, 3/ xscore=score1 to score53. COMPUTE xscore = 0. IF ( xraw = xkey ) xscore = 1. END REPEAT. EXECUTE. COMPUTE meanCorrect = MEAN.53(score1 to score53). EXECUTE.
- you may need to bring up a syntax editor (File - New - Syntax)
- Verbally the syntax roughly reads:
- Set up a loop: create a variable xraw that will take on one of 53 different values (ability1 to abiltiy53); also create a variable xkey which on each iteration through loop will take on the next value in the series; also create a variable xscore that will take on one of 53 different values (score1 to score53).
- For each iteration through the loop initialise the variable xscore to 0. Then if the response for that item (xraw) matches the key (xkey) the respondent answered the item correctly. Therefore, make xscore 1 to indicate that the person answered it correctly. In order for this loop to run include the the EXECUTE command.
- Then compute a new variable to store the mean number of items correct. The mean.53 function calculates the mean of the items. The 53 in the "mean.53" is used so that any person with missing data will get no mean. If you had mean.3 and someone only answered three items and they answered them correctly, then the person would appear to get 100% correct. there are many other ways that this total could be computed.
- Thus, to make this your own example, change 53 to the number of items you have and change the key.
1) The data frame showing the first few variables of the 53 raw ability test items.
2) What the syntax might look like in SPSS using version 17.
3) The data frame with the new variables (score1 to score 53); Note that I have copy and pasted the variable names from the raw items to the scored items.
4) Running basic descriptive statistics on the newly created mean.