FACTOR: Support ANALYSIS subcommand.
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 8 Mar 2015 20:20:26 +0000 (13:20 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 8 Mar 2015 20:20:26 +0000 (13:20 -0700)
This appears in syntax generated by SPSS.

Thanks to Tom Smekens for reporting the omission.

doc/statistics.texi
src/language/stats/factor.c
tests/language/stats/factor.at

index d333de1db24acf10050b413ff000fc063f31f97c..1e24c173516bcfa62ebb8d8af0ad432e3d1d9a34 100644 (file)
@@ -709,6 +709,8 @@ FACTOR  VARIABLES=@var{var_list}
 
         [ /METHOD = @{CORRELATION, COVARIANCE@} ]
 
+        [ /ANALYSIS=@var{var_list} ]
+
         [ /EXTRACTION=@{PC, PAF@}] 
 
         [ /ROTATION=@{VARIMAX, EQUAMAX, QUARTIMAX, PROMAX[(@var{k})], NOROTATE@}]
@@ -727,7 +729,10 @@ 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{VARIABLES} subcommand is required.  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.)
 
 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.  
index c34feb8d05ee7312e0f1e0cbf08be7c4002b0cd3..ed93271b90c5e7d71ddc0d946dea1164bd89d785 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2009, 2010, 2011, 2012, 2014 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010, 2011, 2012, 2014, 2015 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -1051,7 +1051,28 @@ cmd_factor (struct lexer *lexer, struct dataset *ds)
     {
       lex_match (lexer, T_SLASH);
 
-      if (lex_match_id (lexer, "PLOT"))
+      if (lex_match_id (lexer, "ANALYSIS"))
+        {
+          struct const_var_set *vs;
+          const struct variable **vars;
+          size_t n_vars;
+          bool ok;
+
+          lex_match (lexer, T_EQUALS);
+
+          vs = const_var_set_create_from_array (factor.vars, factor.n_vars);
+          ok = parse_const_var_set_vars (lexer, vs, &vars, &n_vars,
+                                         PV_NO_DUPLICATE | PV_NUMERIC);
+          const_var_set_destroy (vs);
+
+          if (!ok)
+            goto error;
+
+          free (factor.vars);
+          factor.vars = vars;
+          factor.n_vars = n_vars;
+        }
+      else if (lex_match_id (lexer, "PLOT"))
        {
           lex_match (lexer, T_EQUALS);
           while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
index 59acba9d4871ad4809ec1c25f020e4c8455e62b0..9ac08b52c70a3e0d8ee2aefeb0cf334c3fe34988 100644 (file)
@@ -1444,6 +1444,7 @@ missing values
 
 factor
  /variables question13 question14 question15 question16 question17 question18 question19 question20 question21 question22 question23 question24
+ /analysis all
  /print univariate det correlation
  /format blank(.30)
  /plot eigen
@@ -1731,7 +1732,8 @@ begin data.
 end data.
 
 factor
-  /variables read write math science socst  
+  /variables read write math science socst
+  /analysis read write math science socst
   /extraction pc
   /plot eigen
   /criteria mineigen (.557)