output: Introduce pivot tables.
[pspp] / doc / statistics.texi
index 1e24c173516bcfa62ebb8d8af0ad432e3d1d9a34..9e9ed9081bd603db13641fccd8dbfce416656af0 100644 (file)
@@ -1,3 +1,12 @@
+@c PSPP - a program for statistical analysis.
+@c Copyright (C) 2017 Free Software Foundation, Inc.
+@c Permission is granted to copy, distribute and/or modify this document
+@c under the terms of the GNU Free Documentation License, Version 1.3
+@c or any later version published by the Free Software Foundation;
+@c with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
+@c A copy of the license is included in the section entitled "GNU
+@c Free Documentation License".
+@c
 @node Statistics
 @chapter Statistics
 
@@ -12,6 +21,7 @@ far.
 * CORRELATIONS::                Correlation tables.
 * CROSSTABS::                   Crosstabulation tables.
 * FACTOR::                      Factor analysis and Principal Components analysis.
+* GLM::                         Univariate Linear Models.
 * LOGISTIC REGRESSION::         Bivariate Logistic Regression.
 * MEANS::                       Average values and other statistics.
 * NPAR TESTS::                  Nonparametric tests.
@@ -60,11 +70,8 @@ excluded on a variable by variable basis; if @subcmd{LISTWISE} is set, then
 the entire case is excluded whenever any value in that case has a
 system-missing or, if @subcmd{INCLUDE} is set, user-missing value.
 
-The @subcmd{FORMAT} subcommand affects the output format.  Currently the
-@subcmd{LABELS/NOLABELS} and @subcmd{NOINDEX/INDEX} settings are not used.
-When @subcmd{SERIAL} is
-set, both valid and missing number of cases are listed in the output;
-when @subcmd{NOSERIAL} is set, only valid cases are listed.
+The @subcmd{FORMAT} subcommand has no effect.  It is accepted for
+backward compatibility.
 
 The @subcmd{SAVE} subcommand causes @cmd{DESCRIPTIVES} to calculate Z scores for all
 the specified variables.  The Z scores are saved to new variables.
@@ -411,8 +418,9 @@ large quantity of output.
 
 @display
 GRAPH
-        /HISTOGRAM = @var{var}
-        /SCATTERPLOT [(BIVARIATE)] = @var{var1} WITH @var{var2} [BY @var{var3}] 
+        /HISTOGRAM [(NORMAL)]= @var{var}
+        /SCATTERPLOT [(BIVARIATE)] = @var{var1} WITH @var{var2} [BY @var{var3}]
+        /BAR = @{@var{summary-function}(@var{var1}) | @var{count-function}@} BY @var{var2} [BY @var{var3}] 
         [ /MISSING=@{LISTWISE, VARIABLE@} [@{EXCLUDE, INCLUDE@}] ] 
                [@{NOREPORT,REPORT@}]
 
@@ -422,11 +430,20 @@ The @cmd{GRAPH} produces graphical plots of data. Only one of the subcommands
 @subcmd{HISTOGRAM} or @subcmd{SCATTERPLOT} can be specified, i.e. only one plot
 can be produced per call of @cmd{GRAPH}. The @subcmd{MISSING} is optional. 
 
+@menu
+* SCATTERPLOT::             Cartesian Plots
+* HISTOGRAM::               Histograms
+* BAR CHART::               Bar Charts
+@end menu
+
+@node SCATTERPLOT
+@subsection Scatterplot
 @cindex scatterplot
 
-The subcommand @subcmd{SCATTERPLOT} produces an xy plot of the data. The different 
-values of the optional third variable @var{var3} will result in different colours and/or
-markers for the plot. The following is an example for producing a scatterplot.
+The subcommand @subcmd{SCATTERPLOT} produces an xy plot of the
+data. The different values of the optional third variable @var{var3}
+will result in different colours and/or markers for the plot. The
+following is an example for producing a scatterplot.
 
 @example
 GRAPH   
@@ -437,10 +454,14 @@ This example will produce a scatterplot where @var{height} is plotted versus @va
 on the value of the @var{gender} variable, the colour of the datapoint is different. With
 this plot it is possible to analyze gender differences for @var{height} vs.@: @var{weight} relation.
 
+@node HISTOGRAM
+@subsection Histogram
 @cindex histogram
 
 The subcommand @subcmd{HISTOGRAM} produces a histogram. Only one variable is allowed for
 the histogram plot.
+The keyword @subcmd{NORMAL} may be specified in parentheses, to indicate that the ideal normal curve
+should be superimposed over the histogram.
 For an alternative method to produce histograms @pxref{EXAMINE}. The
 following example produces a histogram plot for the variable @var{weight}.
 
