1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2011, 2012 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/>. */
19 #include "data/case.h"
20 #include "data/casegrouper.h"
21 #include "data/casereader.h"
22 #include "data/dataset.h"
23 #include "data/dictionary.h"
24 #include "data/format.h"
25 #include "data/variable.h"
27 #include "language/command.h"
28 #include "language/lexer/lexer.h"
29 #include "language/lexer/variable-parser.h"
31 #include "libpspp/misc.h"
32 #include "libpspp/pool.h"
34 #include "math/categoricals.h"
35 #include "math/interaction.h"
36 #include "math/moments.h"
38 #include "output/tab.h"
43 #define _(msgid) gettext (msgid)
44 #define N_(msgid) (msgid)
56 typedef void *stat_create (const struct means *, struct pool *pool);
58 typedef void stat_update (const struct means *, void *stat, double w, double x);
60 typedef double stat_get (const struct means *, struct per_var_data *, void *aux);
65 /* Printable title for output */
68 /* Keyword for syntax */
85 harmonic_create (const struct means *means UNUSED, struct pool *pool)
87 struct harmonic_mean *hm = pool_alloc (pool, sizeof *hm);
97 harmonic_update (const struct means *means UNUSED, void *stat, double w, double x)
99 struct harmonic_mean *hm = stat;
106 harmonic_get (const struct means *means UNUSED, struct per_var_data *pvd UNUSED, void *stat)
108 struct harmonic_mean *hm = stat;
110 return hm->n / hm->rsum;
115 struct geometric_mean
123 geometric_create (const struct means *means UNUSED, struct pool *pool)
125 struct geometric_mean *gm = pool_alloc (pool, sizeof *gm);
135 geometric_update (const struct means *means UNUSED, void *stat, double w, double x)
137 struct geometric_mean *gm = stat;
138 gm->prod *= pow (x, w);
144 geometric_get (const struct means *means UNUSED, struct per_var_data *pvd UNUSED, void *stat)
146 struct geometric_mean *gm = stat;
148 return pow (gm->prod, 1.0 / gm->n);
154 sum_get (const struct means *means UNUSED, struct per_var_data *pvd, void *stat UNUSED)
158 moments1_calculate (pvd->mom, &n, &mean, 0, 0, 0);
165 n_get (const struct means *means UNUSED, struct per_var_data *pvd, void *stat UNUSED)
169 moments1_calculate (pvd->mom, &n, 0, 0, 0, 0);
175 arithmean_get (const const struct means *means UNUSED, struct per_var_data *pvd, void *stat UNUSED)
179 moments1_calculate (pvd->mom, &n, &mean, 0, 0, 0);
185 variance_get (const const struct means *means UNUSED, struct per_var_data *pvd, void *stat UNUSED)
187 double n, mean, variance;
189 moments1_calculate (pvd->mom, &n, &mean, &variance, 0, 0);
196 stddev_get (const const struct means *means UNUSED, struct per_var_data *pvd, void *stat)
198 return sqrt (variance_get (means, pvd, stat));
205 skew_get (const const struct means *means UNUSED, struct per_var_data *pvd, void *stat UNUSED)
209 moments1_calculate (pvd->mom, NULL, NULL, NULL, &skew, 0);
215 sekurt_get (const const struct means *means UNUSED, struct per_var_data *pvd, void *stat UNUSED)
219 moments1_calculate (pvd->mom, &n, NULL, NULL, NULL, NULL);
221 return calc_sekurt (n);
227 seskew_get (const const struct means *means UNUSED, struct per_var_data *pvd, void *stat UNUSED)
231 moments1_calculate (pvd->mom, &n, NULL, NULL, NULL, NULL);
233 return calc_seskew (n);
239 kurt_get (const const struct means *means UNUSED, struct per_var_data *pvd, void *stat UNUSED)
243 moments1_calculate (pvd->mom, NULL, NULL, NULL, NULL, &kurt);
250 semean_get (const struct means *means UNUSED, struct per_var_data *pvd, void *stat UNUSED)
254 moments1_calculate (pvd->mom, &n, NULL, &var, NULL, NULL);
256 return sqrt (var / n);
264 min_create (const struct means *means UNUSED, struct pool *pool)
266 double *r = pool_alloc (pool, sizeof *r);
274 min_update (const struct means *means UNUSED, void *stat, double w UNUSED, double x)
283 min_get (const const struct means *means UNUSED, struct per_var_data *pvd UNUSED, void *stat)
291 max_create (const struct means *means UNUSED, struct pool *pool)
293 double *r = pool_alloc (pool, sizeof *r);
301 max_update (const struct means *means UNUSED, void *stat, double w UNUSED, double x)
310 max_get (const const struct means *means UNUSED, struct per_var_data *pvd UNUSED, void *stat)
326 range_create (const struct means *means UNUSED, struct pool *pool)
328 struct range *r = pool_alloc (pool, sizeof *r);
337 range_update (const struct means *means UNUSED, void *stat, double w UNUSED, double x)
339 struct range *r = stat;
349 range_get (const const struct means *means UNUSED, struct per_var_data *pvd UNUSED, void *stat)
351 struct range *r = stat;
353 return r->max - r->min;
359 last_create (const struct means *means UNUSED, struct pool *pool)
361 double *l = pool_alloc (pool, sizeof *l);
367 last_update (const struct means *means UNUSED, void *stat, double w UNUSED, double x)
375 last_get (const const struct means *means UNUSED, struct per_var_data *pvd UNUSED, void *stat)
384 first_create (const struct means *means UNUSED, struct pool *pool)
386 double *f = pool_alloc (pool, sizeof *f);
394 first_update (const struct means *means UNUSED, void *stat, double w UNUSED, double x)
403 first_get (const const struct means *means UNUSED, struct per_var_data *pvd UNUSED, void *stat)
412 /* Table of cell_specs */
413 static const struct cell_spec cell_spec[] = {
414 {N_("Mean"), "MEAN", NULL, NULL, arithmean_get},
415 {N_("N"), "COUNT", NULL, NULL, n_get},
416 {N_("Std. Deviation"), "STDDEV", NULL, NULL, stddev_get},
418 {N_("Median"), "MEDIAN", NULL, NULL, NULL},
419 {N_("Group Median"), "GMEDIAN", NULL, NULL, NULL},
421 {N_("S.E. Mean"), "SEMEAN", NULL, NULL, semean_get},
422 {N_("Sum"), "SUM", NULL, NULL, sum_get},
423 {N_("Min"), "MIN", min_create, min_update, min_get},
424 {N_("Max"), "MAX", max_create, max_update, max_get},
425 {N_("Range"), "RANGE", range_create, range_update, range_get},
426 {N_("Variance"), "VARIANCE", NULL, NULL, variance_get},
427 {N_("Kurtosis"), "KURT", NULL, NULL, kurt_get},
428 {N_("S.E. Kurt"), "SEKURT", NULL, NULL, sekurt_get},
429 {N_("Skewness"), "SKEW", NULL, NULL, skew_get},
430 {N_("S.E. Skew"), "SESKEW", NULL, NULL, seskew_get},
431 {N_("First"), "FIRST", first_create, first_update, first_get},
432 {N_("Last"), "LAST", last_create, last_update, last_get},
434 {N_("Percent N"), "NPCT", NULL, NULL, NULL},
435 {N_("Percent Sum"), "SPCT", NULL, NULL, NULL},
437 {N_("Harmonic Mean"), "HARMONIC", harmonic_create, harmonic_update, harmonic_get},
438 {N_("Geom. Mean"), "GEOMETRIC", geometric_create, geometric_update, geometric_get}
441 #define n_C (sizeof (cell_spec) / sizeof (struct cell_spec))
447 casenumber non_missing;
451 /* The thing parsed after TABLES= */
455 const struct variable **dep_vars;
457 size_t n_interactions;
458 struct interaction **interactions;
459 struct summary *summary;
461 size_t *n_factor_vars;
462 const struct variable ***factor_vars;
468 struct categoricals *cats;
473 const struct dictionary *dict;
475 struct mtable *table;
478 /* Missing value class for categorical variables */
479 enum mv_class exclude;
481 /* Missing value class for dependent variables */
482 enum mv_class dep_exclude;
484 /* an array indicating which statistics are to be calculated */
490 /* Pool on which cell functions may allocate data */
496 run_means (struct means *cmd, struct casereader *input,
497 const struct dataset *ds);
499 /* Append all the variables belonging to layer and all subsequent layers
500 to iact. And then append iact to the means->interaction.
501 This is a recursive function.
504 iact_append_factor (struct mtable *means, int layer,
505 const struct interaction *iact)
508 const struct variable **fv;
510 if (layer >= means->n_layers)
513 fv = means->factor_vars[layer];
515 for (v = 0; v < means->n_factor_vars[layer]; ++v)
517 struct interaction *nexti = interaction_clone (iact);
519 interaction_add_variable (nexti, fv[v]);
521 iact_append_factor (means, layer + 1, nexti);
523 if (layer == means->n_layers - 1)
525 means->interactions[means->ii++] = nexti;
531 parse_means_table_syntax (struct lexer *lexer, const struct means *cmd, struct mtable *table)
535 table->factor_vars = NULL;
536 table->n_factor_vars = NULL;
538 /* Dependent variable (s) */
539 if (!parse_variables_const (lexer, cmd->dict,
540 &table->dep_vars, &table->n_dep_vars,
541 PV_NO_DUPLICATE | PV_NUMERIC))
544 /* Factor variable (s) */
545 while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
547 if (lex_match (lexer, T_BY))
551 xrealloc (table->factor_vars,
552 sizeof (*table->factor_vars) * table->n_layers);
554 table->n_factor_vars =
555 xrealloc (table->n_factor_vars,
556 sizeof (*table->n_factor_vars) * table->n_layers);
558 if (!parse_variables_const (lexer, cmd->dict,
559 &table->factor_vars[table->n_layers - 1],
560 &table->n_factor_vars[table->n_layers -
572 If the match succeeds, the variable will be placed in VAR.
573 Returns true if successful */
575 lex_is_variable (struct lexer *lexer, const struct dictionary *dict,
579 if (lex_next_token (lexer, n) != T_ID)
582 tstr = lex_next_tokcstr (lexer, n);
584 if (NULL == dict_lookup_var (dict, tstr) )
592 cmd_means (struct lexer *lexer, struct dataset *ds)
598 bool more_tables = true;
600 means.exclude = MV_ANY;
601 means.dep_exclude = MV_ANY;
605 means.dict = dataset_dict (ds);
608 means.cells = xcalloc (means.n_cells, sizeof (*means.cells));
611 /* The first three items (MEAN, COUNT, STDDEV) are the default */
612 for (i = 0; i < 3; ++i)
616 /* Optional TABLES = */
617 if (lex_match_id (lexer, "TABLES"))
619 lex_force_match (lexer, T_EQUALS);
624 /* Parse the "tables" */
628 means.table = xrealloc (means.table, means.n_tables * sizeof (*means.table));
630 if (! parse_means_table_syntax (lexer, &means,
631 &means.table[means.n_tables - 1]))
636 /* Look ahead to see if there are more tables to be parsed */
638 if ( T_SLASH == lex_next_token (lexer, 0) )
640 if (lex_is_variable (lexer, means.dict, 1) )
643 lex_force_match (lexer, T_SLASH);
648 /* /MISSING subcommand */
649 while (lex_token (lexer) != T_ENDCMD)
651 lex_match (lexer, T_SLASH);
653 if (lex_match_id (lexer, "MISSING"))
656 If no MISSING subcommand is specified, each combination of
657 a dependent variable and categorical variables is handled
660 lex_match (lexer, T_EQUALS);
661 if (lex_match_id (lexer, "INCLUDE"))
664 Use the subcommand "/MISSING=INCLUDE" to include user-missing
665 values in the analysis.
668 means.exclude = MV_SYSTEM;
669 means.dep_exclude = MV_SYSTEM;
671 else if (lex_match_id (lexer, "TABLE"))
673 This is the default. (I think).
674 Every case containing a complete set of variables for a given
675 table. If any variable, categorical or dependent for in a table
676 is missing (as defined by what?), then that variable will
677 be dropped FOR THAT TABLE ONLY.
680 means.exclude = MV_ANY;
681 means.dep_exclude = MV_ANY;
683 else if (lex_match_id (lexer, "DEPENDENT"))
685 Use the command "/MISSING=DEPENDENT" to
686 include user-missing values for the categorical variables,
687 while excluding them for the dependent variables.
689 Cases are dropped only when user-missing values
690 appear in dependent variables. User-missing
691 values for categorical variables are treated according to
694 Cases are ALWAYS dropped when System Missing values appear
695 in the categorical variables.
698 means.dep_exclude = MV_ANY;
699 means.exclude = MV_SYSTEM;
703 lex_error (lexer, NULL);
707 else if (lex_match_id (lexer, "CELLS"))
709 lex_match (lexer, T_EQUALS);
711 /* The default values become overwritten */
713 while (lex_token (lexer) != T_ENDCMD
714 && lex_token (lexer) != T_SLASH)
717 for (k = 0; k < n_C; ++k)
719 if (lex_match_id (lexer, cell_spec[k].keyword))
722 xrealloc (means.cells,
723 ++means.n_cells * sizeof (*means.cells));
725 means.cells[means.n_cells - 1] = k;
731 lex_error (lexer, NULL);
738 lex_error (lexer, NULL);
743 means.pool = pool_create ();
746 for (t = 0; t < means.n_tables; ++t)
748 struct mtable *table = &means.table[t];
749 table->n_interactions = 1;
750 for (l = 0; l < table->n_layers; ++l)
752 const int n_vars = table->n_factor_vars[l];
753 table->n_interactions *= n_vars;
756 table->interactions =
757 xcalloc (table->n_interactions, sizeof (*table->interactions));
760 xcalloc (table->n_dep_vars * table->n_interactions, sizeof (*table->summary));
763 if (table->n_layers > 0)
764 iact_append_factor (table, 0, interaction_create (NULL));
766 table->interactions[0] = interaction_create (NULL);
772 struct casegrouper *grouper;
773 struct casereader *group;
776 grouper = casegrouper_create_splits (proc_open (ds), means.dict);
777 while (casegrouper_get_next_group (grouper, &group))
779 run_means (&means, group, ds);
781 ok = casegrouper_destroy (grouper);
782 ok = proc_commit (ds) && ok;
795 is_missing (const struct means *cmd,
796 const struct variable *dvar,
797 const struct interaction *iact,
798 const struct ccase *c)
800 if ( interaction_case_is_missing (iact, c, cmd->exclude) )
804 if (var_is_value_missing (dvar,
812 static void output_case_processing_summary (const struct mtable *);
814 static void output_report (const struct means *, int, const struct mtable *);
819 struct per_var_data *pvd;
825 create_n (const void *aux1, void *aux2)
828 const struct means *means = aux1;
829 struct mtable *table = aux2;
830 struct per_cat_data *per_cat_data = xmalloc (sizeof *per_cat_data);
832 struct per_var_data *pvd = xcalloc (table->n_dep_vars, sizeof *pvd);
834 for (v = 0; v < table->n_dep_vars; ++v)
836 enum moment maxmom = MOMENT_KURTOSIS;
837 struct per_var_data *pp = &pvd[v];
839 pp->cell_stats = xcalloc (means->n_cells, sizeof *pp->cell_stats);
842 for (i = 0; i < means->n_cells; ++i)
844 int csi = means->cells[i];
845 const struct cell_spec *cs = &cell_spec[csi];
848 pp->cell_stats[i] = cs->sc (means, means->pool);
851 pp->mom = moments1_create (maxmom);
855 per_cat_data->pvd = pvd;
856 per_cat_data->warn = true;
861 update_n (const void *aux1, void *aux2, void *user_data, const struct ccase *c)
865 const struct means *means = aux1;
866 struct mtable *table = aux2;
867 struct per_cat_data *per_cat_data = user_data;
869 double weight = dict_get_case_weight (means->dict, c, &per_cat_data->warn);
871 for (v = 0; v < table->n_dep_vars; ++v)
873 struct per_var_data *pvd = &per_cat_data->pvd[v];
875 const double x = case_data (c, table->dep_vars[v])->f;
877 for (i = 0; i < table->n_interactions; ++i)
879 if ( is_missing (means, table->dep_vars[v], table->interactions[i], c))
883 for (i = 0; i < means->n_cells; ++i)
885 const int csi = means->cells[i];
886 const struct cell_spec *cs = &cell_spec[csi];
895 moments1_add (pvd->mom, x, weight);
903 calculate_n (const void *aux1, void *aux2, void *user_data)
907 struct per_cat_data *per_cat_data = user_data;
908 const struct means *means = aux1;
909 struct mtable *table = aux2;
911 for (v = 0; v < table->n_dep_vars; ++v)
913 struct per_var_data *pvd = &per_cat_data->pvd[v];
914 for (i = 0; i < means->n_cells; ++i)
916 int csi = means->cells[i];
917 const struct cell_spec *cs = &cell_spec[csi];
920 cs->sd (means, pvd, pvd->cell_stats[i]);
927 run_means (struct means *cmd, struct casereader *input,
928 const struct dataset *ds UNUSED)
931 const struct variable *wv = dict_get_weight (cmd->dict);
933 struct casereader *reader;
935 struct payload payload;
936 payload.create = create_n;
937 payload.update = update_n;
938 payload.destroy = calculate_n;
940 for (t = 0; t < cmd->n_tables; ++t)
942 struct mtable *table = &cmd->table[t];
944 = categoricals_create (table->interactions,
945 table->n_interactions, wv, cmd->exclude);
947 categoricals_set_payload (table->cats, &payload, cmd, table);
950 for (reader = casereader_clone (input);
951 (c = casereader_read (reader)) != NULL; case_unref (c))
953 for (t = 0; t < cmd->n_tables; ++t)
956 struct mtable *table = &cmd->table[t];
958 for (v = 0; v < table->n_dep_vars; ++v)
961 for (i = 0; i < table->n_interactions; ++i)
964 is_missing (cmd, table->dep_vars[v],
965 table->interactions[i], c);
967 table->summary[v * table->n_interactions + i].missing++;
969 table->summary[v * table->n_interactions + i].non_missing++;
972 categoricals_update (table->cats, c);
975 casereader_destroy (reader);
977 for (t = 0; t < cmd->n_tables; ++t)
979 struct mtable *table = &cmd->table[t];
981 categoricals_done (table->cats);
985 for (t = 0; t < cmd->n_tables; ++t)
987 const struct mtable *table = &cmd->table[t];
989 output_case_processing_summary (table);
991 for (i = 0; i < table->n_interactions; ++i)
993 output_report (cmd, i, table);
996 categoricals_destroy (table->cats);
1002 output_case_processing_summary (const struct mtable *table)
1005 const int heading_columns = 1;
1006 const int heading_rows = 3;
1007 struct tab_table *t;
1009 const int nr = heading_rows + table->n_interactions * table->n_dep_vars;
1012 t = tab_create (nc, nr);
1013 tab_title (t, _("Case Processing Summary"));
1015 tab_headers (t, heading_columns, 0, heading_rows, 0);
1017 tab_box (t, TAL_2, TAL_2, -1, TAL_1, 0, 0, nc - 1, nr - 1);
1019 tab_hline (t, TAL_2, 0, nc - 1, heading_rows);
1020 tab_vline (t, TAL_2, heading_columns, 0, nr - 1);
1023 tab_joint_text (t, heading_columns, 0,
1024 nc - 1, 0, TAB_CENTER | TAT_TITLE, _("Cases"));
1026 tab_joint_text (t, 1, 1, 2, 1, TAB_CENTER | TAT_TITLE, _("Included"));
1027 tab_joint_text (t, 3, 1, 4, 1, TAB_CENTER | TAT_TITLE, _("Excluded"));
1028 tab_joint_text (t, 5, 1, 6, 1, TAB_CENTER | TAT_TITLE, _("Total"));
1030 tab_hline (t, TAL_1, heading_columns, nc - 1, 1);
1031 tab_hline (t, TAL_1, heading_columns, nc - 1, 2);
1034 for (i = 0; i < 3; ++i)
1036 tab_text (t, heading_columns + i * 2, 2, TAB_CENTER | TAT_TITLE,
1038 tab_text (t, heading_columns + i * 2 + 1, 2, TAB_CENTER | TAT_TITLE,
1042 for (v = 0; v < table->n_dep_vars; ++v)
1044 const struct variable *var = table->dep_vars[v];
1045 const char *dv_name = var_to_string (var);
1046 for (i = 0; i < table->n_interactions; ++i)
1048 const int row = v * table->n_interactions + i;
1049 const struct interaction *iact = table->interactions[i];
1053 ds_init_cstr (&str, dv_name);
1054 ds_put_cstr (&str, ": ");
1056 interaction_to_string (iact, &str);
1058 tab_text (t, 0, row + heading_rows,
1059 TAB_LEFT | TAT_TITLE, ds_cstr (&str));
1062 n_total = table->summary[row].missing +
1063 table->summary[row].non_missing;
1065 tab_double (t, 1, row + heading_rows,
1066 0, table->summary[row].non_missing, &F_8_0);
1068 tab_text_format (t, 2, row + heading_rows,
1070 table->summary[row].non_missing / (double) n_total * 100.0);
1073 tab_double (t, 3, row + heading_rows,
1074 0, table->summary[row].missing, &F_8_0);
1077 tab_text_format (t, 4, row + heading_rows,
1079 table->summary[row].missing / (double) n_total * 100.0);
1082 tab_double (t, 5, row + heading_rows,
1083 0, table->summary[row].missing +
1084 table->summary[row].non_missing, &F_8_0);
1086 tab_text_format (t, 6, row + heading_rows,
1088 n_total / (double) n_total * 100.0);
1101 output_report (const struct means *cmd, int iact_idx,
1102 const struct mtable *table)
1107 const struct interaction *iact = table->interactions[iact_idx];
1109 const int heading_columns = 1 + iact->n_vars;
1110 const int heading_rows = 1;
1111 struct tab_table *t;
1113 const int n_cats = categoricals_n_count (table->cats, iact_idx);
1115 const int nr = n_cats * table->n_dep_vars + heading_rows;
1117 const int nc = heading_columns + cmd->n_cells;
1119 t = tab_create (nc, nr);
1120 tab_title (t, _("Report"));
1122 tab_headers (t, heading_columns, 0, heading_rows, 0);
1124 tab_box (t, TAL_2, TAL_2, -1, TAL_1, 0, 0, nc - 1, nr - 1);
1126 tab_hline (t, TAL_2, 0, nc - 1, heading_rows);
1127 tab_vline (t, TAL_2, iact->n_vars, 0, nr - 1);
1129 for (i = 0; i < iact->n_vars; ++i)
1131 tab_text (t, 1 + i, 0, TAB_CENTER | TAT_TITLE,
1132 var_to_string (iact->vars[i]));
1135 for (i = 0; i < cmd->n_cells; ++i)
1137 tab_text (t, heading_columns + i, 0,
1138 TAB_CENTER | TAT_TITLE,
1139 gettext (cell_spec[cmd->cells[i]].title));
1143 for (i = 0; i < n_cats; ++i)
1146 const struct ccase *c =
1147 categoricals_get_case_by_category_real (table->cats, iact_idx, i);
1149 for (dv = 0; dv < table->n_dep_vars; ++dv)
1152 heading_rows + dv * n_cats,
1153 TAB_RIGHT | TAT_TITLE,
1154 var_get_name (table->dep_vars[dv])
1158 tab_hline (t, TAL_1, 0, nc - 1, heading_rows + dv * n_cats);
1160 for (v = 0; v < iact->n_vars; ++v)
1162 const struct variable *var = iact->vars[v];
1163 const union value *val = case_data (c, var);
1165 ds_init_empty (&str);
1166 var_append_value_name (var, val, &str);
1168 tab_text (t, 1 + v, heading_rows + dv * n_cats + i,
1169 TAB_RIGHT | TAT_TITLE, ds_cstr (&str));
1176 for (grp = 0; grp < n_cats; ++grp)
1179 struct per_cat_data *per_cat_data =
1180 categoricals_get_user_data_by_category_real (table->cats, iact_idx, grp);
1182 for (dv = 0; dv < table->n_dep_vars; ++dv)
1184 const struct per_var_data *pvd = &per_cat_data->pvd[dv];
1185 for (i = 0; i < cmd->n_cells; ++i)
1187 const int csi = cmd->cells[i];
1188 const struct cell_spec *cs = &cell_spec[csi];
1190 double result = cs->sd (cmd, pvd, pvd->cell_stats[i]);
1192 tab_double (t, heading_columns + i,
1193 heading_rows + grp + dv * n_cats,