FAQ/baSPSS - CBU statistics Wiki
Self: FAQ/baSPSS
  • = Using SPSS 16+ to produce Bland Altman plots =

DATA LIST LIST/ subject wright1 wright2 mini1 mini2 (5 F8.0).
BEGIN DATA
1       494     490     512     525
2       395     397     430     415
3       516     512     520     508
4       434     401     428     444
5       476     470     500     500
6       557     611     600     625
7       413     415     364     460
8       442     431     380     390
9       650     638     658     642
10      433     429     445     432
11      417     420     432     420
12      656     633     626     605
13      267     275     260     227
14      478     492     477     467
15      178     165     259     268
16      423     372     350     370
17      427     421     451     443
END DATA.
SAVE OUTFILE='C:\Documents and Settings\peterw\Desktop\My Documents\My Documents2\BLAND AND ALTMAN PLOT\dat.sav' /KEEP=WRIGHT1 MINI1. 

GET FILE='C:\Documents and Settings\peterw\Desktop\My Documents\My Documents2\BLAND AND ALTMAN PLOT\dat.sav'. 

COMPUTE diff = WRIGHT1 - MINI1 .
compute average = (WRIGHT1 + MINI1)/2.
EXECUTE .

OMS 
/SELECT TABLES 
/IF SUBTYPES=['Descriptive Statistics'] 
/DESTINATION FORMAT=SAV OUTFILE='C:\Documents and Settings\peterw\Desktop\My Documents\My Documents2\BLAND AND ALTMAN PLOT\des.sav'. 

DESCRIPTIVES  VARIABLES= DIFF
/STATISTICS=MEAN STDDEV.

OMSEND.

SAVE OUTFILE='C:\Documents and Settings\peterw\Desktop\My Documents\My Documents2\BLAND AND ALTMAN PLOT\dat.sav' /KEEP=WRIGHT1 MINI1 DIFF AVERAGE. 

GET FILE='C:\Documents and Settings\peterw\Desktop\My Documents\My Documents2\BLAND AND ALTMAN PLOT\des.sav'. 

RENAME VARIABLES (MEAN STD.DEVIATION=M SD).
COMPUTE L95=M-1.96*SD.
COMPUTE U95=M+1.96*SD.

IF ($CASENUM LE 1) ID=$CASENUM.
SORT CASES BY ID.
SAVE OUTFILE='C:\Documents and Settings\peterw\Desktop\My Documents\My Documents2\BLAND AND ALTMAN PLOT\des.sav' /KEEP=ID M N L95 U95. 

EXE.

GET FILE='C:\Documents and Settings\peterw\Desktop\My Documents\My Documents2\BLAND AND ALTMAN PLOT\dat.sav'. 
COMPUTE ID=1.
EXE.
SORT CASES BY ID.
EXE.

MATCH FILES FILE=*
  /TABLE='C:\Documents and Settings\peterw\Desktop\My Documents\My Documents2\BLAND AND ALTMAN PLOT\des.sav'  
  /BY ID.
EXECUTE.

GRAPH
  /SCATTERPLOT=average WITH diff  
  /MISSING=LISTWISE .

The above should give you a data file containing the original dat plus three columns called M (the mean difference), L95 and U95 representing the lower and upper endpoints of tis 95% confidence interval together with a scatterplot of the difference by average in the output file. To finish things off we need to edit the graph manually. This may be done as follows:

  1. Firstly make sure that the range of the Y-axis contains the lower (L95) and upper (U95) confidence limits for the average inter-test difference (M). If the Y axis needs adjusting click on the graph and go to Edit>Select Y axis and then tner the range (and any increments) required.

  2. We are now ready to add the three lines to the plot for the mean difference(M in the outputted data file) and the limits of its 95% confidence interval (called L95 and U95 in the data file). Go to options>Add a reference line to Y- axis. Put Y equal to M by typing Y=-2.116 in the box. Click Apply and Close. A line at Y=-2.11 should appear on the plot.

  3. repeat for the limits of the confidence interval putting Y equal to the values given by L95 and U95 clicking apply and close each time.

You should now be done: having a scatterplot of the difference (y-axis) by average (x-axis) with the three lines on.

None: FAQ/baSPSS (last edited 2011-07-06 11:18:48 by PeterWatson)