@@ -449,6 +470,60 @@ GRAPH
         /HISTOGRAM = @var{weight}.
 @end example
 
+@node BAR CHART
+@subsection Bar Chart
+@cindex bar chart
+
+The subcommand @subcmd{BAR} produces a bar chart.
+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.
+Following the summary or count function, the keyword @subcmd{BY} should be specified and then a catagorical variable, @var{var2}.
+The values of the variable @var{var2} determine the labels of the bars to be plotted.
+Optionally a second categorical variable @var{var3} may be specified in which case a clustered (grouped) bar chart is produced.
+
+Valid count functions are
+@table @subcmd
+@item COUNT
+The weighted counts of the cases in each category.
+@item PCT
+The weighted counts of the cases in each category expressed as a percentage of the total weights of the cases.
+@item CUFREQ
+The cumulative weighted counts of the cases in each category.
+@item CUPCT
+The cumulative weighted counts of the cases in each category expressed as a percentage of the total weights of the cases.
+@end table
+
+The summary function is applied to @var{var1} across all cases in each category.
+The recognised summary functions are:
+@table @subcmd
+@item SUM
+The sum.
+@item MEAN
+The arithmetic mean.
+@item MAXIMUM
+The maximum value.
+@item MINIMUM
+The minimum value.
+@end table
+
+The following examples assume a dataset which is the results of a survey.
+Each respondent has indicated annual income, their sex and city of residence.
+One could create a bar chart showing how the mean income varies between of residents of different cities, thus:
+@example
+GRAPH  /BAR  = MEAN(@var{income}) BY @var{city}.
+@end example
+
+This can be extended to also indicate how income in each city differs between the sexes.
+@example
+GRAPH  /BAR  = MEAN(@var{income}) BY @var{city} BY @var{sex}.
+@end example
+
+One might also want to see how many respondents there are from each city.  This can be achieved as follows:
+@example
+GRAPH  /BAR  = COUNT BY @var{city}.
+@end example
+
+Bar charts can also be produced using the @ref{FREQUENCIES} and @ref{CROSSTABS} commands.
+
 @node CORRELATIONS
 @section CORRELATIONS
 
@@ -528,6 +603,8 @@ CROSSTABS
                 @{BOX,NOBOX@}
         /CELLS=@{COUNT,ROW,COLUMN,TOTAL,EXPECTED,RESIDUAL,SRESIDUAL,
                 ASRESIDUAL,ALL,NONE@}
+        /COUNT=@{ASIS,CASE,CELL@}
+               @{ROUND,TRUNCATE@}
         /STATISTICS=@{CHISQ,PHI,CC,LAMBDA,UC,BTAU,CTAU,RISK,GAMMA,D,
                      KAPPA,ETA,CORR,ALL,NONE@}
         /BARCHART
@@ -566,8 +643,7 @@ When set to @subcmd{TABLE}, the default, missing values are dropped on a table b
 table basis.  When set to @subcmd{INCLUDE}, user-missing values are included in
 tables and statistics.  When set to @subcmd{REPORT}, which is allowed only in
 integer mode, user-missing values are included in tables but marked with
-an @samp{M} (for ``missing'') and excluded from statistical
-calculations.
+a footnote and excluded from statistical calculations.
 
 Currently the @subcmd{WRITE} subcommand is ignored.
 
@@ -627,6 +703,15 @@ Suppress cells entirely.
 If @subcmd{CELLS} is not specified at all then only @subcmd{COUNT}
 will be selected.
 
+By default, crosstabulation and statistics use raw case weights,
+without rounding.  Use the @subcmd{/COUNT} subcommand to perform
+rounding: CASE rounds the weights of individual weights as cases are
+read, CELL rounds the weights of cells within each crosstabulation
+table after it has been constructed, and ASIS explicitly specifies the
+default non-rounding behavior.  When rounding is requested, ROUND, the
+default, rounds to the nearest integer and TRUNCATE rounds toward
+zero.
+
 The @subcmd{STATISTICS} subcommand selects statistics for computation:
 
 @table @asis
@@ -705,7 +790,10 @@ Fixes for any of these deficiencies would be welcomed.
 @cindex data reduction
 
 @display
-FACTOR  VARIABLES=@var{var_list}
+FACTOR  @{
+         VARIABLES=@var{var_list},
+         MATRIX IN (@{CORR,COV@}=@{*,@var{file_spec}@})
+        @}
 
         [ /METHOD = @{CORRELATION, COVARIANCE@} ]
 
@@ -715,7 +803,7 @@ FACTOR  VARIABLES=@var{var_list}
 
         [ /ROTATION=@{VARIMAX, EQUAMAX, QUARTIMAX, PROMAX[(@var{k})], NOROTATE@}]
 
