docs
[pspp] / doc / statistics.texi
1 @c PSPP - a program for statistical analysis.
2 @c Copyright (C) 2017, 2020 Free Software Foundation, Inc.
3 @c Permission is granted to copy, distribute and/or modify this document
4 @c under the terms of the GNU Free Documentation License, Version 1.3
5 @c or any later version published by the Free Software Foundation;
6 @c with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
7 @c A copy of the license is included in the section entitled "GNU
8 @c Free Documentation License".
9 @c
10 @node Statistics
11 @chapter Statistics
12
13 This chapter documents the statistical procedures that @pspp{} supports so
14 far.
15
16 @menu
17 * DESCRIPTIVES::                Descriptive statistics.
18 * FREQUENCIES::                 Frequency tables.
19 * EXAMINE::                     Testing data for normality.
20 * GRAPH::                       Plot data.
21 * CORRELATIONS::                Correlation tables.
22 * CROSSTABS::                   Crosstabulation tables.
23 * CTABLES::                     Custom tables.
24 * FACTOR::                      Factor analysis and Principal Components analysis.
25 * GLM::                         Univariate Linear Models.
26 * LOGISTIC REGRESSION::         Bivariate Logistic Regression.
27 * MEANS::                       Average values and other statistics.
28 * NPAR TESTS::                  Nonparametric tests.
29 * T-TEST::                      Test hypotheses about means.
30 * ONEWAY::                      One way analysis of variance.
31 * QUICK CLUSTER::               K-Means clustering.
32 * RANK::                        Compute rank scores.
33 * RELIABILITY::                 Reliability analysis.
34 * ROC::                         Receiver Operating Characteristic.
35 @end menu
36
37 @node DESCRIPTIVES
38 @section DESCRIPTIVES
39
40 @vindex DESCRIPTIVES
41 @display
42 DESCRIPTIVES
43         /VARIABLES=@var{var_list}
44         /MISSING=@{VARIABLE,LISTWISE@} @{INCLUDE,NOINCLUDE@}
45         /FORMAT=@{LABELS,NOLABELS@} @{NOINDEX,INDEX@} @{LINE,SERIAL@}
46         /SAVE
47         /STATISTICS=@{ALL,MEAN,SEMEAN,STDDEV,VARIANCE,KURTOSIS,
48                      SKEWNESS,RANGE,MINIMUM,MAXIMUM,SUM,DEFAULT,
49                      SESKEWNESS,SEKURTOSIS@}
50         /SORT=@{NONE,MEAN,SEMEAN,STDDEV,VARIANCE,KURTOSIS,SKEWNESS,
51                RANGE,MINIMUM,MAXIMUM,SUM,SESKEWNESS,SEKURTOSIS,NAME@}
52               @{A,D@}
53 @end display
54
55 The @cmd{DESCRIPTIVES} procedure reads the active dataset and outputs
56 linear descriptive statistics requested by the user.  In addition, it can optionally
57 compute Z-scores.
58
59 The @subcmd{VARIABLES} subcommand, which is required, specifies the list of
60 variables to be analyzed.  Keyword @subcmd{VARIABLES} is optional.
61
62 All other subcommands are optional:
63
64 The @subcmd{MISSING} subcommand determines the handling of missing variables.  If
65 @subcmd{INCLUDE} is set, then user-missing values are included in the
66 calculations.  If @subcmd{NOINCLUDE} is set, which is the default, user-missing
67 values are excluded.  If @subcmd{VARIABLE} is set, then missing values are
68 excluded on a variable by variable basis; if @subcmd{LISTWISE} is set, then
69 the entire case is excluded whenever any value in that case has a
70 system-missing or, if @subcmd{INCLUDE} is set, user-missing value.
71
72 The @subcmd{FORMAT} subcommand has no effect.  It is accepted for
73 backward compatibility.
74
75 The @subcmd{SAVE} subcommand causes @cmd{DESCRIPTIVES} to calculate Z scores for all
76 the specified variables.  The Z scores are saved to new variables.
77 Variable names are generated by trying first the original variable name
78 with Z prepended and truncated to a maximum of 8 characters, then the
79 names ZSC000 through ZSC999, STDZ00 through STDZ09, ZZZZ00 through
80 ZZZZ09, ZQZQ00 through ZQZQ09, in that sequence.  In addition, Z score
81 variable names can be specified explicitly on @subcmd{VARIABLES} in the variable
82 list by enclosing them in parentheses after each variable.
83 When Z scores are calculated, @pspp{} ignores @cmd{TEMPORARY},
84 treating temporary transformations as permanent.
85
86 The @subcmd{STATISTICS} subcommand specifies the statistics to be displayed:
87
88 @table @code
89 @item @subcmd{ALL}
90 All of the statistics below.
91 @item @subcmd{MEAN}
92 Arithmetic mean.
93 @item @subcmd{SEMEAN}
94 Standard error of the mean.
95 @item @subcmd{STDDEV}
96 Standard deviation.
97 @item @subcmd{VARIANCE}
98 Variance.
99 @item @subcmd{KURTOSIS}
100 Kurtosis and standard error of the kurtosis.
101 @item @subcmd{SKEWNESS}
102 Skewness and standard error of the skewness.
103 @item @subcmd{RANGE}
104 Range.
105 @item MINIMUM
106 Minimum value.
107 @item MAXIMUM
108 Maximum value.
109 @item SUM
110 Sum.
111 @item DEFAULT
112 Mean, standard deviation of the mean, minimum, maximum.
113 @item SEKURTOSIS
114 Standard error of the kurtosis.
115 @item SESKEWNESS
116 Standard error of the skewness.
117 @end table
118
119 The @subcmd{SORT} subcommand specifies how the statistics should be sorted.  Most
120 of the possible values should be self-explanatory.  @subcmd{NAME} causes the
121 statistics to be sorted by name.  By default, the statistics are listed
122 in the order that they are specified on the @subcmd{VARIABLES} subcommand.
123 The @subcmd{A} and @subcmd{D} settings request an ascending or descending
124 sort order, respectively.
125
126 @subsection Descriptives Example
127
128 The @file{physiology.sav} file contains various physiological data for a sample
129 of persons.   Running the @cmd{DESCRIPTIVES} command on the variables @exvar{height}
130 and @exvar{temperature} with the default options allows one to see simple linear
131 statistics for these two variables.  In @ref{descriptives:ex}, these variables
132 are specfied on the @subcmd{VARIABLES} subcommand and the @subcmd{SAVE} option
133 has been used, to request that Z scores be calculated.
134
135 After the command has completed, this example runs @cmd{DESCRIPTIVES} again, this
136 time on the @exvar{zheight} and @exvar{ztemperature} variables,
137 which are the two normalized (Z-score) variables generated by the
138 first @cmd{DESCRIPTIVES} command.
139
140 @float Example, descriptives:ex
141 @psppsyntax {descriptives.sps}
142 @caption {Running two @cmd{DESCRIPTIVES} commands, one with the @subcmd{SAVE} subcommand}
143 @end float
144
145 @float Screenshot, descriptives:scr
146 @psppimage {descriptives}
147 @caption {The Descriptives dialog box with two variables and Z-Scores option selected}
148 @end float
149
150 In @ref{descriptives:res}, we can see that there are 40 valid data for each of the variables
151 and no missing values.   The mean average of the height and temperature is 16677.12
152 and 37.02 respectively.  The descriptive statistics for temperature seem reasonable.
153 However there is a very high standard deviation for @exvar{height} and a suspiciously
154 low minimum.  This is due to a data entry error in the
155 data (@pxref{Identifying incorrect data}).
156
157 In the second Descriptive Statistics command, one can see that the mean and standard
158 deviation of both Z score variables is 0 and 1 respectively.  All Z score statistics
159 should have these properties since they are normalized versions of the original scores.
160
161 @float Result, descriptives:res
162 @psppoutput {descriptives}
163 @caption {Descriptives statistics including two normalized variables (Z-scores)}
164 @end float
165
166 @node FREQUENCIES
167 @section FREQUENCIES
168
169 @vindex FREQUENCIES
170 @display
171 FREQUENCIES
172         /VARIABLES=@var{var_list}
173         /FORMAT=@{TABLE,NOTABLE,LIMIT(@var{limit})@}
174                 @{AVALUE,DVALUE,AFREQ,DFREQ@}
175         /MISSING=@{EXCLUDE,INCLUDE@}
176         /STATISTICS=@{DEFAULT,MEAN,SEMEAN,MEDIAN,MODE,STDDEV,VARIANCE,
177                      KURTOSIS,SKEWNESS,RANGE,MINIMUM,MAXIMUM,SUM,
178                      SESKEWNESS,SEKURTOSIS,ALL,NONE@}
179         /NTILES=@var{ntiles}
180         /PERCENTILES=percent@dots{}
181         /HISTOGRAM=[MINIMUM(@var{x_min})] [MAXIMUM(@var{x_max})]
182                    [@{FREQ[(@var{y_max})],PERCENT[(@var{y_max})]@}] [@{NONORMAL,NORMAL@}]
183         /PIECHART=[MINIMUM(@var{x_min})] [MAXIMUM(@var{x_max})]
184                   [@{FREQ,PERCENT@}] [@{NOMISSING,MISSING@}]
185         /BARCHART=[MINIMUM(@var{x_min})] [MAXIMUM(@var{x_max})]
186                   [@{FREQ,PERCENT@}]
187         /ORDER=@{ANALYSIS,VARIABLE@}
188
189
190 (These options are not currently implemented.)
191         /HBAR=@dots{}
192         /GROUPED=@dots{}
193 @end display
194
195 The @cmd{FREQUENCIES} procedure outputs frequency tables for specified
196 variables.
197 @cmd{FREQUENCIES} can also calculate and display descriptive statistics
198 (including median and mode) and percentiles, and various graphical representations
199 of the frequency distribution.
200
201 The @subcmd{VARIABLES} subcommand is the only required subcommand.  Specify the
202 variables to be analyzed.
203
204 The @subcmd{FORMAT} subcommand controls the output format.  It has several
205 possible settings:
206
207 @itemize @subcmd{}
208 @item
209 @subcmd{TABLE}, the default, causes a frequency table to be output for every
210 variable specified.  @subcmd{NOTABLE} prevents them from being output.  @subcmd{LIMIT}
211 with a numeric argument causes them to be output except when there are
212 more than the specified number of values in the table.
213
214 @item
215 Normally frequency tables are sorted in ascending order by value.  This
216 is @subcmd{AVALUE}.  @subcmd{DVALUE} tables are sorted in descending order by value.
217 @subcmd{AFREQ} and @subcmd{DFREQ} tables are sorted in ascending and descending order,
218 respectively, by frequency count.
219 @end itemize
220
221 The @subcmd{MISSING} subcommand controls the handling of user-missing values.
222 When @subcmd{EXCLUDE}, the default, is set, user-missing values are not included
223 in frequency tables or statistics.  When @subcmd{INCLUDE} is set, user-missing
224 are included.  System-missing values are never included in statistics,
225 but are listed in frequency tables.
226
227 The available @subcmd{STATISTICS} are the same as available
228 in @cmd{DESCRIPTIVES} (@pxref{DESCRIPTIVES}), with the addition
229 of @subcmd{MEDIAN}, the data's median
230 value, and MODE, the mode.  (If there are multiple modes, the smallest
231 value is reported.)  By default, the mean, standard deviation of the
232 mean, minimum, and maximum are reported for each variable.
233
234 @cindex percentiles
235 @subcmd{PERCENTILES} causes the specified percentiles to be reported.
236 The percentiles should  be presented at a list of numbers between 0
237 and 100 inclusive.
238 The @subcmd{NTILES} subcommand causes the percentiles to be reported at the
239 boundaries of the data set divided into the specified number of ranges.
240 For instance, @subcmd{/NTILES=4} would cause quartiles to be reported.
241
242 @cindex histogram
243 The @subcmd{HISTOGRAM} subcommand causes the output to include a histogram for
244 each specified numeric variable.  The X axis by default ranges from
245 the minimum to the maximum value observed in the data, but the @subcmd{MINIMUM}
246 and @subcmd{MAXIMUM} keywords can set an explicit range.
247 @footnote{The number of
248 bins is chosen according to the Freedman-Diaconis rule:
249 @math{2 \times IQR(x)n^{-1/3}}, where @math{IQR(x)} is the interquartile range of @math{x}
250 and @math{n} is the number of samples.    Note that
251 @cmd{EXAMINE} uses a different algorithm to determine bin sizes.}
252 Histograms are not created for string variables.
253
254 Specify @subcmd{NORMAL} to superimpose a normal curve on the
255 histogram.
256
257 @cindex piechart
258 The @subcmd{PIECHART} subcommand adds a pie chart for each variable to the data.  Each
259 slice represents one value, with the size of the slice proportional to
260 the value's frequency.  By default, all non-missing values are given
261 slices.
262 The @subcmd{MINIMUM} and @subcmd{MAXIMUM} keywords can be used to limit the
263 displayed slices to a given range of values.
264 The keyword @subcmd{NOMISSING} causes missing values to be omitted from the
265 piechart.  This is the default.
266 If instead, @subcmd{MISSING} is specified, then the pie chart includes
267 a single slice representing all system missing and user-missing cases.
268
269 @cindex bar chart
270 The @subcmd{BARCHART} subcommand produces a bar chart for each variable.
271 The @subcmd{MINIMUM} and @subcmd{MAXIMUM} keywords can be used to omit
272 categories whose counts which lie outside the specified limits.
273 The @subcmd{FREQ} option (default) causes the ordinate to display the frequency
274 of each category, whereas the @subcmd{PERCENT} option displays relative
275 percentages.
276
277 The @subcmd{FREQ} and @subcmd{PERCENT} options on @subcmd{HISTOGRAM} and
278 @subcmd{PIECHART} are accepted but not currently honoured.
279
280 The @subcmd{ORDER} subcommand is accepted but ignored.
281
282 @subsection Frequencies Example
283
284 @ref{frequencies:ex} runs a frequency analysis on the @exvar{sex}
285 and @exvar{occupation} variables from the @file{personnel.sav} file.
286 This is useful to get an general idea of the way in which these nominal
287 variables are distributed.
288
289 @float Example, frequencies:ex
290 @psppsyntax {frequencies.sps}
291 @caption {Running frequencies on the @exvar{sex} and @exvar{occupation} variables}
292 @end float
293
294 If you are using the graphic user interface, the dialog box is set up such that
295 by default, several statistics are calculated.   Some are not particularly useful
296 for categorical variables, so you may want to disable those.
297
298 @float Screenshot, frequencies:scr
299 @psppimage {frequencies}
300 @caption {The frequencies dialog box with the @exvar{sex} and @exvar{occupation} variables selected}
301 @end float
302
303 From @ref{frequencies:res} it is evident that there are 33 males, 21 females and
304 2 persons for whom their sex has not been entered.
305
306 One can also see how many of each occupation there are in the data.
307 When dealing with string variables used as nominal values, running a frequency
308 analysis is useful to detect data input entries.  Notice that
309 one @exvar{occupation} value has been mistyped as ``Scrientist''.  This entry should
310 be corrected, or marked as missing before using the data.
311
312 @float Result, frequencies:res
313 @psppoutput {frequencies}
314 @caption {The relative frequencies of @exvar{sex} and @exvar{occupation}}
315 @end float
316
317 @node EXAMINE
318 @section EXAMINE
319
320 @vindex EXAMINE
321 @cindex Exploratory data analysis
322 @cindex normality, testing
323
324 @display
325 EXAMINE
326         VARIABLES= @var{var1} [@var{var2}] @dots{} [@var{varN}]
327            [BY @var{factor1} [BY @var{subfactor1}]
328              [ @var{factor2} [BY @var{subfactor2}]]
329              @dots{}
330              [ @var{factor3} [BY @var{subfactor3}]]
331             ]
332         /STATISTICS=@{DESCRIPTIVES, EXTREME[(@var{n})], ALL, NONE@}
333         /PLOT=@{BOXPLOT, NPPLOT, HISTOGRAM, SPREADLEVEL[(@var{t})], ALL, NONE@}
334         /CINTERVAL @var{p}
335         /COMPARE=@{GROUPS,VARIABLES@}
336         /ID=@var{identity_variable}
337         /@{TOTAL,NOTOTAL@}
338         /PERCENTILE=[@var{percentiles}]=@{HAVERAGE, WAVERAGE, ROUND, AEMPIRICAL, EMPIRICAL @}
339         /MISSING=@{LISTWISE, PAIRWISE@} [@{EXCLUDE, INCLUDE@}]
340                 [@{NOREPORT,REPORT@}]
341
342 @end display
343
344 The @cmd{EXAMINE} command is used to perform exploratory data analysis.
345 In particular, it is useful for testing how closely a distribution follows a
346 normal distribution, and for finding outliers and extreme values.
347
348 The @subcmd{VARIABLES} subcommand is mandatory.
349 It specifies the dependent variables and optionally variables to use as
350 factors for the analysis.
351 Variables listed before the first @subcmd{BY} keyword (if any) are the
352 dependent variables.
353 The dependent variables may optionally be followed by a list of
354 factors which tell @pspp{} how to break down the analysis for each
355 dependent variable.
356
357 Following the dependent variables, factors may be specified.
358 The factors (if desired) should be preceded by a single @subcmd{BY} keyword.
359 The format for each factor is
360 @display
361 @var{factorvar} [BY @var{subfactorvar}].
362 @end display
363 Each unique combination of the values of  @var{factorvar} and
364 @var{subfactorvar} divide the dataset into @dfn{cells}.
365 Statistics are calculated for each cell
366 and for the entire dataset (unless @subcmd{NOTOTAL} is given).
367
368 The @subcmd{STATISTICS} subcommand specifies which statistics to show.
369 @subcmd{DESCRIPTIVES} produces a table showing some parametric and
370 non-parametrics statistics.
371 @subcmd{EXTREME} produces a table showing the extremities of each cell.
372 A number in parentheses, @var{n} determines
373 how many upper and lower extremities to show.
374 The default number is 5.
375
376 The subcommands @subcmd{TOTAL} and @subcmd{NOTOTAL} are mutually exclusive.
377 If @subcmd{TOTAL} appears, then statistics for the entire dataset
378 as well as for each cell are produced.
379 If @subcmd{NOTOTAL} appears, then statistics are produced only for the cells
380 (unless no factor variables have been given).
381 These subcommands have no effect if there have  been no factor variables
382 specified.
383
384 @cindex boxplot
385 @cindex histogram
386 @cindex npplot
387 @cindex spreadlevel plot
388 The @subcmd{PLOT} subcommand specifies which plots are to be produced if any.
389 Available plots are @subcmd{HISTOGRAM}, @subcmd{NPPLOT},  @subcmd{BOXPLOT} and
390 @subcmd{SPREADLEVEL}.
391 The first three can be used to visualise how closely each cell conforms to a
392 normal distribution, whilst the spread vs.@: level plot can be useful to visualise
393 how the variance differs between factors.
394 Boxplots show you the outliers and extreme values.
395 @footnote{@subcmd{HISTOGRAM} uses Sturges' rule to determine the number of
396 bins, as approximately @math{1 + \log2(n)}, where @math{n} is the number of samples.
397 Note that @cmd{FREQUENCIES} uses a different algorithm to find the bin size.}
398
399 The @subcmd{SPREADLEVEL} plot displays the interquartile range versus the
400 median.  It takes an optional parameter @var{t}, which specifies how the data
401 should be transformed prior to plotting.
402 The given value @var{t} is a power to which the data are raised.  For example, if
403 @var{t} is given as 2, then the square of the data is used.
404 Zero, however is a special value.  If @var{t} is 0 or
405 is omitted, then data are transformed by taking its natural logarithm instead of
406 raising to the power of @var{t}.
407
408 @cindex Shapiro-Wilk
409 When one or more plots are requested, @subcmd{EXAMINE} also performs the
410 Shapiro-Wilk test for each category.
411 There are however a number of provisos:
412 @itemize
413 @item All weight values must be integer.
414 @item The cumulative weight value must be in the range [3, 5000]
415 @end itemize
416
417 The @subcmd{COMPARE} subcommand is only relevant if producing boxplots, and it is only
418 useful there is more than one dependent variable and at least one factor.
419 If
420 @subcmd{/COMPARE=GROUPS} is specified, then one plot per dependent variable is produced,
421 each of which contain boxplots for all the cells.
422 If @subcmd{/COMPARE=VARIABLES} is specified, then one plot per cell is produced,
423 each containing one boxplot per dependent variable.
424 If the @subcmd{/COMPARE} subcommand is omitted, then @pspp{} behaves as if
425 @subcmd{/COMPARE=GROUPS} were given.
426
427 The @subcmd{ID} subcommand is relevant only if @subcmd{/PLOT=BOXPLOT} or
428 @subcmd{/STATISTICS=EXTREME} has been given.
429 If given, it should provide the name of a variable which is to be used
430 to labels extreme values and outliers.
431 Numeric or string variables are permissible.
432 If the @subcmd{ID} subcommand is not given, then the case number is used for
433 labelling.
434
435 The @subcmd{CINTERVAL} subcommand specifies the confidence interval to use in
436 calculation of the descriptives command.  The default is 95%.
437
438 @cindex percentiles
439 The @subcmd{PERCENTILES} subcommand specifies which percentiles are to be calculated,
440 and which algorithm to use for calculating them.  The default is to
441 calculate the 5, 10, 25, 50, 75, 90, 95 percentiles using the
442 @subcmd{HAVERAGE} algorithm.
443
444 The @subcmd{TOTAL} and @subcmd{NOTOTAL} subcommands are mutually exclusive.  If @subcmd{NOTOTAL}
445 is given and factors have been specified in the @subcmd{VARIABLES} subcommand,
446 then statistics for the unfactored dependent variables are
447 produced in addition to the factored variables.  If there are no
448 factors specified then @subcmd{TOTAL} and @subcmd{NOTOTAL} have no effect.
449
450
451 The following example generates descriptive statistics and histograms for
452 two variables @var{score1} and @var{score2}.
453 Two factors are given, @i{viz}: @var{gender} and @var{gender} BY @var{culture}.
454 Therefore, the descriptives and histograms are generated for each
455 distinct  value
456 of @var{gender} @emph{and} for each distinct combination of the values
457 of @var{gender} and @var{race}.
458 Since the @subcmd{NOTOTAL} keyword is given, statistics and histograms for
459 @var{score1} and @var{score2} covering the  whole dataset are not produced.
460 @example
461 EXAMINE @var{score1} @var{score2} BY
462         @var{gender}
463         @var{gender} BY @var{culture}
464         /STATISTICS = DESCRIPTIVES
465         /PLOT = HISTOGRAM
466         /NOTOTAL.
467 @end example
468
469 Here is a second example showing how the @cmd{examine} command can be used to find extremities.
470 @example
471 EXAMINE @var{height} @var{weight} BY
472         @var{gender}
473         /STATISTICS = EXTREME (3)
474         /PLOT = BOXPLOT
475         /COMPARE = GROUPS
476         /ID = @var{name}.
477 @end example
478 In this example, we look at the height and weight of a sample of individuals and
479 how they differ between male and female.
480 A table showing the 3 largest and the 3 smallest values of @exvar{height} and
481 @exvar{weight} for each gender, and for the whole dataset as are shown.
482 In addition, the @subcmd{/PLOT} subcommand requests boxplots.
483 Because @subcmd{/COMPARE = GROUPS} was specified, boxplots for male and female are
484 shown in juxtaposed in the same graphic, allowing us to easily see the difference between
485 the genders.
486 Since the variable @var{name} was specified on the @subcmd{ID} subcommand,
487 values of the @var{name} variable are used to label the extreme values.
488
489 @strong{Warning!}
490 If you specify many dependent variables or factor variables
491 for which there are many distinct values, then @cmd{EXAMINE} will produce a very
492 large quantity of output.
493
494 @node GRAPH
495 @section GRAPH
496
497 @vindex GRAPH
498 @cindex Exploratory data analysis
499 @cindex normality, testing
500
501 @display
502 GRAPH
503         /HISTOGRAM [(NORMAL)]= @var{var}
504         /SCATTERPLOT [(BIVARIATE)] = @var{var1} WITH @var{var2} [BY @var{var3}]
505         /BAR = @{@var{summary-function}(@var{var1}) | @var{count-function}@} BY @var{var2} [BY @var{var3}]
506         [ /MISSING=@{LISTWISE, VARIABLE@} [@{EXCLUDE, INCLUDE@}] ]
507                 [@{NOREPORT,REPORT@}]
508
509 @end display
510
511 The @cmd{GRAPH} command produces graphical plots of data. Only one of the subcommands
512 @subcmd{HISTOGRAM}, @subcmd{BAR} or @subcmd{SCATTERPLOT} can be specified, @i{i.e.} only one plot
513 can be produced per call of @cmd{GRAPH}. The @subcmd{MISSING} is optional.
514
515 @menu
516 * SCATTERPLOT::             Cartesian Plots
517 * HISTOGRAM::               Histograms
518 * BAR CHART::               Bar Charts
519 @end menu
520
521 @node SCATTERPLOT
522 @subsection Scatterplot
523 @cindex scatterplot
524
525 The subcommand @subcmd{SCATTERPLOT} produces an xy plot of the
526 data.
527 @cmd{GRAPH} uses the third variable @var{var3}, if specified, to determine
528 the colours and/or markers for the plot.
529 The following is an example for producing a scatterplot.
530
531 @example
532 GRAPH
533         /SCATTERPLOT = @var{height} WITH @var{weight} BY @var{gender}.
534 @end example
535
536 This example produces a scatterplot where @var{height} is plotted versus @var{weight}. Depending
537 on the value of the @var{gender} variable, the colour of the datapoint is different. With
538 this plot it is possible to analyze gender differences for @var{height} versus @var{weight} relation.
539
540 @node HISTOGRAM
541 @subsection Histogram
542 @cindex histogram
543
544 The subcommand @subcmd{HISTOGRAM} produces a histogram. Only one variable is allowed for
545 the histogram plot.
546 The keyword @subcmd{NORMAL} may be specified in parentheses, to indicate that the ideal normal curve
547 should be superimposed over the histogram.
548 For an alternative method to produce histograms @pxref{EXAMINE}. The
549 following example produces a histogram plot for the variable @var{weight}.
550
551 @example
552 GRAPH
553         /HISTOGRAM = @var{weight}.
554 @end example
555
556 @node BAR CHART
557 @subsection Bar Chart
558 @cindex bar chart
559
560 The subcommand @subcmd{BAR} produces a bar chart.
561 This subcommand requires that a @var{count-function} be specified (with no arguments) or a @var{summary-function} with a variable @var{var1} in parentheses.
562 Following the summary or count function, the keyword @subcmd{BY} should be specified and then a catagorical variable, @var{var2}.
563 The values of the variable @var{var2} determine the labels of the bars to be plotted.
564 Optionally a second categorical variable @var{var3} may be specified in which case a clustered (grouped) bar chart is produced.
565
566 Valid count functions are
567 @table @subcmd
568 @item COUNT
569 The weighted counts of the cases in each category.
570 @item PCT
571 The weighted counts of the cases in each category expressed as a percentage of the total weights of the cases.
572 @item CUFREQ
573 The cumulative weighted counts of the cases in each category.
574 @item CUPCT
575 The cumulative weighted counts of the cases in each category expressed as a percentage of the total weights of the cases.
576 @end table
577
578 The summary function is applied to @var{var1} across all cases in each category.
579 The recognised summary functions are:
580 @table @subcmd
581 @item SUM
582 The sum.
583 @item MEAN
584 The arithmetic mean.
585 @item MAXIMUM
586 The maximum value.
587 @item MINIMUM
588 The minimum value.
589 @end table
590
591 The following examples assume a dataset which is the results of a survey.
592 Each respondent has indicated annual income, their sex and city of residence.
593 One could create a bar chart showing how the mean income varies between of residents of different cities, thus:
594 @example
595 GRAPH  /BAR  = MEAN(@var{income}) BY @var{city}.
596 @end example
597
598 This can be extended to also indicate how income in each city differs between the sexes.
599 @example
600 GRAPH  /BAR  = MEAN(@var{income}) BY @var{city} BY @var{sex}.
601 @end example
602
603 One might also want to see how many respondents there are from each city.  This can be achieved as follows:
604 @example
605 GRAPH  /BAR  = COUNT BY @var{city}.
606 @end example
607
608 Bar charts can also be produced using the @ref{FREQUENCIES} and @ref{CROSSTABS} commands.
609
610 @node CORRELATIONS
611 @section CORRELATIONS
612
613 @vindex CORRELATIONS
614 @display
615 CORRELATIONS
616      /VARIABLES = @var{var_list} [ WITH @var{var_list} ]
617      [
618       .
619       .
620       .
621       /VARIABLES = @var{var_list} [ WITH @var{var_list} ]
622       /VARIABLES = @var{var_list} [ WITH @var{var_list} ]
623      ]
624
625      [ /PRINT=@{TWOTAIL, ONETAIL@} @{SIG, NOSIG@} ]
626      [ /STATISTICS=DESCRIPTIVES XPROD ALL]
627      [ /MISSING=@{PAIRWISE, LISTWISE@} @{INCLUDE, EXCLUDE@} ]
628 @end display
629
630 @cindex correlation
631 The @cmd{CORRELATIONS} procedure produces tables of the Pearson correlation coefficient
632 for a set of variables.  The significance of the coefficients are also given.
633
634 At least one @subcmd{VARIABLES} subcommand is required. If you specify the @subcmd{WITH}
635 keyword, then a non-square correlation table is produced.
636 The variables preceding @subcmd{WITH}, are used as the rows of the table,
637 and the variables following @subcmd{WITH} are used as the columns of the table.
638 If no @subcmd{WITH} subcommand is specified, then @cmd{CORRELATIONS} produces a
639 square, symmetrical table using all variables.
640
641 The @cmd{MISSING} subcommand determines the handling of missing variables.
642 If @subcmd{INCLUDE} is set, then user-missing values are included in the
643 calculations, but system-missing values are not.
644 If @subcmd{EXCLUDE} is set, which is the default, user-missing
645 values are excluded as well as system-missing values.
646
647 If @subcmd{LISTWISE} is set, then the entire case is excluded from analysis
648 whenever any variable  specified in any @cmd{/VARIABLES} subcommand
649 contains a missing value.
650 If @subcmd{PAIRWISE} is set, then a case is considered missing only if either of the
651 values  for the particular coefficient are missing.
652 The default is @subcmd{PAIRWISE}.
653
654 The @subcmd{PRINT} subcommand is used to control how the reported significance values are printed.
655 If the @subcmd{TWOTAIL} option is used, then a two-tailed test of significance is
656 printed.  If the @subcmd{ONETAIL} option is given, then a one-tailed test is used.
657 The default is @subcmd{TWOTAIL}.
658
659 If the @subcmd{NOSIG} option is specified, then correlation coefficients with significance less than
660 0.05 are highlighted.
661 If @subcmd{SIG} is specified, then no highlighting is performed.  This is the default.
662
663 @cindex covariance
664 The @subcmd{STATISTICS} subcommand requests additional statistics to be displayed.  The keyword
665 @subcmd{DESCRIPTIVES} requests that the mean, number of non-missing cases, and the non-biased
666 estimator of the standard deviation are displayed.
667 These statistics are displayed in a separated table, for all the variables listed
668 in any @subcmd{/VARIABLES} subcommand.
669 The @subcmd{XPROD} keyword requests cross-product deviations and covariance estimators to
670 be displayed for each pair of variables.
671 The keyword @subcmd{ALL} is the union of @subcmd{DESCRIPTIVES} and @subcmd{XPROD}.
672
673 @node CROSSTABS
674 @section CROSSTABS
675
676 @vindex CROSSTABS
677 @display
678 CROSSTABS
679         /TABLES=@var{var_list} BY @var{var_list} [BY @var{var_list}]@dots{}
680         /MISSING=@{TABLE,INCLUDE,REPORT@}
681         /FORMAT=@{TABLES,NOTABLES@}
682                 @{AVALUE,DVALUE@}
683         /CELLS=@{COUNT,ROW,COLUMN,TOTAL,EXPECTED,RESIDUAL,SRESIDUAL,
684                 ASRESIDUAL,ALL,NONE@}
685         /COUNT=@{ASIS,CASE,CELL@}
686                @{ROUND,TRUNCATE@}
687         /STATISTICS=@{CHISQ,PHI,CC,LAMBDA,UC,BTAU,CTAU,RISK,GAMMA,D,
688                      KAPPA,ETA,CORR,ALL,NONE@}
689         /BARCHART
690
691 (Integer mode.)
692         /VARIABLES=@var{var_list} (@var{low},@var{high})@dots{}
693 @end display
694
695 The @cmd{CROSSTABS} procedure displays crosstabulation
696 tables requested by the user.  It can calculate several statistics for
697 each cell in the crosstabulation tables.  In addition, a number of
698 statistics can be calculated for each table itself.
699
700 The @subcmd{TABLES} subcommand is used to specify the tables to be reported.  Any
701 number of dimensions is permitted, and any number of variables per
702 dimension is allowed.  The @subcmd{TABLES} subcommand may be repeated as many
703 times as needed.  This is the only required subcommand in @dfn{general
704 mode}.
705
706 Occasionally, one may want to invoke a special mode called @dfn{integer
707 mode}.  Normally, in general mode, @pspp{} automatically determines
708 what values occur in the data.  In integer mode, the user specifies the
709 range of values that the data assumes.  To invoke this mode, specify the
710 @subcmd{VARIABLES} subcommand, giving a range of data values in parentheses for
711 each variable to be used on the @subcmd{TABLES} subcommand.  Data values inside
712 the range are truncated to the nearest integer, then assigned to that
713 value.  If values occur outside this range, they are discarded.  When it
714 is present, the @subcmd{VARIABLES} subcommand must precede the @subcmd{TABLES}
715 subcommand.
716
717 In general mode, numeric and string variables may be specified on
718 TABLES.  In integer mode, only numeric variables are allowed.
719
720 The @subcmd{MISSING} subcommand determines the handling of user-missing values.
721 When set to @subcmd{TABLE}, the default, missing values are dropped on a table by
722 table basis.  When set to @subcmd{INCLUDE}, user-missing values are included in
723 tables and statistics.  When set to @subcmd{REPORT}, which is allowed only in
724 integer mode, user-missing values are included in tables but marked with
725 a footnote and excluded from statistical calculations.
726
727 The @subcmd{FORMAT} subcommand controls the characteristics of the
728 crosstabulation tables to be displayed.  It has a number of possible
729 settings:
730
731 @itemize @w{}
732 @item
733 @subcmd{TABLES}, the default, causes crosstabulation tables to be output.
734 @subcmd{NOTABLES}, which is equivalent to @code{CELLS=NONE}, suppresses them.
735
736 @item
737 @subcmd{AVALUE}, the default, causes values to be sorted in ascending order.
738 @subcmd{DVALUE} asserts a descending sort order.
739 @end itemize
740
741 The @subcmd{CELLS} subcommand controls the contents of each cell in the displayed
742 crosstabulation table.  The possible settings are:
743
744 @table @asis
745 @item COUNT
746 Frequency count.
747 @item ROW
748 Row percent.
749 @item COLUMN
750 Column percent.
751 @item TOTAL
752 Table percent.
753 @item EXPECTED
754 Expected value.
755 @item RESIDUAL
756 Residual.
757 @item SRESIDUAL
758 Standardized residual.
759 @item ASRESIDUAL
760 Adjusted standardized residual.
761 @item ALL
762 All of the above.
763 @item NONE
764 Suppress cells entirely.
765 @end table
766
767 @samp{/CELLS} without any settings specified requests @subcmd{COUNT}, @subcmd{ROW},
768 @subcmd{COLUMN}, and @subcmd{TOTAL}.
769 If @subcmd{CELLS} is not specified at all then only @subcmd{COUNT}
770 is selected.
771
772 By default, crosstabulation and statistics use raw case weights,
773 without rounding.  Use the @subcmd{/COUNT} subcommand to perform
774 rounding: CASE rounds the weights of individual weights as cases are
775 read, CELL rounds the weights of cells within each crosstabulation
776 table after it has been constructed, and ASIS explicitly specifies the
777 default non-rounding behavior.  When rounding is requested, ROUND, the
778 default, rounds to the nearest integer and TRUNCATE rounds toward
779 zero.
780
781 The @subcmd{STATISTICS} subcommand selects statistics for computation:
782
783 @table @asis
784 @item CHISQ
785 @cindex chi-square
786
787 Pearson chi-square, likelihood ratio, Fisher's exact test, continuity
788 correction, linear-by-linear association.
789 @item PHI
790 Phi.
791 @item CC
792 Contingency coefficient.
793 @item LAMBDA
794 Lambda.
795 @item UC
796 Uncertainty coefficient.
797 @item BTAU
798 Tau-b.
799 @item CTAU
800 Tau-c.
801 @item RISK
802 Risk estimate.
803 @item GAMMA
804 Gamma.
805 @item D
806 Somers' D.
807 @item KAPPA
808 Cohen's Kappa.
809 @item ETA
810 Eta.
811 @item CORR
812 Spearman correlation, Pearson's r.
813 @item ALL
814 All of the above.
815 @item NONE
816 No statistics.
817 @end table
818
819 Selected statistics are only calculated when appropriate for the
820 statistic.  Certain statistics require tables of a particular size, and
821 some statistics are calculated only in integer mode.
822
823 @samp{/STATISTICS} without any settings selects CHISQ.  If the
824 @subcmd{STATISTICS} subcommand is not given, no statistics are calculated.
825
826 @cindex bar chart
827 The @samp{/BARCHART} subcommand produces a clustered bar chart for the first two
828 variables on each table.
829 If a table has more than two variables, the counts for the third and subsequent levels
830 are aggregated and the chart is produced as if there were only two variables.
831
832
833 @strong{Please note:} Currently the implementation of @cmd{CROSSTABS} has the
834 following limitations:
835
836 @itemize @bullet
837 @item
838 Significance of some symmetric and directional measures is not calculated.
839 @item
840 Asymptotic standard error is not calculated for
841 Goodman and Kruskal's tau or symmetric Somers' d.
842 @item
843 Approximate T is not calculated for symmetric uncertainty coefficient.
844 @end itemize
845
846 Fixes for any of these deficiencies would be welcomed.
847
848 @subsection Crosstabs Example
849
850 @cindex chi-square test of independence
851
852 A researcher wishes to know if, in an industry, a person's sex is related to
853 the person's occupation.  To investigate this, she has determined that the
854 @file{personnel.sav} is a representative, randomly selected sample of persons.
855 The researcher's null hypothesis is that a person's sex has no relation to a
856 person's occupation. She uses a chi-squared test of independence to investigate
857 the hypothesis.
858
859 @float Example, crosstabs:ex
860 @psppsyntax {crosstabs.sps}
861 @caption {Running crosstabs on the @exvar{sex} and @exvar{occupation} variables}
862 @end float
863
864 The syntax in @ref{crosstabs:ex} conducts a chi-squared test of independence.
865 The line @code{/tables = occupation by sex} indicates that @exvar{occupation}
866 and @exvar{sex} are the variables to be tabulated.  To do this using the @gui{}
867 you must place these variable names respectively in the @samp{Row} and
868 @samp{Column} fields as shown in @ref{crosstabs:scr}.
869
870 @float Screenshot, crosstabs:scr
871 @psppimage {crosstabs}
872 @caption {The Crosstabs dialog box with the @exvar{sex} and @exvar{occupation} variables selected}
873 @end float
874
875 Similarly, the @samp{Cells} button shows a dialog box to select the @code{count}
876 and @code{expected} options.  All other cell options can be deselected for this
877 test.
878
879 You would use the @samp{Format} and @samp{Statistics}  buttons to select options
880 for the @subcmd{FORMAT} and @subcmd{STATISTICS} subcommands.  In this example,
881 the @samp{Statistics} requires only the @samp{Chisq} option to be checked.  All
882 other options should be unchecked.  No special settings are required from the
883 @samp{Format} dialog.
884
885 As shown in @ref{crosstabs:res} @cmd{CROSSTABS} generates a contingency table
886 containing the observed count and the expected count of each sex and each
887 occupation.  The expected count is the count which would be observed if the
888 null hypothesis were true.
889
890 The significance of the Pearson Chi-Square value is very much larger than the
891 normally accepted value of 0.05 and so one cannot reject the null hypothesis.
892 Thus the researcher must conclude that a person's sex has no relation to the
893 person's occupation.
894
895 @float Results, crosstabs:res
896 @psppoutput {crosstabs}
897 @caption {The results of a test of independence between @exvar{sex} and @exvar{occupation}}
898 @end float
899
900 @node CTABLES
901 @section CTABLES
902
903 @vindex CTABLES
904 @cindex custom tables
905 @cindex tables, custom
906
907 @code{CTABLES} has the following overall syntax.  At least one
908 @code{TABLE} subcommand is required:
909
910 @display
911 @t{CTABLES}
912   @dots{}@i{global subcommands}@dots{}
913   [@t{/TABLE} @i{axis} [@t{BY} @i{axis} [@t{BY} @i{axis}]]
914    @dots{}@i{per-table subcommands}@dots{}]@dots{}
915 @end display
916
917 @noindent
918 where each @i{axis} may be empty or take one of the following forms:
919
920 @display
921 @i{variable}
922 @i{variable} @t{[}@{@t{C} @math{|} @t{S}@}@t{]}
923 @i{axis} + @i{axis}
924 @i{axis} > @i{axis}
925 (@i{axis})
926 @i{axis} @t{[}@i{summary} [@i{string}] [@i{format}]@t{]}
927 @end display
928
929 The following subcommands precede the first @code{TABLE} subcommand
930 and apply to all of the output tables.  All of these subcommands are
931 optional:
932
933 @display
934 @t{/FORMAT}
935     [@t{MINCOLWIDTH=}@{@t{DEFAULT} @math{|} @i{width}@}]
936     [@t{MAXCOLWIDTH=}@{@t{DEFAULT} @math{|} @i{width}@}]
937     [@t{UNITS=}@{@t{POINTS} @math{|} @t{INCHES} @math{|} @t{CM}@}]
938     [@t{EMPTY=}@{@t{ZERO} @math{|} @t{BLANK} @math{|} @i{string}@}]
939     [@t{MISSING=}@i{string}]
940 @t{/VLABELS}
941     @t{VARIABLES=}@i{variables}
942     @t{DISPLAY}=@{@t{DEFAULT} @math{|} @t{NAME} @math{|} @t{LABEL} @math{|} @t{BOTH} @math{|} @t{NONE}@}
943 @ignore @c not yet implemented
944 @t{/MRSETS COUNTDUPLICATES=}@{@t{YES} @math{|} @t{NO}@}
945 @end ignore
946 @t{/SMISSING} @{@t{VARIABLE} @math{|} @t{LISTWISE}@}
947 @t{/PCOMPUTE} @t{&}@i{postcompute}@t{=EXPR(}@i{expression}@t{)}
948 @t{/PPROPERTIES} @t{&}@i{postcompute}@dots{}
949     [@t{LABEL=}@i{string}]
950     [@t{FORMAT=}[@i{summary} @i{format}]@dots{}]
951     [@t{HIDESOURCECATS=}@{@t{NO} @math{|} @t{YES}@}
952 @t{/WEIGHT VARIABLE=}@i{variable}
953 @t{/HIDESMALLCOUNTS COUNT=@i{count}}
954 @end display
955
956 The following subcommands follow @code{TABLE} and apply only to the
957 previous @code{TABLE}.  All of these subcommands are optional:
958
959 @display
960 @t{/SLABELS}
961     [@t{POSITION=}@{@t{COLUMN} @math{|} @t{ROW} @math{|} @t{LAYER}@}]
962     [@t{VISIBLE=}@{@t{YES} @math{|} @t{NO}@}]
963 @t{/CLABELS} @{@t{AUTO} @math{|} @{@t{ROWLABELS}@math{|}@t{COLLABELS}@}@t{=}@{@t{OPPOSITE}@math{|}@t{LAYER}@}@}
964 @t{/CATEGORIES} @t{VARIABLES=}@i{variables}
965     @{@t{[}@i{value}@t{,} @i{value}@dots{}@t{]}
966    @math{|} [@t{ORDER=}@{@t{A} @math{|} @t{D}@}]
967      [@t{KEY=}@{@t{VALUE} @math{|} @t{LABEL} @math{|} @i{summary}@t{(}@i{variable}@t{)}@}]
968      [@t{MISSING=}@{@t{EXCLUDE} @math{|} @t{INCLUDE}@}]@}
969     [@t{TOTAL=}@{@t{NO} @math{|} @t{YES}@} [@t{LABEL=}@i{string}] [@t{POSITION=}@{@t{AFTER} @math{|} @t{BEFORE}@}]]
970     [@t{EMPTY=}@{@t{INCLUDE} @math{|} @t{EXCLUDE}@}]
971 @t{/TITLES}
972     [@t{TITLE=}@i{string}@dots{}]
973     [@t{CAPTION=}@i{string}@dots{}]
974     [@t{CORNER=}@i{string}@dots{}]
975 @ignore  @c not yet implemented
976 @t{/CRITERIA CILEVEL=}@i{percentage}
977 @t{/SIGTEST TYPE=CHISQUARE}
978     [@t{ALPHA=}@i{siglevel}]
979     [@t{INCLUDEMRSETS=}@{@t{YES} @math{|} @t{NO}@}]
980     [@t{CATEGORIES=}@{@t{ALLVISIBLE} @math{|} @t{SUBTOTALS}@}]
981 @t{/COMPARETEST TYPE=}@{@t{PROP} @math{|} @t{MEAN}@}
982     [@t{ALPHA=}@i{value}[@t{,} @i{value}]]
983     [@t{ADJUST=}@{@t{BONFERRONI} @math{|} @t{BH} @math{|} @t{NONE}@}]
984     [@t{INCLUDEMRSETS=}@{@t{YES} @math{|} @t{NO}@}]
985     [@t{MEANSVARIANCE=}@{@t{ALLCATS} @math{|} @t{TESTEDCATS}@}]
986     [@t{CATEGORIES=}@{@t{ALLVISIBLE} @math{|} @t{SUBTOTALS}@}]
987     [@t{MERGE=}@{@t{NO} @math{|} @t{YES}@}]
988     [@t{STYLE=}@{@t{APA} @math{|} @t{SIMPLE}@}]
989     [@t{SHOWSIG=}@{@t{NO} @math{|} @t{YES}@}]
990 @end ignore
991 @end display
992
993 The @code{CTABLES} (aka ``custom tables'') command produces
994 multi-dimensional tables from categorical and scale data.  It offers
995 many options for data summarization and formatting.
996
997 This section's examples use data from the 2008 (USA) National Survey
998 of Drinking and Driving Attitudes and Behaviors, a public domain data
999 set from the (USA) National Highway Traffic Administration and
1000 available at @url{https://data.transportation.gov}.  @pspp{} includes
1001 this data set, with a slightly modified dictionary, as
1002 @file{examples/nhtsa.sav}.
1003
1004 @node CTABLES Basics
1005 @subsection Basics
1006
1007 The only required subcommand is @code{TABLE}, which specifies the
1008 variables to include along each axis:
1009 @display
1010 @t{/TABLE} @i{rows} [@t{BY} @i{columns} [@t{BY} @i{layers}]]
1011 @end display
1012 @noindent
1013 In @code{TABLE}, each of @var{rows}, @var{columns}, and @var{layers}
1014 is either empty or an axis expression that specifies one or more
1015 variables.  At least one must specify an axis expression.
1016
1017 @menu
1018 * CTABLES Categorical Variable Basics::
1019 * CTABLES Scalar Variable Basics::
1020 * CTABLES Overriding Measurement Level::
1021 @end menu
1022
1023 @node CTABLES Categorical Variable Basics
1024 @subsubsection Categorical Variables
1025
1026 An axis expression that names a categorical variable divides the data
1027 into cells according to the values of that variable.  When all the
1028 variables named on @code{TABLE} are categorical, by default each cell
1029 displays the number of cases that it contains, so specifying a single
1030 variable yields a frequency table, much like the output of the
1031 @code{FREQUENCIES} command (@pxref{FREQUENCIES}):
1032
1033 @example
1034 CTABLES /TABLE=AgeGroup.
1035 @end example
1036 @psppoutput {ctables1}
1037
1038 @noindent
1039 Specifying a row and a column categorical variable yields a
1040 crosstabulation, much like the output of the @code{CROSSTABS} command
1041 (@pxref{CROSSTABS}):
1042
1043 @example
1044 CTABLES /TABLE=AgeGroup BY qns3a.
1045 @end example
1046 @psppoutput {ctables2}
1047
1048 @noindent
1049 The @samp{>} ``nesting'' operator nests multiple variables on a single
1050 axis, e.g.:
1051
1052 @example
1053 CTABLES /TABLE qn105ba BY AgeGroup > qns3a.
1054 @end example
1055 @psppoutput {ctables3}
1056
1057 @noindent
1058 The @samp{+} ``stacking'' operator allows a single output table to
1059 include multiple data analyses.  With @samp{+}, @code{CTABLES} divides
1060 the output table into multiple @dfn{sections}, each of which includes
1061 an analysis of the full data set.  For example, the following command
1062 separately tabulates age group and driving frequency by gender:
1063
1064 @example
1065 CTABLES /TABLE AgeGroup + qn1 BY qns3a.
1066 @end example
1067 @psppoutput {ctables4}
1068
1069 @noindent
1070 When @samp{+} and @samp{>} are used together, @samp{>} binds more
1071 tightly.  Use parentheses to override operator precedence.  Thus:
1072
1073 @example
1074 CTABLES /TABLE qn26 + qn27 > qns3a.
1075 CTABLES /TABLE (qn26 + qn27) > qns3a.
1076 @end example
1077 @psppoutput {ctables5}
1078
1079 @node CTABLES Scalar Variable Basics
1080 @subsubsection Scalar Variables
1081
1082 For a categorical variable, @code{CTABLES} divides the table into a
1083 cell per category.  For a scalar variable, @code{CTABLES} instead
1084 calculates a summary measure, by default the mean, of the values that
1085 fall into a cell.  For example, if the only variable specified is a
1086 scalar variable, then the output is a single cell that holds the mean
1087 of all of the data:
1088
1089 @example
1090 CTABLES /TABLE qnd1.
1091 @end example
1092 @psppoutput {ctables6}
1093
1094 A scalar variable may nest with categorical variables.  The following
1095 example shows the mean age of survey respondents across gender and
1096 language groups:
1097
1098 @example
1099 CTABLES /TABLE qns3a > qnd1 BY region.
1100 @end example
1101 @psppoutput {ctables7}
1102
1103 The order of nesting of scalar and categorical variables affects table
1104 labeling, but it does not affect the data displayed in the table.  The
1105 following example shows how the output changes when the nesting order
1106 of the scalar and categorical variable are interchanged:
1107
1108 @example
1109 CTABLES /TABLE qnd1 > qns3a BY region.
1110 @end example
1111 @psppoutput {ctables8}
1112
1113 Only a single scalar variable may appear in each section; that is, a
1114 scalar variable may not nest inside a scalar variable directly or
1115 indirectly.  Scalar variables may only appear on one axis within
1116 @code{TABLE}.
1117
1118 @node CTABLES Overriding Measurement Level
1119 @subsubsection Overriding Measurement Level
1120
1121 By default, @code{CTABLES} uses a variable's measurement level to
1122 decide whether to treat it as categorical or scalar.  Variables
1123 assigned the nominal or ordinal measurement level are treated as
1124 categorical, and scalar variables are treated as scalar.
1125
1126 When @pspp{} reads data from a file in an external format, such as a
1127 text file, variables' measurement levels are often unknown.  If
1128 @code{CTABLES} runs when a variable has an unknown measurement level,
1129 it makes an initial pass through the data to guess measurement levels
1130 using the rules described earlier in this manual (@pxref{Measurement
1131 Level}).  Use the @code{VARIABLE LEVEL} command to set or change a
1132 variable's measurement level (@pxref{VARIABLE LEVEL}).
1133
1134 To treat a variable as categorical or scalar only for one use on
1135 @code{CTABLES}, add @samp{[C]} or @samp{[S]}, respectively, after the
1136 variable name.  The following example shows the output when variable
1137 @code{qn20} is analyzed as scalar (the default for its measurement
1138 level) and as categorical:
1139
1140 @example
1141 CTABLES
1142     /TABLE qn20 BY qns3a
1143     /TABLE qn20 [C] BY qns3a.
1144 @end example
1145 @psppoutput {ctables9}
1146
1147 @ignore
1148 @node CTABLES Multiple Response Sets
1149 @subsubheading Multiple Response Sets
1150
1151 The @code{CTABLES} command does not yet support multiple response
1152 sets.
1153 @end ignore
1154
1155 @node CTABLES Data Summarization
1156 @subsection Data Summarization
1157
1158 The @code{CTABLES} command allows the user to control how the data are
1159 summarized with @dfn{summary specifications}, syntax that lists one or
1160 more summary function names, optionally separated by commas, and which
1161 are enclosed in square brackets following a variable name on the
1162 @code{TABLE} subcommand.  When all the variables are categorical,
1163 summary specifications can be given for the innermost nested variables
1164 on any one axis.  When a scalar variable is present, only the scalar
1165 variable may have summary specifications.
1166
1167 The following example includes a summary specification for column and
1168 row percentages for categorical variables, and mean and median for a
1169 scalar variable:
1170
1171 @example
1172 CTABLES
1173     /TABLE=qnd1 [MEAN, MEDIAN] BY qns3a
1174     /TABLE=AgeGroup [COLPCT, ROWPCT] BY qns3a.
1175 @end example
1176 @psppoutput {ctables10}
1177
1178 A summary specification may override the default label and format by
1179 appending a string or format specification or both (in that order) to
1180 the summary function name.  For example:
1181
1182 @example
1183 CTABLES /TABLE=AgeGroup [COLPCT 'Gender %' PCT5.0,
1184                          ROWPCT 'Age Group %' PCT5.0]
1185                BY qns3a.
1186 @end example
1187 @psppoutput {ctables11}
1188
1189 @c TODO special CTABLES formats
1190
1191 Parentheses provide a shorthand to apply summary specifications to
1192 multiple variables.  For example, both of these commands:
1193
1194 @example
1195 CTABLES /TABLE=AgeGroup[COLPCT] + qns1[COLPCT] BY qns3a.
1196 CTABLES /TABLE=(AgeGroup + qns1)[COLPCT] BY qns3a.
1197 @end example
1198
1199 @noindent
1200 produce the same output shown below:
1201
1202 @psppoutput {ctables12}
1203
1204 The following sections list the available summary functions.  After
1205 each function's name is given its default label and format.  If no
1206 format is listed, then the default format is the print format for the
1207 variable being summarized.
1208
1209 @menu
1210 * CTABLES Summary Functions for Individual Cells::
1211 * CTABLES Summary Functions for Groups of Cells::
1212 * CTABLES Summary Functions for Adjusted Weights::
1213 * CTABLES Unweighted Summary Functions::
1214 @end menu
1215
1216 @node CTABLES Summary Functions for Individual Cells
1217 @subsubsection Summary Functions for Individual Cells
1218
1219 This section lists the summary functions that consider only an
1220 individual cell in @code{CTABLES}.  Only one such summary function,
1221 @code{COUNT}, may be applied to both categorical and scale variables:
1222
1223 @table @asis
1224 @item @code{COUNT} (``Count'', F40.0)
1225 The sum of weights in a cell.
1226
1227 If @code{CATEGORIES} for one or more of the variables in a table
1228 include missing values (@pxref{CTABLES Per-Variable Category
1229 Options}), then some or all of the categories for a cell might be
1230 missing values.  @code{COUNT} counts data included in a cell
1231 regardless of whether its categories are missing.
1232 @end table
1233
1234 The following summary functions apply only to scale variables or
1235 totals and subtotals for categorical variables.  Be cautious about
1236 interpreting the summary value in the latter case, because it is not
1237 necessarily meaningful; however, the mean of a Likert scale, etc.@:
1238 may have a straightforward interpreation.
1239
1240 @table @asis
1241 @item @code{MAXIMUM} (``Maximum'')
1242 The largest value.
1243
1244 @item @code{MEAN} (``Mean'')
1245 The mean.
1246
1247 @item @code{MEDIAN} (``Median'')
1248 The median value.
1249
1250 @item @code{MINIMUM} (``Minimum'')
1251 The smallest value.
1252
1253 @item @code{MISSING} (``Missing'')
1254 Sum of weights of user- and system-missing values.
1255
1256 @item @code{MODE} (``Mode'')
1257 The highest-frequency value.  Ties are broken by taking the smallest mode.
1258
1259 @item @code{PTILE} @i{n} (``Percentile @i{n}'')
1260 The @var{n}th percentile, where @math{0 @leq{} @var{n} @leq{} 100}.
1261
1262 @item @code{RANGE} (``Range'')
1263 The maximum minus the minimum.
1264
1265 @item @code{SEMEAN} (``Std Error of Mean'')
1266 The standard error of the mean.
1267
1268 @item @code{STDDEV} (``Std Deviation'')
1269 The standard deviation.
1270
1271 @item @code{SUM} (``Sum'')
1272 The sum.
1273
1274 @item @code{TOTALN} (``Total N'', F40.0)
1275 The sum of weights in a cell.
1276
1277 For scale data, @code{COUNT} and @code{TOTALN} are the same.
1278
1279 For categorical data, @code{TOTALN} counts missing values in excluded
1280 categories, that is, user-missing values not in an explicit category
1281 list on @code{CATEGORIES} (@pxref{CTABLES Per-Variable Category
1282 Options}), or user-missing values excluded because
1283 @code{MISSING=EXCLUDE} is in effect on @code{CATEGORIES}, or
1284 system-missing values.  @code{COUNT} does not count these.
1285
1286 @item @code{VALIDN} (``Valid N'', F40.0)
1287 The sum of valid count weights in included categories.
1288
1289 @code{VALIDN} does not count missing values regardless of whether they
1290 are in included categories via @code{CATEGORIES}.  @code{VALIDN} does
1291 not count valid values that are in excluded categories.
1292
1293 @item @code{VARIANCE} (``Variance'')
1294 The variance.
1295 @end table
1296
1297 @node CTABLES Summary Functions for Groups of Cells
1298 @subsubsection Summary Functions for Groups of Cells
1299
1300 These summary functions summarize over multiple cells within an area
1301 of the output chosen by the user and specified as part of the function
1302 name.  The following basic @var{area}s are supported, in decreasing
1303 order of size:
1304
1305 @table @code
1306 @item TABLE
1307 A @dfn{section}.  Stacked variables divide sections of the output from
1308 each other.  sections may span multiple layers.
1309
1310 @item LAYER
1311 A section within a single layer.
1312
1313 @item SUBTABLE
1314 A @dfn{subtable}, whose contents are the cells that pair an innermost
1315 row variable and an innermost column variable within a single layer.
1316 @end table
1317
1318 The following shows how the output for the table expression @code{qn61
1319 > qn57 BY qnd7a > qn86 + qn64b BY qns3a}@footnote{This is not
1320 necessarily a meaningful table, so for clarity variable labels are
1321 omitted.} is divided up into @code{TABLE}, @code{LAYER}, and
1322 @code{SUBTABLE} areas.  Each unique value for Table ID is one section,
1323 and similarly for Layer ID and Subtable ID.  Thus, this output has two
1324 @code{TABLE} areas (one for @code{qnd7a} and one for @code{qn64b}),
1325 four @code{LAYER} areas (for those two variables, per layer), and 12
1326 @code{SUBTABLE} areas.
1327 @psppoutput {ctables22}
1328
1329 @code{CTABLES} also supports the following @var{area}s that further
1330 divide a subtable or a layer within a section:
1331
1332 @table @code
1333 @item LAYERROW
1334 @itemx LAYERCOL
1335 A row or column, respectively, in one layer of a section.
1336
1337 @item ROW
1338 @itemx COL
1339 A row or column, respectively, in a subtable.
1340 @end table
1341
1342 The following summary functions for groups of cells are available for
1343 each @var{area} described above, for both categorical and scale
1344 variables:
1345
1346 @table @asis
1347 @item @code{@i{area}PCT} or @code{@i{area}PCT.COUNT} (``@i{Area} %'', PCT40.1)
1348 A percentage of total counts within @var{area}.
1349
1350 @item @code{@i{area}PCT.VALIDN} (``@i{Area} Valid N %'', PCT40.1)
1351 A percentage of total counts for valid values within @var{area}.
1352
1353 @item @code{@i{area}PCT.TOTALN} (``@i{Area} Total N %'', PCT40.1)
1354 A percentage of total counts for all values within @var{area}.
1355 @end table
1356
1357 Scale variables and totals and subtotals for categorical variables may
1358 use the following additional group cell summary function:
1359
1360 @table @asis
1361 @item @code{@i{area}PCT.SUM} (``@i{Area} Sum %'', PCT40.1)
1362 Percentage of the sum of the values within @var{area}.
1363 @end table
1364
1365 @node CTABLES Summary Functions for Adjusted Weights
1366 @subsubsection Summary Functions for Adjusted Weights
1367
1368 If the @code{WEIGHT} subcommand specified an adjustment weight
1369 variable, then the following summary functions use its value instead
1370 of the dictionary weight variable.  Otherwise, they are equivalent to
1371 the summary function without the @samp{E}-prefix:
1372
1373 @itemize @bullet
1374 @item
1375 @code{ECOUNT} (``Adjusted Count'', F40.0)
1376
1377 @item
1378 @code{ETOTALN} (``Adjusted Total N'', F40.0)
1379
1380 @item
1381 @code{EVALIDN} (``Adjusted Valid N'', F40.0)
1382 @end itemize
1383
1384 @node CTABLES Unweighted Summary Functions
1385 @subsubsection Unweighted Summary Functions
1386
1387 The following summary functions with a @samp{U}-prefix are equivalent
1388 to the same ones without the prefix, except that they use unweighted
1389 counts:
1390
1391 @itemize @bullet
1392 @item
1393 @code{UCOUNT} (``Unweighted Count'', F40.0)
1394
1395 @item
1396 @code{U@i{area}PCT} or @code{U@i{area}PCT.COUNT} (``Unweighted @i{Area} %'', PCT40.1)
1397
1398 @item
1399 @code{U@i{area}PCT.VALIDN} (``Unweighted @i{Area} Valid N %'', PCT40.1)
1400
1401 @item
1402 @code{U@i{area}PCT.TOTALN} (``Unweighted @i{Area} Total N %'', PCT40.1)
1403
1404 @item
1405 @code{UMEAN} (``Unweighted Mean'')
1406
1407 @item
1408 @code{UMEDIAN} (``Unweighted Median'')
1409
1410 @item
1411 @code{UMISSING} (``Unweighted Missing'')
1412
1413 @item
1414 @code{UMODE} (``Unweight Mode'')
1415
1416 @item
1417 @code{U@i{area}PCT.SUM} (``Unweighted @i{Area} Sum %'', PCT40.1)
1418
1419 @item
1420 @code{UPTILE} @i{n} (``Unweighted Percentile @i{n}'') 
1421
1422 @item
1423 @code{USEMEAN} (``Unweighted Std Error of Mean'')
1424
1425 @item
1426 @code{USTDDEV} (``Unweighted Std Deviation'')
1427
1428 @item
1429 @code{USUM} (``Unweighted Sum'')
1430
1431 @item
1432 @code{UTOTALN} (``Unweighted Total N'', F40.0)
1433
1434 @item
1435 @code{UVALIDN} (``Unweighted Valid N'', F40.0)
1436
1437 @item
1438 @code{UVARIANCE} (``Unweighted Variance'', F40.0)
1439 @end itemize
1440
1441 @node CTABLES Statistics Positions and Labels
1442 @subsection Statistics Positions and Labels
1443
1444 @display
1445 @t{/SLABELS}
1446     [@t{POSITION=}@{@t{COLUMN} @math{|} @t{ROW} @math{|} @t{LAYER}@}]
1447     [@t{VISIBLE=}@{@t{YES} @math{|} @t{NO}@}]
1448 @end display
1449
1450 The @code{SLABELS} subcommand controls the position and visibility of
1451 summary statistics for the @code{TABLE} subcommand that it follows.
1452
1453 @code{POSITION} sets the axis on which summary statistics appear.
1454 With @t{POSITION=COLUMN}, which is the default, each summary statistic
1455 appears in a column.  For example:
1456
1457 @example
1458 CTABLES /TABLE=qnd1 [MEAN, MEDIAN] BY qns3a.
1459 @end example
1460 @psppoutput {ctables13}
1461
1462 @noindent
1463 With @t{POSITION=ROW}, each summary statistic appears in a row, as
1464 shown below:
1465
1466 @example
1467 CTABLES /TABLE=qnd1 [MEAN, MEDIAN] BY qns3a /SLABELS POSITION=ROW.
1468 @end example
1469 @psppoutput {ctables14}
1470
1471 @noindent
1472 @t{POSITION=LAYER} is also available to place each summary statistic in
1473 a separate layer.
1474
1475 Labels for summary statistics are shown by default.  Use
1476 @t{VISIBLE=NO} to suppress them.  Because unlabeled data can cause
1477 confusion, it should only be considered if the meaning of the data is
1478 evident, as in a simple case like this:
1479
1480 @example
1481 CTABLES /TABLE=AgeGroup [TABLEPCT] /SLABELS VISIBLE=NO.
1482 @end example
1483 @psppoutput {ctables15}
1484
1485 @node CTABLES Category Label Positions
1486 @subsection Category Label Positions
1487
1488 @display
1489 @t{/CLABELS} @{@t{AUTO} @math{|} @{@t{ROWLABELS}@math{|}@t{COLLABELS}@}@t{=}@{@t{OPPOSITE}@math{|}@t{LAYER}@}@}
1490 @end display
1491
1492 The @code{CLABELS} subcommand controls the position of category labels
1493 for the @code{TABLE} subcommand that it follows.  By default, or if
1494 @t{AUTO} is specified, category labels for a given variable nest
1495 inside the variable's label on the same axis.  For example, the
1496 command below results in age categories nesting within the age group
1497 variable on the rows axis and gender categories within the gender
1498 variable on the columns axis:
1499
1500 @example
1501 CTABLES /TABLE AgeGroup BY qns3a.
1502 @end example
1503 @psppoutput {ctables16}
1504
1505 @t{ROWLABELS=OPPOSITE} or @t{COLLABELS=OPPOSITE} move row or column
1506 variable category labels, respectively, to the opposite axis.  The
1507 setting affects only the innermost variable on the given axis.  For
1508 example:
1509
1510 @example
1511 CTABLES /TABLE AgeGroup BY qns3a /CLABELS ROWLABELS=OPPOSITE.
1512 CTABLES /TABLE AgeGroup BY qns3a /CLABELS COLLABELS=OPPOSITE.
1513 @end example
1514 @psppoutput {ctables17}
1515
1516 @t{ROWLABELS=LAYER} or @t{COLLABELS=LAYER} move the innermost row or
1517 column variable category labels, respectively, to the layer axis.
1518
1519 Only one axis's labels may be moved, whether to the opposite axis or
1520 to the layer axis.
1521
1522 @c TODO Moving category labels for stacked variables
1523
1524 @subsubheading Effect on Summary Statistics
1525
1526 @code{CLABELS} primarily affects the appearance of tables, not the
1527 data displayed in them.  However, @code{CTABLES} can affect the values
1528 displayed for statistics that summarize areas of a table, since it can
1529 change the definitions of these areas.
1530
1531 For example, consider the following syntax and output:
1532
1533 @example
1534 CTABLES /TABLE AgeGroup BY qns3a [ROWPCT, COLPCT].
1535 @end example
1536 @psppoutput {ctables23}
1537
1538 @noindent
1539 Using @code{COLLABELS=OPPOSITE} changes the definitions of rows and
1540 columns, so that column percentages display what were previously row
1541 percentages and the new row percentages become meaningless (because
1542 there is only one cell per row):
1543
1544 @example
1545 CTABLES
1546     /TABLE AgeGroup BY qns3a [ROWPCT, COLPCT]
1547     /CLABELS COLLABELS=OPPOSITE.
1548 @end example
1549 @psppoutput {ctables24}
1550
1551 @node CTABLES Per-Variable Category Options
1552 @subsection Per-Variable Category Options
1553
1554 @display
1555 @t{/CATEGORIES} @t{VARIABLES=}@i{variables}
1556     @{@t{[}@i{value}@t{,} @i{value}@dots{}@t{]}
1557    @math{|} [@t{ORDER=}@{@t{A} @math{|} @t{D}@}]
1558      [@t{KEY=}@{@t{VALUE} @math{|} @t{LABEL} @math{|} @i{summary}@t{(}@i{variable}@t{)}@}]
1559      [@t{MISSING=}@{@t{EXCLUDE} @math{|} @t{INCLUDE}@}]@}
1560     [@t{TOTAL=}@{@t{NO} @math{|} @t{YES}@} [@t{LABEL=}@i{string}] [@t{POSITION=}@{@t{AFTER} @math{|} @t{BEFORE}@}]]
1561     [@t{EMPTY=}@{@t{INCLUDE} @math{|} @t{EXCLUDE}@}]
1562 @end display
1563
1564 The @code{CATEGORIES} subcommand specifies, for one or more
1565 categorical variables, the categories to include and exclude, the sort
1566 order for included categories, and treatment of missing values.  It
1567 also controls the totals and subtotals to display.  It may be
1568 specified any number of times, each time for a different set of
1569 variables.  @code{CATEGORIES} applies to the table produced by the
1570 @code{TABLE} subcommand that it follows.
1571
1572 @code{CATEGORIES} does not apply to scalar variables.
1573
1574 @t{VARIABLES} is required and must list the variables for the subcommand
1575 to affect.
1576
1577 There are two way to specify the Categories to include and their sort
1578 order:
1579
1580 @table @asis
1581 @item Explicit categories.
1582 @anchor{CTABLES Explicit Category List}
1583 To explicitly specify categories to include, list the categories
1584 within square brackets in the desired sort order.  Use spaces or
1585 commas to separate values.  Categories not covered by the list are
1586 excluded from analysis.
1587
1588 Each element of the list takes one of the following forms:
1589
1590 @table @t
1591 @item @i{number}
1592 @itemx '@i{string}'
1593 A numeric or string category value, for variables that have the
1594 corresponding type.
1595
1596 @item '@i{date}'
1597 @itemx '@i{time}'
1598 A date or time category value, for variables that have a date or time
1599 print format.
1600
1601 @item @i{min} THRU @i{max}
1602 @itemx LO THRU @i{max}
1603 @itemx @i{min} THRU HI
1604 A range of category values, where @var{min} and @var{max} each takes
1605 one of the forms above, in increasing order.
1606
1607 @item MISSING
1608 All user-missing values.  (To match individual user-missing values,
1609 specify their category values.)
1610
1611 @item OTHERNM
1612 Any non-missing value not covered by any other element of the list
1613 (regardless of where @t{OTHERNM} is placed in the list).
1614
1615 @item &@i{postcompute}
1616 A computed category name (@pxref{CTABLES Computed Categories}).
1617 @end table
1618
1619 Additional forms, described later, allow for subtotals.
1620 If multiple elements of the list cover a given category, the last one
1621 in the list takes precedence.
1622
1623 @item Implicit categories.
1624 Without an explicit list of categories, @pspp{} sorts
1625 categories automatically.
1626
1627 The @code{KEY} setting specifies the sort key.  By default, or with
1628 @code{KEY=VALUE}, categories are sorted by default.  Categories may
1629 also be sorted by value label, with @code{KEY=LABEL}, or by the value
1630 of a summary function, e.g.@: @code{KEY=COUNT}.
1631 @ignore  @c Not yet implemented
1632 For summary functions, a variable name may be specified in
1633 parentheses, e.g.@: @code{KEY=MAXIUM(qnd1)}, and this is required for
1634 functions that apply only to scalar variables.  The @code{PTILE}
1635 function also requires a percentage argument, e.g.@:
1636 @code{KEY=PTILE(qnd1, 90)}.  Only summary functions used in the table
1637 may be used, except that @code{COUNT} is always allowed.
1638 @end ignore
1639
1640 By default, or with @code{ORDER=A}, categories are sorted in ascending
1641 order.  Specify @code{ORDER=D} to sort in descending order.
1642
1643 User-missing values are excluded by default, or with
1644 @code{MISSING=EXCLUDE}.  Specify @code{MISSING=INCLUDE} to include
1645 user-missing values.  The system-missing value is always excluded.
1646 @end table
1647
1648 @subsubheading Totals and Subtotals
1649
1650 @code{CATEGORIES} also controls display of totals and subtotals.
1651 Totals are not displayed with @code{TOTAL=NO}, which is also the
1652 default.  Specify @code{TOTAL=YES} to display a total.  By default,
1653 the total is labeled ``Total''; use @code{LABEL="@i{label}"} to
1654 override it.
1655
1656 Subtotals are also not displayed by default.  To add one or more
1657 subtotals, use an explicit category list and insert @code{SUBTOTAL} or
1658 @code{HSUBTOTAL} in the position or positions where the subtotal
1659 should appear.  With @code{SUBTOTAL}, the subtotal becomes an extra
1660 row or column or layer; @code{HSUBTOTAL} additionally hides the
1661 categories that make up the subtotal.  Either way, the default label
1662 is ``Subtotal'', use @code{SUBTOTAL="@i{label}"} or
1663 @code{HSUBTOTAL="@i{label}"} to specify a custom label.
1664
1665 By default, or with @code{POSITION=AFTER}, totals are displayed in the
1666 output after the last category and subtotals apply to categories that
1667 precede them.  With @code{POSITION=BEFORE}, totals come before the
1668 first category and subtotals apply to categories that follow them.
1669
1670 Only categorical variables may have totals and subtotals.  Scalar
1671 variables may be ``totaled'' indirectly by enabling totals and
1672 subtotals on a categorical variable within which the scalar variable is
1673 summarized.
1674
1675 @c TODO Specifying summaries for totals and subtotals
1676
1677 @subsubheading Categories Without Values
1678
1679 Some categories might not be included in the data set being analyzed.
1680 For example, our example data set has no cases in the ``15 or
1681 younger'' age group.  By default, or with @code{EMPTY=INCLUDE},
1682 @pspp{} includes these empty categories in output tables.  To exclude
1683 them, specify @code{EMPTY=EXCLUDE}.
1684
1685 For implicit categories, empty categories potentially include all the
1686 values with value labels for a given variable; for explicit
1687 categories, they include all the values listed individually and all
1688 values with value labels that are covered by ranges or @code{MISSING}
1689 or @code{OTHERNM}.
1690
1691 @node CTABLES Titles
1692 @subsection Titles
1693
1694 @display
1695 @t{/TITLES}
1696     [@t{TITLE=}@i{string}@dots{}]
1697     [@t{CAPTION=}@i{string}@dots{}]
1698     [@t{CORNER=}@i{string}@dots{}]
1699 @end display
1700
1701 @c TODO Describe substitution variables
1702
1703 The @code{TITLES} subcommand sets the title, caption, and corner text
1704 for the table output for the previous @code{TABLE} subcommand.  The
1705 title appears above the table, the caption below the table, and the
1706 corner text appears in the table's upper left corner.  By default, the
1707 title is ``Custom Tables'' and the caption and corner text are empty.
1708 With some table output styles, the corner text is not displayed.
1709
1710 @node CTABLES Table Formatting
1711 @subsection Table Formatting
1712
1713 @display
1714 @t{/FORMAT}
1715     [@t{MINCOLWIDTH=}@{@t{DEFAULT} @math{|} @i{width}@}]
1716     [@t{MAXCOLWIDTH=}@{@t{DEFAULT} @math{|} @i{width}@}]
1717     [@t{UNITS=}@{@t{POINTS} @math{|} @t{INCHES} @math{|} @t{CM}@}]
1718     [@t{EMPTY=}@{@t{ZERO} @math{|} @t{BLANK} @math{|} @i{string}@}]
1719     [@t{MISSING=}@i{string}]
1720 @end display
1721
1722 The @code{FORMAT} subcommand, which must precede the first
1723 @code{TABLE} subcommand, controls formatting for all the output
1724 tables.  @code{FORMAT} and all of its settings are optional.
1725
1726 Use @code{MINCOLWIDTH} and @code{MAXCOLWIDTH} to control the minimum
1727 or maximum width of columns in output tables.  By default, with
1728 @code{DEFAULT}, column width varies based on content.  Otherwise,
1729 specify a number for either or both of these settings.  If both are
1730 specified, @code{MAXCOLWIDTH} must be greater than or equal to
1731 @code{MINCOLWIDTH}.  The default unit, or with @code{UNITS=POINTS}, is
1732 points (1/72 inch), or specify @code{UNITS=INCHES} to use inches or
1733 @code{UNITS=CM} for centimeters.
1734
1735 By default, or with @code{EMPTY=ZERO}, zero values are displayed in
1736 their usual format.  Use @code{EMPTY=BLANK} to use an empty cell
1737 instead, or @code{EMPTY="@i{string}"} to use the specified string.
1738
1739 By default, missing values are displayed as @samp{.}, the same as in
1740 other tables.  Specify @code{MISSING="@i{string}"} to instead use a
1741 custom string.
1742
1743 @node CTABLES Display of Variable Labels
1744 @subsection Display of Variable Labels
1745
1746 @display
1747 @t{/VLABELS}
1748     @t{VARIABLES=}@i{variables}
1749     @t{DISPLAY}=@{@t{DEFAULT} @math{|} @t{NAME} @math{|} @t{LABEL} @math{|} @t{BOTH} @math{|} @t{NONE}@}
1750 @end display
1751
1752 The @code{VLABELS} subcommand, which must precede the first
1753 @code{TABLE} subcommand, controls display of variable labels in all
1754 the output tables.  @code{VLABELS} is optional.  It may appear
1755 multiple times to adjust settings for different variables.
1756
1757 @code{VARIABLES} and @code{DISPLAY} are required.  The value of
1758 @code{DISPLAY} controls how variable labels are displayed for the
1759 variables listed on @code{VARIABLES}.  The supported values are:
1760
1761 @table @code
1762 @item DEFAULT
1763 Use the setting from @code{SET TVARS} (@pxref{SET TVARS}).
1764
1765 @item NAME
1766 Show only a variable name.
1767
1768 @item LABEL
1769 Show only a variable label.
1770
1771 @item BOTH
1772 Show variable name and label.
1773
1774 @item NONE
1775 Show nothing.
1776 @end table
1777
1778 @node CTABLES Missing Value Treatment
1779 @subsection Missing Value Treatment
1780
1781 @display
1782 @t{/SMISSING} @{@t{VARIABLE} @math{|} @t{LISTWISE}@}
1783 @end display
1784
1785 The @code{SMISSING} subcommand, which must precede the first
1786 @code{TABLE} subcommand, controls treatment of missing values for
1787 scalar variables in producing all the output tables.  @code{SMISSING}
1788 is optional.
1789
1790 With @code{SMISSING=VARIABLE}, which is the default, missing values
1791 are excluded on a variable-by-variable basis.  With
1792 @code{SMISSING=LISTWISE}, when stacked scalar variables are nested
1793 together with a categorical variable, a missing value for any of the
1794 scalar variables causes the case to be excluded for all of them.
1795
1796 As an example, consider the following dataset, in which @samp{x} is a
1797 categorical variable and @samp{y} and @samp{z} are scale:
1798
1799 @psppoutput{ctables18}
1800
1801 @noindent
1802 With the default missing-value treatment, @samp{x}'s mean is 20, based
1803 on the values 10, 20, and 30, and @samp{y}'s mean is 50, based on 40,
1804 50, and 60:
1805
1806 @example
1807 CTABLES /TABLE (y + z) > x.
1808 @end example
1809 @psppoutput{ctables19}
1810
1811 @noindent
1812 By adding @code{SMISSING=LISTWISE}, only cases where @samp{y} and
1813 @samp{z} are both non-missing are considered, so @samp{x}'s mean
1814 becomes 15, as the average of 10 and 20, and @samp{y}'s mean becomes
1815 55, the average of 50 and 60:
1816
1817 @example
1818 CTABLES /SMISSING LISTWISE /TABLE (y + z) > x.
1819 @end example
1820 @psppoutput{ctables20}
1821
1822 @noindent
1823 Even with @code{SMISSING=LISTWISE}, if @samp{y} and @samp{z} are
1824 separately nested with @samp{x}, instead of using a single @samp{>}
1825 operator, missing values revert to being considered on a
1826 variable-by-variable basis:
1827
1828 @example
1829 CTABLES /SMISSING LISTWISE /TABLE (y > x) + (z > x).
1830 @end example
1831 @psppoutput{ctables21}
1832
1833 @node CTABLES Computed Categories
1834 @subsection Computed Categories
1835
1836 @display
1837 @t{/PCOMPUTE} @t{&}@i{postcompute}@t{=EXPR(}@i{expression}@t{)}
1838 @end display
1839
1840 @dfn{Computed categories}, also called @dfn{postcomputes}, are
1841 categories created using arithmetic on categories obtained from the
1842 data.  The @code{PCOMPUTE} subcommand defines computed categories,
1843 which can then be used in two places: on @code{CATEGORIES} within an
1844 explicit category list (@pxref{CTABLES Explicit Category List}), and on
1845 the @code{PPROPERTIES} subcommand to define further properties for a
1846 given postcompute.
1847
1848 @code{PCOMPUTE} must precede the first @code{TABLE} command.  It is
1849 optional and it may be used any number of times to define multiple
1850 postcomputes.
1851
1852 Each @code{PCOMPUTE} defines one postcompute.  Its syntax consists of
1853 a name to identify the postcompute as a @pspp{} identifier prefixed by
1854 @samp{&}, followed by @samp{=} and a postcompute expression enclosed
1855 in @code{EXPR(@dots{})}.  A postcompute expression consists of:
1856
1857 @table @t
1858 @item [@i{category}]
1859 This form evaluates to the summary statistic for @i{category}, e.g.@:
1860 @code{[1]} evaluates to the value of the summary statistic associated
1861 with category 1.  The @i{category} may be a number, a quoted string,
1862 or a quoted time or date value.  All of the categories for a given
1863 postcompute must have the same form.  The category must appear in all
1864 the @code{CATEGORIES} list in which the postcompute is used.
1865
1866 @item [@i{min} THRU @i{max}]
1867 @itemx [LO THRU @i{max}]
1868 @itemx [@i{min} THRU HI]
1869 @itemx MISSING
1870 @itemx OTHERNM
1871 These forms evaluate to the summary statistics for a category
1872 specified with the same syntax, as described in previous section
1873 (@pxref{CTABLES Explicit Category List}).  The category must appear in
1874 all the @code{CATEGORIES} list in which the postcompute is used.
1875
1876 @item SUBTOTAL
1877 The summary statistic for the subtotal category.  This form is allowed
1878 only if the @code{CATEGORIES} lists that include this postcompute have
1879 exactly one subtotal.
1880
1881 @item SUBTOTAL[@i{index}]
1882 The summary statistic for subtotal category @i{index}, where 1 is the
1883 first subtotal, 2 is the second, and so on.  This form may be used for
1884 @code{CATEGORIES} lists with any number of subtotals.
1885
1886 @item TOTAL
1887 The summary statistic for the total.  The @code{CATEGORIES} lsits that
1888 include this postcompute must have a total enabled.
1889
1890 @item @i{a} + @i{b}
1891 @itemx @i{a} - @i{b}
1892 @itemx @i{a} * @i{b}
1893 @itemx @i{a} / @i{b}
1894 @itemx @i{a} ** @i{b}
1895 These forms perform arithmetic on the values of postcompute
1896 expressions @i{a} and @i{b}.  The usual operator precedence rules
1897 apply.
1898
1899 @item @i{number}
1900 Numeric constants may be used in postcompute expressions.
1901
1902 @item (@i{a})
1903 Parentheses override operator precedence.
1904 @end table
1905
1906 A postcompute is not associated with any particular variable.
1907 Instead, it may be referenced within @code{CATEGORIES} for any
1908 suitable variable (e.g.@: only a string variable is suitable for a
1909 postcompute expression that refers to a string category, only a
1910 variable with subtotals for an expression that refers to subtotals,
1911 @dots{}).
1912
1913 Normally a named postcompute is defined only once, but if a later
1914 @code{PCOMPUTE} redefines a postcompute with the same name as an
1915 earlier one, the later one take precedence.
1916
1917 @node CTABLES Computed Category Properties
1918 @subsection Computed Category Properties
1919
1920 @display
1921 @t{/PPROPERTIES} @t{&}@i{postcompute}@dots{}
1922     [@t{LABEL=}@i{string}]
1923     [@t{FORMAT=}[@i{summary} @i{format}]@dots{}]
1924     [@t{HIDESOURCECATS=}@{@t{NO} @math{|} @t{YES}@}
1925 @end display
1926
1927 The @code{PPROPERTIES} subcommand, which must appear before
1928 @code{TABLE}, sets properties for one or more postcomputes defined on
1929 prior @code{PCOMPUTE} subcommands.  The subcommand syntax begins with
1930 the list of postcomputes, each prefixed with @samp{&} as specified on
1931 @code{PCOMPUTE}.
1932
1933 All of the settings on @code{PPROPERTIES} are optional.  Use
1934 @code{LABEL} to set the label shown for the postcomputes in table
1935 output.  The default label for a postcompute is the expression used to
1936 define it.
1937
1938 The @code{FORMAT} setting sets summary statistics and display formats
1939 for the postcomputes.
1940
1941 By default, or with @code{HIDESOURCECATS=NO}, categories referred to
1942 by computed categories are displayed like other categories.  Use
1943 @code{HIDESOURCECATS=YES} to hide them.
1944
1945 @node CTABLES Base Weight
1946 @subsection Base Weight
1947
1948 @display
1949 @t{/WEIGHT VARIABLE=}@i{variable}
1950 @end display
1951
1952 The @code{WEIGHT} subcommand is optional and must appear before
1953 @code{TABLE}.  If it appears, it must name a numeric variable, known
1954 as the @dfn{effective base weight} or @dfn{adjustment weight}.  The
1955 effective base weight variable stands in for the dictionary's weight
1956 variable (@pxref{WEIGHT}), if any, in most calculations in
1957 @code{CTABLES}.  The only exceptions are the @code{COUNT},
1958 @code{TOTALN}, and @code{VALIDN} summary functions, which use the
1959 dictionary weight instead.
1960
1961 Weights obtained from the @pspp{} dictionary are rounded to the
1962 nearest integer at the case level.  Effective base weights are not
1963 rounded.  Regardless of the weighting source, @pspp{} does not analyze
1964 cases with zero, missing, or negative effective weights.
1965
1966 @node CTABLES Hiding Small Counts
1967 @subsection Hiding Small Counts
1968
1969 @display
1970 @t{/HIDESMALLCOUNTS COUNT=@i{count}}
1971 @end display
1972
1973 The @code{HIDESMALLCOUNTS} subcommand is optional.  If it specified,
1974 then count values in output tables less than the value of @i{count}
1975 are shown as @code{<@i{count}} instead of their true values.  The
1976 value of @i{count} must be an integer and must be at least 2.  Case
1977 weights are considered for deciding whether to hide a count.
1978
1979 @node FACTOR
1980 @section FACTOR
1981
1982 @vindex FACTOR
1983 @cindex factor analysis
1984 @cindex principal components analysis
1985 @cindex principal axis factoring
1986 @cindex data reduction
1987
1988 @display
1989 FACTOR  @{
1990          VARIABLES=@var{var_list},
1991          MATRIX IN (@{CORR,COV@}=@{*,@var{file_spec}@})
1992         @}
1993
1994         [ /METHOD = @{CORRELATION, COVARIANCE@} ]
1995
1996         [ /ANALYSIS=@var{var_list} ]
1997
1998         [ /EXTRACTION=@{PC, PAF@}]
1999
2000         [ /ROTATION=@{VARIMAX, EQUAMAX, QUARTIMAX, PROMAX[(@var{k})], NOROTATE@}]
2001
2002         [ /PRINT=[INITIAL] [EXTRACTION] [ROTATION] [UNIVARIATE] [CORRELATION] [COVARIANCE] [DET] [KMO] [AIC] [SIG] [ALL] [DEFAULT] ]
2003
2004         [ /PLOT=[EIGEN] ]
2005
2006         [ /FORMAT=[SORT] [BLANK(@var{n})] [DEFAULT] ]
2007
2008         [ /CRITERIA=[FACTORS(@var{n})] [MINEIGEN(@var{l})] [ITERATE(@var{m})] [ECONVERGE (@var{delta})] [DEFAULT] ]
2009
2010         [ /MISSING=[@{LISTWISE, PAIRWISE@}] [@{INCLUDE, EXCLUDE@}] ]
2011 @end display
2012
2013 The @cmd{FACTOR} command performs Factor Analysis or Principal Axis Factoring on a dataset.  It may be used to find
2014 common factors in the data or for data reduction purposes.
2015
2016 The @subcmd{VARIABLES} subcommand is required (unless the @subcmd{MATRIX IN}
2017 subcommand is used).
2018 It lists the variables which are to partake in the analysis.  (The @subcmd{ANALYSIS}
2019 subcommand may optionally further limit the variables that
2020 participate; it is useful primarily in conjunction with @subcmd{MATRIX IN}.)
2021
2022 If @subcmd{MATRIX IN} instead of @subcmd{VARIABLES} is specified, then the analysis
2023 is performed on a pre-prepared correlation or covariance matrix file instead of on
2024 individual data cases.  Typically the matrix file will have been generated by
2025 @cmd{MATRIX DATA} (@pxref{MATRIX DATA}) or provided by a third party.
2026 If specified, @subcmd{MATRIX IN} must be followed by @samp{COV} or @samp{CORR},
2027 then by @samp{=} and @var{file_spec} all in parentheses.
2028 @var{file_spec} may either be an asterisk, which indicates the currently loaded
2029 dataset, or it may be a file name to be loaded. @xref{MATRIX DATA}, for the expected
2030 format of the file.
2031
2032 The @subcmd{/EXTRACTION} subcommand is used to specify the way in which factors
2033 (components) are extracted from the data.
2034 If @subcmd{PC} is specified, then Principal Components Analysis is used.
2035 If @subcmd{PAF} is specified, then Principal Axis Factoring is
2036 used. By default Principal Components Analysis is used.
2037
2038 The @subcmd{/ROTATION} subcommand is used to specify the method by which the
2039 extracted solution is rotated.  Three orthogonal rotation methods are available:
2040 @subcmd{VARIMAX} (which is the default), @subcmd{EQUAMAX}, and @subcmd{QUARTIMAX}.
2041 There is one oblique rotation method, @i{viz}: @subcmd{PROMAX}.
2042 Optionally you may enter the power of the promax rotation @var{k}, which must be enclosed in parentheses.
2043 The default value of @var{k} is 5.
2044 If you don't want any rotation to be performed, the word @subcmd{NOROTATE}
2045 prevents the command from performing any rotation on the data.
2046
2047 The @subcmd{/METHOD} subcommand should be used to determine whether the
2048 covariance matrix or the correlation matrix of the data is
2049 to be analysed.  By default, the correlation matrix is analysed.
2050
2051 The @subcmd{/PRINT} subcommand may be used to select which features of the analysis are reported:
2052
2053 @itemize
2054 @item @subcmd{UNIVARIATE}
2055       A table of mean values, standard deviations and total weights are printed.
2056 @item @subcmd{INITIAL}
2057       Initial communalities and eigenvalues are printed.
2058 @item @subcmd{EXTRACTION}
2059       Extracted communalities and eigenvalues are printed.
2060 @item @subcmd{ROTATION}
2061       Rotated communalities and eigenvalues are printed.
2062 @item @subcmd{CORRELATION}
2063       The correlation matrix is printed.
2064 @item @subcmd{COVARIANCE}
2065       The covariance matrix is printed.
2066 @item @subcmd{DET}
2067       The determinant of the correlation or covariance matrix is printed.
2068 @item @subcmd{AIC}
2069       The anti-image covariance and anti-image correlation matrices are printed.
2070 @item @subcmd{KMO}
2071       The Kaiser-Meyer-Olkin measure of sampling adequacy and the Bartlett test of sphericity is printed.
2072 @item @subcmd{SIG}
2073       The significance of the elements of correlation matrix is printed.
2074 @item @subcmd{ALL}
2075       All of the above are printed.
2076 @item @subcmd{DEFAULT}
2077       Identical to @subcmd{INITIAL} and @subcmd{EXTRACTION}.
2078 @end itemize
2079
2080 If @subcmd{/PLOT=EIGEN} is given, then a ``Scree'' plot of the eigenvalues is
2081 printed.  This can be useful for visualizing the factors and deciding
2082 which factors (components) should be retained.
2083
2084 The @subcmd{/FORMAT} subcommand determined how data are to be
2085 displayed in loading matrices.  If @subcmd{SORT} is specified, then
2086 the variables are sorted in descending order of significance.  If
2087 @subcmd{BLANK(@var{n})} is specified, then coefficients whose absolute
2088 value is less than @var{n} are not printed.  If the keyword
2089 @subcmd{DEFAULT} is specified, or if no @subcmd{/FORMAT} subcommand is
2090 specified, then no sorting is performed, and all coefficients are printed.
2091
2092 You can use the @subcmd{/CRITERIA} subcommand to specify how the number of
2093 extracted factors (components) are chosen.  If @subcmd{FACTORS(@var{n})} is
2094 specified, where @var{n} is an integer, then @var{n} factors are
2095 extracted.  Otherwise, the @subcmd{MINEIGEN} setting is used.
2096 @subcmd{MINEIGEN(@var{l})} requests that all factors whose eigenvalues
2097 are greater than or equal to @var{l} are extracted. The default value
2098 of @var{l} is 1. The @subcmd{ECONVERGE} setting has effect only when
2099 using iterative algorithms for factor extraction (such as Principal Axis
2100 Factoring).  @subcmd{ECONVERGE(@var{delta})} specifies that
2101 iteration should cease when the maximum absolute value of the
2102 communality estimate between one iteration and the previous is less
2103 than @var{delta}. The default value of @var{delta} is 0.001.
2104
2105 The @subcmd{ITERATE(@var{m})} may appear any number of times and is
2106 used for two different purposes. It is used to set the maximum number
2107 of iterations (@var{m}) for convergence and also to set the maximum
2108 number of iterations for rotation.
2109 Whether it affects convergence or rotation depends upon which
2110 subcommand follows the @subcmd{ITERATE} subcommand.
2111 If @subcmd{EXTRACTION} follows, it affects convergence.
2112 If @subcmd{ROTATION} follows, it affects rotation.
2113 If neither @subcmd{ROTATION} nor @subcmd{EXTRACTION} follow a
2114 @subcmd{ITERATE} subcommand, then the entire subcommand is ignored.
2115 The default value of @var{m} is 25.
2116
2117 The @cmd{MISSING} subcommand determines the handling of missing
2118 variables.  If @subcmd{INCLUDE} is set, then user-missing values are
2119 included in the calculations, but system-missing values are not.
2120 If @subcmd{EXCLUDE} is set, which is the default, user-missing
2121 values are excluded as well as system-missing values.  This is the
2122 default. If @subcmd{LISTWISE} is set, then the entire case is excluded
2123 from analysis whenever any variable  specified in the @cmd{VARIABLES}
2124 subcommand contains a missing value.
2125
2126 If @subcmd{PAIRWISE} is set, then a case is considered missing only if
2127 either of the values  for the particular coefficient are missing.
2128 The default is @subcmd{LISTWISE}.
2129
2130 @node GLM
2131 @section GLM
2132
2133 @vindex GLM
2134 @cindex univariate analysis of variance
2135 @cindex fixed effects
2136 @cindex factorial anova
2137 @cindex analysis of variance
2138 @cindex ANOVA
2139
2140
2141 @display
2142 GLM @var{dependent_vars} BY @var{fixed_factors}
2143      [/METHOD = SSTYPE(@var{type})]
2144      [/DESIGN = @var{interaction_0} [@var{interaction_1} [... @var{interaction_n}]]]
2145      [/INTERCEPT = @{INCLUDE|EXCLUDE@}]
2146      [/MISSING = @{INCLUDE|EXCLUDE@}]
2147 @end display
2148
2149 The @cmd{GLM} procedure can be used for fixed effects factorial Anova.
2150
2151 The @var{dependent_vars} are the variables to be analysed.
2152 You may analyse several variables in the same command in which case they should all
2153 appear before the @code{BY} keyword.
2154
2155 The @var{fixed_factors} list must be one or more categorical variables.  Normally it
2156 does not make sense to enter a scalar variable in the @var{fixed_factors} and doing
2157 so may cause @pspp{} to do a lot of unnecessary processing.
2158
2159 The @subcmd{METHOD} subcommand is used to change the method for producing the sums of
2160 squares.  Available values of @var{type} are 1, 2 and 3.  The default is type 3.
2161
2162 You may specify a custom design using the @subcmd{DESIGN} subcommand.
2163 The design comprises a list of interactions where each interaction is a
2164 list of variables separated by a @samp{*}.  For example the command
2165 @display
2166 GLM subject BY sex age_group race
2167     /DESIGN = age_group sex group age_group*sex age_group*race
2168 @end display
2169 @noindent specifies the model @math{subject = age_group + sex + race + age_group*sex + age_group*race}.
2170 If no @subcmd{DESIGN} subcommand is specified, then the default is all possible combinations
2171 of the fixed factors.  That is to say
2172 @display
2173 GLM subject BY sex age_group race
2174 @end display
2175 implies the model
2176 @math{subject = age_group + sex + race + age_group*sex + age_group*race + sex*race + age_group*sex*race}.
2177
2178
2179 The @subcmd{MISSING} subcommand determines the handling of missing
2180 variables.
2181 If @subcmd{INCLUDE} is set then, for the purposes of GLM analysis,
2182 only system-missing values are considered
2183 to be missing; user-missing values are not regarded as missing.
2184 If @subcmd{EXCLUDE} is set, which is the default, then user-missing
2185 values are considered to be missing as well as system-missing values.
2186 A case for which any dependent variable or any factor
2187 variable has a missing value is excluded from the analysis.
2188
2189 @node LOGISTIC REGRESSION
2190 @section LOGISTIC REGRESSION
2191
2192 @vindex LOGISTIC REGRESSION
2193 @cindex logistic regression
2194 @cindex bivariate logistic regression
2195
2196 @display
2197 LOGISTIC REGRESSION [VARIABLES =] @var{dependent_var} WITH @var{predictors}
2198
2199      [/CATEGORICAL = @var{categorical_predictors}]
2200
2201      [@{/NOCONST | /ORIGIN | /NOORIGIN @}]
2202
2203      [/PRINT = [SUMMARY] [DEFAULT] [CI(@var{confidence})] [ALL]]
2204
2205      [/CRITERIA = [BCON(@var{min_delta})] [ITERATE(@var{max_interations})]
2206                   [LCON(@var{min_likelihood_delta})] [EPS(@var{min_epsilon})]
2207                   [CUT(@var{cut_point})]]
2208
2209      [/MISSING = @{INCLUDE|EXCLUDE@}]
2210 @end display
2211
2212 Bivariate Logistic Regression is used when you want to explain a dichotomous dependent
2213 variable in terms of one or more predictor variables.
2214
2215 The minimum command is
2216 @example
2217 LOGISTIC REGRESSION @var{y} WITH @var{x1} @var{x2} @dots{} @var{xn}.
2218 @end example
2219 Here, @var{y} is the dependent variable, which must be dichotomous and @var{x1} @dots{} @var{xn}
2220 are the predictor variables whose coefficients the procedure estimates.
2221
2222 By default, a constant term is included in the model.
2223 Hence, the full model is
2224 @math{
2225 {\bf y}
2226 = b_0 + b_1 {\bf x_1}
2227 + b_2 {\bf x_2}
2228 + \dots
2229 + b_n {\bf x_n}
2230 }
2231
2232 Predictor variables which are categorical in nature should be listed on the @subcmd{/CATEGORICAL} subcommand.
2233 Simple variables as well as interactions between variables may be listed here.
2234
2235 If you want a model without the constant term @math{b_0}, use the keyword @subcmd{/ORIGIN}.
2236 @subcmd{/NOCONST} is a synonym for @subcmd{/ORIGIN}.
2237
2238 An iterative Newton-Raphson procedure is used to fit the model.
2239 The @subcmd{/CRITERIA} subcommand is used to specify the stopping criteria of the procedure,
2240 and other parameters.
2241 The value of @var{cut_point} is used in the classification table.  It is the
2242 threshold above which predicted values are considered to be 1.  Values
2243 of @var{cut_point} must lie in the range [0,1].
2244 During iterations, if any one of the stopping criteria are satisfied, the procedure is
2245 considered complete.
2246 The stopping criteria are:
2247 @itemize
2248 @item The number of iterations exceeds @var{max_iterations}.
2249       The default value of @var{max_iterations} is 20.
2250 @item The change in the all coefficient estimates are less than @var{min_delta}.
2251 The default value of @var{min_delta} is 0.001.
2252 @item The magnitude of change in the likelihood estimate is less than @var{min_likelihood_delta}.
2253 The default value of @var{min_delta} is zero.
2254 This means that this criterion is disabled.
2255 @item The differential of the estimated probability for all cases is less than @var{min_epsilon}.
2256 In other words, the probabilities are close to zero or one.
2257 The default value of @var{min_epsilon} is 0.00000001.
2258 @end itemize
2259
2260
2261 The @subcmd{PRINT} subcommand controls the display of optional statistics.
2262 Currently there is one such option, @subcmd{CI}, which indicates that the
2263 confidence interval of the odds ratio should be displayed as well as its value.
2264 @subcmd{CI} should be followed by an integer in parentheses, to indicate the
2265 confidence level of the desired confidence interval.
2266
2267 The @subcmd{MISSING} subcommand determines the handling of missing
2268 variables.
2269 If @subcmd{INCLUDE} is set, then user-missing values are included in the
2270 calculations, but system-missing values are not.
2271 If @subcmd{EXCLUDE} is set, which is the default, user-missing
2272 values are excluded as well as system-missing values.
2273 This is the default.
2274
2275 @node MEANS
2276 @section MEANS
2277
2278 @vindex MEANS
2279 @cindex means
2280
2281 @display
2282 MEANS [TABLES =]
2283       @{@var{var_list}@}
2284         [ BY @{@var{var_list}@} [BY @{@var{var_list}@} [BY @{@var{var_list}@} @dots{} ]]]
2285
2286       [ /@{@var{var_list}@}
2287          [ BY @{@var{var_list}@} [BY @{@var{var_list}@} [BY @{@var{var_list}@} @dots{} ]]] ]
2288
2289       [/CELLS = [MEAN] [COUNT] [STDDEV] [SEMEAN] [SUM] [MIN] [MAX] [RANGE]
2290         [VARIANCE] [KURT] [SEKURT]
2291         [SKEW] [SESKEW] [FIRST] [LAST]
2292         [HARMONIC] [GEOMETRIC]
2293         [DEFAULT]
2294         [ALL]
2295         [NONE] ]
2296
2297       [/MISSING = [INCLUDE] [DEPENDENT]]
2298 @end display
2299
2300 You can use the @cmd{MEANS} command to calculate the arithmetic mean and similar
2301 statistics, either for the dataset as a whole or for categories of data.
2302
2303 The simplest form of the command is
2304 @example
2305 MEANS @var{v}.
2306 @end example
2307 @noindent which calculates the mean, count and standard deviation for @var{v}.
2308 If you specify a grouping variable, for example
2309 @example
2310 MEANS @var{v} BY @var{g}.
2311 @end example
2312 @noindent then the means, counts and standard deviations for @var{v} after having
2313 been grouped by @var{g} are calculated.
2314 Instead of the mean, count and standard deviation, you could specify the statistics
2315 in which you are interested:
2316 @example
2317 MEANS @var{x} @var{y} BY @var{g}
2318       /CELLS = HARMONIC SUM MIN.
2319 @end example
2320 This example calculates the harmonic mean, the sum and the minimum values of @var{x} and @var{y}
2321 grouped by @var{g}.
2322
2323 The @subcmd{CELLS} subcommand specifies which statistics to calculate.  The available statistics
2324 are:
2325 @itemize
2326 @item @subcmd{MEAN}
2327 @cindex arithmetic mean
2328       The arithmetic mean.
2329 @item @subcmd{COUNT}
2330       The count of the values.
2331 @item @subcmd{STDDEV}
2332       The standard deviation.
2333 @item @subcmd{SEMEAN}
2334       The standard error of the mean.
2335 @item @subcmd{SUM}
2336       The sum of the values.
2337 @item @subcmd{MIN}
2338       The minimum value.
2339 @item @subcmd{MAX}
2340       The maximum value.
2341 @item @subcmd{RANGE}
2342       The difference between the maximum and minimum values.
2343 @item @subcmd{VARIANCE}
2344       The variance.
2345 @item @subcmd{FIRST}
2346       The first value in the category.
2347 @item @subcmd{LAST}
2348       The last value in the category.
2349 @item @subcmd{SKEW}
2350       The skewness.
2351 @item @subcmd{SESKEW}
2352       The standard error of the skewness.
2353 @item @subcmd{KURT}
2354       The kurtosis
2355 @item @subcmd{SEKURT}
2356       The standard error of the kurtosis.
2357 @item @subcmd{HARMONIC}
2358 @cindex harmonic mean
2359       The harmonic mean.
2360 @item @subcmd{GEOMETRIC}
2361 @cindex geometric mean
2362       The geometric mean.
2363 @end itemize
2364
2365 In addition, three special keywords are recognized:
2366 @itemize
2367 @item @subcmd{DEFAULT}
2368       This is the same as @subcmd{MEAN} @subcmd{COUNT} @subcmd{STDDEV}.
2369 @item @subcmd{ALL}
2370       All of the above statistics are calculated.
2371 @item @subcmd{NONE}
2372       No statistics are calculated (only a summary is shown).
2373 @end itemize
2374
2375
2376 More than one @dfn{table} can be specified in a single command.
2377 Each table is separated by a @samp{/}. For
2378 example
2379 @example
2380 MEANS TABLES =
2381       @var{c} @var{d} @var{e} BY @var{x}
2382       /@var{a} @var{b} BY @var{x} @var{y}
2383       /@var{f} BY @var{y} BY @var{z}.
2384 @end example
2385 has three tables (the @samp{TABLE =} is optional).
2386 The first table has three dependent variables @var{c}, @var{d} and @var{e}
2387 and a single categorical variable @var{x}.
2388 The second table has two dependent variables @var{a} and @var{b},
2389 and two categorical variables @var{x} and @var{y}.
2390 The third table has a single dependent variables @var{f}
2391 and a categorical variable formed by the combination of @var{y} and @var{z}.
2392
2393
2394 By default values are omitted from the analysis only if missing values
2395 (either system missing or user missing)
2396 for any of the variables directly involved in their calculation are
2397 encountered.
2398 This behaviour can be modified with the  @subcmd{/MISSING} subcommand.
2399 Three options are possible: @subcmd{TABLE}, @subcmd{INCLUDE} and @subcmd{DEPENDENT}.
2400
2401 @subcmd{/MISSING = INCLUDE} says that user missing values, either in the dependent
2402 variables or in the categorical variables should be taken at their face
2403 value, and not excluded.
2404
2405 @subcmd{/MISSING = DEPENDENT} says that user missing values, in the dependent
2406 variables should be taken at their face value, however cases which
2407 have user missing values for the categorical variables should be omitted
2408 from the calculation.
2409
2410 @subsection Example Means
2411
2412 The dataset in @file{repairs.sav} contains the mean time between failures (@exvar{mtbf})
2413 for a sample of artifacts produced by different factories and trialed under
2414 different operating conditions.
2415 Since there are four combinations of categorical variables, by simply looking
2416 at the list of data, it would be hard to how the scores vary for each category.
2417 @ref{means:ex} shows one way of tabulating the @exvar{mtbf} in a way which is
2418 easier to understand.
2419
2420 @float Example, means:ex
2421 @psppsyntax {means.sps}
2422 @caption {Running @cmd{MEANS} on the @exvar{mtbf} score with categories @exvar{factory} and @exvar{environment}}
2423 @end float
2424
2425 The results are shown in @ref{means:res}.   The figures shown indicate the mean,
2426 standard deviation and number of samples in each category.
2427 These figures however do not indicate whether the results are statistically
2428 significant.  For that, you would need to use the procedures @cmd{ONEWAY}, @cmd{GLM} or
2429 @cmd{T-TEST} depending on the hypothesis being tested.
2430
2431 @float Result, means:res
2432 @psppoutput {means}
2433 @caption {The @exvar{mtbf} categorised by @exvar{factory} and @exvar{environment}}
2434 @end float
2435
2436 Note that there is no limit to the number of variables for which you can calculate
2437 statistics, nor to the number of categorical variables per layer, nor the number
2438 of layers.
2439 However, running @cmd{MEANS} on a large numbers of variables, or with categorical variables
2440 containing a large number of distinct values may result in an extremely large output, which
2441 will not be easy to interpret.
2442 So you should consider carefully which variables to select for participation in the analysis.
2443
2444 @node NPAR TESTS
2445 @section NPAR TESTS
2446
2447 @vindex NPAR TESTS
2448 @cindex nonparametric tests
2449
2450 @display
2451 NPAR TESTS
2452
2453      nonparametric test subcommands
2454      .
2455      .
2456      .
2457
2458      [ /STATISTICS=@{DESCRIPTIVES@} ]
2459
2460      [ /MISSING=@{ANALYSIS, LISTWISE@} @{INCLUDE, EXCLUDE@} ]
2461
2462      [ /METHOD=EXACT [ TIMER [(@var{n})] ] ]
2463 @end display
2464
2465 @cmd{NPAR TESTS} performs nonparametric tests.
2466 Non parametric tests make very few assumptions about the distribution of the
2467 data.
2468 One or more tests may be specified by using the corresponding subcommand.
2469 If the @subcmd{/STATISTICS} subcommand is also specified, then summary statistics are
2470 produces for each variable that is the subject of any test.
2471
2472 Certain tests may take a long time to execute, if an exact figure is required.
2473 Therefore, by default asymptotic approximations are used unless the
2474 subcommand @subcmd{/METHOD=EXACT} is specified.
2475 Exact tests give more accurate results, but may take an unacceptably long
2476 time to perform.  If the @subcmd{TIMER} keyword is used, it sets a maximum time,
2477 after which the test is abandoned, and a warning message printed.
2478 The time, in minutes, should be specified in parentheses after the @subcmd{TIMER} keyword.
2479 If the @subcmd{TIMER} keyword is given without this figure, then a default value of 5 minutes
2480 is used.
2481
2482
2483 @menu
2484 * BINOMIAL::                Binomial Test
2485 * CHISQUARE::               Chi-square Test
2486 * COCHRAN::                 Cochran Q Test
2487 * FRIEDMAN::                Friedman Test
2488 * KENDALL::                 Kendall's W Test
2489 * KOLMOGOROV-SMIRNOV::      Kolmogorov Smirnov Test
2490 * KRUSKAL-WALLIS::          Kruskal-Wallis Test
2491 * MANN-WHITNEY::            Mann Whitney U Test
2492 * MCNEMAR::                 McNemar Test
2493 * MEDIAN::                  Median Test
2494 * RUNS::                    Runs Test
2495 * SIGN::                    The Sign Test
2496 * WILCOXON::                Wilcoxon Signed Ranks Test
2497 @end menu
2498
2499
2500 @node    BINOMIAL
2501 @subsection Binomial test
2502 @vindex BINOMIAL
2503 @cindex binomial test
2504
2505 @display
2506      [ /BINOMIAL[(@var{p})]=@var{var_list}[(@var{value1}[, @var{value2})] ] ]
2507 @end display
2508
2509 The @subcmd{/BINOMIAL} subcommand compares the observed distribution of a dichotomous
2510 variable with that of a binomial distribution.
2511 The variable @var{p} specifies the test proportion of the binomial
2512 distribution.
2513 The default value of 0.5 is assumed if @var{p} is omitted.
2514
2515 If a single value appears after the variable list, then that value is
2516 used as the threshold to partition the observed values. Values less
2517 than or equal to the threshold value form the first category.  Values
2518 greater than the threshold form the second category.
2519
2520 If two values appear after the variable list, then they are used
2521 as the values which a variable must take to be in the respective
2522 category.
2523 Cases for which a variable takes a value equal to neither of the specified
2524 values, take no part in the test for that variable.
2525
2526 If no values appear, then the variable must assume dichotomous
2527 values.
2528 If more than two distinct, non-missing values for a variable
2529 under test are encountered then an error occurs.
2530
2531 If the test proportion is equal to 0.5, then a two tailed test is
2532 reported.   For any other test proportion, a one tailed test is
2533 reported.
2534 For one tailed tests, if the test proportion is less than
2535 or equal to the observed proportion, then the significance of
2536 observing the observed proportion or more is reported.
2537 If the test proportion is more than the observed proportion, then the
2538 significance of observing the observed proportion or less is reported.
2539 That is to say, the test is always performed in the observed
2540 direction.
2541
2542 @pspp{} uses a very precise approximation to the gamma function to
2543 compute the binomial significance.  Thus, exact results are reported
2544 even for very large sample sizes.
2545
2546
2547 @node    CHISQUARE
2548 @subsection Chi-square Test
2549 @vindex CHISQUARE
2550 @cindex chi-square test
2551
2552
2553 @display
2554      [ /CHISQUARE=@var{var_list}[(@var{lo},@var{hi})] [/EXPECTED=@{EQUAL|@var{f1}, @var{f2} @dots{} @var{fn}@}] ]
2555 @end display
2556
2557
2558 The @subcmd{/CHISQUARE} subcommand produces a chi-square statistic for the differences
2559 between the expected and observed frequencies of the categories of a variable.
2560 Optionally, a range of values may appear after the variable list.
2561 If a range is given, then non integer values are truncated, and values
2562 outside the  specified range are excluded from the analysis.
2563
2564 The @subcmd{/EXPECTED} subcommand specifies the expected values of each
2565 category.
2566 There must be exactly one non-zero expected value, for each observed
2567 category, or the @subcmd{EQUAL} keyword must be specified.
2568 You may use the notation @subcmd{@var{n}*@var{f}} to specify @var{n}
2569 consecutive expected categories all taking a frequency of @var{f}.
2570 The frequencies given are proportions, not absolute frequencies.  The
2571 sum of the frequencies need not be 1.
2572 If no @subcmd{/EXPECTED} subcommand is given, then equal frequencies
2573 are expected.
2574
2575 @subsubsection Chi-square Example
2576
2577 A researcher wishes to investigate whether there are an equal number of
2578 persons of each sex in a population.   The sample chosen for invesigation
2579 is that from the @file {physiology.sav} dataset.   The null hypothesis for
2580 the test is that the population comprises an equal number of males and females.
2581 The analysis is performed as shown in @ref{chisquare:ex}.
2582
2583 @float Example, chisquare:ex
2584 @psppsyntax {chisquare.sps}
2585 @caption {Performing a chi-square test to check for equal distribution of sexes}
2586 @end float
2587
2588 There is only one test variable, @i{viz:} @exvar{sex}.  The other variables in the dataset
2589 are ignored.
2590
2591 @float Screenshot, chisquare:scr
2592 @psppimage {chisquare}
2593 @caption {Performing a chi-square test using the graphic user interface}
2594 @end float
2595
2596 In @ref{chisquare:res} the summary box shows that in the sample, there are more males
2597 than females.  However the significance of chi-square result is greater than 0.05
2598 --- the most commonly accepted p-value --- and therefore
2599 there is not enough evidence to reject the null hypothesis and one must conclude
2600 that the evidence does not indicate that there is an imbalance of the sexes
2601 in the population.
2602
2603 @float Result, chisquare:res
2604 @psppoutput {chisquare}
2605 @caption {The results of running a chi-square test on @exvar{sex}}
2606 @end float
2607
2608
2609 @node COCHRAN
2610 @subsection Cochran Q Test
2611 @vindex Cochran
2612 @cindex Cochran Q test
2613 @cindex Q, Cochran Q
2614
2615 @display
2616      [ /COCHRAN = @var{var_list} ]
2617 @end display
2618
2619 The Cochran Q test is used to test for differences between three or more groups.
2620 The data for @var{var_list} in all cases must assume exactly two
2621 distinct values (other than missing values).
2622
2623 The value of Q is displayed along with its Asymptotic significance
2624 based on a chi-square distribution.
2625
2626 @node FRIEDMAN
2627 @subsection Friedman Test
2628 @vindex FRIEDMAN
2629 @cindex Friedman test
2630
2631 @display
2632      [ /FRIEDMAN = @var{var_list} ]
2633 @end display
2634
2635 The Friedman test is used to test for differences between repeated measures when
2636 there is no indication that the distributions are normally distributed.
2637
2638 A list of variables which contain the measured data must be given.  The procedure
2639 prints the sum of ranks for each variable, the test statistic and its significance.
2640
2641 @node KENDALL
2642 @subsection Kendall's W Test
2643 @vindex KENDALL
2644 @cindex Kendall's W test
2645 @cindex coefficient of concordance
2646
2647 @display
2648      [ /KENDALL = @var{var_list} ]
2649 @end display
2650
2651 The Kendall test investigates whether an arbitrary number of related samples come from the
2652 same population.
2653 It is identical to the Friedman test except that the additional statistic W, Kendall's Coefficient of Concordance is printed.
2654 It has the range [0,1] --- a value of zero indicates no agreement between the samples whereas a value of
2655 unity indicates complete agreement.
2656
2657
2658 @node KOLMOGOROV-SMIRNOV
2659 @subsection Kolmogorov-Smirnov Test
2660 @vindex KOLMOGOROV-SMIRNOV
2661 @vindex K-S
2662 @cindex Kolmogorov-Smirnov test
2663
2664 @display
2665      [ /KOLMOGOROV-SMIRNOV (@{NORMAL [@var{mu}, @var{sigma}], UNIFORM [@var{min}, @var{max}], POISSON [@var{lambda}], EXPONENTIAL [@var{scale}] @}) = @var{var_list} ]
2666 @end display
2667
2668 The one sample Kolmogorov-Smirnov subcommand is used to test whether or not a dataset is
2669 drawn from a particular distribution.  Four distributions are supported, @i{viz:}
2670 Normal, Uniform, Poisson and Exponential.
2671
2672 Ideally you should provide the parameters of the distribution against
2673 which you wish to test the data. For example, with the normal
2674 distribution  the mean (@var{mu})and standard deviation (@var{sigma})
2675 should be given; with the uniform distribution, the minimum
2676 (@var{min})and maximum (@var{max}) value should be provided.
2677 However, if the parameters are omitted they are imputed from the
2678 data.  Imputing the parameters reduces the power of the test so should
2679 be avoided if possible.
2680
2681 In the following example, two variables @var{score} and @var{age} are
2682 tested to see if they follow a normal distribution with a mean of 3.5
2683 and a standard deviation of 2.0.
2684 @example
2685   NPAR TESTS
2686         /KOLMOGOROV-SMIRNOV (normal 3.5 2.0) = @var{score} @var{age}.
2687 @end example
2688 If the variables need to be tested against different distributions, then a separate
2689 subcommand must be used.  For example the following syntax tests @var{score} against
2690 a normal distribution with mean of 3.5 and standard deviation of 2.0 whilst @var{age}
2691 is tested against a normal distribution of mean 40 and standard deviation 1.5.
2692 @example
2693   NPAR TESTS
2694         /KOLMOGOROV-SMIRNOV (normal 3.5 2.0) = @var{score}
2695         /KOLMOGOROV-SMIRNOV (normal 40 1.5) =  @var{age}.
2696 @end example
2697
2698 The abbreviated subcommand  @subcmd{K-S} may be used in place of @subcmd{KOLMOGOROV-SMIRNOV}.
2699
2700 @node KRUSKAL-WALLIS
2701 @subsection Kruskal-Wallis Test
2702 @vindex KRUSKAL-WALLIS
2703 @vindex K-W
2704 @cindex Kruskal-Wallis test
2705
2706 @display
2707      [ /KRUSKAL-WALLIS = @var{var_list} BY var (@var{lower}, @var{upper}) ]
2708 @end display
2709
2710 The Kruskal-Wallis test is used to compare data from an
2711 arbitrary number of populations.  It does not assume normality.
2712 The data to be compared are specified by @var{var_list}.
2713 The categorical variable determining the groups to which the
2714 data belongs is given by @var{var}. The limits @var{lower} and
2715 @var{upper} specify the valid range of @var{var}.
2716 If @var{upper} is smaller than @var{lower}, the PSPP will assume their values
2717 to be reversed. Any cases for which @var{var} falls outside
2718 [@var{lower}, @var{upper}] are ignored.
2719
2720 The mean rank of each group as well as the chi-squared value and
2721 significance of the test are printed.
2722 The abbreviated subcommand  @subcmd{K-W} may be used in place of
2723 @subcmd{KRUSKAL-WALLIS}.
2724
2725
2726 @node MANN-WHITNEY
2727 @subsection Mann-Whitney U Test
2728 @vindex MANN-WHITNEY
2729 @vindex M-W
2730 @cindex Mann-Whitney U test
2731 @cindex U, Mann-Whitney U
2732
2733 @display
2734      [ /MANN-WHITNEY = @var{var_list} BY var (@var{group1}, @var{group2}) ]
2735 @end display
2736
2737 The Mann-Whitney subcommand is used to test whether two groups of data
2738 come from different populations. The variables to be tested should be
2739 specified in @var{var_list} and the grouping variable, that determines
2740 to which group the test variables belong, in @var{var}.
2741 @var{Var} may be either a string or an alpha variable.
2742 @var{Group1} and @var{group2} specify the
2743 two values of @var{var} which determine the groups of the test data.
2744 Cases for which the @var{var} value is neither @var{group1} or
2745 @var{group2} are ignored.
2746
2747 The value of the Mann-Whitney U statistic, the Wilcoxon W, and the
2748 significance are printed.
2749 You may abbreviated the subcommand @subcmd{MANN-WHITNEY} to
2750 @subcmd{M-W}.
2751
2752
2753 @node MCNEMAR
2754 @subsection McNemar Test
2755 @vindex MCNEMAR
2756 @cindex McNemar test
2757
2758 @display
2759      [ /MCNEMAR @var{var_list} [ WITH @var{var_list} [ (PAIRED) ]]]
2760 @end display
2761
2762 Use McNemar's test to analyse the significance of the difference between
2763 pairs of correlated proportions.
2764
2765 If the @code{WITH} keyword is omitted, then tests for all
2766 combinations of the listed variables are performed.
2767 If the @code{WITH} keyword is given, and the @code{(PAIRED)} keyword
2768 is also given, then the number of variables preceding @code{WITH}
2769 must be the same as the number following it.
2770 In this case, tests for each respective pair of variables are
2771 performed.
2772 If the @code{WITH} keyword is given, but the
2773 @code{(PAIRED)} keyword is omitted, then tests for each combination
2774 of variable preceding @code{WITH} against variable following
2775 @code{WITH} are performed.
2776
2777 The data in each variable must be dichotomous.  If there are more
2778 than two distinct variables an error will occur and the test will
2779 not be run.
2780
2781 @node MEDIAN
2782 @subsection Median Test
2783 @vindex MEDIAN
2784 @cindex Median test
2785
2786 @display
2787      [ /MEDIAN [(@var{value})] = @var{var_list} BY @var{variable} (@var{value1}, @var{value2}) ]
2788 @end display
2789
2790 The median test is used to test whether independent samples come from
2791 populations with a common median.
2792 The median of the populations against which the samples are to be tested
2793 may be given in parentheses immediately after the
2794 @subcmd{/MEDIAN} subcommand.  If it is not given, the median is imputed from the
2795 union of all the samples.
2796
2797 The variables of the samples to be tested should immediately follow the @samp{=} sign. The
2798 keyword @code{BY} must come next, and then the grouping variable.  Two values
2799 in parentheses should follow.  If the first value is greater than the second,
2800 then a 2 sample test is performed using these two values to determine the groups.
2801 If however, the first variable is less than the second, then a @i{k} sample test is
2802 conducted and the group values used are all values encountered which lie in the
2803 range [@var{value1},@var{value2}].
2804
2805
2806 @node RUNS
2807 @subsection Runs Test
2808 @vindex RUNS
2809 @cindex runs test
2810
2811 @display
2812      [ /RUNS (@{MEAN, MEDIAN, MODE, @var{value}@})  = @var{var_list} ]
2813 @end display
2814
2815 The @subcmd{/RUNS} subcommand tests whether a data sequence is randomly ordered.
2816
2817 It works by examining the number of times a variable's value crosses a given threshold.
2818 The desired threshold must be specified within parentheses.
2819 It may either be specified as a number or as one of @subcmd{MEAN}, @subcmd{MEDIAN} or @subcmd{MODE}.
2820 Following the threshold specification comes the list of variables whose values are to be
2821 tested.
2822
2823 The subcommand shows the number of runs, the asymptotic significance based on the
2824 length of the data.
2825
2826 @node SIGN
2827 @subsection Sign Test
2828 @vindex SIGN
2829 @cindex sign test
2830
2831 @display
2832      [ /SIGN @var{var_list} [ WITH @var{var_list} [ (PAIRED) ]]]
2833 @end display
2834
2835 The @subcmd{/SIGN} subcommand tests for differences between medians of the
2836 variables listed.
2837 The test does not make any assumptions about the
2838 distribution of the data.
2839
2840 If the @code{WITH} keyword is omitted, then tests for all
2841 combinations of the listed variables are performed.
2842 If the @code{WITH} keyword is given, and the @code{(PAIRED)} keyword
2843 is also given, then the number of variables preceding @code{WITH}
2844 must be the same as the number following it.
2845 In this case, tests for each respective pair of variables are
2846 performed.
2847 If the @code{WITH} keyword is given, but the
2848 @code{(PAIRED)} keyword is omitted, then tests for each combination
2849 of variable preceding @code{WITH} against variable following
2850 @code{WITH} are performed.
2851
2852 @node WILCOXON
2853 @subsection Wilcoxon Matched Pairs Signed Ranks Test
2854 @vindex WILCOXON
2855 @cindex wilcoxon matched pairs signed ranks test
2856
2857 @display
2858      [ /WILCOXON @var{var_list} [ WITH @var{var_list} [ (PAIRED) ]]]
2859 @end display
2860
2861 The @subcmd{/WILCOXON} subcommand tests for differences between medians of the
2862 variables listed.
2863 The test does not make any assumptions about the variances of the samples.
2864 It does however assume that the distribution is symmetrical.
2865
2866 If the @subcmd{WITH} keyword is omitted, then tests for all
2867 combinations of the listed variables are performed.
2868 If the @subcmd{WITH} keyword is given, and the @subcmd{(PAIRED)} keyword
2869 is also given, then the number of variables preceding @subcmd{WITH}
2870 must be the same as the number following it.
2871 In this case, tests for each respective pair of variables are
2872 performed.
2873 If the @subcmd{WITH} keyword is given, but the
2874 @subcmd{(PAIRED)} keyword is omitted, then tests for each combination
2875 of variable preceding @subcmd{WITH} against variable following
2876 @subcmd{WITH} are performed.
2877
2878 @node T-TEST
2879 @section T-TEST
2880
2881 @vindex T-TEST
2882
2883 @display
2884 T-TEST
2885         /MISSING=@{ANALYSIS,LISTWISE@} @{EXCLUDE,INCLUDE@}
2886         /CRITERIA=CI(@var{confidence})
2887
2888
2889 (One Sample mode.)
2890         TESTVAL=@var{test_value}
2891         /VARIABLES=@var{var_list}
2892
2893
2894 (Independent Samples mode.)
2895         GROUPS=var(@var{value1} [, @var{value2}])
2896         /VARIABLES=@var{var_list}
2897
2898
2899 (Paired Samples mode.)
2900         PAIRS=@var{var_list} [WITH @var{var_list} [(PAIRED)] ]
2901
2902 @end display
2903
2904
2905 The @cmd{T-TEST} procedure outputs tables used in testing hypotheses about
2906 means.
2907 It operates in one of three modes:
2908 @itemize
2909 @item One Sample mode.
2910 @item Independent Groups mode.
2911 @item Paired mode.
2912 @end itemize
2913
2914 @noindent
2915 Each of these modes are described in more detail below.
2916 There are two optional subcommands which are common to all modes.
2917
2918 The @cmd{/CRITERIA} subcommand tells @pspp{} the confidence interval used
2919 in the tests.  The default value is 0.95.
2920
2921
2922 The @cmd{MISSING} subcommand determines the handling of missing
2923 variables.
2924 If @subcmd{INCLUDE} is set, then user-missing values are included in the
2925 calculations, but system-missing values are not.
2926 If @subcmd{EXCLUDE} is set, which is the default, user-missing
2927 values are excluded as well as system-missing values.
2928 This is the default.
2929
2930 If @subcmd{LISTWISE} is set, then the entire case is excluded from analysis
2931 whenever any variable  specified in the @subcmd{/VARIABLES}, @subcmd{/PAIRS} or
2932 @subcmd{/GROUPS} subcommands contains a missing value.
2933 If @subcmd{ANALYSIS} is set, then missing values are excluded only in the analysis for
2934 which they would be needed. This is the default.
2935
2936
2937 @menu
2938 * One Sample Mode::             Testing against a hypothesized mean
2939 * Independent Samples Mode::    Testing two independent groups for equal mean
2940 * Paired Samples Mode::         Testing two interdependent groups for equal mean
2941 @end menu
2942
2943 @node One Sample Mode
2944 @subsection One Sample Mode
2945
2946 The @subcmd{TESTVAL} subcommand invokes the One Sample mode.
2947 This mode is used to test a population mean against a hypothesized
2948 mean.
2949 The value given to the @subcmd{TESTVAL} subcommand is the value against
2950 which you wish to test.
2951 In this mode, you must also use the @subcmd{/VARIABLES} subcommand to
2952 tell @pspp{} which variables you wish to test.
2953
2954 @subsubsection Example - One Sample T-test
2955
2956 A researcher wishes to know whether the weight of persons in a population
2957 is different from the national average.
2958 The samples are drawn from the population under investigation and recorded
2959 in the file @file{physiology.sav}.
2960 From the Department of Health, she
2961 knows that the national average weight of healthy adults is 76.8kg.
2962 Accordingly the @subcmd{TESTVAL} is set to 76.8.
2963 The null hypothesis therefore is that the mean average weight of the
2964 population from which the sample was drawn is 76.8kg.
2965
2966 As previously noted (@pxref{Identifying incorrect data}), one
2967 sample in the dataset contains a weight value
2968 which is clearly incorrect.  So this is excluded from the analysis
2969 using the @cmd{SELECT} command.
2970
2971 @float Example, one-sample-t:ex
2972 @psppsyntax {one-sample-t.sps}
2973 @caption {Running a one sample T-Test after excluding all non-positive values}
2974 @end float
2975
2976 @float Screenshot, one-sample-t:scr
2977 @psppimage {one-sample-t}
2978 @caption {Using the One Sample T-Test dialog box to test @exvar{weight} for a mean of 76.8kg}
2979 @end float
2980
2981
2982 @ref{one-sample-t:res} shows that the mean of our sample differs from the test value
2983 by -1.40kg.  However the significance is very high (0.610).  So one cannot
2984 reject the null hypothesis, and must conclude there is not enough evidence
2985 to suggest that the mean weight of the persons in our population is different
2986 from 76.8kg.
2987
2988 @float Results, one-sample-t:res
2989 @psppoutput {one-sample-t}
2990 @caption {The results of a one sample T-test of @exvar{weight} using a test value of 76.8kg}
2991 @end float
2992
2993 @node Independent Samples Mode
2994 @subsection Independent Samples Mode
2995
2996 The @subcmd{GROUPS} subcommand invokes Independent Samples mode or
2997 `Groups' mode.
2998 This mode is used to test whether two groups of values have the
2999 same population mean.
3000 In this mode, you must also use the @subcmd{/VARIABLES} subcommand to
3001 tell @pspp{} the dependent variables you wish to test.
3002
3003 The variable given in the @subcmd{GROUPS} subcommand is the independent
3004 variable which determines to which group the samples belong.
3005 The values in parentheses are the specific values of the independent
3006 variable for each group.
3007 If the parentheses are omitted and no values are given, the default values
3008 of 1.0 and 2.0 are assumed.
3009
3010 If the independent variable is numeric,
3011 it is acceptable to specify only one value inside the parentheses.
3012 If you do this, cases where the independent variable is
3013 greater than or equal to this value belong to the first group, and cases
3014 less than this value belong to the second group.
3015 When using this form of the @subcmd{GROUPS} subcommand, missing values in
3016 the independent variable are excluded on a listwise basis, regardless
3017 of whether @subcmd{/MISSING=LISTWISE} was specified.
3018
3019 @subsubsection Example - Independent Samples T-test
3020
3021 A researcher wishes to know whether within a population, adult males
3022 are taller than adult females.
3023 The samples are drawn from the population under investigation and recorded
3024 in the file @file{physiology.sav}.
3025
3026 As previously noted (@pxref{Identifying incorrect data}), one
3027 sample in the dataset contains a height value
3028 which is clearly incorrect.  So this is excluded from the analysis
3029 using the @cmd{SELECT} command.
3030
3031
3032 @float Example, indepdendent-samples-t:ex
3033 @psppsyntax {independent-samples-t.sps}
3034 @caption {Running a independent samples T-Test after excluding all observations less than 200kg}
3035 @end float
3036
3037
3038 The null hypothesis is that both males and females are on average
3039 of equal height.
3040
3041 @float Screenshot, independent-samples-t:scr
3042 @psppimage {independent-samples-t}
3043 @caption {Using the Independent Sample T-test dialog, to test for differences of @exvar{height} between values of @exvar{sex}}
3044 @end float
3045
3046
3047 In this case, the grouping variable is @exvar{sex}, so this is entered
3048 as the variable for the @subcmd{GROUP} subcommand.  The group values are  0 (male) and
3049 1 (female).
3050
3051 If you are running the proceedure using syntax, then you need to enter
3052 the values corresponding to each group within parentheses.
3053 If you are using the graphic user interface, then you have to open
3054 the ``Define Groups'' dialog box and enter the values corresponding
3055 to each group as shown in @ref{define-groups-t:scr}.  If, as in this case, the dataset has defined value
3056 labels for the group variable, then you can enter them by label
3057 or by value.
3058
3059 @float Screenshot, define-groups-t:scr
3060 @psppimage {define-groups-t}
3061 @caption {Setting the values of the grouping variable for an Independent Samples T-test}
3062 @end float
3063
3064 From @ref{independent-samples-t:res}, one can clearly see that the @emph{sample} mean height
3065 is greater for males than for females.  However in order to see if this
3066 is a significant result, one must consult the T-Test table.
3067
3068 The T-Test table contains two rows; one for use if the variance of the samples
3069 in each group may be safely assumed to be equal, and the second row
3070 if the variances in each group may not be safely assumed to be equal.
3071
3072 In this case however, both rows show a 2-tailed significance less than 0.001 and
3073 one must therefore reject the null hypothesis and conclude that within
3074 the population the mean height of males and of females are unequal.
3075
3076 @float Result, independent-samples-t:res
3077 @psppoutput {independent-samples-t}
3078 @caption {The results of an independent samples T-test of @exvar{height} by @exvar{sex}}
3079 @end float
3080
3081 @node Paired Samples Mode
3082 @subsection Paired Samples Mode
3083
3084 The @cmd{PAIRS} subcommand introduces Paired Samples mode.
3085 Use this mode when repeated measures have been taken from the same
3086 samples.
3087 If the @subcmd{WITH} keyword is omitted, then tables for all
3088 combinations of variables given in the @cmd{PAIRS} subcommand are
3089 generated.
3090 If the @subcmd{WITH} keyword is given, and the @subcmd{(PAIRED)} keyword
3091 is also given, then the number of variables preceding @subcmd{WITH}
3092 must be the same as the number following it.
3093 In this case, tables for each respective pair of variables are
3094 generated.
3095 In the event that the @subcmd{WITH} keyword is given, but the
3096 @subcmd{(PAIRED)} keyword is omitted, then tables for each combination
3097 of variable preceding @subcmd{WITH} against variable following
3098 @subcmd{WITH} are generated.
3099
3100
3101 @node ONEWAY
3102 @section ONEWAY
3103
3104 @vindex ONEWAY
3105 @cindex analysis of variance
3106 @cindex ANOVA
3107
3108 @display
3109 ONEWAY
3110         [/VARIABLES = ] @var{var_list} BY @var{var}
3111         /MISSING=@{ANALYSIS,LISTWISE@} @{EXCLUDE,INCLUDE@}
3112         /CONTRAST= @var{value1} [, @var{value2}] ... [,@var{valueN}]
3113         /STATISTICS=@{DESCRIPTIVES,HOMOGENEITY@}
3114         /POSTHOC=@{BONFERRONI, GH, LSD, SCHEFFE, SIDAK, TUKEY, ALPHA ([@var{value}])@}
3115 @end display
3116
3117 The @cmd{ONEWAY} procedure performs a one-way analysis of variance of
3118 variables factored by a single independent variable.
3119 It is used to compare the means of a population
3120 divided into more than two groups.
3121
3122 The dependent variables to be analysed should be given in the @subcmd{VARIABLES}
3123 subcommand.
3124 The list of variables must be followed by the @subcmd{BY} keyword and
3125 the name of the independent (or factor) variable.
3126
3127 You can use the @subcmd{STATISTICS} subcommand to tell @pspp{} to display
3128 ancillary information.  The options accepted are:
3129 @itemize
3130 @item DESCRIPTIVES
3131 Displays descriptive statistics about the groups factored by the independent
3132 variable.
3133 @item HOMOGENEITY
3134 Displays the Levene test of Homogeneity of Variance for the
3135 variables and their groups.
3136 @end itemize
3137
3138 The @subcmd{CONTRAST} subcommand is used when you anticipate certain
3139 differences between the groups.
3140 The subcommand must be followed by a list of numerals which are the
3141 coefficients of the groups to be tested.
3142 The number of coefficients must correspond to the number of distinct
3143 groups (or values of the independent variable).
3144 If the total sum of the coefficients are not zero, then @pspp{} will
3145 display a warning, but will proceed with the analysis.
3146 The @subcmd{CONTRAST} subcommand may be given up to 10 times in order
3147 to specify different contrast tests.
3148 The @subcmd{MISSING} subcommand defines how missing values are handled.
3149 If @subcmd{LISTWISE} is specified then cases which have missing values for
3150 the independent variable or any dependent variable are ignored.
3151 If @subcmd{ANALYSIS} is specified, then cases are ignored if the independent
3152 variable is missing or if the dependent variable currently being
3153 analysed is missing.  The default is @subcmd{ANALYSIS}.
3154 A setting of @subcmd{EXCLUDE} means that variables whose values are
3155 user-missing are to be excluded from the analysis. A setting of
3156 @subcmd{INCLUDE} means they are to be included.  The default is @subcmd{EXCLUDE}.
3157
3158 Using the @code{POSTHOC} subcommand you can perform multiple
3159 pairwise comparisons on the data. The following comparison methods
3160 are available:
3161 @itemize
3162 @item @subcmd{LSD}
3163 Least Significant Difference.
3164 @item @subcmd{TUKEY}
3165 Tukey Honestly Significant Difference.
3166 @item @subcmd{BONFERRONI}
3167 Bonferroni test.
3168 @item @subcmd{SCHEFFE}
3169 Scheff@'e's test.
3170 @item @subcmd{SIDAK}
3171 Sidak test.
3172 @item @subcmd{GH}
3173 The Games-Howell test.
3174 @end itemize
3175
3176 @noindent
3177 Use the optional syntax @code{ALPHA(@var{value})} to indicate that
3178 @cmd{ONEWAY} should perform the posthoc tests at a confidence level of
3179 @var{value}.  If @code{ALPHA(@var{value})} is not specified, then the
3180 confidence level used is 0.05.
3181
3182 @node QUICK CLUSTER
3183 @section QUICK CLUSTER
3184 @vindex QUICK CLUSTER
3185
3186 @cindex K-means clustering
3187 @cindex clustering
3188
3189 @display
3190 QUICK CLUSTER @var{var_list}
3191       [/CRITERIA=CLUSTERS(@var{k}) [MXITER(@var{max_iter})] CONVERGE(@var{epsilon}) [NOINITIAL]]
3192       [/MISSING=@{EXCLUDE,INCLUDE@} @{LISTWISE, PAIRWISE@}]
3193       [/PRINT=@{INITIAL@} @{CLUSTER@}]
3194       [/SAVE[=[CLUSTER[(@var{membership_var})]] [DISTANCE[(@var{distance_var})]]]
3195 @end display
3196
3197 The @cmd{QUICK CLUSTER} command performs k-means clustering on the
3198 dataset.  This is useful when you wish to allocate cases into clusters
3199 of similar values and you already know the number of clusters.
3200
3201 The minimum specification is @samp{QUICK CLUSTER} followed by the names
3202 of the variables which contain the cluster data.  Normally you will also
3203 want to specify @subcmd{/CRITERIA=CLUSTERS(@var{k})} where @var{k} is the
3204 number of clusters.  If this is not specified, then @var{k} defaults to 2.
3205
3206 If you use @subcmd{/CRITERIA=NOINITIAL} then a naive algorithm to select
3207 the initial clusters is used.   This will provide for faster execution but
3208 less well separated initial clusters and hence possibly an inferior final
3209 result.
3210
3211
3212 @cmd{QUICK CLUSTER} uses an iterative algorithm to select the clusters centers.
3213 The subcommand  @subcmd{/CRITERIA=MXITER(@var{max_iter})} sets the maximum number of iterations.
3214 During classification, @pspp{} will continue iterating until until @var{max_iter}
3215 iterations have been done or the convergence criterion (see below) is fulfilled.
3216 The default value of @var{max_iter} is 2.
3217
3218 If however, you specify @subcmd{/CRITERIA=NOUPDATE} then after selecting the initial centers,
3219 no further update to the cluster centers is done.  In this case, @var{max_iter}, if specified.
3220 is ignored.
3221
3222 The subcommand  @subcmd{/CRITERIA=CONVERGE(@var{epsilon})} is used
3223 to set the convergence criterion.  The value of convergence criterion is  @var{epsilon}
3224 times the minimum distance between the @emph{initial} cluster centers.  Iteration stops when
3225 the  mean cluster distance between  one iteration and the next
3226 is less than the convergence criterion.  The default value of @var{epsilon} is zero.
3227
3228 The @subcmd{MISSING} subcommand determines the handling of missing variables.
3229 If @subcmd{INCLUDE} is set, then user-missing values are considered at their face
3230 value and not as missing values.
3231 If @subcmd{EXCLUDE} is set, which is the default, user-missing
3232 values are excluded as well as system-missing values.
3233
3234 If @subcmd{LISTWISE} is set, then the entire case is excluded from the analysis
3235 whenever any of the clustering variables contains a missing value.
3236 If @subcmd{PAIRWISE} is set, then a case is considered missing only if all the
3237 clustering variables contain missing values.  Otherwise it is clustered
3238 on the basis of the non-missing values.
3239 The default is @subcmd{LISTWISE}.
3240
3241 The @subcmd{PRINT} subcommand requests additional output to be printed.
3242 If @subcmd{INITIAL} is set, then the initial cluster memberships will
3243 be printed.
3244 If @subcmd{CLUSTER} is set, the cluster memberships of the individual
3245 cases are displayed (potentially generating lengthy output).
3246
3247 You can specify the subcommand @subcmd{SAVE} to ask that each case's cluster membership
3248 and the euclidean distance between the case and its cluster center be saved to
3249 a new variable in the active dataset.   To save the cluster membership use the
3250 @subcmd{CLUSTER} keyword and to save the distance use the @subcmd{DISTANCE} keyword.
3251 Each keyword may optionally be followed by a variable name in parentheses to specify
3252 the new variable which is to contain the saved parameter.  If no variable name is specified,
3253 then PSPP will create one.
3254
3255 @node RANK
3256 @section RANK
3257
3258 @vindex RANK
3259 @display
3260 RANK
3261         [VARIABLES=] @var{var_list} [@{A,D@}] [BY @var{var_list}]
3262         /TIES=@{MEAN,LOW,HIGH,CONDENSE@}
3263         /FRACTION=@{BLOM,TUKEY,VW,RANKIT@}
3264         /PRINT[=@{YES,NO@}
3265         /MISSING=@{EXCLUDE,INCLUDE@}
3266
3267         /RANK [INTO @var{var_list}]
3268         /NTILES(k) [INTO @var{var_list}]
3269         /NORMAL [INTO @var{var_list}]
3270         /PERCENT [INTO @var{var_list}]
3271         /RFRACTION [INTO @var{var_list}]
3272         /PROPORTION [INTO @var{var_list}]
3273         /N [INTO @var{var_list}]
3274         /SAVAGE [INTO @var{var_list}]
3275 @end display
3276
3277 The @cmd{RANK} command ranks variables and stores the results into new
3278 variables.
3279
3280 The @subcmd{VARIABLES} subcommand, which is mandatory, specifies one or
3281 more variables whose values are to be ranked.
3282 After each variable, @samp{A} or @samp{D} may appear, indicating that
3283 the variable is to be ranked in ascending or descending order.
3284 Ascending is the default.
3285 If a @subcmd{BY} keyword appears, it should be followed by a list of variables
3286 which are to serve as group variables.
3287 In this case, the cases are gathered into groups, and ranks calculated
3288 for each group.
3289
3290 The @subcmd{TIES} subcommand specifies how tied values are to be treated.  The
3291 default is to take the mean value of all the tied cases.
3292
3293 The @subcmd{FRACTION} subcommand specifies how proportional ranks are to be
3294 calculated.  This only has any effect if @subcmd{NORMAL} or @subcmd{PROPORTIONAL} rank
3295 functions are requested.
3296
3297 The @subcmd{PRINT} subcommand may be used to specify that a summary of the rank
3298 variables created should appear in the output.
3299
3300 The function subcommands are @subcmd{RANK}, @subcmd{NTILES}, @subcmd{NORMAL}, @subcmd{PERCENT}, @subcmd{RFRACTION},
3301 @subcmd{PROPORTION} and @subcmd{SAVAGE}.  Any number of function subcommands may appear.
3302 If none are given, then the default is RANK.
3303 The @subcmd{NTILES} subcommand must take an integer specifying the number of
3304 partitions into which values should be ranked.
3305 Each subcommand may be followed by the @subcmd{INTO} keyword and a list of
3306 variables which are the variables to be created and receive the rank
3307 scores.  There may be as many variables specified as there are
3308 variables named on the @subcmd{VARIABLES} subcommand.  If fewer are specified,
3309 then the variable names are automatically created.
3310
3311 The @subcmd{MISSING} subcommand determines how user missing values are to be
3312 treated. A setting of @subcmd{EXCLUDE} means that variables whose values are
3313 user-missing are to be excluded from the rank scores. A setting of
3314 @subcmd{INCLUDE} means they are to be included.  The default is @subcmd{EXCLUDE}.
3315
3316 @include regression.texi
3317
3318
3319 @node RELIABILITY
3320 @section RELIABILITY
3321
3322 @vindex RELIABILITY
3323 @display
3324 RELIABILITY
3325         /VARIABLES=@var{var_list}
3326         /SCALE (@var{name}) = @{@var{var_list}, ALL@}
3327         /MODEL=@{ALPHA, SPLIT[(@var{n})]@}
3328         /SUMMARY=@{TOTAL,ALL@}
3329         /MISSING=@{EXCLUDE,INCLUDE@}
3330 @end display
3331
3332 @cindex Cronbach's Alpha
3333 The @cmd{RELIABILITY} command performs reliability analysis on the data.
3334
3335 The @subcmd{VARIABLES} subcommand is required. It determines the set of variables
3336 upon which analysis is to be performed.
3337
3338 The @subcmd{SCALE} subcommand determines the  variables for which
3339 reliability is to be calculated.  If @subcmd{SCALE} is omitted, then analysis for
3340 all variables named in the @subcmd{VARIABLES} subcommand are used.
3341 Optionally, the @var{name} parameter may be specified to set a string name
3342 for the scale.
3343
3344 The @subcmd{MODEL} subcommand determines the type of analysis. If @subcmd{ALPHA} is specified,
3345 then Cronbach's Alpha is calculated for the scale.  If the model is @subcmd{SPLIT},
3346 then the variables  are divided into 2 subsets.  An optional parameter
3347 @var{n} may be given, to specify how many variables to be in the first subset.
3348 If @var{n} is omitted, then it defaults to one half of the variables in the
3349 scale, or one half minus one if there are an odd number of variables.
3350 The default model is @subcmd{ALPHA}.
3351
3352 By default, any cases with user missing, or system missing values for
3353 any variables given in the @subcmd{VARIABLES} subcommand are omitted
3354 from the analysis.  The @subcmd{MISSING} subcommand determines whether
3355 user missing values are included or excluded in the analysis.
3356
3357 The @subcmd{SUMMARY} subcommand determines the type of summary analysis to be performed.
3358 Currently there is only one type: @subcmd{SUMMARY=TOTAL}, which displays per-item
3359 analysis tested against the totals.
3360
3361 @subsection Example - Reliability
3362
3363 Before analysing the results of a survey -- particularly for a multiple choice survey --
3364 it is desireable to know whether the respondents have considered their answers
3365 or simply provided random answers.
3366
3367 In the following example the survey results from the file @file{hotel.sav} are used.
3368 All five survey questions are included in the reliability analysis.
3369 However, before running the analysis, the data must be preprocessed.
3370 An examination of the survey questions reveals that two questions, @i{viz:} v3 and v5
3371 are negatively worded, whereas the others are positively worded.
3372 All questions must be based upon the same scale for the analysis to be meaningful.
3373 One could use the @cmd{RECODE} command (@pxref{RECODE}), however a simpler way is
3374 to use @cmd{COMPUTE} (@pxref{COMPUTE}) and this is what is done in @ref{reliability:ex}.
3375
3376 @float Example, reliability:ex
3377 @psppsyntax {reliability.sps}
3378 @caption {Investigating the reliability of survey responses}
3379 @end float
3380
3381 In this case, all variables in the data set are used.  So we can use the special
3382 keyword @samp{ALL} (@pxref{BNF}).
3383
3384 @float Screenshot, reliability:src
3385 @psppimage {reliability}
3386 @caption {Reliability dialog box with all variables selected}
3387 @end float
3388
3389 @ref{reliability:res} shows that Cronbach's Alpha is 0.11  which is a value normally considered too
3390 low to indicate consistency within the data.  This is possibly due to the small number of
3391 survey questions.  The survey should be redesigned before serious use of the results are
3392 applied.
3393
3394 @float Result, reliability:res
3395 @psppoutput {reliability}
3396 @caption {The results of the reliability command on @file{hotel.sav}}
3397 @end float
3398
3399
3400 @node ROC
3401 @section ROC
3402
3403 @vindex ROC
3404 @cindex Receiver Operating Characteristic
3405 @cindex Area under curve
3406
3407 @display
3408 ROC     @var{var_list} BY @var{state_var} (@var{state_value})
3409         /PLOT = @{ CURVE [(REFERENCE)], NONE @}
3410         /PRINT = [ SE ] [ COORDINATES ]
3411         /CRITERIA = [ CUTOFF(@{INCLUDE,EXCLUDE@}) ]
3412           [ TESTPOS (@{LARGE,SMALL@}) ]
3413           [ CI (@var{confidence}) ]
3414           [ DISTRIBUTION (@{FREE, NEGEXPO @}) ]
3415         /MISSING=@{EXCLUDE,INCLUDE@}
3416 @end display
3417
3418
3419 The @cmd{ROC} command is used to plot the receiver operating characteristic curve
3420 of a dataset, and to estimate the area under the curve.
3421 This is useful for analysing the efficacy of a variable as a predictor of a state of nature.
3422
3423 The mandatory @var{var_list} is the list of predictor variables.
3424 The variable @var{state_var} is the variable whose values represent the actual states,
3425 and @var{state_value} is the value of this variable which represents the positive state.
3426
3427 The optional subcommand @subcmd{PLOT} is used to determine if and how the @subcmd{ROC} curve is drawn.
3428 The keyword @subcmd{CURVE} means that the @subcmd{ROC} curve should be drawn, and the optional keyword @subcmd{REFERENCE},
3429 which should be enclosed in parentheses, says that the diagonal reference line should be drawn.
3430 If the keyword @subcmd{NONE} is given, then no @subcmd{ROC} curve is drawn.
3431 By default, the curve is drawn with no reference line.
3432
3433 The optional subcommand @subcmd{PRINT} determines which additional
3434 tables should be printed.  Two additional tables are available.  The
3435 @subcmd{SE} keyword says that standard error of the area under the
3436 curve should be printed as well as the area itself.  In addition, a
3437 p-value for the null hypothesis that the area under the curve equals
3438 0.5 is printed.   The @subcmd{COORDINATES} keyword says that a
3439 table of coordinates of the @subcmd{ROC} curve should be printed.
3440
3441 The @subcmd{CRITERIA} subcommand has four optional parameters:
3442 @itemize @bullet
3443 @item The @subcmd{TESTPOS} parameter may be @subcmd{LARGE} or @subcmd{SMALL}.
3444 @subcmd{LARGE} is the default, and says that larger values in the predictor variables are to be
3445 considered positive.  @subcmd{SMALL} indicates that smaller values should be considered positive.
3446
3447 @item The @subcmd{CI} parameter specifies the confidence interval that should be printed.
3448 It has no effect if the @subcmd{SE} keyword in the @subcmd{PRINT} subcommand has not been given.
3449
3450 @item The @subcmd{DISTRIBUTION} parameter determines the method to be used when estimating the area
3451 under the curve.
3452 There are two possibilities, @i{viz}: @subcmd{FREE} and @subcmd{NEGEXPO}.
3453 The @subcmd{FREE} method uses a non-parametric estimate, and the @subcmd{NEGEXPO} method a bi-negative
3454 exponential distribution estimate.
3455 The @subcmd{NEGEXPO} method should only be used when the number of positive actual states is
3456 equal to the number of negative actual states.
3457 The default is @subcmd{FREE}.
3458
3459 @item The @subcmd{CUTOFF} parameter is for compatibility and is ignored.
3460 @end itemize
3461
3462 The @subcmd{MISSING} subcommand determines whether user missing values are to
3463 be included or excluded in the analysis.  The default behaviour is to
3464 exclude them.
3465 Cases are excluded on a listwise basis; if any of the variables in @var{var_list}
3466 or if the variable @var{state_var} is missing, then the entire case is
3467 excluded.
3468
3469 @c  LocalWords:  subcmd subcommand