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 (struct pool *pool);
57 typedef void stat_update (void *stat, double w, double x);
58 typedef double stat_get (const struct per_var_data *, void *aux);
62 /* Printable title for output */
65 /* Keyword for syntax */
80 harmonic_create (struct pool *pool)
82 struct harmonic_mean *hm = pool_alloc (pool, sizeof *hm);
92 harmonic_update (void *stat, double w, double x)
94 struct harmonic_mean *hm = stat;
101 harmonic_get (const struct per_var_data *pvd UNUSED, void *stat)
103 struct harmonic_mean *hm = stat;
105 return hm->n / hm->rsum;
110 struct geometric_mean
118 geometric_create (struct pool *pool)
120 struct geometric_mean *gm = pool_alloc (pool, sizeof *gm);
130 geometric_update (void *stat, double w, double x)
132 struct geometric_mean *gm = stat;
133 gm->prod *= pow (x, w);
139 geometric_get (const struct per_var_data *pvd UNUSED, void *stat)
141 struct geometric_mean *gm = stat;
143 return pow (gm->prod, 1.0 / gm->n);
149 sum_get (const struct per_var_data *pvd, void *stat UNUSED)
153 moments1_calculate (pvd->mom, &n, &mean, 0, 0, 0);
160 n_get (const struct per_var_data *pvd, void *stat UNUSED)
164 moments1_calculate (pvd->mom, &n, 0, 0, 0, 0);
170 arithmean_get (const struct per_var_data *pvd, void *stat UNUSED)
174 moments1_calculate (pvd->mom, &n, &mean, 0, 0, 0);
180 variance_get (const struct per_var_data *pvd, void *stat UNUSED)
182 double n, mean, variance;
184 moments1_calculate (pvd->mom, &n, &mean, &variance, 0, 0);
191 stddev_get (const struct per_var_data *pvd, void *stat)
193 return sqrt (variance_get (pvd, stat));
200 skew_get (const struct per_var_data *pvd, void *stat UNUSED)
204 moments1_calculate (pvd->mom, NULL, NULL, NULL, &skew, 0);
210 sekurt_get (const struct per_var_data *pvd, void *stat UNUSED)
214 moments1_calculate (pvd->mom, &n, NULL, NULL, NULL, NULL);
216 return calc_sekurt (n);
220 seskew_get (const struct per_var_data *pvd, void *stat UNUSED)
224 moments1_calculate (pvd->mom, &n, NULL, NULL, NULL, NULL);
226 return calc_seskew (n);
230 kurt_get (const struct per_var_data *pvd, void *stat UNUSED)
234 moments1_calculate (pvd->mom, NULL, NULL, NULL, NULL, &kurt);
240 semean_get (const struct per_var_data *pvd, void *stat UNUSED)
244 moments1_calculate (pvd->mom, &n, NULL, &var, NULL, NULL);
246 return sqrt (var / n);
252 min_create (struct pool *pool)
254 double *r = pool_alloc (pool, sizeof *r);
262 min_update (void *stat, double w UNUSED, double x)
271 min_get (const struct per_var_data *pvd UNUSED, void *stat)
279 max_create (struct pool *pool)
281 double *r = pool_alloc (pool, sizeof *r);
289 max_update (void *stat, double w UNUSED, double x)
298 max_get (const struct per_var_data *pvd UNUSED, void *stat)
314 range_create (struct pool *pool)
316 struct range *r = pool_alloc (pool, sizeof *r);
325 range_update (void *stat, double w UNUSED, double x)
327 struct range *r = stat;
337 range_get (const struct per_var_data *pvd UNUSED, void *stat)
339 struct range *r = stat;
341 return r->max - r->min;
347 last_create (struct pool *pool)
349 double *l = pool_alloc (pool, sizeof *l);
355 last_update (void *stat, double w UNUSED, double x)
363 last_get (const struct per_var_data *pvd UNUSED, void *stat)
372 first_create (struct pool *pool)
374 double *f = pool_alloc (pool, sizeof *f);
382 first_update (void *stat, double w UNUSED, double x)
391 first_get (const struct per_var_data *pvd UNUSED, void *stat)
405 /* Table of cell_specs */
406 static const struct cell_spec cell_spec[] = {
407 {N_("Mean"), "MEAN", NULL, NULL, arithmean_get},
408 {N_("N"), "COUNT", NULL, NULL, n_get},
409 {N_("Std. Deviation"), "STDDEV", NULL, NULL, stddev_get},
411 {N_("Median"), "MEDIAN", NULL, NULL, NULL},
412 {N_("Group Median"), "GMEDIAN", NULL, NULL, NULL},
414 {N_("S.E. Mean"), "SEMEAN", NULL, NULL, semean_get},
415 {N_("Sum"), "SUM", NULL, NULL, sum_get},
416 {N_("Min"), "MIN", min_create, min_update, min_get},
417 {N_("Max"), "MAX", max_create, max_update, max_get},
418 {N_("Range"), "RANGE", range_create, range_update, range_get},
419 {N_("Variance"), "VARIANCE", NULL, NULL, variance_get},
420 {N_("Kurtosis"), "KURT", NULL, NULL, kurt_get},
421 {N_("S.E. Kurt"), "SEKURT", NULL, NULL, sekurt_get},
422 {N_("Skewness"), "SKEW", NULL, NULL, skew_get},
423 {N_("S.E. Skew"), "SESKEW", NULL, NULL, seskew_get},
424 {N_("First"), "FIRST", first_create, first_update, first_get},
425 {N_("Last"), "LAST", last_create, last_update, last_get},
427 {N_("Percent N"), "NPCT", NULL, NULL, NULL},
428 {N_("Percent Sum"), "SPCT", NULL, NULL, NULL},
430 {N_("Harmonic Mean"), "HARMONIC", harmonic_create, harmonic_update, harmonic_get},
431 {N_("Geom. Mean"), "GEOMETRIC", geometric_create, geometric_update, geometric_get}
434 #define n_C (sizeof (cell_spec) / sizeof (struct cell_spec))
440 casenumber non_missing;
444 /* The thing parsed after TABLES= */
448 const struct variable **dep_vars;
450 size_t n_interactions;
451 struct interaction **interactions;
452 struct summary *summary;
454 size_t *n_factor_vars;
455 const struct variable ***factor_vars;
461 struct categoricals *cats;
466 const struct dictionary *dict;
468 struct mtable *table;
471 /* Missing value class for categorical variables */
472 enum mv_class exclude;
474 /* Missing value class for dependent variables */
475 enum mv_class dep_exclude;
477 bool listwise_exclude;
479 /* an array indicating which statistics are to be calculated */
485 /* Pool on which cell functions may allocate data */
491 run_means (struct means *cmd, struct casereader *input,
492 const struct dataset *ds);
494 /* Append all the variables belonging to layer and all subsequent layers
495 to iact. And then append iact to the means->interaction.
496 This is a recursive function.
499 iact_append_factor (struct mtable *means, int layer,
500 const struct interaction *iact)
503 const struct variable **fv;
505 if (layer >= means->n_layers)
508 fv = means->factor_vars[layer];
510 for (v = 0; v < means->n_factor_vars[layer]; ++v)
512 struct interaction *nexti = interaction_clone (iact);
514 interaction_add_variable (nexti, fv[v]);
516 iact_append_factor (means, layer + 1, nexti);
518 if (layer == means->n_layers - 1)
520 means->interactions[means->ii++] = nexti;
526 parse_means_table_syntax (struct lexer *lexer, const struct means *cmd, struct mtable *table)
530 table->factor_vars = NULL;
531 table->n_factor_vars = NULL;
533 /* Dependent variable (s) */
534 if (!parse_variables_const (lexer, cmd->dict,
535 &table->dep_vars, &table->n_dep_vars,
536 PV_NO_DUPLICATE | PV_NUMERIC))
539 /* Factor variable (s) */
540 while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
542 if (lex_match (lexer, T_BY))
546 xrealloc (table->factor_vars,
547 sizeof (*table->factor_vars) * table->n_layers);
549 table->n_factor_vars =
550 xrealloc (table->n_factor_vars,
551 sizeof (*table->n_factor_vars) * table->n_layers);
553 if (!parse_variables_const (lexer, cmd->dict,
554 &table->factor_vars[table->n_layers - 1],
555 &table->n_factor_vars[table->n_layers -
567 If the match succeeds, the variable will be placed in VAR.
568 Returns true if successful */
570 lex_is_variable (struct lexer *lexer, const struct dictionary *dict,
574 if (lex_next_token (lexer, n) != T_ID)
577 tstr = lex_next_tokcstr (lexer, n);
579 if (NULL == dict_lookup_var (dict, tstr) )
587 cmd_means (struct lexer *lexer, struct dataset *ds)
593 bool more_tables = true;
595 means.exclude = MV_ANY;
596 means.dep_exclude = MV_ANY;
597 means.listwise_exclude = false;
601 means.dict = dataset_dict (ds);
604 means.cells = xcalloc (means.n_cells, sizeof (*means.cells));
607 /* The first three items (MEAN, COUNT, STDDEV) are the default */
608 for (i = 0; i < 3; ++i)
612 /* Optional TABLES = */
613 if (lex_match_id (lexer, "TABLES"))
615 lex_force_match (lexer, T_EQUALS);
620 /* Parse the "tables" */
624 means.table = xrealloc (means.table, means.n_tables * sizeof (*means.table));
626 if (! parse_means_table_syntax (lexer, &means,
627 &means.table[means.n_tables - 1]))
632 /* Look ahead to see if there are more tables to be parsed */
634 if ( T_SLASH == lex_next_token (lexer, 0) )
636 if (lex_is_variable (lexer, means.dict, 1) )
639 lex_force_match (lexer, T_SLASH);
644 /* /MISSING subcommand */
645 while (lex_token (lexer) != T_ENDCMD)
647 lex_match (lexer, T_SLASH);
649 if (lex_match_id (lexer, "MISSING"))
652 If no MISSING subcommand is specified, each combination of
653 a dependent variable and categorical variables is handled
656 lex_match (lexer, T_EQUALS);
657 if (lex_match_id (lexer, "INCLUDE"))
660 Use the subcommand "/MISSING=INCLUDE" to include user-missing
661 values in the analysis.
664 means.exclude = MV_SYSTEM;
665 means.dep_exclude = MV_SYSTEM;
667 else if (lex_match_id (lexer, "TABLE"))
669 This is the default. (I think).
670 Every case containing a complete set of variables for a given
671 table. If any variable, categorical or dependent for in a table
672 is missing (as defined by what?), then that variable will
673 be dropped FOR THAT TABLE ONLY.
676 means.listwise_exclude = true;
678 else if (lex_match_id (lexer, "DEPENDENT"))
680 Use the command "/MISSING=DEPENDENT" to
681 include user-missing values for the categorical variables,
682 while excluding them for the dependent variables.
684 Cases are dropped only when user-missing values
685 appear in dependent variables. User-missing
686 values for categorical variables are treated according to
689 Cases are ALWAYS dropped when System Missing values appear
690 in the categorical variables.
693 means.dep_exclude = MV_ANY;
694 means.exclude = MV_SYSTEM;
698 lex_error (lexer, NULL);
702 else if (lex_match_id (lexer, "CELLS"))
704 lex_match (lexer, T_EQUALS);
706 /* The default values become overwritten */
708 while (lex_token (lexer) != T_ENDCMD
709 && lex_token (lexer) != T_SLASH)
712 if (lex_match (lexer, T_ALL))
716 xrealloc (means.cells,
717 (means.n_cells += n_C) * sizeof (*means.cells));
719 for (x = 0; x < n_C; ++x)
720 means.cells[means.n_cells - (n_C - 1 - x) - 1] = x;
722 else if (lex_match_id (lexer, "NONE"))
726 else if (lex_match_id (lexer, "DEFAULT"))
729 xrealloc (means.cells,
730 (means.n_cells += 3) * sizeof (*means.cells));
732 means.cells[means.n_cells - 2 - 1] = MEANS_MEAN;
733 means.cells[means.n_cells - 1 - 1] = MEANS_N;
734 means.cells[means.n_cells - 0 - 1] = MEANS_STDDEV;
740 if (lex_match_id (lexer, cell_spec[k].keyword))
743 xrealloc (means.cells,
744 ++means.n_cells * sizeof (*means.cells));
746 means.cells[means.n_cells - 1] = k;
753 lex_error (lexer, NULL);
760 lex_error (lexer, NULL);
765 means.pool = pool_create ();
768 for (t = 0; t < means.n_tables; ++t)
770 struct mtable *table = &means.table[t];
771 table->n_interactions = 1;
772 for (l = 0; l < table->n_layers; ++l)
774 const int n_vars = table->n_factor_vars[l];
775 table->n_interactions *= n_vars;
778 table->interactions =
779 xcalloc (table->n_interactions, sizeof (*table->interactions));
782 xcalloc (table->n_dep_vars * table->n_interactions, sizeof (*table->summary));
785 if (table->n_layers > 0)
786 iact_append_factor (table, 0, interaction_create (NULL));
788 table->interactions[0] = interaction_create (NULL);
794 struct casegrouper *grouper;
795 struct casereader *group;
798 grouper = casegrouper_create_splits (proc_open (ds), means.dict);
799 while (casegrouper_get_next_group (grouper, &group))
801 run_means (&means, group, ds);
803 ok = casegrouper_destroy (grouper);
804 ok = proc_commit (ds) && ok;
817 is_missing (const struct means *cmd,
818 const struct variable *dvar,
819 const struct interaction *iact,
820 const struct ccase *c)
822 if ( interaction_case_is_missing (iact, c, cmd->exclude) )
826 if (var_is_value_missing (dvar,
834 static void output_case_processing_summary (const struct mtable *);
836 static void output_report (const struct means *, int, const struct mtable *);
841 struct per_var_data *pvd;
847 create_n (const void *aux1, void *aux2)
850 const struct means *means = aux1;
851 struct mtable *table = aux2;
852 struct per_cat_data *per_cat_data = xmalloc (sizeof *per_cat_data);
854 struct per_var_data *pvd = xcalloc (table->n_dep_vars, sizeof *pvd);
856 for (v = 0; v < table->n_dep_vars; ++v)
858 enum moment maxmom = MOMENT_KURTOSIS;
859 struct per_var_data *pp = &pvd[v];
861 pp->cell_stats = xcalloc (means->n_cells, sizeof *pp->cell_stats);
864 for (i = 0; i < means->n_cells; ++i)
866 int csi = means->cells[i];
867 const struct cell_spec *cs = &cell_spec[csi];
870 pp->cell_stats[i] = cs->sc (means->pool);
873 pp->mom = moments1_create (maxmom);
877 per_cat_data->pvd = pvd;
878 per_cat_data->warn = true;
883 update_n (const void *aux1, void *aux2, void *user_data, const struct ccase *c, double weight)
887 const struct means *means = aux1;
888 struct mtable *table = aux2;
889 struct per_cat_data *per_cat_data = user_data;
891 for (v = 0; v < table->n_dep_vars; ++v)
893 struct per_var_data *pvd = &per_cat_data->pvd[v];
895 const double x = case_data (c, table->dep_vars[v])->f;
897 for (i = 0; i < table->n_interactions; ++i)
899 if ( is_missing (means, table->dep_vars[v],
900 table->interactions[i], c))
904 for (i = 0; i < means->n_cells; ++i)
906 const int csi = means->cells[i];
907 const struct cell_spec *cs = &cell_spec[csi];
911 cs->su (pvd->cell_stats[i],
915 moments1_add (pvd->mom, x, weight);
923 calculate_n (const void *aux1, void *aux2, void *user_data)
927 struct per_cat_data *per_cat_data = user_data;
928 const struct means *means = aux1;
929 struct mtable *table = aux2;
931 for (v = 0; v < table->n_dep_vars; ++v)
933 struct per_var_data *pvd = &per_cat_data->pvd[v];
934 for (i = 0; i < means->n_cells; ++i)
936 int csi = means->cells[i];
937 const struct cell_spec *cs = &cell_spec[csi];
940 cs->sd (pvd, pvd->cell_stats[i]);
947 run_means (struct means *cmd, struct casereader *input,
948 const struct dataset *ds UNUSED)
951 const struct variable *wv = dict_get_weight (cmd->dict);
953 struct casereader *reader;
955 struct payload payload;
956 payload.create = create_n;
957 payload.update = update_n;
958 payload.destroy = calculate_n;
960 for (t = 0; t < cmd->n_tables; ++t)
962 struct mtable *table = &cmd->table[t];
964 = categoricals_create (table->interactions,
965 table->n_interactions, wv, cmd->exclude);
967 categoricals_set_payload (table->cats, &payload, cmd, table);
970 for (reader = casereader_clone (input);
971 (c = casereader_read (reader)) != NULL; case_unref (c))
973 for (t = 0; t < cmd->n_tables; ++t)
975 bool something_missing = false;
977 struct mtable *table = &cmd->table[t];
979 for (v = 0; v < table->n_dep_vars; ++v)
982 for (i = 0; i < table->n_interactions; ++i)
985 is_missing (cmd, table->dep_vars[v],
986 table->interactions[i], c);
989 something_missing = true;
990 table->summary[v * table->n_interactions + i].missing++;
993 table->summary[v * table->n_interactions + i].non_missing++;
996 if ( something_missing && cmd->listwise_exclude)
999 categoricals_update (table->cats, c);
1002 casereader_destroy (reader);
1004 for (t = 0; t < cmd->n_tables; ++t)
1006 struct mtable *table = &cmd->table[t];
1008 categoricals_done (table->cats);
1012 for (t = 0; t < cmd->n_tables; ++t)
1014 const struct mtable *table = &cmd->table[t];
1016 output_case_processing_summary (table);
1018 for (i = 0; i < table->n_interactions; ++i)
1020 output_report (cmd, i, table);
1023 categoricals_destroy (table->cats);
1029 output_case_processing_summary (const struct mtable *table)
1032 const int heading_columns = 1;
1033 const int heading_rows = 3;
1034 struct tab_table *t;
1036 const int nr = heading_rows + table->n_interactions * table->n_dep_vars;
1039 t = tab_create (nc, nr);
1040 tab_title (t, _("Case Processing Summary"));
1042 tab_headers (t, heading_columns, 0, heading_rows, 0);
1044 tab_box (t, TAL_2, TAL_2, -1, TAL_1, 0, 0, nc - 1, nr - 1);
1046 tab_hline (t, TAL_2, 0, nc - 1, heading_rows);
1047 tab_vline (t, TAL_2, heading_columns, 0, nr - 1);
1050 tab_joint_text (t, heading_columns, 0,
1051 nc - 1, 0, TAB_CENTER | TAT_TITLE, _("Cases"));
1053 tab_joint_text (t, 1, 1, 2, 1, TAB_CENTER | TAT_TITLE, _("Included"));
1054 tab_joint_text (t, 3, 1, 4, 1, TAB_CENTER | TAT_TITLE, _("Excluded"));
1055 tab_joint_text (t, 5, 1, 6, 1, TAB_CENTER | TAT_TITLE, _("Total"));
1057 tab_hline (t, TAL_1, heading_columns, nc - 1, 1);
1058 tab_hline (t, TAL_1, heading_columns, nc - 1, 2);
1061 for (i = 0; i < 3; ++i)
1063 tab_text (t, heading_columns + i * 2, 2, TAB_CENTER | TAT_TITLE,
1065 tab_text (t, heading_columns + i * 2 + 1, 2, TAB_CENTER | TAT_TITLE,
1069 for (v = 0; v < table->n_dep_vars; ++v)
1071 const struct variable *var = table->dep_vars[v];
1072 const char *dv_name = var_to_string (var);
1073 for (i = 0; i < table->n_interactions; ++i)
1075 const int row = v * table->n_interactions + i;
1076 const struct interaction *iact = table->interactions[i];
1080 ds_init_cstr (&str, dv_name);
1081 ds_put_cstr (&str, ": ");
1083 interaction_to_string (iact, &str);
1085 tab_text (t, 0, row + heading_rows,
1086 TAB_LEFT | TAT_TITLE, ds_cstr (&str));
1089 n_total = table->summary[row].missing +
1090 table->summary[row].non_missing;
1092 tab_double (t, 1, row + heading_rows,
1093 0, table->summary[row].non_missing, &F_8_0);
1095 tab_text_format (t, 2, row + heading_rows,
1097 table->summary[row].non_missing / (double) n_total * 100.0);
1100 tab_double (t, 3, row + heading_rows,
1101 0, table->summary[row].missing, &F_8_0);
1104 tab_text_format (t, 4, row + heading_rows,
1106 table->summary[row].missing / (double) n_total * 100.0);
1109 tab_double (t, 5, row + heading_rows,
1110 0, table->summary[row].missing +
1111 table->summary[row].non_missing, &F_8_0);
1113 tab_text_format (t, 6, row + heading_rows,
1115 n_total / (double) n_total * 100.0);
1128 output_report (const struct means *cmd, int iact_idx,
1129 const struct mtable *table)
1134 const struct interaction *iact = table->interactions[iact_idx];
1136 const int heading_columns = 1 + iact->n_vars;
1137 const int heading_rows = 1;
1138 struct tab_table *t;
1140 const int n_cats = categoricals_n_count (table->cats, iact_idx);
1142 const int nr = n_cats * table->n_dep_vars + heading_rows;
1144 const int nc = heading_columns + cmd->n_cells;
1146 t = tab_create (nc, nr);
1147 tab_title (t, _("Report"));
1149 tab_headers (t, heading_columns, 0, heading_rows, 0);
1151 tab_box (t, TAL_2, TAL_2, -1, TAL_1, 0, 0, nc - 1, nr - 1);
1153 tab_hline (t, TAL_2, 0, nc - 1, heading_rows);
1154 tab_vline (t, TAL_2, iact->n_vars, 0, nr - 1);
1156 for (i = 0; i < iact->n_vars; ++i)
1158 tab_text (t, 1 + i, 0, TAB_CENTER | TAT_TITLE,
1159 var_to_string (iact->vars[i]));
1162 for (i = 0; i < cmd->n_cells; ++i)
1164 tab_text (t, heading_columns + i, 0,
1165 TAB_CENTER | TAT_TITLE,
1166 gettext (cell_spec[cmd->cells[i]].title));
1170 for (i = 0; i < n_cats; ++i)
1173 const struct ccase *c =
1174 categoricals_get_case_by_category_real (table->cats, iact_idx, i);
1176 for (dv = 0; dv < table->n_dep_vars; ++dv)
1179 heading_rows + dv * n_cats,
1180 TAB_RIGHT | TAT_TITLE,
1181 var_get_name (table->dep_vars[dv])
1185 tab_hline (t, TAL_1, 0, nc - 1, heading_rows + dv * n_cats);
1187 for (v = 0; v < iact->n_vars; ++v)
1189 const struct variable *var = iact->vars[v];
1190 const union value *val = case_data (c, var);
1192 ds_init_empty (&str);
1193 var_append_value_name (var, val, &str);
1195 tab_text (t, 1 + v, heading_rows + dv * n_cats + i,
1196 TAB_RIGHT | TAT_TITLE, ds_cstr (&str));
1203 for (grp = 0; grp < n_cats; ++grp)
1206 struct per_cat_data *per_cat_data =
1207 categoricals_get_user_data_by_category_real (table->cats, iact_idx, grp);
1209 for (dv = 0; dv < table->n_dep_vars; ++dv)
1211 const struct per_var_data *pvd = &per_cat_data->pvd[dv];
1212 for (i = 0; i < cmd->n_cells; ++i)
1214 const int csi = cmd->cells[i];
1215 const struct cell_spec *cs = &cell_spec[csi];
1217 double result = cs->sd (pvd, pvd->cell_stats[i]);
1219 tab_double (t, heading_columns + i,
1220 heading_rows + grp + dv * n_cats,