How to Compute Deviation Scores

This lesson explains how to use matrix methods to transform raw scores to deviation scores. We show the transformation to deviation scores for vectors and for matrices.

Deviation Scores: Vectors

A deviation score is the difference between a raw score and the mean.

di = xi - x

where

di is the deviation score for the ith observation in a set of observations
xi is the raw score for the ith observation in a set of observations
x is the mean of all the observations in a set of observations

Often, it is easier to work with deviation scores than with raw scores. Use the following formula to transform a vector of n raw scores into a vector of n deviation scores.

d = x - 1'x1 ( 1'1 )-1 = x - 1'x1 ( 1/n )

where

1 is an n x 1 column vector of ones
d is an n x 1 column vector of deviation scores: d1, d2, . . . , dn
x is an n x 1 column vector of raw scores: x1, x2, . . . , xn

To show how this works, let's transform the raw scores in vector x to deviation scores in vector d. For this example, let x' = [ 1 2 3 ].

d   =    x    -    1' x    1 ( 1' 1   )-1
d   =   
1
2
3
   -    [ 1 1 1 ]   
1
2
3
  
1
1
1
   (    [ 1 1 1 ]   
1
1
1
  )-1  
d   =   
1
2
3
   -   
2
2
2
   =   
-1
0
1

Note that the mean deviation score is zero.

Deviation Scores: Matrices

Let X be an r x c matrix holding raw scores; and let x be the corresponding r x c matrix holding deviation scores.

When transforming raw scores from X into deviation scores for x, we often want to compute deviation scores separately within columns, consistent with the equation below.

xrc = Xrc - Xc

where

xrc is the deviation score from row r and column c of matrix x
Xrc is the raw score from row r and column c of matrix X
Xc is the mean score, based on all r scores from column c of matrix X

To transform the raw scores from matrix X into deviation scores for matrix x, we use this matrix equation.

x = X - 11'X ( 1'1 )-1 = X - 11'X ( 1 / r )

where

1 is an r x 1 column vector of ones
x is an r x c matrix of deviation scores: x11, x12, . . . , xrc
X is an r x c matrix of raw scores: X11, X12, . . . , Xrc

Note: Deviation score matrices are often denoted by a lower-case, boldface letter, such as x. This can cause confusion, since vectors are also denoted by lower-case, boldface letters; but usually the meaning is clear from the context.

Test Your Understanding

Problem 1

Consider matrix X.

X   =   
3 5 1
9 1 4

Using matrix methods, create a 2 x 3 vector D, such that the elements of D are deviation scores based on elements from X. That is,

D   =   
3 - X1    5 - X2    1 - X3
9 - X1    1 - X2    4 - X3

where Xc is the mean of elements from column c of matrix X.

Solution

To solve this problem, we use the following equation: D = X - 11'X ( 1 / r ). Each step in the computation is shown below.

D   =    X    -    1 1' X ( 1/r )
D   =   
3 5 1
9 1 4
   -   
1
1
   [ 1 1 ]   
3 5 1
9 1 4
   ( 1/r )
D   =   
3 5 1
9 1 4
   -   
1 1
1 1
  
3 5 1
9 1 4
   ( 1/2 )
D   =   
3 5 1
9 1 4
   -   
12 6 5
12 6 5
   ( 1/2 )
D   =   
3 5 1
9 1 4
   -   
6 3 2.5
6 3 2.5
   =   
-3 2 -1.5
3 -2 1.5

Thus, matrix D has the deviation scores, based on raw scores from matrix X. Note that the mean and sum of each column in matrix D is zero.