1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2005, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 #include <gsl/gsl_cdf.h>
22 #include <gsl/gsl_matrix.h>
24 #include <data/dataset.h>
26 #include "language/command.h"
27 #include "language/lexer/lexer.h"
28 #include "language/lexer/value-parser.h"
29 #include "language/lexer/variable-parser.h"
32 #include "data/casegrouper.h"
33 #include "data/casereader.h"
34 #include "data/dictionary.h"
36 #include "math/covariance.h"
37 #include "math/linreg.h"
38 #include "math/moments.h"
40 #include "libpspp/message.h"
41 #include "libpspp/taint.h"
43 #include "output/tab.h"
46 #define _(msgid) gettext (msgid)
47 #define N_(msgid) msgid
50 #include <gl/intprops.h>
52 #define REG_LARGE_DATA 1000
58 const struct variable **vars;
61 const struct variable **dep_vars;
74 struct regression_workspace
79 static void run_regression (const struct regression *cmd,
81 struct casereader *input);
86 Transformations for saving predicted values
91 linreg *c; /* Linear model for this trns. */
92 const struct variable *var;
96 Gets the predicted values.
99 regression_trns_pred_proc (void *t_, struct ccase **c,
100 casenumber case_idx UNUSED)
104 struct reg_trns *trns = t_;
106 union value *output = NULL;
107 const union value *tmp;
109 const struct variable **vars = NULL;
111 assert (trns != NULL);
113 assert (model != NULL);
114 assert (model->depvar != NULL);
116 vars = linreg_get_vars (model);
117 n_vals = linreg_n_coeffs (model);
118 vals = xnmalloc (n_vals, sizeof (*vals));
119 *c = case_unshare (*c);
121 output = case_data_rw (*c, trns->var);
123 for (i = 0; i < n_vals; i++)
125 tmp = case_data (*c, vars[i]);
128 output->f = linreg_predict (model, vals, n_vals);
130 return TRNS_CONTINUE;
137 regression_trns_resid_proc (void *t_, struct ccase **c,
138 casenumber case_idx UNUSED)
142 struct reg_trns *trns = t_;
144 union value *output = NULL;
145 const union value *tmp;
148 const struct variable **vars = NULL;
150 assert (trns != NULL);
152 assert (model != NULL);
153 assert (model->depvar != NULL);
155 vars = linreg_get_vars (model);
156 n_vals = linreg_n_coeffs (model);
158 vals = xnmalloc (n_vals, sizeof (*vals));
159 *c = case_unshare (*c);
160 output = case_data_rw (*c, trns->var);
161 assert (output != NULL);
163 for (i = 0; i < n_vals; i++)
165 tmp = case_data (*c, vars[i]);
168 tmp = case_data (*c, model->depvar);
170 output->f = linreg_residual (model, obs, vals, n_vals);
173 return TRNS_CONTINUE;
178 reg_get_name (const struct dictionary *dict, const char *prefix)
183 /* XXX handle too-long prefixes */
184 name = xmalloc (strlen (prefix) + INT_BUFSIZE_BOUND (i) + 1);
187 sprintf (name, "%s%d", prefix, i);
188 if (dict_lookup_var (dict, name) == NULL)
194 Free the transformation. Free its linear model if this
195 transformation is the last one.
198 regression_trns_free (void *t_)
200 struct reg_trns *t = t_;
210 static const struct variable *
211 create_aux_var (struct dataset *ds, const char *prefix)
213 struct variable *var;
214 struct dictionary *dict = dataset_dict (ds);
215 char *name = reg_get_name (dict, prefix);
216 var = dict_create_var_assert (dict, name, 0);
222 reg_save_var (struct dataset *ds, trns_proc_func * f,
223 const struct variable *var,
226 struct reg_trns *t = xmalloc (sizeof (*t));
231 add_transformation (ds, f, regression_trns_free, t);
235 subcommand_save (const struct regression *cmd,
236 struct regression_workspace *workspace,
240 for (i = 0; i < cmd->n_dep_vars; ++i)
243 const struct variable *resvar = NULL;
244 const struct variable *predvar = NULL;
247 resvar = create_aux_var (cmd->ds, "RES");
250 predvar = create_aux_var (cmd->ds, "PRED");
252 for (w = 0 ; w < n_m; ++w)
254 linreg **models = workspace[w].models;
255 linreg *lc = models[i];
259 if (lc->depvar == NULL)
264 reg_save_var (cmd->ds, regression_trns_resid_proc, resvar, lc);
269 reg_save_var (cmd->ds, regression_trns_pred_proc, predvar, lc);
276 cmd_regression (struct lexer *lexer, struct dataset *ds)
279 struct regression_workspace *workspace = NULL;
280 size_t n_workspaces = 0;
281 struct regression regression;
282 const struct dictionary *dict = dataset_dict (ds);
285 memset (®ression, 0, sizeof (struct regression));
287 regression.anova = true;
288 regression.coeff = true;
291 regression.pred = false;
292 regression.resid = false;
296 /* Accept an optional, completely pointless "/VARIABLES=" */
297 lex_match (lexer, T_SLASH);
298 if (lex_match_id (lexer, "VARIABLES"))
300 if (!lex_force_match (lexer, T_EQUALS))
304 if (!parse_variables_const (lexer, dict,
305 ®ression.vars, ®ression.n_vars,
306 PV_NO_DUPLICATE | PV_NUMERIC))
310 while (lex_token (lexer) != T_ENDCMD)
312 lex_match (lexer, T_SLASH);
314 if (lex_match_id (lexer, "DEPENDENT"))
316 if (!lex_force_match (lexer, T_EQUALS))
319 if (!parse_variables_const (lexer, dict,
320 ®ression.dep_vars,
321 ®ression.n_dep_vars,
322 PV_NO_DUPLICATE | PV_NUMERIC))
325 else if (lex_match_id (lexer, "METHOD"))
327 lex_match (lexer, T_EQUALS);
329 if (!lex_force_match_id (lexer, "ENTER"))
334 else if (lex_match_id (lexer, "STATISTICS"))
336 lex_match (lexer, T_EQUALS);
338 while (lex_token (lexer) != T_ENDCMD
339 && lex_token (lexer) != T_SLASH)
341 if (lex_match (lexer, T_ALL))
344 else if (lex_match_id (lexer, "DEFAULTS"))
347 else if (lex_match_id (lexer, "R"))
350 else if (lex_match_id (lexer, "COEFF"))
353 else if (lex_match_id (lexer, "ANOVA"))
356 else if (lex_match_id (lexer, "BCOV"))
361 lex_error (lexer, NULL);
366 else if (lex_match_id (lexer, "SAVE"))
368 lex_match (lexer, T_EQUALS);
370 while (lex_token (lexer) != T_ENDCMD
371 && lex_token (lexer) != T_SLASH)
373 if (lex_match_id (lexer, "PRED"))
375 regression.pred = true;
377 else if (lex_match_id (lexer, "RESID"))
379 regression.resid = true;
383 lex_error (lexer, NULL);
390 lex_error (lexer, NULL);
395 if (!regression.vars)
397 dict_get_vars (dict, ®ression.vars, ®ression.n_vars, 0);
401 save = regression.pred || regression.resid;
404 if (proc_make_temporary_transformations_permanent (ds))
405 msg (SW, _("REGRESSION with SAVE ignores TEMPORARY. "
406 "Temporary transformations will be made permanent."));
410 struct casegrouper *grouper;
411 struct casereader *group;
414 grouper = casegrouper_create_splits (proc_open_filtering (ds, !save),
416 while (casegrouper_get_next_group (grouper, &group))
418 workspace = xrealloc (workspace, sizeof (workspace) * (n_workspaces + 1));
419 workspace[n_workspaces].models = xcalloc (regression.n_dep_vars, sizeof (linreg *));
420 run_regression (®ression, workspace[n_workspaces++].models, group);
422 ok = casegrouper_destroy (grouper);
423 ok = proc_commit (ds) && ok;
428 subcommand_save (®ression, workspace, n_workspaces);
431 for (w = 0 ; w < n_workspaces; ++w)
434 linreg **models = workspace[w].models;
435 for (i = 0; i < regression.n_dep_vars; ++i)
436 linreg_unref (models[i]);
441 free (regression.vars);
442 free (regression.dep_vars);
446 for (w = 0 ; w < n_workspaces; ++w)
449 linreg **models = workspace[w].models;
450 for (i = 0; i < regression.n_dep_vars; ++i)
451 linreg_unref (models[i]);
456 free (regression.vars);
457 free (regression.dep_vars);
463 get_n_all_vars (const struct regression *cmd)
465 size_t result = cmd->n_vars;
469 result += cmd->n_dep_vars;
470 for (i = 0; i < cmd->n_dep_vars; i++)
472 for (j = 0; j < cmd->n_vars; j++)
474 if (cmd->vars[j] == cmd->dep_vars[i])
484 fill_all_vars (const struct variable **vars, const struct regression *cmd)
490 for (i = 0; i < cmd->n_vars; i++)
492 vars[i] = cmd->vars[i];
494 for (i = 0; i < cmd->n_dep_vars; i++)
497 for (j = 0; j < cmd->n_vars; j++)
499 if (cmd->dep_vars[i] == cmd->vars[j])
507 vars[i + cmd->n_vars] = cmd->dep_vars[i];
513 Is variable k the dependent variable?
516 is_depvar (const struct regression *cmd, size_t k, const struct variable *v)
518 return v == cmd->vars[k];
522 /* Identify the explanatory variables in v_variables. Returns
523 the number of independent variables. */
525 identify_indep_vars (const struct regression *cmd,
526 const struct variable **indep_vars,
527 const struct variable *depvar)
529 int n_indep_vars = 0;
532 for (i = 0; i < cmd->n_vars; i++)
533 if (!is_depvar (cmd, i, depvar))
534 indep_vars[n_indep_vars++] = cmd->vars[i];
535 if ((n_indep_vars < 1) && is_depvar (cmd, 0, depvar))
538 There is only one independent variable, and it is the same
539 as the dependent variable. Print a warning and continue.
543 ("The dependent variable is equal to the independent variable."
544 "The least squares line is therefore Y=X."
545 "Standard errors and related statistics may be meaningless."));
547 indep_vars[0] = cmd->vars[0];
554 fill_covariance (gsl_matrix * cov, struct covariance *all_cov,
555 const struct variable **vars,
556 size_t n_vars, const struct variable *dep_var,
557 const struct variable **all_vars, size_t n_all_vars,
562 size_t dep_subscript;
564 const gsl_matrix *ssizes;
565 const gsl_matrix *mean_matrix;
566 const gsl_matrix *ssize_matrix;
569 gsl_matrix *cm = covariance_calculate_unnormalized (all_cov);
574 rows = xnmalloc (cov->size1 - 1, sizeof (*rows));
576 for (i = 0; i < n_all_vars; i++)
578 for (j = 0; j < n_vars; j++)
580 if (vars[j] == all_vars[i])
585 if (all_vars[i] == dep_var)
590 mean_matrix = covariance_moments (all_cov, MOMENT_MEAN);
591 ssize_matrix = covariance_moments (all_cov, MOMENT_NONE);
592 for (i = 0; i < cov->size1 - 1; i++)
594 means[i] = gsl_matrix_get (mean_matrix, rows[i], 0)
595 / gsl_matrix_get (ssize_matrix, rows[i], 0);
596 for (j = 0; j < cov->size2 - 1; j++)
598 gsl_matrix_set (cov, i, j, gsl_matrix_get (cm, rows[i], rows[j]));
599 gsl_matrix_set (cov, j, i, gsl_matrix_get (cm, rows[j], rows[i]));
602 means[cov->size1 - 1] = gsl_matrix_get (mean_matrix, dep_subscript, 0)
603 / gsl_matrix_get (ssize_matrix, dep_subscript, 0);
604 ssizes = covariance_moments (all_cov, MOMENT_NONE);
605 result = gsl_matrix_get (ssizes, dep_subscript, rows[0]);
606 for (i = 0; i < cov->size1 - 1; i++)
608 gsl_matrix_set (cov, i, cov->size1 - 1,
609 gsl_matrix_get (cm, rows[i], dep_subscript));
610 gsl_matrix_set (cov, cov->size1 - 1, i,
611 gsl_matrix_get (cm, rows[i], dep_subscript));
612 if (result > gsl_matrix_get (ssizes, rows[i], dep_subscript))
614 result = gsl_matrix_get (ssizes, rows[i], dep_subscript);
617 gsl_matrix_set (cov, cov->size1 - 1, cov->size1 - 1,
618 gsl_matrix_get (cm, dep_subscript, dep_subscript));
620 gsl_matrix_free (cm);
626 STATISTICS subcommand output functions.
628 static void reg_stats_r (linreg *, void *, const struct variable *);
629 static void reg_stats_coeff (linreg *, void *, const struct variable *);
630 static void reg_stats_anova (linreg *, void *, const struct variable *);
631 static void reg_stats_bcov (linreg *, void *, const struct variable *);
634 statistics_keyword_output (void (*)
635 (linreg *, void *, const struct variable *), bool,
636 linreg *, void *, const struct variable *);
641 subcommand_statistics (const struct regression *cmd, linreg * c, void *aux,
642 const struct variable *var)
644 statistics_keyword_output (reg_stats_r, cmd->r, c, aux, var);
645 statistics_keyword_output (reg_stats_anova, cmd->anova, c, aux, var);
646 statistics_keyword_output (reg_stats_coeff, cmd->coeff, c, aux, var);
647 statistics_keyword_output (reg_stats_bcov, cmd->bcov, c, aux, var);
652 run_regression (const struct regression *cmd, linreg **models, struct casereader *input)
659 struct covariance *cov;
660 const struct variable **vars;
661 const struct variable **all_vars;
662 struct casereader *reader;
665 n_all_vars = get_n_all_vars (cmd);
666 all_vars = xnmalloc (n_all_vars, sizeof (*all_vars));
667 fill_all_vars (all_vars, cmd);
668 vars = xnmalloc (cmd->n_vars, sizeof (*vars));
669 means = xnmalloc (n_all_vars, sizeof (*means));
670 cov = covariance_1pass_create (n_all_vars, all_vars,
671 dict_get_weight (dataset_dict (cmd->ds)),
674 reader = casereader_clone (input);
675 reader = casereader_create_filter_missing (reader, all_vars, n_all_vars,
679 for (; (c = casereader_read (reader)) != NULL; case_unref (c))
681 covariance_accumulate (cov, c);
684 for (k = 0; k < cmd->n_dep_vars; k++)
687 const struct variable *dep_var = cmd->dep_vars[k];
690 n_indep = identify_indep_vars (cmd, vars, dep_var);
692 this_cm = gsl_matrix_alloc (n_indep + 1, n_indep + 1);
693 n_data = fill_covariance (this_cm, cov, vars, n_indep,
694 dep_var, all_vars, n_all_vars, means);
695 models[k] = linreg_alloc (dep_var, vars, n_data, n_indep);
696 models[k]->depvar = dep_var;
697 for (i = 0; i < n_indep; i++)
699 linreg_set_indep_variable_mean (models[k], i, means[i]);
701 linreg_set_depvar_mean (models[k], means[i]);
703 For large data sets, use QR decomposition.
705 if (n_data > sqrt (n_indep) && n_data > REG_LARGE_DATA)
707 models[k]->method = LINREG_QR;
713 Find the least-squares estimates and other statistics.
715 linreg_fit (this_cm, models[k]);
717 if (!taint_has_tainted_successor (casereader_get_taint (input)))
719 subcommand_statistics (cmd, models[k], this_cm, dep_var);
724 msg (SE, _("No valid data found. This command was skipped."));
726 gsl_matrix_free (this_cm);
729 casereader_destroy (reader);
733 casereader_destroy (input);
734 covariance_destroy (cov);
742 reg_stats_r (linreg * c, void *aux UNUSED, const struct variable *var)
752 rsq = linreg_ssreg (c) / linreg_sst (c);
754 (1.0 - rsq) * linreg_n_coeffs (c) / (linreg_n_obs (c) -
755 linreg_n_coeffs (c) - 1);
756 std_error = sqrt (linreg_mse (c));
757 t = tab_create (n_cols, n_rows);
758 tab_box (t, TAL_2, TAL_2, -1, TAL_1, 0, 0, n_cols - 1, n_rows - 1);
759 tab_hline (t, TAL_2, 0, n_cols - 1, 1);
760 tab_vline (t, TAL_2, 2, 0, n_rows - 1);
761 tab_vline (t, TAL_0, 1, 0, 0);
763 tab_text (t, 1, 0, TAB_CENTER | TAT_TITLE, _("R"));
764 tab_text (t, 2, 0, TAB_CENTER | TAT_TITLE, _("R Square"));
765 tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("Adjusted R Square"));
766 tab_text (t, 4, 0, TAB_CENTER | TAT_TITLE, _("Std. Error of the Estimate"));
767 tab_double (t, 1, 1, TAB_RIGHT, sqrt (rsq), NULL);
768 tab_double (t, 2, 1, TAB_RIGHT, rsq, NULL);
769 tab_double (t, 3, 1, TAB_RIGHT, adjrsq, NULL);
770 tab_double (t, 4, 1, TAB_RIGHT, std_error, NULL);
771 tab_title (t, _("Model Summary (%s)"), var_to_string (var));
776 Table showing estimated regression coefficients.
779 reg_stats_coeff (linreg * c, void *aux_, const struct variable *var)
791 const struct variable *v;
793 gsl_matrix *cov = aux_;
796 n_rows = linreg_n_coeffs (c) + 3;
798 t = tab_create (n_cols, n_rows);
799 tab_headers (t, 2, 0, 1, 0);
800 tab_box (t, TAL_2, TAL_2, -1, TAL_1, 0, 0, n_cols - 1, n_rows - 1);
801 tab_hline (t, TAL_2, 0, n_cols - 1, 1);
802 tab_vline (t, TAL_2, 2, 0, n_rows - 1);
803 tab_vline (t, TAL_0, 1, 0, 0);
805 tab_text (t, 2, 0, TAB_CENTER | TAT_TITLE, _("B"));
806 tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("Std. Error"));
807 tab_text (t, 4, 0, TAB_CENTER | TAT_TITLE, _("Beta"));
808 tab_text (t, 5, 0, TAB_CENTER | TAT_TITLE, _("t"));
809 tab_text (t, 6, 0, TAB_CENTER | TAT_TITLE, _("Significance"));
810 tab_text (t, 1, 1, TAB_LEFT | TAT_TITLE, _("(Constant)"));
811 tab_double (t, 2, 1, 0, linreg_intercept (c), NULL);
812 std_err = sqrt (gsl_matrix_get (linreg_cov (c), 0, 0));
813 tab_double (t, 3, 1, 0, std_err, NULL);
814 tab_double (t, 4, 1, 0, 0.0, NULL);
815 t_stat = linreg_intercept (c) / std_err;
816 tab_double (t, 5, 1, 0, t_stat, NULL);
818 2 * gsl_cdf_tdist_Q (fabs (t_stat),
819 (double) (linreg_n_obs (c) - linreg_n_coeffs (c)));
820 tab_double (t, 6, 1, 0, pval, NULL);
821 for (j = 0; j < linreg_n_coeffs (c); j++)
824 ds_init_empty (&tstr);
827 v = linreg_indep_var (c, j);
828 label = var_to_string (v);
829 /* Do not overwrite the variable's name. */
830 ds_put_cstr (&tstr, label);
831 tab_text (t, 1, this_row, TAB_CENTER, ds_cstr (&tstr));
833 Regression coefficients.
835 tab_double (t, 2, this_row, 0, linreg_coeff (c, j), NULL);
837 Standard error of the coefficients.
839 std_err = sqrt (gsl_matrix_get (linreg_cov (c), j + 1, j + 1));
840 tab_double (t, 3, this_row, 0, std_err, NULL);
842 Standardized coefficient, i.e., regression coefficient
843 if all variables had unit variance.
845 beta = sqrt (gsl_matrix_get (cov, j, j));
846 beta *= linreg_coeff (c, j) /
847 sqrt (gsl_matrix_get (cov, cov->size1 - 1, cov->size2 - 1));
848 tab_double (t, 4, this_row, 0, beta, NULL);
851 Test statistic for H0: coefficient is 0.
853 t_stat = linreg_coeff (c, j) / std_err;
854 tab_double (t, 5, this_row, 0, t_stat, NULL);
856 P values for the test statistic above.
859 2 * gsl_cdf_tdist_Q (fabs (t_stat),
860 (double) (linreg_n_obs (c) -
861 linreg_n_coeffs (c) - 1));
862 tab_double (t, 6, this_row, 0, pval, NULL);
865 tab_title (t, _("Coefficients (%s)"), var_to_string (var));
870 Display the ANOVA table.
873 reg_stats_anova (linreg * c, void *aux UNUSED, const struct variable *var)
877 const double msm = linreg_ssreg (c) / linreg_dfmodel (c);
878 const double mse = linreg_mse (c);
879 const double F = msm / mse;
880 const double pval = gsl_cdf_fdist_Q (F, c->dfm, c->dfe);
885 t = tab_create (n_cols, n_rows);
886 tab_headers (t, 2, 0, 1, 0);
888 tab_box (t, TAL_2, TAL_2, -1, TAL_1, 0, 0, n_cols - 1, n_rows - 1);
890 tab_hline (t, TAL_2, 0, n_cols - 1, 1);
891 tab_vline (t, TAL_2, 2, 0, n_rows - 1);
892 tab_vline (t, TAL_0, 1, 0, 0);
894 tab_text (t, 2, 0, TAB_CENTER | TAT_TITLE, _("Sum of Squares"));
895 tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("df"));
896 tab_text (t, 4, 0, TAB_CENTER | TAT_TITLE, _("Mean Square"));
897 tab_text (t, 5, 0, TAB_CENTER | TAT_TITLE, _("F"));
898 tab_text (t, 6, 0, TAB_CENTER | TAT_TITLE, _("Significance"));
900 tab_text (t, 1, 1, TAB_LEFT | TAT_TITLE, _("Regression"));
901 tab_text (t, 1, 2, TAB_LEFT | TAT_TITLE, _("Residual"));
902 tab_text (t, 1, 3, TAB_LEFT | TAT_TITLE, _("Total"));
904 /* Sums of Squares */
905 tab_double (t, 2, 1, 0, linreg_ssreg (c), NULL);
906 tab_double (t, 2, 3, 0, linreg_sst (c), NULL);
907 tab_double (t, 2, 2, 0, linreg_sse (c), NULL);
910 /* Degrees of freedom */
911 tab_text_format (t, 3, 1, TAB_RIGHT, "%g", c->dfm);
912 tab_text_format (t, 3, 2, TAB_RIGHT, "%g", c->dfe);
913 tab_text_format (t, 3, 3, TAB_RIGHT, "%g", c->dft);
916 tab_double (t, 4, 1, TAB_RIGHT, msm, NULL);
917 tab_double (t, 4, 2, TAB_RIGHT, mse, NULL);
919 tab_double (t, 5, 1, 0, F, NULL);
921 tab_double (t, 6, 1, 0, pval, NULL);
923 tab_title (t, _("ANOVA (%s)"), var_to_string (var));
929 reg_stats_bcov (linreg * c, void *aux UNUSED, const struct variable *var)
941 n_cols = c->n_indeps + 1 + 2;
942 n_rows = 2 * (c->n_indeps + 1);
943 t = tab_create (n_cols, n_rows);
944 tab_headers (t, 2, 0, 1, 0);
945 tab_box (t, TAL_2, TAL_2, -1, TAL_1, 0, 0, n_cols - 1, n_rows - 1);
946 tab_hline (t, TAL_2, 0, n_cols - 1, 1);
947 tab_vline (t, TAL_2, 2, 0, n_rows - 1);
948 tab_vline (t, TAL_0, 1, 0, 0);
949 tab_text (t, 0, 0, TAB_CENTER | TAT_TITLE, _("Model"));
950 tab_text (t, 1, 1, TAB_CENTER | TAT_TITLE, _("Covariances"));
951 for (i = 0; i < linreg_n_coeffs (c); i++)
953 const struct variable *v = linreg_indep_var (c, i);
954 label = var_to_string (v);
955 tab_text (t, 2, i, TAB_CENTER, label);
956 tab_text (t, i + 2, 0, TAB_CENTER, label);
957 for (k = 1; k < linreg_n_coeffs (c); k++)
959 col = (i <= k) ? k : i;
960 row = (i <= k) ? i : k;
961 tab_double (t, k + 2, i, TAB_CENTER,
962 gsl_matrix_get (c->cov, row, col), NULL);
965 tab_title (t, _("Coefficient Correlations (%s)"), var_to_string (var));
970 statistics_keyword_output (void (*function)
971 (linreg *, void *, const struct variable * var),
972 bool keyword, linreg * c, void *aux,
973 const struct variable *var)
977 (*function) (c, aux, var);