-        [ /PRINT=[INITIAL] [EXTRACTION] [ROTATION] [UNIVARIATE] [CORRELATION] [COVARIANCE] [DET] [KMO] [SIG] [ALL] [DEFAULT] ]
+        [ /PRINT=[INITIAL] [EXTRACTION] [ROTATION] [UNIVARIATE] [CORRELATION] [COVARIANCE] [DET] [KMO] [AIC] [SIG] [ALL] [DEFAULT] ]
 
         [ /PLOT=[EIGEN] ]
 
@@ -729,10 +817,21 @@ FACTOR  VARIABLES=@var{var_list}
 The @cmd{FACTOR} command performs Factor Analysis or Principal Axis Factoring on a dataset.  It may be used to find
 common factors in the data or for data reduction purposes.
 
-The @subcmd{VARIABLES} subcommand is required.  It lists the variables
-which are to partake in the analysis.  (The @subcmd{ANALYSIS}
+The @subcmd{VARIABLES} subcommand is required (unless the @subcmd{MATRIX IN}
+subcommand is used).
+It lists the variables which are to partake in the analysis.  (The @subcmd{ANALYSIS}
 subcommand may optionally further limit the variables that
-participate; it is not useful and implemented only for compatibility.)
+participate; it is useful primarily in conjunction with @subcmd{MATRIX IN}.)
+
+If @subcmd{MATRIX IN} instead of @subcmd{VARIABLES} is specified, then the analysis
+is performed on a pre-prepared correlation or covariance matrix file instead of on
+individual data cases.  Typically the matrix file will have been generated by
+@cmd{MATRIX DATA} (@pxref{MATRIX DATA}) or provided by a third party.
+If specified, @subcmd{MATRIX IN} must be followed by @samp{COV} or @samp{CORR},
+then by @samp{=} and @var{file_spec} all in parentheses.
+@var{file_spec} may either be an asterisk, which indicates the currently loaded
+dataset, or it may be a filename to be loaded. @xref{MATRIX DATA}, for the expected
+format of the file.
 
 The @subcmd{/EXTRACTION} subcommand is used to specify the way in which factors (components) are extracted from the data.
 If @subcmd{PC} is specified, then Principal Components Analysis is used.  
@@ -768,6 +867,8 @@ The @subcmd{/PRINT} subcommand may be used to select which features of the analy
       The covariance matrix is printed.
 @item @subcmd{DET}
       The determinant of the correlation or covariance matrix is printed.
+@item @subcmd{AIC}
+      The anti-image covariance and anti-image correlation matrices are printed.
 @item @subcmd{KMO}
       The Kaiser-Meyer-Olkin measure of sampling adequacy and the Bartlett test of sphericity is printed.
 @item @subcmd{SIG}
@@ -820,6 +921,65 @@ If @subcmd{PAIRWISE} is set, then a case is considered missing only if either of
 values  for the particular coefficient are missing.
 The default is @subcmd{LISTWISE}.
 
+@node GLM
+@section GLM
+
+@vindex GLM
+@cindex univariate analysis of variance
+@cindex fixed effects
+@cindex factorial anova
+@cindex analysis of variance
+@cindex ANOVA
+
+
+@display
+GLM @var{dependent_vars} BY @var{fixed_factors}
+     [/METHOD = SSTYPE(@var{type})]
+     [/DESIGN = @var{interaction_0} [@var{interaction_1} [... @var{interaction_n}]]]
+     [/INTERCEPT = @{INCLUDE|EXCLUDE@}]
+     [/MISSING = @{INCLUDE|EXCLUDE@}]
+@end display
+
+The @cmd{GLM} procedure can be used for fixed effects factorial Anova.
+
+The @var{dependent_vars} are the variables to be analysed.
+You may analyse several variables in the same command in which case they should all
+appear before the @code{BY} keyword.
+
+The @var{fixed_factors} list must be one or more categorical variables.  Normally it
+will not make sense to enter a scalar variable in the @var{fixed_factors} and doing
+so may cause @pspp{} to do a lot of unnecessary processing.
+
+The @subcmd{METHOD} subcommand is used to change the method for producing the sums of
+squares.  Available values of @var{type} are 1, 2 and 3.  The default is type 3.
+
+You may specify a custom design using the @subcmd{DESIGN} subcommand.
+The design comprises a list of interactions where each interaction is a 
+list of variables separated by a @samp{*}.  For example the command
+@display
+GLM subject BY sex age_group race
+    /DESIGN = age_group sex group age_group*sex age_group*race
+@end display
+@noindent specifies the model @math{subject = age_group + sex + race + age_group*sex + age_group*race}.
+If no @subcmd{DESIGN} subcommand is specified, then the default is all possible combinations
+of the fixed factors.  That is to say
+@display
+GLM subject BY sex age_group race
+@end display
+implies the model
+@math{subject = age_group + sex + race + age_group*sex + age_group*race + sex*race + age_group*sex*race}.
+
+
+The @subcmd{MISSING} subcommand determines the handling of missing
+variables.  
+If @subcmd{INCLUDE} is set then, for the purposes of GLM analysis,
+only system-missing values are considered
+to be missing; user-missing values are not regarded as missing.
+If @subcmd{EXCLUDE} is set, which is the default, then user-missing
+values are considered to be missing as well as system-missing values. 
+A case for which any dependent variable or any factor
+variable has a missing value is excluded from the analysis.
+
 @node LOGISTIC REGRESSION
 @section LOGISTIC REGRESSION
 
