FAQ/box - CBU statistics Wiki

Revision 6 as of 2006-07-27 12:20:12

Clear message
location: FAQ / box

The interactive graphics in SPSS can be accessed from the menu by choosing graphs:interactive. It enables the availability of a greater range of graphics than are present using older, non-interactive graph options. An example is given below in SPSS syntax for one such enhancement: clustered boxplots. Further editing of the graph may be performed by clicking on particular parts of the outputted graph.

[CUT AND PASTE THE SYNTAX IN THE BOX BELOW INTO A SPSS SYNTAX WINDOW AND RUN]

Set format f10.5.
Data list free/
Score group  sex.
Begin data
1 1 1
2 1 1
3 1 1
4 1 2
3 1 2
4 1 2
17 2 1
78 2 1
23 2 1
45 2 2
23 2 2
56 2 2
45 3 1
23 3 1
67 3 1
45 3 2
23 3 2
12 3 2
end data.

* This macro fits a clustered boxplot for a continuous response 
* and two categorical variables of upto five levels each. 
DEFINE !BOX          ( !POS !TOKENS(1)
                     / !POS !TOKENS(1)
                     / !POS !TOKENS(1)
                     / !POS !TOKENS(1)
                     / !POS !TOKENS(1)
                     / !POS !TOKENS(1)
                     / !POS !TOKENS(1)
                     / !POS !TOKENS(1)
                     / !POS !TOKENS(1)
                     / !POS !TOKENS(1)
                     / !POS !TOKENS(1)
                     / !POS !TOKENS(1)
                     / !POS !TOKENS(1)
                     / !POS !TOKENS(1)
                     / !POS !TOKENS(1)
                     / !POS !TOKENS(1)
                     / !POS !TOKENS(1)
                     / !POS !CMDEND).

RANK
  VARIABLES = !2 
  /NTILES(!3) 
  /PRINT = NO
  /TIES = MEAN .

RANK
  VARIABLES = !4
  /NTILES(!5) 
  /PRINT = NO
  /TIES = MEAN .

VAR LABELS      !1      !6/
                           !CONCAT(n,!2)      !7/  
                           !CONCAT(n,!4)      !8/.

VALUE LABELS    !CONCAT(n,!2)                 (1) !9
                                              (2) !10
                                              (3) !11
                                              (4) !12
                                              (5) !13/
                !CONCAT(n,!4)                 (1) !14
                                              (2) !15
                                              (3) !16
                                              (4) !17
                                              (5) !18/.
IGRAPH /VIEWNAME='Boxplot' /X1 = VAR(!concat(n,!2)) TYPE = CATEGORICAL /Y = VAR(!1)
  TYPE = SCALE  /STYLE = VAR(!concat(n,!4)) /COORDINATE = VERTICAL  /X1LENGTH=3.0
 /YLENGTH=3.0 /X2LENGTH=3.0 /CHARTLOOK='NONE' /CATORDER VAR(!concat(n,!4)) (ASCENDING
  VALUES OMITEMPTY) /CATORDER VAR(!concat(n,!2)) (ASCENDING VALUES OMITEMPTY) /BOX
  OUTLIERS = ON EXTREME = ON MEDIAN = ON WHISKER = T.
EXE.
!ENDDEFINE.

* The line below can be adapted as required for specific data to * specify variable column names and their labels in the boxplot, * number of levels of each categorical variable and the names of * these levels to appear in the boxplot. It is set up for the 
* example data above. In the line below asterisks denote levels 
* of variables which are not present.
!BOX SCORE GROUP 3 SEX 2 score gender group CONTROLS PATIENTS OTHERS * * MALE FEMALE * * *.

* Multiple invocations of the macro in the same interactive session will produce the following note:

>The macro name specified on the DEFINE command duplicates the name of a previously defined macro. This instance will take precedence.

This warning does not indicate a problem and may be ignored.