From 5ce0aa4323a1caafd709713671bae889e8410057 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sun, 8 Mar 2015 13:20:26 -0700 Subject: [PATCH] FACTOR: Support ANALYSIS subcommand. This appears in syntax generated by SPSS. Thanks to Tom Smekens for reporting the omission. --- doc/statistics.texi | 7 ++++++- src/language/stats/factor.c | 25 +++++++++++++++++++++++-- tests/language/stats/factor.at | 4 +++- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/doc/statistics.texi b/doc/statistics.texi index d333de1db2..1e24c17351 100644 --- a/doc/statistics.texi +++ b/doc/statistics.texi @@ -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. diff --git a/src/language/stats/factor.c b/src/language/stats/factor.c index c34feb8d05..ed93271b90 100644 --- a/src/language/stats/factor.c +++ b/src/language/stats/factor.c @@ -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) diff --git a/tests/language/stats/factor.at b/tests/language/stats/factor.at index 59acba9d48..9ac08b52c7 100644 --- a/tests/language/stats/factor.at +++ b/tests/language/stats/factor.at @@ -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) -- 2.30.2