This function scores a serial subtraction task where respondents are scored based on their ability to successfully subtract a specific value (e.g., 7) from the previous value. A score of 1 is given for correct subtraction, and a score of 0 is given for incorrect subtraction. However, a respondent can still receive a score of 1 if they recover from an initial mistake by correctly subtracting later.
Value
A numeric vector where:
1
: Correct subtraction.0
: Incorrect subtraction.NA
: If the original value is missing (NA), it remains NA.
Details
The function checks if the respondent's answer (val
) is equal to the correct subtraction
difference (diff
). If so, they are awarded a score of 1. If they make a mistake, they get 0.
However, if they correct their mistake in the next step, they can receive a score of 1 for that step.
Missing values (NA) in the input remain as NA in the output.