From cd62d8a6af433560a534fabb84bb06030bc89b57 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Thu, 9 Jul 2015 17:46:00 +0200 Subject: [PATCH] Fix behaviour of the REGRESSION /STATISTICS subcommand. --- doc/regression.texi | 6 ++++-- src/language/stats/regression.c | 19 ++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/doc/regression.texi b/doc/regression.texi index 9ff569d4d6..de639352d0 100644 --- a/doc/regression.texi +++ b/doc/regression.texi @@ -20,7 +20,7 @@ the @math{k}th explanatory variable. @item The dependent variable @math{Y} has the following relationship to the explanatory variables: -@math{Y_i = b_0 + b_1 X_{1i} + ... + b_k X_{ki} + Z_i} +@math{Y_i = b_0 + b_1 X_{1i} + ... + b_k X_{ki} + Z_i} where @math{b_0, b_1, @dots{}, b_k} are unknown coefficients, and @math{Z_1,@dots{},Z_n} are independent, normally distributed @dfn{noise} terms with mean zero and common variance. @@ -61,7 +61,7 @@ are treated as explanatory variables in the linear model. All other subcommands are optional: -The @subcmd{STATISTICS} subcommand specifies additional statistics to be displayed. +The @subcmd{STATISTICS} subcommand specifies which statistics are to be displayed. The following keywords are accepted: @table @subcmd @@ -82,6 +82,8 @@ Analysis of variance table for the model. The covariance matrix for the estimated model coefficients. @item DEFAULT The same as if R, COEFF, and ANOVA had been selected. +This is what you get if the /STATISTICS command is not specified, +or if it is specified without any parameters. @end table The @subcmd{SAVE} subcommand causes @pspp{} to save the residuals or predicted diff --git a/src/language/stats/regression.c b/src/language/stats/regression.c index 52009e2968..51502e5fe0 100644 --- a/src/language/stats/regression.c +++ b/src/language/stats/regression.c @@ -248,6 +248,7 @@ cmd_regression (struct lexer *lexer, struct dataset *ds) } else if (lex_match_id (lexer, "STATISTICS")) { + unsigned long statistics = 0; lex_match (lexer, T_EQUALS); while (lex_token (lexer) != T_ENDCMD @@ -255,31 +256,31 @@ cmd_regression (struct lexer *lexer, struct dataset *ds) { if (lex_match (lexer, T_ALL)) { - regression.stats = ~0; + statistics = ~0; } else if (lex_match_id (lexer, "DEFAULTS")) { - regression.stats |= STATS_DEFAULT; + statistics |= STATS_DEFAULT; } else if (lex_match_id (lexer, "R")) { - regression.stats |= STATS_R; + statistics |= STATS_R; } else if (lex_match_id (lexer, "COEFF")) { - regression.stats |= STATS_COEFF; + statistics |= STATS_COEFF; } else if (lex_match_id (lexer, "ANOVA")) { - regression.stats |= STATS_ANOVA; + statistics |= STATS_ANOVA; } else if (lex_match_id (lexer, "BCOV")) { - regression.stats |= STATS_BCOV; + statistics |= STATS_BCOV; } else if (lex_match_id (lexer, "CI")) { - regression.stats |= STATS_CI; + statistics |= STATS_CI; if (lex_match (lexer, T_LPAREN)) { @@ -294,6 +295,10 @@ cmd_regression (struct lexer *lexer, struct dataset *ds) goto error; } } + + if (statistics) + regression.stats = statistics; + } else if (lex_match_id (lexer, "SAVE")) { -- 2.30.2