Diff for "FAQ/baSPSS" - CBU statistics Wiki
location: Diff for "FAQ/baSPSS"
Differences between revisions 9 and 10
Revision 9 as of 2011-07-07 11:12:59
Size: 5584
Editor: PeterWatson
Comment:
Revision 10 as of 2013-03-08 10:17:25
Size: 5586
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 114: Line 114:
You should now be finished and have a scatterplot of the inter-test difference (y-axis) by the average test score (x-axis) with three lines for the mean and its 95% confidence limits looking something like [attachment:baplot.doc this.]  You should now be finished and have a scatterplot of the inter-test difference (y-axis) by the average test score (x-axis) with three lines for the mean and its 95% confidence limits looking something like [[attachment:baplot.doc|this.]]

Using SPSS to produce Bland Altman plots

Using the data on the previous page we illustrate, step-by-step, how to use SPSS syntax and its graphing editor to produce Bland-Altman plots. Note: you will need to adjust the file names and variable names and their graph labels in the below accordingly for using on data on your own PC.

We firstly make sure we have the data in a saved SPSS spreadsheet. We only need wright1 and mini1 for our calculations.

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. 

We now run some syntax that will produce a difference by average scatterplot plus the mean and its 95% confidence limits ready for su to add on shortly. Remember you will need to change the file names, variable names and the graph labels.

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 difference = 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= DIFFERENCE
/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 DIFFERENCE 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.

VAR LABEL difference 'Wright peak flow meter  #1 - Mini Wright peak flow meter #1'
/average '(Wright peak flow meter  #1 + Mini Wright peak flow meter #1)/2'.

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

Running the above in a syntax window should give you a data file containing the original data 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 enter the range of the y-axis (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.11 in the box. Click Apply and Close. A line at Y=-2.11 should appear on the plot.

  3. Repeat the previous step twice more for the limits of the confidence interval putting Y equal to the values -78.10 and, then, 73.86 representing L95 and U95 respectively clicking Apply and Close each time.

You should now be finished and have a scatterplot of the inter-test difference (y-axis) by the average test score (x-axis) with three lines for the mean and its 95% confidence limits looking something like this.

None: FAQ/baSPSS (last edited 2013-03-08 10:17:25 by localhost)