spv-file-format: More detailed requirements for structure members.
[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 * FACTOR::                      Factor analysis and Principal Components analysis.
24 * GLM::                         Univariate Linear Models.
25 * LOGISTIC REGRESSION::         Bivariate Logistic Regression.
26 * MEANS::                       Average values and other statistics.
27 * NPAR TESTS::                  Nonparametric tests.
28 * T-TEST::                      Test hypotheses about means.
29 * ONEWAY::                      One way analysis of variance.
30 * QUICK CLUSTER::               K-Means clustering.
31 * RANK::                        Compute rank scores.
32 * REGRESSION::                  Linear regression.
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         /WRITE=@{NONE,CELLS,ALL@}
682         /FORMAT=@{TABLES,NOTABLES@}
683                 @{PIVOT,NOPIVOT@}
684                 @{AVALUE,DVALUE@}
685                 @{NOINDEX,INDEX@}
686                 @{BOX,NOBOX@}
687         /CELLS=@{COUNT,ROW,COLUMN,TOTAL,EXPECTED,RESIDUAL,SRESIDUAL,
688                 ASRESIDUAL,ALL,NONE@}
689         /COUNT=@{ASIS,CASE,CELL@}
690                @{ROUND,TRUNCATE@}
691         /STATISTICS=@{CHISQ,PHI,CC,LAMBDA,UC,BTAU,CTAU,RISK,GAMMA,D,
692                      KAPPA,ETA,CORR,ALL,NONE@}
693         /BARCHART
694
695 (Integer mode.)
696         /VARIABLES=@var{var_list} (@var{low},@var{high})@dots{}
697 @end display
698
699 The @cmd{CROSSTABS} procedure displays crosstabulation
700 tables requested by the user.  It can calculate several statistics for
701 each cell in the crosstabulation tables.  In addition, a number of
702 statistics can be calculated for each table itself.
703
704 The @subcmd{TABLES} subcommand is used to specify the tables to be reported.  Any
705 number of dimensions is permitted, and any number of variables per
706 dimension is allowed.  The @subcmd{TABLES} subcommand may be repeated as many
707 times as needed.  This is the only required subcommand in @dfn{general
708 mode}.
709
710 Occasionally, one may want to invoke a special mode called @dfn{integer
711 mode}.  Normally, in general mode, @pspp{} automatically determines
712 what values occur in the data.  In integer mode, the user specifies the
713 range of values that the data assumes.  To invoke this mode, specify the
714 @subcmd{VARIABLES} subcommand, giving a range of data values in parentheses for
715 each variable to be used on the @subcmd{TABLES} subcommand.  Data values inside
716 the range are truncated to the nearest integer, then assigned to that
717 value.  If values occur outside this range, they are discarded.  When it
718 is present, the @subcmd{VARIABLES} subcommand must precede the @subcmd{TABLES}
719 subcommand.
720
721 In general mode, numeric and string variables may be specified on
722 TABLES.  In integer mode, only numeric variables are allowed.
723
724 The @subcmd{MISSING} subcommand determines the handling of user-missing values.
725 When set to @subcmd{TABLE}, the default, missing values are dropped on a table by
726 table basis.  When set to @subcmd{INCLUDE}, user-missing values are included in
727 tables and statistics.  When set to @subcmd{REPORT}, which is allowed only in
728 integer mode, user-missing values are included in tables but marked with
729 a footnote and excluded from statistical calculations.
730
731 Currently the @subcmd{WRITE} subcommand is ignored.
732
733 The @subcmd{FORMAT} subcommand controls the characteristics of the
734 crosstabulation tables to be displayed.  It has a number of possible
735 settings:
736
737 @itemize @w{}
738 @item
739 @subcmd{TABLES}, the default, causes crosstabulation tables to be output.
740 @subcmd{NOTABLES} suppresses them.
741
742 @item
743 @subcmd{PIVOT}, the default, causes each @subcmd{TABLES} subcommand to be displayed in a
744 pivot table format.  @subcmd{NOPIVOT} causes the old-style crosstabulation format
745 to be used.
746
747 @item
748 @subcmd{AVALUE}, the default, causes values to be sorted in ascending order.
749 @subcmd{DVALUE} asserts a descending sort order.
750
751 @item
752 @subcmd{INDEX} and @subcmd{NOINDEX} are currently ignored.
753
754 @item
755 @subcmd{BOX} and @subcmd{NOBOX} is currently ignored.
756 @end itemize
757
758 The @subcmd{CELLS} subcommand controls the contents of each cell in the displayed
759 crosstabulation table.  The possible settings are:
760
761 @table @asis
762 @item COUNT
763 Frequency count.
764 @item ROW
765 Row percent.
766 @item COLUMN
767 Column percent.
768 @item TOTAL
769 Table percent.
770 @item EXPECTED
771 Expected value.
772 @item RESIDUAL
773 Residual.
774 @item SRESIDUAL
775 Standardized residual.
776 @item ASRESIDUAL
777 Adjusted standardized residual.
778 @item ALL
779 All of the above.
780 @item NONE
781 Suppress cells entirely.
782 @end table
783
784 @samp{/CELLS} without any settings specified requests @subcmd{COUNT}, @subcmd{ROW},
785 @subcmd{COLUMN}, and @subcmd{TOTAL}.
786 If @subcmd{CELLS} is not specified at all then only @subcmd{COUNT}
787 is selected.
788
789 By default, crosstabulation and statistics use raw case weights,
790 without rounding.  Use the @subcmd{/COUNT} subcommand to perform
791 rounding: CASE rounds the weights of individual weights as cases are
792 read, CELL rounds the weights of cells within each crosstabulation
793 table after it has been constructed, and ASIS explicitly specifies the
794 default non-rounding behavior.  When rounding is requested, ROUND, the
795 default, rounds to the nearest integer and TRUNCATE rounds toward
796 zero.
797
798 The @subcmd{STATISTICS} subcommand selects statistics for computation:
799
800 @table @asis
801 @item CHISQ
802 @cindex chi-square
803
804 Pearson chi-square, likelihood ratio, Fisher's exact test, continuity
805 correction, linear-by-linear association.
806 @item PHI
807 Phi.
808 @item CC
809 Contingency coefficient.
810 @item LAMBDA
811 Lambda.
812 @item UC
813 Uncertainty coefficient.
814 @item BTAU
815 Tau-b.
816 @item CTAU
817 Tau-c.
818 @item RISK
819 Risk estimate.
820 @item GAMMA
821 Gamma.
822 @item D
823 Somers' D.
824 @item KAPPA
825 Cohen's Kappa.
826 @item ETA
827 Eta.
828 @item CORR
829 Spearman correlation, Pearson's r.
830 @item ALL
831 All of the above.
832 @item NONE
833 No statistics.
834 @end table
835
836 Selected statistics are only calculated when appropriate for the
837 statistic.  Certain statistics require tables of a particular size, and
838 some statistics are calculated only in integer mode.
839
840 @samp{/STATISTICS} without any settings selects CHISQ.  If the
841 @subcmd{STATISTICS} subcommand is not given, no statistics are calculated.
842
843 @cindex bar chart
844 The @samp{/BARCHART} subcommand produces a clustered bar chart for the first two
845 variables on each table.
846 If a table has more than two variables, the counts for the third and subsequent levels
847 are aggregated and the chart is produced as if there were only two variables.
848
849
850 @strong{Please note:} Currently the implementation of @cmd{CROSSTABS} has the
851 following limitations:
852
853 @itemize @bullet
854 @item
855 Significance of some symmetric and directional measures is not calculated.
856 @item
857 Asymptotic standard error is not calculated for
858 Goodman and Kruskal's tau or symmetric Somers' d.
859 @item
860 Approximate T is not calculated for symmetric uncertainty coefficient.
861 @end itemize
862
863 Fixes for any of these deficiencies would be welcomed.
864
865 @subsection Crosstabs Example
866
867 @cindex chi-square test of independence
868
869 A researcher wishes to know if, in an industry, a person's sex is related to
870 the person's occupation.  To investigate this, she has determined that the
871 @file{personnel.sav} is a representative, randomly selected sample of persons.
872 The researcher's null hypothesis is that a person's sex has no relation to a
873 person's occupation. She uses a chi-squared test of independence to investigate
874 the hypothesis.
875
876 @float Example, crosstabs:ex
877 @psppsyntax {crosstabs.sps}
878 @caption {Running crosstabs on the @exvar{sex} and @exvar{occupation} variables}
879 @end float
880
881 The syntax in @ref{crosstabs:ex} conducts a chi-squared test of independence.
882 The line @code{/tables = occupation by sex} indicates that @exvar{occupation}
883 and @exvar{sex} are the variables to be tabulated.  To do this using the @gui{}
884 you must place these variable names respectively in the @samp{Row} and
885 @samp{Column} fields as shown in @ref{crosstabs:scr}.
886
887 @float Screenshot, crosstabs:scr
888 @psppimage {crosstabs}
889 @caption {The Crosstabs dialog box with the @exvar{sex} and @exvar{occupation} variables selected}
890 @end float
891
892 Similarly, the @samp{Cells} button shows a dialog box to select the @code{count}
893 and @code{expected} options.  All other cell options can be deselected for this
894 test.
895
896 You would use the @samp{Format} and @samp{Statistics}  buttons to select options
897 for the @subcmd{FORMAT} and @subcmd{STATISTICS} subcommands.  In this example,
898 the @samp{Statistics} requires only the @samp{Chisq} option to be checked.  All
899 other options should be unchecked.  No special settings are required from the
900 @samp{Format} dialog.
901
902 As shown in @ref{crosstabs:res} @cmd{CROSSTABS} generates a contingency table
903 containing the observed count and the expected count of each sex and each
904 occupation.  The expected count is the count which would be observed if the
905 null hypothesis were true.
906
907 The significance of the Pearson Chi-Square value is very much larger than the
908 normally accepted value of 0.05 and so one cannot reject the null hypothesis.
909 Thus the researcher must conclude that a person's sex has no relation to the
910 person's occupation.
911
912 @float Results, crosstabs:res
913 @psppoutput {crosstabs}
914 @caption {The results of a test of independence between @exvar{sex} and @exvar{occupation}}
915 @end float
916
917
918 @node FACTOR
919 @section FACTOR
920
921 @vindex FACTOR
922 @cindex factor analysis
923 @cindex principal components analysis
924 @cindex principal axis factoring
925 @cindex data reduction
926
927 @display
928 FACTOR  @{
929          VARIABLES=@var{var_list},
930          MATRIX IN (@{CORR,COV@}=@{*,@var{file_spec}@})
931         @}
932
933         [ /METHOD = @{CORRELATION, COVARIANCE@} ]
934
935         [ /ANALYSIS=@var{var_list} ]
936
937         [ /EXTRACTION=@{PC, PAF@}]
938
939         [ /ROTATION=@{VARIMAX, EQUAMAX, QUARTIMAX, PROMAX[(@var{k})], NOROTATE@}]
940
941         [ /PRINT=[INITIAL] [EXTRACTION] [ROTATION] [UNIVARIATE] [CORRELATION] [COVARIANCE] [DET] [KMO] [AIC] [SIG] [ALL] [DEFAULT] ]
942
943         [ /PLOT=[EIGEN] ]
944
945         [ /FORMAT=[SORT] [BLANK(@var{n})] [DEFAULT] ]
946
947         [ /CRITERIA=[FACTORS(@var{n})] [MINEIGEN(@var{l})] [ITERATE(@var{m})] [ECONVERGE (@var{delta})] [DEFAULT] ]
948
949         [ /MISSING=[@{LISTWISE, PAIRWISE@}] [@{INCLUDE, EXCLUDE@}] ]
950 @end display
951
952 The @cmd{FACTOR} command performs Factor Analysis or Principal Axis Factoring on a dataset.  It may be used to find
953 common factors in the data or for data reduction purposes.
954
955 The @subcmd{VARIABLES} subcommand is required (unless the @subcmd{MATRIX IN}
956 subcommand is used).
957 It lists the variables which are to partake in the analysis.  (The @subcmd{ANALYSIS}
958 subcommand may optionally further limit the variables that
959 participate; it is useful primarily in conjunction with @subcmd{MATRIX IN}.)
960
961 If @subcmd{MATRIX IN} instead of @subcmd{VARIABLES} is specified, then the analysis
962 is performed on a pre-prepared correlation or covariance matrix file instead of on
963 individual data cases.  Typically the matrix file will have been generated by
964 @cmd{MATRIX DATA} (@pxref{MATRIX DATA}) or provided by a third party.
965 If specified, @subcmd{MATRIX IN} must be followed by @samp{COV} or @samp{CORR},
966 then by @samp{=} and @var{file_spec} all in parentheses.
967 @var{file_spec} may either be an asterisk, which indicates the currently loaded
968 dataset, or it may be a file name to be loaded. @xref{MATRIX DATA}, for the expected
969 format of the file.
970
971 The @subcmd{/EXTRACTION} subcommand is used to specify the way in which factors
972 (components) are extracted from the data.
973 If @subcmd{PC} is specified, then Principal Components Analysis is used.
974 If @subcmd{PAF} is specified, then Principal Axis Factoring is
975 used. By default Principal Components Analysis is used.
976
977 The @subcmd{/ROTATION} subcommand is used to specify the method by which the
978 extracted solution is rotated.  Three orthogonal rotation methods are available:
979 @subcmd{VARIMAX} (which is the default), @subcmd{EQUAMAX}, and @subcmd{QUARTIMAX}.
980 There is one oblique rotation method, @i{viz}: @subcmd{PROMAX}.
981 Optionally you may enter the power of the promax rotation @var{k}, which must be enclosed in parentheses.
982 The default value of @var{k} is 5.
983 If you don't want any rotation to be performed, the word @subcmd{NOROTATE}
984 prevents the command from performing any rotation on the data.
985
986 The @subcmd{/METHOD} subcommand should be used to determine whether the
987 covariance matrix or the correlation matrix of the data is
988 to be analysed.  By default, the correlation matrix is analysed.
989
990 The @subcmd{/PRINT} subcommand may be used to select which features of the analysis are reported:
991
992 @itemize
993 @item @subcmd{UNIVARIATE}
994       A table of mean values, standard deviations and total weights are printed.
995 @item @subcmd{INITIAL}
996       Initial communalities and eigenvalues are printed.
997 @item @subcmd{EXTRACTION}
998       Extracted communalities and eigenvalues are printed.
999 @item @subcmd{ROTATION}
1000       Rotated communalities and eigenvalues are printed.
1001 @item @subcmd{CORRELATION}
1002       The correlation matrix is printed.
1003 @item @subcmd{COVARIANCE}
1004       The covariance matrix is printed.
1005 @item @subcmd{DET}
1006       The determinant of the correlation or covariance matrix is printed.
1007 @item @subcmd{AIC}
1008       The anti-image covariance and anti-image correlation matrices are printed.
1009 @item @subcmd{KMO}
1010       The Kaiser-Meyer-Olkin measure of sampling adequacy and the Bartlett test of sphericity is printed.
1011 @item @subcmd{SIG}
1012       The significance of the elements of correlation matrix is printed.
1013 @item @subcmd{ALL}
1014       All of the above are printed.
1015 @item @subcmd{DEFAULT}
1016       Identical to @subcmd{INITIAL} and @subcmd{EXTRACTION}.
1017 @end itemize
1018
1019 If @subcmd{/PLOT=EIGEN} is given, then a ``Scree'' plot of the eigenvalues is
1020 printed.  This can be useful for visualizing the factors and deciding
1021 which factors (components) should be retained.
1022
1023 The @subcmd{/FORMAT} subcommand determined how data are to be
1024 displayed in loading matrices.  If @subcmd{SORT} is specified, then
1025 the variables are sorted in descending order of significance.  If
1026 @subcmd{BLANK(@var{n})} is specified, then coefficients whose absolute
1027 value is less than @var{n} are not printed.  If the keyword
1028 @subcmd{DEFAULT} is specified, or if no @subcmd{/FORMAT} subcommand is
1029 specified, then no sorting is performed, and all coefficients are printed.
1030
1031 You can use the @subcmd{/CRITERIA} subcommand to specify how the number of
1032 extracted factors (components) are chosen.  If @subcmd{FACTORS(@var{n})} is
1033 specified, where @var{n} is an integer, then @var{n} factors are
1034 extracted.  Otherwise, the @subcmd{MINEIGEN} setting is used.
1035 @subcmd{MINEIGEN(@var{l})} requests that all factors whose eigenvalues
1036 are greater than or equal to @var{l} are extracted. The default value
1037 of @var{l} is 1. The @subcmd{ECONVERGE} setting has effect only when
1038 using iterative algorithms for factor extraction (such as Principal Axis
1039 Factoring).  @subcmd{ECONVERGE(@var{delta})} specifies that
1040 iteration should cease when the maximum absolute value of the
1041 communality estimate between one iteration and the previous is less
1042 than @var{delta}. The default value of @var{delta} is 0.001.
1043
1044 The @subcmd{ITERATE(@var{m})} may appear any number of times and is
1045 used for two different purposes. It is used to set the maximum number
1046 of iterations (@var{m}) for convergence and also to set the maximum
1047 number of iterations for rotation.
1048 Whether it affects convergence or rotation depends upon which
1049 subcommand follows the @subcmd{ITERATE} subcommand.
1050 If @subcmd{EXTRACTION} follows, it affects convergence.
1051 If @subcmd{ROTATION} follows, it affects rotation.
1052 If neither @subcmd{ROTATION} nor @subcmd{EXTRACTION} follow a
1053 @subcmd{ITERATE} subcommand, then the entire subcommand is ignored.
1054 The default value of @var{m} is 25.
1055
1056 The @cmd{MISSING} subcommand determines the handling of missing
1057 variables.  If @subcmd{INCLUDE} is set, then user-missing values are
1058 included in the calculations, but system-missing values are not.
1059 If @subcmd{EXCLUDE} is set, which is the default, user-missing
1060 values are excluded as well as system-missing values.  This is the
1061 default. If @subcmd{LISTWISE} is set, then the entire case is excluded
1062 from analysis whenever any variable  specified in the @cmd{VARIABLES}
1063 subcommand contains a missing value.
1064
1065 If @subcmd{PAIRWISE} is set, then a case is considered missing only if
1066 either of the values  for the particular coefficient are missing.
1067 The default is @subcmd{LISTWISE}.
1068
1069 @node GLM
1070 @section GLM
1071
1072 @vindex GLM
1073 @cindex univariate analysis of variance
1074 @cindex fixed effects
1075 @cindex factorial anova
1076 @cindex analysis of variance
1077 @cindex ANOVA
1078
1079
1080 @display
1081 GLM @var{dependent_vars} BY @var{fixed_factors}
1082      [/METHOD = SSTYPE(@var{type})]
1083      [/DESIGN = @var{interaction_0} [@var{interaction_1} [... @var{interaction_n}]]]
1084      [/INTERCEPT = @{INCLUDE|EXCLUDE@}]
1085      [/MISSING = @{INCLUDE|EXCLUDE@}]
1086 @end display
1087
1088 The @cmd{GLM} procedure can be used for fixed effects factorial Anova.
1089
1090 The @var{dependent_vars} are the variables to be analysed.
1091 You may analyse several variables in the same command in which case they should all
1092 appear before the @code{BY} keyword.
1093
1094 The @var{fixed_factors} list must be one or more categorical variables.  Normally it
1095 does not make sense to enter a scalar variable in the @var{fixed_factors} and doing
1096 so may cause @pspp{} to do a lot of unnecessary processing.
1097
1098 The @subcmd{METHOD} subcommand is used to change the method for producing the sums of
1099 squares.  Available values of @var{type} are 1, 2 and 3.  The default is type 3.
1100
1101 You may specify a custom design using the @subcmd{DESIGN} subcommand.
1102 The design comprises a list of interactions where each interaction is a
1103 list of variables separated by a @samp{*}.  For example the command
1104 @display
1105 GLM subject BY sex age_group race
1106     /DESIGN = age_group sex group age_group*sex age_group*race
1107 @end display
1108 @noindent specifies the model @math{subject = age_group + sex + race + age_group*sex + age_group*race}.
1109 If no @subcmd{DESIGN} subcommand is specified, then the default is all possible combinations
1110 of the fixed factors.  That is to say
1111 @display
1112 GLM subject BY sex age_group race
1113 @end display
1114 implies the model
1115 @math{subject = age_group + sex + race + age_group*sex + age_group*race + sex*race + age_group*sex*race}.
1116
1117
1118 The @subcmd{MISSING} subcommand determines the handling of missing
1119 variables.
1120 If @subcmd{INCLUDE} is set then, for the purposes of GLM analysis,
1121 only system-missing values are considered
1122 to be missing; user-missing values are not regarded as missing.
1123 If @subcmd{EXCLUDE} is set, which is the default, then user-missing
1124 values are considered to be missing as well as system-missing values.
1125 A case for which any dependent variable or any factor
1126 variable has a missing value is excluded from the analysis.
1127
1128 @node LOGISTIC REGRESSION
1129 @section LOGISTIC REGRESSION
1130
1131 @vindex LOGISTIC REGRESSION
1132 @cindex logistic regression
1133 @cindex bivariate logistic regression
1134
1135 @display
1136 LOGISTIC REGRESSION [VARIABLES =] @var{dependent_var} WITH @var{predictors}
1137
1138      [/CATEGORICAL = @var{categorical_predictors}]
1139
1140      [@{/NOCONST | /ORIGIN | /NOORIGIN @}]
1141
1142      [/PRINT = [SUMMARY] [DEFAULT] [CI(@var{confidence})] [ALL]]
1143
1144      [/CRITERIA = [BCON(@var{min_delta})] [ITERATE(@var{max_interations})]
1145                   [LCON(@var{min_likelihood_delta})] [EPS(@var{min_epsilon})]
1146                   [CUT(@var{cut_point})]]
1147
1148      [/MISSING = @{INCLUDE|EXCLUDE@}]
1149 @end display
1150
1151 Bivariate Logistic Regression is used when you want to explain a dichotomous dependent
1152 variable in terms of one or more predictor variables.
1153
1154 The minimum command is
1155 @example
1156 LOGISTIC REGRESSION @var{y} WITH @var{x1} @var{x2} @dots{} @var{xn}.
1157 @end example
1158 Here, @var{y} is the dependent variable, which must be dichotomous and @var{x1} @dots{} @var{xn}
1159 are the predictor variables whose coefficients the procedure estimates.
1160
1161 By default, a constant term is included in the model.
1162 Hence, the full model is
1163 @math{
1164 {\bf y}
1165 = b_0 + b_1 {\bf x_1}
1166 + b_2 {\bf x_2}
1167 + \dots
1168 + b_n {\bf x_n}
1169 }
1170
1171 Predictor variables which are categorical in nature should be listed on the @subcmd{/CATEGORICAL} subcommand.
1172 Simple variables as well as interactions between variables may be listed here.
1173
1174 If you want a model without the constant term @math{b_0}, use the keyword @subcmd{/ORIGIN}.
1175 @subcmd{/NOCONST} is a synonym for @subcmd{/ORIGIN}.
1176
1177 An iterative Newton-Raphson procedure is used to fit the model.
1178 The @subcmd{/CRITERIA} subcommand is used to specify the stopping criteria of the procedure,
1179 and other parameters.
1180 The value of @var{cut_point} is used in the classification table.  It is the
1181 threshold above which predicted values are considered to be 1.  Values
1182 of @var{cut_point} must lie in the range [0,1].
1183 During iterations, if any one of the stopping criteria are satisfied, the procedure is
1184 considered complete.
1185 The stopping criteria are:
1186 @itemize
1187 @item The number of iterations exceeds @var{max_iterations}.
1188       The default value of @var{max_iterations} is 20.
1189 @item The change in the all coefficient estimates are less than @var{min_delta}.
1190 The default value of @var{min_delta} is 0.001.
1191 @item The magnitude of change in the likelihood estimate is less than @var{min_likelihood_delta}.
1192 The default value of @var{min_delta} is zero.
1193 This means that this criterion is disabled.
1194 @item The differential of the estimated probability for all cases is less than @var{min_epsilon}.
1195 In other words, the probabilities are close to zero or one.
1196 The default value of @var{min_epsilon} is 0.00000001.
1197 @end itemize
1198
1199
1200 The @subcmd{PRINT} subcommand controls the display of optional statistics.
1201 Currently there is one such option, @subcmd{CI}, which indicates that the
1202 confidence interval of the odds ratio should be displayed as well as its value.
1203 @subcmd{CI} should be followed by an integer in parentheses, to indicate the
1204 confidence level of the desired confidence interval.
1205
1206 The @subcmd{MISSING} subcommand determines the handling of missing
1207 variables.
1208 If @subcmd{INCLUDE} is set, then user-missing values are included in the
1209 calculations, but system-missing values are not.
1210 If @subcmd{EXCLUDE} is set, which is the default, user-missing
1211 values are excluded as well as system-missing values.
1212 This is the default.
1213
1214 @node MEANS
1215 @section MEANS
1216
1217 @vindex MEANS
1218 @cindex means
1219
1220 @display
1221 MEANS [TABLES =]
1222       @{@var{var_list}@}
1223         [ BY @{@var{var_list}@} [BY @{@var{var_list}@} [BY @{@var{var_list}@} @dots{} ]]]
1224
1225       [ /@{@var{var_list}@}
1226          [ BY @{@var{var_list}@} [BY @{@var{var_list}@} [BY @{@var{var_list}@} @dots{} ]]] ]
1227
1228       [/CELLS = [MEAN] [COUNT] [STDDEV] [SEMEAN] [SUM] [MIN] [MAX] [RANGE]
1229         [VARIANCE] [KURT] [SEKURT]
1230         [SKEW] [SESKEW] [FIRST] [LAST]
1231         [HARMONIC] [GEOMETRIC]
1232         [DEFAULT]
1233         [ALL]
1234         [NONE] ]
1235
1236       [/MISSING = [INCLUDE] [DEPENDENT]]
1237 @end display
1238
1239 You can use the @cmd{MEANS} command to calculate the arithmetic mean and similar
1240 statistics, either for the dataset as a whole or for categories of data.
1241
1242 The simplest form of the command is
1243 @example
1244 MEANS @var{v}.
1245 @end example
1246 @noindent which calculates the mean, count and standard deviation for @var{v}.
1247 If you specify a grouping variable, for example
1248 @example
1249 MEANS @var{v} BY @var{g}.
1250 @end example
1251 @noindent then the means, counts and standard deviations for @var{v} after having
1252 been grouped by @var{g} are calculated.
1253 Instead of the mean, count and standard deviation, you could specify the statistics
1254 in which you are interested:
1255 @example
1256 MEANS @var{x} @var{y} BY @var{g}
1257       /CELLS = HARMONIC SUM MIN.
1258 @end example
1259 This example calculates the harmonic mean, the sum and the minimum values of @var{x} and @var{y}
1260 grouped by @var{g}.
1261
1262 The @subcmd{CELLS} subcommand specifies which statistics to calculate.  The available statistics
1263 are:
1264 @itemize
1265 @item @subcmd{MEAN}
1266 @cindex arithmetic mean
1267       The arithmetic mean.
1268 @item @subcmd{COUNT}
1269       The count of the values.
1270 @item @subcmd{STDDEV}
1271       The standard deviation.
1272 @item @subcmd{SEMEAN}
1273       The standard error of the mean.
1274 @item @subcmd{SUM}
1275       The sum of the values.
1276 @item @subcmd{MIN}
1277       The minimum value.
1278 @item @subcmd{MAX}
1279       The maximum value.
1280 @item @subcmd{RANGE}
1281       The difference between the maximum and minimum values.
1282 @item @subcmd{VARIANCE}
1283       The variance.
1284 @item @subcmd{FIRST}
1285       The first value in the category.
1286 @item @subcmd{LAST}
1287       The last value in the category.
1288 @item @subcmd{SKEW}
1289       The skewness.
1290 @item @subcmd{SESKEW}
1291       The standard error of the skewness.
1292 @item @subcmd{KURT}
1293       The kurtosis
1294 @item @subcmd{SEKURT}
1295       The standard error of the kurtosis.
1296 @item @subcmd{HARMONIC}
1297 @cindex harmonic mean
1298       The harmonic mean.
1299 @item @subcmd{GEOMETRIC}
1300 @cindex geometric mean
1301       The geometric mean.
1302 @end itemize
1303
1304 In addition, three special keywords are recognized:
1305 @itemize
1306 @item @subcmd{DEFAULT}
1307       This is the same as @subcmd{MEAN} @subcmd{COUNT} @subcmd{STDDEV}.
1308 @item @subcmd{ALL}
1309       All of the above statistics are calculated.
1310 @item @subcmd{NONE}
1311       No statistics are calculated (only a summary is shown).
1312 @end itemize
1313
1314
1315 More than one @dfn{table} can be specified in a single command.
1316 Each table is separated by a @samp{/}. For
1317 example
1318 @example
1319 MEANS TABLES =
1320       @var{c} @var{d} @var{e} BY @var{x}
1321       /@var{a} @var{b} BY @var{x} @var{y}
1322       /@var{f} BY @var{y} BY @var{z}.
1323 @end example
1324 has three tables (the @samp{TABLE =} is optional).
1325 The first table has three dependent variables @var{c}, @var{d} and @var{e}
1326 and a single categorical variable @var{x}.
1327 The second table has two dependent variables @var{a} and @var{b},
1328 and two categorical variables @var{x} and @var{y}.
1329 The third table has a single dependent variables @var{f}
1330 and a categorical variable formed by the combination of @var{y} and @var{z}.
1331
1332
1333 By default values are omitted from the analysis only if missing values
1334 (either system missing or user missing)
1335 for any of the variables directly involved in their calculation are
1336 encountered.
1337 This behaviour can be modified with the  @subcmd{/MISSING} subcommand.
1338 Three options are possible: @subcmd{TABLE}, @subcmd{INCLUDE} and @subcmd{DEPENDENT}.
1339
1340 @subcmd{/MISSING = INCLUDE} says that user missing values, either in the dependent
1341 variables or in the categorical variables should be taken at their face
1342 value, and not excluded.
1343
1344 @subcmd{/MISSING = DEPENDENT} says that user missing values, in the dependent
1345 variables should be taken at their face value, however cases which
1346 have user missing values for the categorical variables should be omitted
1347 from the calculation.
1348
1349 @subsection Example Means
1350
1351 The dataset in @file{repairs.sav} contains the mean time between failures (@exvar{mtbf})
1352 for a sample of artifacts produced by different factories and trialed under
1353 different operating conditions.
1354 Since there are four combinations of categorical variables, by simply looking
1355 at the list of data, it would be hard to how the scores vary for each category.
1356 @ref{means:ex} shows one way of tabulating the @exvar{mtbf} in a way which is
1357 easier to understand.
1358
1359 @float Example, means:ex
1360 @psppsyntax {means.sps}
1361 @caption {Running @cmd{MEANS} on the @exvar{mtbf} score with categories @exvar{factory} and @exvar{environment}}
1362 @end float
1363
1364 The results are shown in @ref{means:res}.   The figures shown indicate the mean,
1365 standard deviation and number of samples in each category.
1366 These figures however do not indicate whether the results are statistically
1367 significant.  For that, you would need to use the procedures @cmd{ONEWAY}, @cmd{GLM} or
1368 @cmd{T-TEST} depending on the hypothesis being tested.
1369
1370 @float Result, means:res
1371 @psppoutput {means}
1372 @caption {The @exvar{mtbf} categorised by @exvar{factory} and @exvar{environment}}
1373 @end float
1374
1375 Note that there is no limit to the number of variables for which you can calculate
1376 statistics, nor to the number of categorical variables per layer, nor the number
1377 of layers.
1378 However, running @cmd{MEANS} on a large numbers of variables, or with categorical variables
1379 containing a large number of distinct values may result in an extremely large output, which
1380 will not be easy to interpret.
1381 So you should consider carefully which variables to select for participation in the analysis.
1382
1383 @node NPAR TESTS
1384 @section NPAR TESTS
1385
1386 @vindex NPAR TESTS
1387 @cindex nonparametric tests
1388
1389 @display
1390 NPAR TESTS
1391
1392      nonparametric test subcommands
1393      .
1394      .
1395      .
1396
1397      [ /STATISTICS=@{DESCRIPTIVES@} ]
1398
1399      [ /MISSING=@{ANALYSIS, LISTWISE@} @{INCLUDE, EXCLUDE@} ]
1400
1401      [ /METHOD=EXACT [ TIMER [(@var{n})] ] ]
1402 @end display
1403
1404 @cmd{NPAR TESTS} performs nonparametric tests.
1405 Non parametric tests make very few assumptions about the distribution of the
1406 data.
1407 One or more tests may be specified by using the corresponding subcommand.
1408 If the @subcmd{/STATISTICS} subcommand is also specified, then summary statistics are
1409 produces for each variable that is the subject of any test.
1410
1411 Certain tests may take a long time to execute, if an exact figure is required.
1412 Therefore, by default asymptotic approximations are used unless the
1413 subcommand @subcmd{/METHOD=EXACT} is specified.
1414 Exact tests give more accurate results, but may take an unacceptably long
1415 time to perform.  If the @subcmd{TIMER} keyword is used, it sets a maximum time,
1416 after which the test is abandoned, and a warning message printed.
1417 The time, in minutes, should be specified in parentheses after the @subcmd{TIMER} keyword.
1418 If the @subcmd{TIMER} keyword is given without this figure, then a default value of 5 minutes
1419 is used.
1420
1421
1422 @menu
1423 * BINOMIAL::                Binomial Test
1424 * CHISQUARE::               Chi-square Test
1425 * COCHRAN::                 Cochran Q Test
1426 * FRIEDMAN::                Friedman Test
1427 * KENDALL::                 Kendall's W Test
1428 * KOLMOGOROV-SMIRNOV::      Kolmogorov Smirnov Test
1429 * KRUSKAL-WALLIS::          Kruskal-Wallis Test
1430 * MANN-WHITNEY::            Mann Whitney U Test
1431 * MCNEMAR::                 McNemar Test
1432 * MEDIAN::                  Median Test
1433 * RUNS::                    Runs Test
1434 * SIGN::                    The Sign Test
1435 * WILCOXON::                Wilcoxon Signed Ranks Test
1436 @end menu
1437
1438
1439 @node    BINOMIAL
1440 @subsection Binomial test
1441 @vindex BINOMIAL
1442 @cindex binomial test
1443
1444 @display
1445      [ /BINOMIAL[(@var{p})]=@var{var_list}[(@var{value1}[, @var{value2})] ] ]
1446 @end display
1447
1448 The @subcmd{/BINOMIAL} subcommand compares the observed distribution of a dichotomous
1449 variable with that of a binomial distribution.
1450 The variable @var{p} specifies the test proportion of the binomial
1451 distribution.
1452 The default value of 0.5 is assumed if @var{p} is omitted.
1453
1454 If a single value appears after the variable list, then that value is
1455 used as the threshold to partition the observed values. Values less
1456 than or equal to the threshold value form the first category.  Values
1457 greater than the threshold form the second category.
1458
1459 If two values appear after the variable list, then they are used
1460 as the values which a variable must take to be in the respective
1461 category.
1462 Cases for which a variable takes a value equal to neither of the specified
1463 values, take no part in the test for that variable.
1464
1465 If no values appear, then the variable must assume dichotomous
1466 values.
1467 If more than two distinct, non-missing values for a variable
1468 under test are encountered then an error occurs.
1469
1470 If the test proportion is equal to 0.5, then a two tailed test is
1471 reported.   For any other test proportion, a one tailed test is
1472 reported.
1473 For one tailed tests, if the test proportion is less than
1474 or equal to the observed proportion, then the significance of
1475 observing the observed proportion or more is reported.
1476 If the test proportion is more than the observed proportion, then the
1477 significance of observing the observed proportion or less is reported.
1478 That is to say, the test is always performed in the observed
1479 direction.
1480
1481 @pspp{} uses a very precise approximation to the gamma function to
1482 compute the binomial significance.  Thus, exact results are reported
1483 even for very large sample sizes.
1484
1485
1486 @node    CHISQUARE
1487 @subsection Chi-square Test
1488 @vindex CHISQUARE
1489 @cindex chi-square test
1490
1491
1492 @display
1493      [ /CHISQUARE=@var{var_list}[(@var{lo},@var{hi})] [/EXPECTED=@{EQUAL|@var{f1}, @var{f2} @dots{} @var{fn}@}] ]
1494 @end display
1495
1496
1497 The @subcmd{/CHISQUARE} subcommand produces a chi-square statistic for the differences
1498 between the expected and observed frequencies of the categories of a variable.
1499 Optionally, a range of values may appear after the variable list.
1500 If a range is given, then non integer values are truncated, and values
1501 outside the  specified range are excluded from the analysis.
1502
1503 The @subcmd{/EXPECTED} subcommand specifies the expected values of each
1504 category.
1505 There must be exactly one non-zero expected value, for each observed
1506 category, or the @subcmd{EQUAL} keyword must be specified.
1507 You may use the notation @subcmd{@var{n}*@var{f}} to specify @var{n}
1508 consecutive expected categories all taking a frequency of @var{f}.
1509 The frequencies given are proportions, not absolute frequencies.  The
1510 sum of the frequencies need not be 1.
1511 If no @subcmd{/EXPECTED} subcommand is given, then equal frequencies
1512 are expected.
1513
1514 @subsubsection Chi-square Example
1515
1516 A researcher wishes to investigate whether there are an equal number of
1517 persons of each sex in a population.   The sample chosen for invesigation
1518 is that from the @file {physiology.sav} dataset.   The null hypothesis for
1519 the test is that the population comprises an equal number of males and females.
1520 The analysis is performed as shown in @ref{chisquare:ex}.
1521
1522 @float Example, chisquare:ex
1523 @psppsyntax {chisquare.sps}
1524 @caption {Performing a chi-square test to check for equal distribution of sexes}
1525 @end float
1526
1527 There is only one test variable, @i{viz:} @exvar{sex}.  The other variables in the dataset
1528 are ignored.
1529
1530 @float Screenshot, chisquare:scr
1531 @psppimage {chisquare}
1532 @caption {Performing a chi-square test using the graphic user interface}
1533 @end float
1534
1535 In @ref{chisquare:res} the summary box shows that in the sample, there are more males
1536 than females.  However the significance of chi-square result is greater than 0.05
1537 --- the most commonly accepted p-value --- and therefore
1538 there is not enough evidence to reject the null hypothesis and one must conclude
1539 that the evidence does not indicate that there is an imbalance of the sexes
1540 in the population.
1541
1542 @float Result, chisquare:res
1543 @psppoutput {chisquare}
1544 @caption {The results of running a chi-square test on @exvar{sex}}
1545 @end float
1546
1547
1548 @node COCHRAN
1549 @subsection Cochran Q Test
1550 @vindex Cochran
1551 @cindex Cochran Q test
1552 @cindex Q, Cochran Q
1553
1554 @display
1555      [ /COCHRAN = @var{var_list} ]
1556 @end display
1557
1558 The Cochran Q test is used to test for differences between three or more groups.
1559 The data for @var{var_list} in all cases must assume exactly two
1560 distinct values (other than missing values).
1561
1562 The value of Q is displayed along with its Asymptotic significance
1563 based on a chi-square distribution.
1564
1565 @node FRIEDMAN
1566 @subsection Friedman Test
1567 @vindex FRIEDMAN
1568 @cindex Friedman test
1569
1570 @display
1571      [ /FRIEDMAN = @var{var_list} ]
1572 @end display
1573
1574 The Friedman test is used to test for differences between repeated measures when
1575 there is no indication that the distributions are normally distributed.
1576
1577 A list of variables which contain the measured data must be given.  The procedure
1578 prints the sum of ranks for each variable, the test statistic and its significance.
1579
1580 @node KENDALL
1581 @subsection Kendall's W Test
1582 @vindex KENDALL
1583 @cindex Kendall's W test
1584 @cindex coefficient of concordance
1585
1586 @display
1587      [ /KENDALL = @var{var_list} ]
1588 @end display
1589
1590 The Kendall test investigates whether an arbitrary number of related samples come from the
1591 same population.
1592 It is identical to the Friedman test except that the additional statistic W, Kendall's Coefficient of Concordance is printed.
1593 It has the range [0,1] --- a value of zero indicates no agreement between the samples whereas a value of
1594 unity indicates complete agreement.
1595
1596
1597 @node KOLMOGOROV-SMIRNOV
1598 @subsection Kolmogorov-Smirnov Test
1599 @vindex KOLMOGOROV-SMIRNOV
1600 @vindex K-S
1601 @cindex Kolmogorov-Smirnov test
1602
1603 @display
1604      [ /KOLMOGOROV-SMIRNOV (@{NORMAL [@var{mu}, @var{sigma}], UNIFORM [@var{min}, @var{max}], POISSON [@var{lambda}], EXPONENTIAL [@var{scale}] @}) = @var{var_list} ]
1605 @end display
1606
1607 The one sample Kolmogorov-Smirnov subcommand is used to test whether or not a dataset is
1608 drawn from a particular distribution.  Four distributions are supported, @i{viz:}
1609 Normal, Uniform, Poisson and Exponential.
1610
1611 Ideally you should provide the parameters of the distribution against
1612 which you wish to test the data. For example, with the normal
1613 distribution  the mean (@var{mu})and standard deviation (@var{sigma})
1614 should be given; with the uniform distribution, the minimum
1615 (@var{min})and maximum (@var{max}) value should be provided.
1616 However, if the parameters are omitted they are imputed from the
1617 data.  Imputing the parameters reduces the power of the test so should
1618 be avoided if possible.
1619
1620 In the following example, two variables @var{score} and @var{age} are
1621 tested to see if they follow a normal distribution with a mean of 3.5
1622 and a standard deviation of 2.0.
1623 @example
1624   NPAR TESTS
1625         /KOLMOGOROV-SMIRNOV (normal 3.5 2.0) = @var{score} @var{age}.
1626 @end example
1627 If the variables need to be tested against different distributions, then a separate
1628 subcommand must be used.  For example the following syntax tests @var{score} against
1629 a normal distribution with mean of 3.5 and standard deviation of 2.0 whilst @var{age}
1630 is tested against a normal distribution of mean 40 and standard deviation 1.5.
1631 @example
1632   NPAR TESTS
1633         /KOLMOGOROV-SMIRNOV (normal 3.5 2.0) = @var{score}
1634         /KOLMOGOROV-SMIRNOV (normal 40 1.5) =  @var{age}.
1635 @end example
1636
1637 The abbreviated subcommand  @subcmd{K-S} may be used in place of @subcmd{KOLMOGOROV-SMIRNOV}.
1638
1639 @node KRUSKAL-WALLIS
1640 @subsection Kruskal-Wallis Test
1641 @vindex KRUSKAL-WALLIS
1642 @vindex K-W
1643 @cindex Kruskal-Wallis test
1644
1645 @display
1646      [ /KRUSKAL-WALLIS = @var{var_list} BY var (@var{lower}, @var{upper}) ]
1647 @end display
1648
1649 The Kruskal-Wallis test is used to compare data from an
1650 arbitrary number of populations.  It does not assume normality.
1651 The data to be compared are specified by @var{var_list}.
1652 The categorical variable determining the groups to which the
1653 data belongs is given by @var{var}. The limits @var{lower} and
1654 @var{upper} specify the valid range of @var{var}. Any cases for
1655 which @var{var} falls outside [@var{lower}, @var{upper}] are
1656 ignored.
1657
1658 The mean rank of each group as well as the chi-squared value and
1659 significance of the test are printed.
1660 The abbreviated subcommand  @subcmd{K-W} may be used in place of
1661 @subcmd{KRUSKAL-WALLIS}.
1662
1663
1664 @node MANN-WHITNEY
1665 @subsection Mann-Whitney U Test
1666 @vindex MANN-WHITNEY
1667 @vindex M-W
1668 @cindex Mann-Whitney U test
1669 @cindex U, Mann-Whitney U
1670
1671 @display
1672      [ /MANN-WHITNEY = @var{var_list} BY var (@var{group1}, @var{group2}) ]
1673 @end display
1674
1675 The Mann-Whitney subcommand is used to test whether two groups of data
1676 come from different populations. The variables to be tested should be
1677 specified in @var{var_list} and the grouping variable, that determines
1678 to which group the test variables belong, in @var{var}.
1679 @var{Var} may be either a string or an alpha variable.
1680 @var{Group1} and @var{group2} specify the
1681 two values of @var{var} which determine the groups of the test data.
1682 Cases for which the @var{var} value is neither @var{group1} or
1683 @var{group2} are ignored.
1684
1685 The value of the Mann-Whitney U statistic, the Wilcoxon W, and the
1686 significance are printed.
1687 You may abbreviated the subcommand @subcmd{MANN-WHITNEY} to
1688 @subcmd{M-W}.
1689
1690
1691 @node MCNEMAR
1692 @subsection McNemar Test
1693 @vindex MCNEMAR
1694 @cindex McNemar test
1695
1696 @display
1697      [ /MCNEMAR @var{var_list} [ WITH @var{var_list} [ (PAIRED) ]]]
1698 @end display
1699
1700 Use McNemar's test to analyse the significance of the difference between
1701 pairs of correlated proportions.
1702
1703 If the @code{WITH} keyword is omitted, then tests for all
1704 combinations of the listed variables are performed.
1705 If the @code{WITH} keyword is given, and the @code{(PAIRED)} keyword
1706 is also given, then the number of variables preceding @code{WITH}
1707 must be the same as the number following it.
1708 In this case, tests for each respective pair of variables are
1709 performed.
1710 If the @code{WITH} keyword is given, but the
1711 @code{(PAIRED)} keyword is omitted, then tests for each combination
1712 of variable preceding @code{WITH} against variable following
1713 @code{WITH} are performed.
1714
1715 The data in each variable must be dichotomous.  If there are more
1716 than two distinct variables an error will occur and the test will
1717 not be run.
1718
1719 @node MEDIAN
1720 @subsection Median Test
1721 @vindex MEDIAN
1722 @cindex Median test
1723
1724 @display
1725      [ /MEDIAN [(@var{value})] = @var{var_list} BY @var{variable} (@var{value1}, @var{value2}) ]
1726 @end display
1727
1728 The median test is used to test whether independent samples come from
1729 populations with a common median.
1730 The median of the populations against which the samples are to be tested
1731 may be given in parentheses immediately after the
1732 @subcmd{/MEDIAN} subcommand.  If it is not given, the median is imputed from the
1733 union of all the samples.
1734
1735 The variables of the samples to be tested should immediately follow the @samp{=} sign. The
1736 keyword @code{BY} must come next, and then the grouping variable.  Two values
1737 in parentheses should follow.  If the first value is greater than the second,
1738 then a 2 sample test is performed using these two values to determine the groups.
1739 If however, the first variable is less than the second, then a @i{k} sample test is
1740 conducted and the group values used are all values encountered which lie in the
1741 range [@var{value1},@var{value2}].
1742
1743
1744 @node RUNS
1745 @subsection Runs Test
1746 @vindex RUNS
1747 @cindex runs test
1748
1749 @display
1750      [ /RUNS (@{MEAN, MEDIAN, MODE, @var{value}@})  = @var{var_list} ]
1751 @end display
1752
1753 The @subcmd{/RUNS} subcommand tests whether a data sequence is randomly ordered.
1754
1755 It works by examining the number of times a variable's value crosses a given threshold.
1756 The desired threshold must be specified within parentheses.
1757 It may either be specified as a number or as one of @subcmd{MEAN}, @subcmd{MEDIAN} or @subcmd{MODE}.
1758 Following the threshold specification comes the list of variables whose values are to be
1759 tested.
1760
1761 The subcommand shows the number of runs, the asymptotic significance based on the
1762 length of the data.
1763
1764 @node SIGN
1765 @subsection Sign Test
1766 @vindex SIGN
1767 @cindex sign test
1768
1769 @display
1770      [ /SIGN @var{var_list} [ WITH @var{var_list} [ (PAIRED) ]]]
1771 @end display
1772
1773 The @subcmd{/SIGN} subcommand tests for differences between medians of the
1774 variables listed.
1775 The test does not make any assumptions about the
1776 distribution of the data.
1777
1778 If the @code{WITH} keyword is omitted, then tests for all
1779 combinations of the listed variables are performed.
1780 If the @code{WITH} keyword is given, and the @code{(PAIRED)} keyword
1781 is also given, then the number of variables preceding @code{WITH}
1782 must be the same as the number following it.
1783 In this case, tests for each respective pair of variables are
1784 performed.
1785 If the @code{WITH} keyword is given, but the
1786 @code{(PAIRED)} keyword is omitted, then tests for each combination
1787 of variable preceding @code{WITH} against variable following
1788 @code{WITH} are performed.
1789
1790 @node WILCOXON
1791 @subsection Wilcoxon Matched Pairs Signed Ranks Test
1792 @vindex WILCOXON
1793 @cindex wilcoxon matched pairs signed ranks test
1794
1795 @display
1796      [ /WILCOXON @var{var_list} [ WITH @var{var_list} [ (PAIRED) ]]]
1797 @end display
1798
1799 The @subcmd{/WILCOXON} subcommand tests for differences between medians of the
1800 variables listed.
1801 The test does not make any assumptions about the variances of the samples.
1802 It does however assume that the distribution is symmetrical.
1803
1804 If the @subcmd{WITH} keyword is omitted, then tests for all
1805 combinations of the listed variables are performed.
1806 If the @subcmd{WITH} keyword is given, and the @subcmd{(PAIRED)} keyword
1807 is also given, then the number of variables preceding @subcmd{WITH}
1808 must be the same as the number following it.
1809 In this case, tests for each respective pair of variables are
1810 performed.
1811 If the @subcmd{WITH} keyword is given, but the
1812 @subcmd{(PAIRED)} keyword is omitted, then tests for each combination
1813 of variable preceding @subcmd{WITH} against variable following
1814 @subcmd{WITH} are performed.
1815
1816 @node T-TEST
1817 @section T-TEST
1818
1819 @vindex T-TEST
1820
1821 @display
1822 T-TEST
1823         /MISSING=@{ANALYSIS,LISTWISE@} @{EXCLUDE,INCLUDE@}
1824         /CRITERIA=CI(@var{confidence})
1825
1826
1827 (One Sample mode.)
1828         TESTVAL=@var{test_value}
1829         /VARIABLES=@var{var_list}
1830
1831
1832 (Independent Samples mode.)
1833         GROUPS=var(@var{value1} [, @var{value2}])
1834         /VARIABLES=@var{var_list}
1835
1836
1837 (Paired Samples mode.)
1838         PAIRS=@var{var_list} [WITH @var{var_list} [(PAIRED)] ]
1839
1840 @end display
1841
1842
1843 The @cmd{T-TEST} procedure outputs tables used in testing hypotheses about
1844 means.
1845 It operates in one of three modes:
1846 @itemize
1847 @item One Sample mode.
1848 @item Independent Groups mode.
1849 @item Paired mode.
1850 @end itemize
1851
1852 @noindent
1853 Each of these modes are described in more detail below.
1854 There are two optional subcommands which are common to all modes.
1855
1856 The @cmd{/CRITERIA} subcommand tells @pspp{} the confidence interval used
1857 in the tests.  The default value is 0.95.
1858
1859
1860 The @cmd{MISSING} subcommand determines the handling of missing
1861 variables.
1862 If @subcmd{INCLUDE} is set, then user-missing values are included in the
1863 calculations, but system-missing values are not.
1864 If @subcmd{EXCLUDE} is set, which is the default, user-missing
1865 values are excluded as well as system-missing values.
1866 This is the default.
1867
1868 If @subcmd{LISTWISE} is set, then the entire case is excluded from analysis
1869 whenever any variable  specified in the @subcmd{/VARIABLES}, @subcmd{/PAIRS} or
1870 @subcmd{/GROUPS} subcommands contains a missing value.
1871 If @subcmd{ANALYSIS} is set, then missing values are excluded only in the analysis for
1872 which they would be needed. This is the default.
1873
1874
1875 @menu
1876 * One Sample Mode::             Testing against a hypothesized mean
1877 * Independent Samples Mode::    Testing two independent groups for equal mean
1878 * Paired Samples Mode::         Testing two interdependent groups for equal mean
1879 @end menu
1880
1881 @node One Sample Mode
1882 @subsection One Sample Mode
1883
1884 The @subcmd{TESTVAL} subcommand invokes the One Sample mode.
1885 This mode is used to test a population mean against a hypothesized
1886 mean.
1887 The value given to the @subcmd{TESTVAL} subcommand is the value against
1888 which you wish to test.
1889 In this mode, you must also use the @subcmd{/VARIABLES} subcommand to
1890 tell @pspp{} which variables you wish to test.
1891
1892 @subsubsection Example - One Sample T-test
1893
1894 A researcher wishes to know whether the weight of persons in a population
1895 is different from the national average.
1896 The samples are drawn from the population under investigation and recorded
1897 in the file @file{physiology.sav}.
1898 From the Department of Health, she
1899 knows that the national average weight of healthy adults is 76.8kg.
1900 Accordingly the @subcmd{TESTVAL} is set to 76.8.
1901 The null hypothesis therefore is that the mean average weight of the
1902 population from which the sample was drawn is 76.8kg.
1903
1904 As previously noted (@pxref{Identifying incorrect data}), one
1905 sample in the dataset contains a weight value
1906 which is clearly incorrect.  So this is excluded from the analysis
1907 using the @cmd{SELECT} command.
1908
1909 @float Example, one-sample-t:ex
1910 @psppsyntax {one-sample-t.sps}
1911 @caption {Running a one sample T-Test after excluding all non-positive values}
1912 @end float
1913
1914 @float Screenshot, one-sample-t:scr
1915 @psppimage {one-sample-t}
1916 @caption {Using the One Sample T-Test dialog box to test @exvar{weight} for a mean of 76.8kg}
1917 @end float
1918
1919
1920 @ref{one-sample-t:res} shows that the mean of our sample differs from the test value
1921 by -1.40kg.  However the significance is very high (0.610).  So one cannot
1922 reject the null hypothesis, and must conclude there is not enough evidence
1923 to suggest that the mean weight of the persons in our population is different
1924 from 76.8kg.
1925
1926 @float Results, one-sample-t:res
1927 @psppoutput {one-sample-t}
1928 @caption {The results of a one sample T-test of @exvar{weight} using a test value of 76.8kg}
1929 @end float
1930
1931 @node Independent Samples Mode
1932 @subsection Independent Samples Mode
1933
1934 The @subcmd{GROUPS} subcommand invokes Independent Samples mode or
1935 `Groups' mode.
1936 This mode is used to test whether two groups of values have the
1937 same population mean.
1938 In this mode, you must also use the @subcmd{/VARIABLES} subcommand to
1939 tell @pspp{} the dependent variables you wish to test.
1940
1941 The variable given in the @subcmd{GROUPS} subcommand is the independent
1942 variable which determines to which group the samples belong.
1943 The values in parentheses are the specific values of the independent
1944 variable for each group.
1945 If the parentheses are omitted and no values are given, the default values
1946 of 1.0 and 2.0 are assumed.
1947
1948 If the independent variable is numeric,
1949 it is acceptable to specify only one value inside the parentheses.
1950 If you do this, cases where the independent variable is
1951 greater than or equal to this value belong to the first group, and cases
1952 less than this value belong to the second group.
1953 When using this form of the @subcmd{GROUPS} subcommand, missing values in
1954 the independent variable are excluded on a listwise basis, regardless
1955 of whether @subcmd{/MISSING=LISTWISE} was specified.
1956
1957 @subsubsection Example - Independent Samples T-test
1958
1959 A researcher wishes to know whether within a population, adult males
1960 are taller than adult females.
1961 The samples are drawn from the population under investigation and recorded
1962 in the file @file{physiology.sav}.
1963
1964 As previously noted (@pxref{Identifying incorrect data}), one
1965 sample in the dataset contains a height value
1966 which is clearly incorrect.  So this is excluded from the analysis
1967 using the @cmd{SELECT} command.
1968
1969
1970 @float Example, indepdendent-samples-t:ex
1971 @psppsyntax {independent-samples-t.sps}
1972 @caption {Running a independent samples T-Test after excluding all observations less than 200kg}
1973 @end float
1974
1975
1976 The null hypothesis is that both males and females are on average
1977 of equal height.
1978
1979 @float Screenshot, independent-samples-t:scr
1980 @psppimage {independent-samples-t}
1981 @caption {Using the Independent Sample T-test dialog, to test for differences of @exvar{height} between values of @exvar{sex}}
1982 @end float
1983
1984
1985 In this case, the grouping variable is @exvar{sex}, so this is entered
1986 as the variable for the @subcmd{GROUP} subcommand.  The group values are  0 (male) and
1987 1 (female).
1988
1989 If you are running the proceedure using syntax, then you need to enter
1990 the values corresponding to each group within parentheses.
1991 If you are using the graphic user interface, then you have to open
1992 the ``Define Groups'' dialog box and enter the values corresponding
1993 to each group as shown in @ref{define-groups-t:scr}.  If, as in this case, the dataset has defined value
1994 labels for the group variable, then you can enter them by label
1995 or by value.
1996
1997 @float Screenshot, define-groups-t:scr
1998 @psppimage {define-groups-t}
1999 @caption {Setting the values of the grouping variable for an Independent Samples T-test}
2000 @end float
2001
2002 From @ref{independent-samples-t:res}, one can clearly see that the @emph{sample} mean height
2003 is greater for males than for females.  However in order to see if this
2004 is a significant result, one must consult the T-Test table.
2005
2006 The T-Test table contains two rows; one for use if the variance of the samples
2007 in each group may be safely assumed to be equal, and the second row
2008 if the variances in each group may not be safely assumed to be equal.
2009
2010 In this case however, both rows show a 2-tailed significance less than 0.001 and
2011 one must therefore reject the null hypothesis and conclude that within
2012 the population the mean height of males and of females are unequal.
2013
2014 @float Result, independent-samples-t:res
2015 @psppoutput {independent-samples-t}
2016 @caption {The results of an independent samples T-test of @exvar{height} by @exvar{sex}}
2017 @end float
2018
2019 @node Paired Samples Mode
2020 @subsection Paired Samples Mode
2021
2022 The @cmd{PAIRS} subcommand introduces Paired Samples mode.
2023 Use this mode when repeated measures have been taken from the same
2024 samples.
2025 If the @subcmd{WITH} keyword is omitted, then tables for all
2026 combinations of variables given in the @cmd{PAIRS} subcommand are
2027 generated.
2028 If the @subcmd{WITH} keyword is given, and the @subcmd{(PAIRED)} keyword
2029 is also given, then the number of variables preceding @subcmd{WITH}
2030 must be the same as the number following it.
2031 In this case, tables for each respective pair of variables are
2032 generated.
2033 In the event that the @subcmd{WITH} keyword is given, but the
2034 @subcmd{(PAIRED)} keyword is omitted, then tables for each combination
2035 of variable preceding @subcmd{WITH} against variable following
2036 @subcmd{WITH} are generated.
2037
2038
2039 @node ONEWAY
2040 @section ONEWAY
2041
2042 @vindex ONEWAY
2043 @cindex analysis of variance
2044 @cindex ANOVA
2045
2046 @display
2047 ONEWAY
2048         [/VARIABLES = ] @var{var_list} BY @var{var}
2049         /MISSING=@{ANALYSIS,LISTWISE@} @{EXCLUDE,INCLUDE@}
2050         /CONTRAST= @var{value1} [, @var{value2}] ... [,@var{valueN}]
2051         /STATISTICS=@{DESCRIPTIVES,HOMOGENEITY@}
2052         /POSTHOC=@{BONFERRONI, GH, LSD, SCHEFFE, SIDAK, TUKEY, ALPHA ([@var{value}])@}
2053 @end display
2054
2055 The @cmd{ONEWAY} procedure performs a one-way analysis of variance of
2056 variables factored by a single independent variable.
2057 It is used to compare the means of a population
2058 divided into more than two groups.
2059
2060 The dependent variables to be analysed should be given in the @subcmd{VARIABLES}
2061 subcommand.
2062 The list of variables must be followed by the @subcmd{BY} keyword and
2063 the name of the independent (or factor) variable.
2064
2065 You can use the @subcmd{STATISTICS} subcommand to tell @pspp{} to display
2066 ancillary information.  The options accepted are:
2067 @itemize
2068 @item DESCRIPTIVES
2069 Displays descriptive statistics about the groups factored by the independent
2070 variable.
2071 @item HOMOGENEITY
2072 Displays the Levene test of Homogeneity of Variance for the
2073 variables and their groups.
2074 @end itemize
2075
2076 The @subcmd{CONTRAST} subcommand is used when you anticipate certain
2077 differences between the groups.
2078 The subcommand must be followed by a list of numerals which are the
2079 coefficients of the groups to be tested.
2080 The number of coefficients must correspond to the number of distinct
2081 groups (or values of the independent variable).
2082 If the total sum of the coefficients are not zero, then @pspp{} will
2083 display a warning, but will proceed with the analysis.
2084 The @subcmd{CONTRAST} subcommand may be given up to 10 times in order
2085 to specify different contrast tests.
2086 The @subcmd{MISSING} subcommand defines how missing values are handled.
2087 If @subcmd{LISTWISE} is specified then cases which have missing values for
2088 the independent variable or any dependent variable are ignored.
2089 If @subcmd{ANALYSIS} is specified, then cases are ignored if the independent
2090 variable is missing or if the dependent variable currently being
2091 analysed is missing.  The default is @subcmd{ANALYSIS}.
2092 A setting of @subcmd{EXCLUDE} means that variables whose values are
2093 user-missing are to be excluded from the analysis. A setting of
2094 @subcmd{INCLUDE} means they are to be included.  The default is @subcmd{EXCLUDE}.
2095
2096 Using the @code{POSTHOC} subcommand you can perform multiple
2097 pairwise comparisons on the data. The following comparison methods
2098 are available:
2099 @itemize
2100 @item @subcmd{LSD}
2101 Least Significant Difference.
2102 @item @subcmd{TUKEY}
2103 Tukey Honestly Significant Difference.
2104 @item @subcmd{BONFERRONI}
2105 Bonferroni test.
2106 @item @subcmd{SCHEFFE}
2107 Scheff@'e's test.
2108 @item @subcmd{SIDAK}
2109 Sidak test.
2110 @item @subcmd{GH}
2111 The Games-Howell test.
2112 @end itemize
2113
2114 @noindent
2115 Use the optional syntax @code{ALPHA(@var{value})} to indicate that
2116 @cmd{ONEWAY} should perform the posthoc tests at a confidence level of
2117 @var{value}.  If @code{ALPHA(@var{value})} is not specified, then the
2118 confidence level used is 0.05.
2119
2120 @node QUICK CLUSTER
2121 @section QUICK CLUSTER
2122 @vindex QUICK CLUSTER
2123
2124 @cindex K-means clustering
2125 @cindex clustering
2126
2127 @display
2128 QUICK CLUSTER @var{var_list}
2129       [/CRITERIA=CLUSTERS(@var{k}) [MXITER(@var{max_iter})] CONVERGE(@var{epsilon}) [NOINITIAL]]
2130       [/MISSING=@{EXCLUDE,INCLUDE@} @{LISTWISE, PAIRWISE@}]
2131       [/PRINT=@{INITIAL@} @{CLUSTER@}]
2132       [/SAVE[=[CLUSTER[(@var{membership_var})]] [DISTANCE[(@var{distance_var})]]]
2133 @end display
2134
2135 The @cmd{QUICK CLUSTER} command performs k-means clustering on the
2136 dataset.  This is useful when you wish to allocate cases into clusters
2137 of similar values and you already know the number of clusters.
2138
2139 The minimum specification is @samp{QUICK CLUSTER} followed by the names
2140 of the variables which contain the cluster data.  Normally you will also
2141 want to specify @subcmd{/CRITERIA=CLUSTERS(@var{k})} where @var{k} is the
2142 number of clusters.  If this is not specified, then @var{k} defaults to 2.
2143
2144 If you use @subcmd{/CRITERIA=NOINITIAL} then a naive algorithm to select
2145 the initial clusters is used.   This will provide for faster execution but
2146 less well separated initial clusters and hence possibly an inferior final
2147 result.
2148
2149
2150 @cmd{QUICK CLUSTER} uses an iterative algorithm to select the clusters centers.
2151 The subcommand  @subcmd{/CRITERIA=MXITER(@var{max_iter})} sets the maximum number of iterations.
2152 During classification, @pspp{} will continue iterating until until @var{max_iter}
2153 iterations have been done or the convergence criterion (see below) is fulfilled.
2154 The default value of @var{max_iter} is 2.
2155
2156 If however, you specify @subcmd{/CRITERIA=NOUPDATE} then after selecting the initial centers,
2157 no further update to the cluster centers is done.  In this case, @var{max_iter}, if specified.
2158 is ignored.
2159
2160 The subcommand  @subcmd{/CRITERIA=CONVERGE(@var{epsilon})} is used
2161 to set the convergence criterion.  The value of convergence criterion is  @var{epsilon}
2162 times the minimum distance between the @emph{initial} cluster centers.  Iteration stops when
2163 the  mean cluster distance between  one iteration and the next
2164 is less than the convergence criterion.  The default value of @var{epsilon} is zero.
2165
2166 The @subcmd{MISSING} subcommand determines the handling of missing variables.
2167 If @subcmd{INCLUDE} is set, then user-missing values are considered at their face
2168 value and not as missing values.
2169 If @subcmd{EXCLUDE} is set, which is the default, user-missing
2170 values are excluded as well as system-missing values.
2171
2172 If @subcmd{LISTWISE} is set, then the entire case is excluded from the analysis
2173 whenever any of the clustering variables contains a missing value.
2174 If @subcmd{PAIRWISE} is set, then a case is considered missing only if all the
2175 clustering variables contain missing values.  Otherwise it is clustered
2176 on the basis of the non-missing values.
2177 The default is @subcmd{LISTWISE}.
2178
2179 The @subcmd{PRINT} subcommand requests additional output to be printed.
2180 If @subcmd{INITIAL} is set, then the initial cluster memberships will
2181 be printed.
2182 If @subcmd{CLUSTER} is set, the cluster memberships of the individual
2183 cases are displayed (potentially generating lengthy output).
2184
2185 You can specify the subcommand @subcmd{SAVE} to ask that each case's cluster membership
2186 and the euclidean distance between the case and its cluster center be saved to
2187 a new variable in the active dataset.   To save the cluster membership use the
2188 @subcmd{CLUSTER} keyword and to save the distance use the @subcmd{DISTANCE} keyword.
2189 Each keyword may optionally be followed by a variable name in parentheses to specify
2190 the new variable which is to contain the saved parameter.  If no variable name is specified,
2191 then PSPP will create one.
2192
2193 @node RANK
2194 @section RANK
2195
2196 @vindex RANK
2197 @display
2198 RANK
2199         [VARIABLES=] @var{var_list} [@{A,D@}] [BY @var{var_list}]
2200         /TIES=@{MEAN,LOW,HIGH,CONDENSE@}
2201         /FRACTION=@{BLOM,TUKEY,VW,RANKIT@}
2202         /PRINT[=@{YES,NO@}
2203         /MISSING=@{EXCLUDE,INCLUDE@}
2204
2205         /RANK [INTO @var{var_list}]
2206         /NTILES(k) [INTO @var{var_list}]
2207         /NORMAL [INTO @var{var_list}]
2208         /PERCENT [INTO @var{var_list}]
2209         /RFRACTION [INTO @var{var_list}]
2210         /PROPORTION [INTO @var{var_list}]
2211         /N [INTO @var{var_list}]
2212         /SAVAGE [INTO @var{var_list}]
2213 @end display
2214
2215 The @cmd{RANK} command ranks variables and stores the results into new
2216 variables.
2217
2218 The @subcmd{VARIABLES} subcommand, which is mandatory, specifies one or
2219 more variables whose values are to be ranked.
2220 After each variable, @samp{A} or @samp{D} may appear, indicating that
2221 the variable is to be ranked in ascending or descending order.
2222 Ascending is the default.
2223 If a @subcmd{BY} keyword appears, it should be followed by a list of variables
2224 which are to serve as group variables.
2225 In this case, the cases are gathered into groups, and ranks calculated
2226 for each group.
2227
2228 The @subcmd{TIES} subcommand specifies how tied values are to be treated.  The
2229 default is to take the mean value of all the tied cases.
2230
2231 The @subcmd{FRACTION} subcommand specifies how proportional ranks are to be
2232 calculated.  This only has any effect if @subcmd{NORMAL} or @subcmd{PROPORTIONAL} rank
2233 functions are requested.
2234
2235 The @subcmd{PRINT} subcommand may be used to specify that a summary of the rank
2236 variables created should appear in the output.
2237
2238 The function subcommands are @subcmd{RANK}, @subcmd{NTILES}, @subcmd{NORMAL}, @subcmd{PERCENT}, @subcmd{RFRACTION},
2239 @subcmd{PROPORTION} and @subcmd{SAVAGE}.  Any number of function subcommands may appear.
2240 If none are given, then the default is RANK.
2241 The @subcmd{NTILES} subcommand must take an integer specifying the number of
2242 partitions into which values should be ranked.
2243 Each subcommand may be followed by the @subcmd{INTO} keyword and a list of
2244 variables which are the variables to be created and receive the rank
2245 scores.  There may be as many variables specified as there are
2246 variables named on the @subcmd{VARIABLES} subcommand.  If fewer are specified,
2247 then the variable names are automatically created.
2248
2249 The @subcmd{MISSING} subcommand determines how user missing values are to be
2250 treated. A setting of @subcmd{EXCLUDE} means that variables whose values are
2251 user-missing are to be excluded from the rank scores. A setting of
2252 @subcmd{INCLUDE} means they are to be included.  The default is @subcmd{EXCLUDE}.
2253
2254 @include regression.texi
2255
2256
2257 @node RELIABILITY
2258 @section RELIABILITY
2259
2260 @vindex RELIABILITY
2261 @display
2262 RELIABILITY
2263         /VARIABLES=@var{var_list}
2264         /SCALE (@var{name}) = @{@var{var_list}, ALL@}
2265         /MODEL=@{ALPHA, SPLIT[(@var{n})]@}
2266         /SUMMARY=@{TOTAL,ALL@}
2267         /MISSING=@{EXCLUDE,INCLUDE@}
2268 @end display
2269
2270 @cindex Cronbach's Alpha
2271 The @cmd{RELIABILITY} command performs reliability analysis on the data.
2272
2273 The @subcmd{VARIABLES} subcommand is required. It determines the set of variables
2274 upon which analysis is to be performed.
2275
2276 The @subcmd{SCALE} subcommand determines the  variables for which
2277 reliability is to be calculated.  If @subcmd{SCALE} is omitted, then analysis for
2278 all variables named in the @subcmd{VARIABLES} subcommand are used.
2279 Optionally, the @var{name} parameter may be specified to set a string name
2280 for the scale.
2281
2282 The @subcmd{MODEL} subcommand determines the type of analysis. If @subcmd{ALPHA} is specified,
2283 then Cronbach's Alpha is calculated for the scale.  If the model is @subcmd{SPLIT},
2284 then the variables  are divided into 2 subsets.  An optional parameter
2285 @var{n} may be given, to specify how many variables to be in the first subset.
2286 If @var{n} is omitted, then it defaults to one half of the variables in the
2287 scale, or one half minus one if there are an odd number of variables.
2288 The default model is @subcmd{ALPHA}.
2289
2290 By default, any cases with user missing, or system missing values for
2291 any variables given in the @subcmd{VARIABLES} subcommand are omitted
2292 from the analysis.  The @subcmd{MISSING} subcommand determines whether
2293 user missing values are included or excluded in the analysis.
2294
2295 The @subcmd{SUMMARY} subcommand determines the type of summary analysis to be performed.
2296 Currently there is only one type: @subcmd{SUMMARY=TOTAL}, which displays per-item
2297 analysis tested against the totals.
2298
2299 @subsection Example - Reliability
2300
2301 Before analysing the results of a survey -- particularly for a multiple choice survey --
2302 it is desireable to know whether the respondents have considered their answers
2303 or simply provided random answers.
2304
2305 In the following example the survey results from the file @file{hotel.sav} are used.
2306 All five survey questions are included in the reliability analysis.
2307 However, before running the analysis, the data must be preprocessed.
2308 An examination of the survey questions reveals that two questions, @i{viz:} v3 and v5
2309 are negatively worded, whereas the others are positively worded.
2310 All questions must be based upon the same scale for the analysis to be meaningful.
2311 One could use the @cmd{RECODE} command (@pxref{RECODE}), however a simpler way is
2312 to use @cmd{COMPUTE} (@pxref{COMPUTE}) and this is what is done in @ref{reliability:ex}.
2313
2314 @float Example, reliability:ex
2315 @psppsyntax {reliability.sps}
2316 @caption {Investigating the reliability of survey responses}
2317 @end float
2318
2319 In this case, all variables in the data set are used.  So we can use the special
2320 keyword @samp{ALL} (@pxref{BNF}).
2321
2322 @float Screenshot, reliability:src
2323 @psppimage {reliability}
2324 @caption {Reliability dialog box with all variables selected}
2325 @end float
2326
2327 @ref{reliability:res} shows that Cronbach's Alpha is 0.11  which is a value normally considered too
2328 low to indicate consistency within the data.  This is possibly due to the small number of
2329 survey questions.  The survey should be redesigned before serious use of the results are
2330 applied.
2331
2332 @float Result, reliability:res
2333 @psppoutput {reliability}
2334 @caption {The results of the reliability command on @file{hotel.sav}}
2335 @end float
2336
2337
2338 @node ROC
2339 @section ROC
2340
2341 @vindex ROC
2342 @cindex Receiver Operating Characteristic
2343 @cindex Area under curve
2344
2345 @display
2346 ROC     @var{var_list} BY @var{state_var} (@var{state_value})
2347         /PLOT = @{ CURVE [(REFERENCE)], NONE @}
2348         /PRINT = [ SE ] [ COORDINATES ]
2349         /CRITERIA = [ CUTOFF(@{INCLUDE,EXCLUDE@}) ]
2350           [ TESTPOS (@{LARGE,SMALL@}) ]
2351           [ CI (@var{confidence}) ]
2352           [ DISTRIBUTION (@{FREE, NEGEXPO @}) ]
2353         /MISSING=@{EXCLUDE,INCLUDE@}
2354 @end display
2355
2356
2357 The @cmd{ROC} command is used to plot the receiver operating characteristic curve
2358 of a dataset, and to estimate the area under the curve.
2359 This is useful for analysing the efficacy of a variable as a predictor of a state of nature.
2360
2361 The mandatory @var{var_list} is the list of predictor variables.
2362 The variable @var{state_var} is the variable whose values represent the actual states,
2363 and @var{state_value} is the value of this variable which represents the positive state.
2364
2365 The optional subcommand @subcmd{PLOT} is used to determine if and how the @subcmd{ROC} curve is drawn.
2366 The keyword @subcmd{CURVE} means that the @subcmd{ROC} curve should be drawn, and the optional keyword @subcmd{REFERENCE},
2367 which should be enclosed in parentheses, says that the diagonal reference line should be drawn.
2368 If the keyword @subcmd{NONE} is given, then no @subcmd{ROC} curve is drawn.
2369 By default, the curve is drawn with no reference line.
2370
2371 The optional subcommand @subcmd{PRINT} determines which additional
2372 tables should be printed.  Two additional tables are available.  The
2373 @subcmd{SE} keyword says that standard error of the area under the
2374 curve should be printed as well as the area itself.  In addition, a
2375 p-value for the null hypothesis that the area under the curve equals
2376 0.5 is printed.   The @subcmd{COORDINATES} keyword says that a
2377 table of coordinates of the @subcmd{ROC} curve should be printed.
2378
2379 The @subcmd{CRITERIA} subcommand has four optional parameters:
2380 @itemize @bullet
2381 @item The @subcmd{TESTPOS} parameter may be @subcmd{LARGE} or @subcmd{SMALL}.
2382 @subcmd{LARGE} is the default, and says that larger values in the predictor variables are to be
2383 considered positive.  @subcmd{SMALL} indicates that smaller values should be considered positive.
2384
2385 @item The @subcmd{CI} parameter specifies the confidence interval that should be printed.
2386 It has no effect if the @subcmd{SE} keyword in the @subcmd{PRINT} subcommand has not been given.
2387
2388 @item The @subcmd{DISTRIBUTION} parameter determines the method to be used when estimating the area
2389 under the curve.
2390 There are two possibilities, @i{viz}: @subcmd{FREE} and @subcmd{NEGEXPO}.
2391 The @subcmd{FREE} method uses a non-parametric estimate, and the @subcmd{NEGEXPO} method a bi-negative
2392 exponential distribution estimate.
2393 The @subcmd{NEGEXPO} method should only be used when the number of positive actual states is
2394 equal to the number of negative actual states.
2395 The default is @subcmd{FREE}.
2396
2397 @item The @subcmd{CUTOFF} parameter is for compatibility and is ignored.
2398 @end itemize
2399
2400 The @subcmd{MISSING} subcommand determines whether user missing values are to
2401 be included or excluded in the analysis.  The default behaviour is to
2402 exclude them.
2403 Cases are excluded on a listwise basis; if any of the variables in @var{var_list}
2404 or if the variable @var{state_var} is missing, then the entire case is
2405 excluded.
2406
2407 @c  LocalWords:  subcmd subcommand