@@ -1442,7 +1602,7 @@ of variable preceding @subcmd{WITH} against variable following
 @display
 T-TEST
         /MISSING=@{ANALYSIS,LISTWISE@} @{EXCLUDE,INCLUDE@}
-        /CRITERIA=CIN(@var{confidence})
+        /CRITERIA=CI(@var{confidence})
 
 
 (One Sample mode.)
@@ -1647,8 +1807,9 @@ The default is 0.05.
 
 @display
 QUICK CLUSTER @var{var_list}
-      [/CRITERIA=CLUSTERS(@var{k}) [MXITER(@var{max_iter})]]
+      [/CRITERIA=CLUSTERS(@var{k}) [MXITER(@var{max_iter})] CONVERGE(@var{epsilon}) [NOINITIAL]]
       [/MISSING=@{EXCLUDE,INCLUDE@} @{LISTWISE, PAIRWISE@}]
+      [/PRINT=@{INITIAL@} @{CLUSTER@}]
 @end display
 
 The @cmd{QUICK CLUSTER} command performs k-means clustering on the
@@ -1658,11 +1819,29 @@ of similar values and you already know the number of clusters.
 The minimum specification is @samp{QUICK CLUSTER} followed by the names
 of the variables which contain the cluster data.  Normally you will also
 want to specify @subcmd{/CRITERIA=CLUSTERS(@var{k})} where @var{k} is the
-number of clusters.  If this is not given, then @var{k} defaults to 2.
+number of clusters.  If this is not specified, then @var{k} defaults to 2.
 
-The command uses an iterative algorithm to determine the clusters for
-each case.  It will continue iterating until convergence, or until @var{max_iter}
-iterations have been done.  The default value of @var{max_iter} is 2.
+If you use @subcmd{/CRITERIA=NOINITIAL} then a naive algorithm to select
+the initial clusters is used.   This will provide for faster execution but
+less well separated initial clusters and hence possibly an inferior final
+result.
+
+
+@cmd{QUICK CLUSTER} uses an iterative algorithm to select the clusters centers.
+The subcommand  @subcmd{/CRITERIA=MXITER(@var{max_iter})} sets the maximum number of iterations.
+During classification, @pspp{} will continue iterating until until @var{max_iter}
+iterations have been done or the convergence criterion (see below) is fulfilled.
+The default value of @var{max_iter} is 2.
+
+If however, you specify @subcmd{/CRITERIA=NOUPDATE} then after selecting the initial centers,
+no further update to the cluster centers is done.  In this case, @var{max_iter}, if specified.
+is ignored.
+
+The subcommand  @subcmd{/CRITERIA=CONVERGE(@var{epsilon})} is used
+to set the convergence criterion.  The value of convergence criterion is  @var{epsilon}
+times the minimum distance between the @emph{initial} cluster centers.  Iteration stops when
+the  mean cluster distance between  one iteration and the next  
+is less than the convergence criterion.  The default value of @var{epsilon} is zero.
 
 The @subcmd{MISSING} subcommand determines the handling of missing variables.  
 If @subcmd{INCLUDE} is set, then user-missing values are considered at their face
@@ -1677,6 +1856,12 @@ clustering variables contain missing values.  Otherwise it is clustered
 on the basis of the non-missing values.
 The default is @subcmd{LISTWISE}.
 
+The @subcmd{PRINT} subcommand requests additional output to be printed.
+If @subcmd{INITIAL} is set, then the initial cluster memberships will
+be printed.
+If @subcmd{CLUSTER} is set, the cluster memberships of the individual
+cases will be displayed (potentially generating lengthy output).
+
 
 @node RANK
 @section RANK
@@ -1855,3 +2040,5 @@ exclude them.
 Cases are excluded on a listwise basis; if any of the variables in @var{var_list} 
 or if the variable @var{state_var} is missing, then the entire case will be 
 excluded.
+
+@c  LocalWords:  subcmd subcommand