Deviation scores are obtained by subtracting the mean from the raw scores, deviation score = x = (X - mean). Deviation scores have a mean = 0 and the same standard deviation as the raw scores.
Standard scores (z-scores) are obtained by dividing deviation scores by the standard deviation, z-score = (X - mean)/sd = x/sd. Standard Scores have a mean = 0 and sd = 1.
use http://www.philender.com/courses/data/hsb2, clear summarize write Variable | Obs Mean Std. Dev. Min Max ---------+----------------------------------------------------- write | 200 52.775 9.478586 31 67 return list scalars: r(N) = 200 r(sum_w) = 200 r(mean) = 52.775 r(Var) = 89.84359296482413 r(sd) = 9.47858602138653 r(min) = 31 r(max) = 67 r(sum) = 10555 generate dwrite = write - r(mean) generate zwrite1 = dwrite/r(sd) /* also -- zwrite1 = (write - r(mean))/r(sd) */ egen zwrite2 = std(write) list write dwrite zwrite1 zwrite2 write dwrite zwrite1 zwrite2 1. 52 -.775 -.0817632 -.0817633 2. 59 6.225 .6567435 .6567435 3. 33 -19.775 -2.086282 -2.086282 4. 44 -8.775 -.9257709 -.925771 5. 52 -.775 -.0817632 -.0817633 6. 52 -.775 -.0817632 -.0817633 7. 59 6.225 .6567435 .6567435 8. 46 -6.775 -.7147691 -.7147691 9. 57 4.225 .4457416 .4457416 10. 55 2.225 .2347396 .2347396 ... summarize write dwrite zwrite1 zwrite2 Variable | Obs Mean Std. Dev. Min Max ---------+----------------------------------------------------- write | 200 52.775 9.478586 31 67 dwrite | 200 1.58e-07 9.478586 -21.775 14.225 zwrite1 | 200 1.84e-08 1 -2.297284 1.500751 zwrite2 | 200 5.53e-09 1 -2.297284 1.500751 correlate read write dwrite zwrite1 zwrite2 (obs=200) | read write dwrite zwrite1 zwrite2 ---------+--------------------------------------------- read | 1.0000 write | 0.5968 1.0000 dwrite | 0.5968 1.0000 1.0000 zwrite1 | 0.5968 1.0000 1.0000 1.0000 zwrite2 | 0.5968 1.0000 1.0000 1.0000 1.0000
zcalc 31 30 5.5 /* findit zcalc*/ z-score for sample observations (X - m) (31 - 30) z = --------- = ------------------ = 0.18 s 5.5 zcalc 37 30 5.5 z-score for sample observations (X - m) (37 - 30) z = --------- = ------------------ = 1.27 s 5.5 zcalc 24 30 5.5 z-score for sample observations (X - m) (24 - 30) z = --------- = ------------------ = -1.09 s 5.5 zcalc 28 30 5.5 z-score for sample observations (X - m) (28 - 30) z = --------- = ------------------ = -0.36 s 5.5
Intro Home Page
Phil Ender, 15Jan98