Change identifiers for consistency with other commands
[pspp-builds.git] / src / language / stats / npar.c
1 /* PSPP - a program for statistical analysis. -*-c-*-
2    Copyright (C) 2006, 2008, 2009, 2010 Free Software Foundation, Inc.
3
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.
8
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.
13
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/>. */
16
17 #include <config.h>
18
19 #include <language/stats/npar.h>
20 #include "npar-summary.h"
21
22 #include <stdlib.h>
23 #include <math.h>
24
25 #include "xalloc.h"
26 #include <data/case.h>
27 #include <data/casegrouper.h>
28 #include <data/casereader.h>
29 #include <data/dictionary.h>
30 #include <data/procedure.h>
31 #include <data/settings.h>
32 #include <data/variable.h>
33 #include <language/command.h>
34 #include <language/lexer/lexer.h>
35 #include <language/lexer/variable-parser.h>
36 #include <language/stats/binomial.h>
37 #include <language/stats/chisquare.h>
38 #include <language/stats/wilcoxon.h>
39 #include <language/stats/sign.h>
40 #include <libpspp/assertion.h>
41 #include <libpspp/cast.h>
42 #include <libpspp/hash.h>
43 #include <libpspp/message.h>
44 #include <libpspp/pool.h>
45 #include <libpspp/str.h>
46 #include <libpspp/taint.h>
47 #include <math/moments.h>
48
49 #include "gettext.h"
50 #define _(msgid) gettext (msgid)
51
52 /* Settings for subcommand specifiers. */
53 enum missing_type
54   {
55     MISS_ANALYSIS,
56     MISS_LISTWISE,
57   };
58
59 enum
60   {
61     NPAR_INCLUDE,
62     NPAR_EXCLUDE
63   };
64
65 /* Array indices for STATISTICS subcommand. */
66 enum
67   {
68     NPAR_ST_DESCRIPTIVES = 0,
69     NPAR_ST_QUARTILES = 1,
70     NPAR_ST_ALL = 2,
71     NPAR_ST_count
72   };
73
74 /* NPAR TESTS structure. */
75 struct cmd_npar_tests
76   {
77     /* CHISQUARE subcommand. */
78     int chisquare;
79
80     /* BINOMIAL subcommand. */
81     int binomial;
82
83     /* WILCOXON subcommand. */
84     int wilcoxon;
85
86     /* SIGN subcommand. */
87     int sign;
88
89     /* MISSING subcommand. */
90     int missing;
91     long miss;
92     long incl;
93
94     /* METHOD subcommand. */
95     int method;
96
97     /* STATISTICS subcommand. */
98     int statistics;
99     int a_statistics[NPAR_ST_count];
100   };
101
102
103 struct npar_specs
104 {
105   struct pool *pool;
106   struct npar_test **test;
107   size_t n_tests;
108
109   const struct variable **vv; /* Compendium of all variables
110                                   (those mentioned on ANY subcommand */
111   int n_vars; /* Number of variables in vv */
112
113   enum mv_class filter;    /* Missing values to filter. */
114
115   bool descriptives;       /* Descriptive statistics should be calculated */
116   bool quartiles;          /* Quartiles should be calculated */
117
118   bool exact;  /* Whether exact calculations have been requested */
119   double timer;   /* Maximum time (in minutes) to wait for exact calculations */
120 };
121
122
123 /* Prototype for custom subcommands of NPAR TESTS. */
124 static int npar_chisquare (struct lexer *, struct dataset *, struct npar_specs *);
125 static int npar_binomial (struct lexer *, struct dataset *,  struct npar_specs *);
126 static int npar_wilcoxon (struct lexer *, struct dataset *, struct npar_specs *);
127 static int npar_sign (struct lexer *, struct dataset *, struct npar_specs *);
128 static int npar_method (struct lexer *, struct npar_specs *);
129
130 /* Command parsing functions. */
131 static int parse_npar_tests (struct lexer *lexer, struct dataset *ds, struct cmd_npar_tests *p,
132                              struct npar_specs *npar_specs );
133
134 static int
135 parse_npar_tests (struct lexer *lexer, struct dataset *ds, struct cmd_npar_tests *npt,
136                   struct npar_specs *nps)
137 {
138   npt->chisquare = 0;
139   npt->binomial = 0;
140   npt->wilcoxon = 0;
141   npt->sign = 0;
142   npt->missing = 0;
143   npt->miss = MISS_ANALYSIS;
144   npt->incl = NPAR_EXCLUDE;
145   npt->method = 0;
146   npt->statistics = 0;
147   memset (npt->a_statistics, 0, sizeof npt->a_statistics);
148   for (;;)
149     {
150       if (lex_match_hyphenated_word (lexer, "CHISQUARE"))
151         {
152           lex_match (lexer, '=');
153           npt->chisquare++;
154           switch (npar_chisquare (lexer, ds, nps))
155             {
156             case 0:
157               goto lossage;
158             case 1:
159               break;
160             case 2:
161               lex_error (lexer, NULL);
162               goto lossage;
163             default:
164               NOT_REACHED ();
165             }
166         }
167       else if (lex_match_hyphenated_word (lexer, "BINOMIAL"))
168         {
169           lex_match (lexer, '=');
170           npt->binomial++;
171           switch (npar_binomial (lexer, ds, nps))
172             {
173             case 0:
174               goto lossage;
175             case 1:
176               break;
177             case 2:
178               lex_error (lexer, NULL);
179               goto lossage;
180             default:
181               NOT_REACHED ();
182             }
183         }
184       else if (lex_match_hyphenated_word (lexer, "WILCOXON"))
185         {
186           lex_match (lexer, '=');
187           npt->wilcoxon++;
188           switch (npar_wilcoxon (lexer, ds, nps))
189             {
190             case 0:
191               goto lossage;
192             case 1:
193               break;
194             case 2:
195               lex_error (lexer, NULL);
196               goto lossage;
197             default:
198               NOT_REACHED ();
199             }
200         }
201       else if (lex_match_hyphenated_word (lexer, "SIGN"))
202         {
203           lex_match (lexer, '=');
204           npt->sign++;
205           switch (npar_sign (lexer, ds, nps))
206             {
207             case 0:
208               goto lossage;
209             case 1:
210               break;
211             case 2:
212               lex_error (lexer, NULL);
213               goto lossage;
214             default:
215               NOT_REACHED ();
216             }
217         }
218       else if (lex_match_hyphenated_word (lexer, "MISSING"))
219         {
220           lex_match (lexer, '=');
221           npt->missing++;
222           if (npt->missing > 1)
223             {
224               msg (SE, _ ("The %s subcommand may be given only once."), "MISSING");
225               goto lossage;
226             }
227           while (lex_token (lexer) != '/' && lex_token (lexer) != '.')
228             {
229               if (lex_match_hyphenated_word (lexer, "ANALYSIS"))
230                 npt->miss = MISS_ANALYSIS;
231               else if (lex_match_hyphenated_word (lexer, "LISTWISE"))
232                 npt->miss = MISS_LISTWISE;
233               else if (lex_match_hyphenated_word (lexer, "INCLUDE"))
234                 npt->incl = NPAR_INCLUDE;
235               else if (lex_match_hyphenated_word (lexer, "EXCLUDE"))
236                 npt->incl = NPAR_EXCLUDE;
237               else
238                 {
239                   lex_error (lexer, NULL);
240                   goto lossage;
241                 }
242               lex_match (lexer, ',');
243             }
244         }
245       else if (lex_match_hyphenated_word (lexer, "METHOD"))
246         {
247           lex_match (lexer, '=');
248           npt->method++;
249           if (npt->method > 1)
250             {
251               msg (SE, _ ("The %s subcommand may be given only once."), "METHOD");
252               goto lossage;
253             }
254           switch (npar_method (lexer, nps))
255             {
256             case 0:
257               goto lossage;
258             case 1:
259               break;
260             case 2:
261               lex_error (lexer, NULL);
262               goto lossage;
263             default:
264               NOT_REACHED ();
265             }
266         }
267       else if (lex_match_hyphenated_word (lexer, "STATISTICS"))
268         {
269           lex_match (lexer, '=');
270           npt->statistics++;
271           while (lex_token (lexer) != '/' && lex_token (lexer) != '.')
272             {
273               if (lex_match_hyphenated_word (lexer, "DESCRIPTIVES"))
274                 npt->a_statistics[NPAR_ST_DESCRIPTIVES] = 1;
275               else if (lex_match_hyphenated_word (lexer, "QUARTILES"))
276                 npt->a_statistics[NPAR_ST_QUARTILES] = 1;
277               else if (lex_match (lexer, T_ALL))
278                 npt->a_statistics[NPAR_ST_ALL] = 1;
279               else
280                 {
281                   lex_error (lexer, NULL);
282                   goto lossage;
283                 }
284               lex_match (lexer, ',');
285             }
286         }
287       else if ( settings_get_syntax () != COMPATIBLE && lex_match_id (lexer, "ALGORITHM"))
288         {
289           lex_match (lexer, '=');
290           if (lex_match_id (lexer, "COMPATIBLE"))
291             settings_set_cmd_algorithm (COMPATIBLE);
292           else if (lex_match_id (lexer, "ENHANCED"))
293             settings_set_cmd_algorithm (ENHANCED);
294           }
295         if (!lex_match (lexer, '/'))
296           break;
297       }
298
299     if (lex_token (lexer) != '.')
300       {
301         lex_error (lexer, _ ("expecting end of command"));
302         goto lossage;
303       }
304
305   return true;
306
307 lossage:
308   return false;
309 }
310
311
312
313
314 static void one_sample_insert_variables (const struct npar_test *test,
315                                          struct const_hsh_table *variables);
316
317 static void two_sample_insert_variables (const struct npar_test *test,
318                                          struct const_hsh_table *variables);
319
320
321 static void
322 npar_execute (struct casereader *input,
323              const struct npar_specs *specs,
324              const struct dataset *ds)
325 {
326   int t;
327   struct descriptives *summary_descriptives = NULL;
328
329   for ( t = 0 ; t < specs->n_tests; ++t )
330     {
331       const struct npar_test *test = specs->test[t];
332       if ( NULL == test->execute )
333         {
334           msg (SW, _ ("NPAR subcommand not currently implemented."));
335           continue;
336         }
337       test->execute (ds, casereader_clone (input), specs->filter, test, specs->exact, specs->timer);
338     }
339
340   if ( specs->descriptives )
341     {
342       summary_descriptives = xnmalloc (sizeof (*summary_descriptives),
343                                        specs->n_vars);
344
345       npar_summary_calc_descriptives (summary_descriptives,
346                                       casereader_clone (input),
347                                       dataset_dict (ds),
348                                       specs->vv, specs->n_vars,
349                                       specs->filter);
350     }
351
352   if ( (specs->descriptives || specs->quartiles)
353        && !taint_has_tainted_successor (casereader_get_taint (input)) )
354     do_summary_box (summary_descriptives, specs->vv, specs->n_vars );
355
356   free (summary_descriptives);
357   casereader_destroy (input);
358 }
359
360
361 int
362 cmd_npar_tests (struct lexer *lexer, struct dataset *ds)
363 {
364   struct cmd_npar_tests cmd;
365   bool ok;
366   int i;
367   struct npar_specs npar_specs = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
368   struct const_hsh_table *var_hash;
369   struct casegrouper *grouper;
370   struct casereader *input, *group;
371
372   npar_specs.pool = pool_create ();
373
374   var_hash = const_hsh_create_pool (npar_specs.pool, 0,
375                                     compare_vars_by_name, hash_var_by_name,
376                                     NULL, NULL);
377
378   if ( ! parse_npar_tests (lexer, ds, &cmd, &npar_specs) )
379     {
380       pool_destroy (npar_specs.pool);
381       return CMD_FAILURE;
382     }
383
384   for (i = 0; i < npar_specs.n_tests; ++i )
385     {
386       const struct npar_test *test = npar_specs.test[i];
387       test->insert_variables (test, var_hash);
388     }
389
390   npar_specs.vv = (const struct variable **) const_hsh_sort (var_hash);
391   npar_specs.n_vars = const_hsh_count (var_hash);
392
393   if ( cmd.statistics )
394     {
395       int i;
396
397       for ( i = 0 ; i < NPAR_ST_count; ++i )
398         {
399           if ( cmd.a_statistics[i] )
400             {
401               switch ( i )
402                 {
403                 case NPAR_ST_DESCRIPTIVES:
404                   npar_specs.descriptives = true;
405                   break;
406                 case NPAR_ST_QUARTILES:
407                   npar_specs.quartiles = true;
408                   break;
409                 case NPAR_ST_ALL:
410                   npar_specs.quartiles = true;
411                   npar_specs.descriptives = true;
412                   break;
413                 default:
414                   NOT_REACHED ();
415                 };
416             }
417         }
418     }
419
420   npar_specs.filter = cmd.incl == NPAR_EXCLUDE ? MV_ANY : MV_SYSTEM;
421
422   input = proc_open (ds);
423   if ( cmd.miss == MISS_LISTWISE )
424     {
425       input = casereader_create_filter_missing (input,
426                                                 npar_specs.vv,
427                                                 npar_specs.n_vars,
428                                                 npar_specs.filter,
429                                                 NULL, NULL);
430     }
431
432
433   grouper = casegrouper_create_splits (input, dataset_dict (ds));
434   while (casegrouper_get_next_group (grouper, &group))
435     npar_execute (group, &npar_specs, ds);
436   ok = casegrouper_destroy (grouper);
437   ok = proc_commit (ds) && ok;
438
439   const_hsh_destroy (var_hash);
440
441   pool_destroy (npar_specs.pool);
442
443   return ok ? CMD_SUCCESS : CMD_CASCADING_FAILURE;
444 }
445
446 static int
447 npar_chisquare (struct lexer *lexer, struct dataset *ds,
448                 struct npar_specs *specs)
449 {
450   struct chisquare_test *cstp = pool_alloc (specs->pool, sizeof (*cstp));
451   struct one_sample_test *tp = &cstp->parent;
452   struct npar_test *nt = &tp->parent;
453
454   nt->execute = chisquare_execute;
455   nt->insert_variables = one_sample_insert_variables;
456
457   if (!parse_variables_const_pool (lexer, specs->pool, dataset_dict (ds),
458                                    &tp->vars, &tp->n_vars,
459                                    PV_NO_SCRATCH | PV_NO_DUPLICATE))
460     {
461       return 2;
462     }
463
464   cstp->ranged = false;
465
466   if ( lex_match (lexer, '('))
467     {
468       cstp->ranged = true;
469       if ( ! lex_force_num (lexer)) return 0;
470       cstp->lo = lex_integer (lexer);
471       lex_get (lexer);
472       lex_force_match (lexer, ',');
473       if (! lex_force_num (lexer) ) return 0;
474       cstp->hi = lex_integer (lexer);
475       if ( cstp->lo >= cstp->hi )
476         {
477           msg (ME,
478               _ ("The specified value of HI (%d) is "
479                 "lower than the specified value of LO (%d)"),
480               cstp->hi, cstp->lo);
481           return 0;
482         }
483       lex_get (lexer);
484       if (! lex_force_match (lexer, ')')) return 0;
485     }
486
487   cstp->n_expected = 0;
488   cstp->expected = NULL;
489   if ( lex_match (lexer, '/') )
490     {
491       if ( lex_match_id (lexer, "EXPECTED") )
492         {
493           lex_force_match (lexer, '=');
494           if ( ! lex_match_id (lexer, "EQUAL") )
495             {
496               double f;
497               int n;
498               while ( lex_is_number (lexer) )
499                 {
500                   int i;
501                   n = 1;
502                   f = lex_number (lexer);
503                   lex_get (lexer);
504                   if ( lex_match (lexer, '*'))
505                     {
506                       n = f;
507                       f = lex_number (lexer);
508                       lex_get (lexer);
509                     }
510                   lex_match (lexer, ',');
511
512                   cstp->n_expected += n;
513                   cstp->expected = pool_realloc (specs->pool,
514                                                  cstp->expected,
515                                                  sizeof (double) *
516                                                  cstp->n_expected);
517                   for ( i = cstp->n_expected - n ;
518                         i < cstp->n_expected;
519                         ++i )
520                     cstp->expected[i] = f;
521
522                 }
523             }
524         }
525       else
526         lex_put_back (lexer, '/');
527     }
528
529   if ( cstp->ranged && cstp->n_expected > 0 &&
530        cstp->n_expected != cstp->hi - cstp->lo + 1 )
531     {
532       msg (ME,
533           _ ("%d expected values were given, but the specified "
534             "range (%d-%d) requires exactly %d values."),
535           cstp->n_expected, cstp->lo, cstp->hi,
536           cstp->hi - cstp->lo +1);
537       return 0;
538     }
539
540   specs->n_tests++;
541   specs->test = pool_realloc (specs->pool,
542                               specs->test,
543                               sizeof (*specs->test) * specs->n_tests);
544
545   specs->test[specs->n_tests - 1] = nt;
546
547   return 1;
548 }
549
550
551 static int
552 npar_binomial (struct lexer *lexer, struct dataset *ds,
553                struct npar_specs *specs)
554 {
555   struct binomial_test *btp = pool_alloc (specs->pool, sizeof (*btp));
556   struct one_sample_test *tp = &btp->parent;
557   struct npar_test *nt = &tp->parent;
558
559   nt->execute = binomial_execute;
560   nt->insert_variables = one_sample_insert_variables;
561
562   btp->category1 = btp->category2 = btp->cutpoint = SYSMIS;
563
564   btp->p = 0.5;
565
566   if ( lex_match (lexer, '(') )
567     {
568       if ( lex_force_num (lexer) )
569         {
570           btp->p = lex_number (lexer);
571           lex_get (lexer);
572           lex_force_match (lexer, ')');
573         }
574       else
575         return 0;
576     }
577   else
578     /* Kludge: q2c swallows the '=' so put it back here  */
579      lex_put_back (lexer, '=');
580
581   if (lex_match (lexer, '=') )
582     {
583       if (parse_variables_const_pool (lexer, specs->pool, dataset_dict (ds),
584                                       &tp->vars, &tp->n_vars,
585                                       PV_NUMERIC | PV_NO_SCRATCH | PV_NO_DUPLICATE) )
586         {
587           if (lex_match (lexer, '('))
588             {
589               lex_force_num (lexer);
590               btp->category1 = lex_number (lexer);
591               lex_get (lexer);
592               if ( lex_match (lexer, ','))
593                 {
594                   if ( ! lex_force_num (lexer) ) return 2;
595                   btp->category2 = lex_number (lexer);
596                   lex_get (lexer);
597                 }
598               else
599                 {
600                   btp->cutpoint = btp->category1;
601                 }
602
603               lex_force_match (lexer, ')');
604             }
605         }
606       else
607         return 2;
608
609     }
610
611   specs->n_tests++;
612   specs->test = pool_realloc (specs->pool,
613                               specs->test,
614                               sizeof (*specs->test) * specs->n_tests);
615
616   specs->test[specs->n_tests - 1] = nt;
617
618   return 1;
619 }
620
621
622 static bool
623 parse_two_sample_related_test (struct lexer *lexer,
624                                     const struct dictionary *dict,
625                                     struct two_sample_test *test_parameters,
626                                     struct pool *pool
627                                     );
628
629
630 static bool
631 parse_two_sample_related_test (struct lexer *lexer,
632                                const struct dictionary *dict,
633                                struct two_sample_test *test_parameters,
634                                struct pool *pool
635                                )
636 {
637   int n = 0;
638   bool paired = false;
639   bool with = false;
640   const struct variable **vlist1;
641   size_t n_vlist1;
642
643   const struct variable **vlist2;
644   size_t n_vlist2;
645
646   test_parameters->parent.insert_variables = two_sample_insert_variables;
647
648   if (!parse_variables_const_pool (lexer, pool,
649                                    dict,
650                                    &vlist1, &n_vlist1,
651                                    PV_NUMERIC | PV_NO_SCRATCH | PV_NO_DUPLICATE) )
652     return false;
653
654   if ( lex_match (lexer, T_WITH))
655     {
656       with = true;
657       if ( !parse_variables_const_pool (lexer, pool, dict,
658                                         &vlist2, &n_vlist2,
659                                         PV_NUMERIC | PV_NO_SCRATCH | PV_NO_DUPLICATE) )
660         return false;
661
662       paired = (lex_match (lexer, '(') &&
663                 lex_match_id (lexer, "PAIRED") && lex_match (lexer, ')'));
664     }
665
666
667   if ( with )
668     {
669       if (paired)
670         {
671           if ( n_vlist1 != n_vlist2)
672             msg (SE, _ ("PAIRED was specified but the number of variables "
673                        "preceding WITH (%zu) did not match the number "
674                        "following (%zu)."), n_vlist1, n_vlist2);
675
676           test_parameters->n_pairs = n_vlist1 ;
677         }
678       else
679         {
680           test_parameters->n_pairs = n_vlist1 * n_vlist2;
681         }
682     }
683   else
684     {
685       test_parameters->n_pairs = (n_vlist1 * (n_vlist1 - 1)) / 2 ;
686     }
687
688   test_parameters->pairs =
689     pool_alloc (pool, sizeof ( variable_pair) * test_parameters->n_pairs);
690
691   if ( with )
692     {
693       if (paired)
694         {
695           int i;
696           assert (n_vlist1 == n_vlist2);
697           for ( i = 0 ; i < n_vlist1; ++i )
698             {
699               test_parameters->pairs[n][1] = vlist1[i];
700               test_parameters->pairs[n][0] = vlist2[i];
701               n++;
702             }
703         }
704       else
705         {
706           int i,j;
707           for ( i = 0 ; i < n_vlist1; ++i )
708             {
709               for ( j = 0 ; j < n_vlist2; ++j )
710                 {
711                   test_parameters->pairs[n][1] = vlist1[i];
712                   test_parameters->pairs[n][0] = vlist2[j];
713                   n++;
714                 }
715             }
716         }
717     }
718   else
719     {
720       int i,j;
721       for ( i = 0 ; i < n_vlist1 - 1; ++i )
722         {
723           for ( j = i + 1 ; j < n_vlist1; ++j )
724             {
725               assert ( n < test_parameters->n_pairs);
726               test_parameters->pairs[n][1] = vlist1[i];
727               test_parameters->pairs[n][0] = vlist1[j];
728               n++;
729             }
730         }
731     }
732
733   assert ( n == test_parameters->n_pairs);
734
735   return true;
736 }
737
738 static int
739 npar_wilcoxon (struct lexer *lexer,
740                struct dataset *ds,
741                struct npar_specs *specs )
742 {
743
744
745   struct two_sample_test *tp = pool_alloc (specs->pool, sizeof (*tp));
746   struct npar_test *nt = &tp->parent;
747   nt->execute = wilcoxon_execute;
748
749   if (!parse_two_sample_related_test (lexer, dataset_dict (ds),
750                                       tp, specs->pool) )
751     return 0;
752
753   specs->n_tests++;
754   specs->test = pool_realloc (specs->pool,
755                               specs->test,
756                               sizeof (*specs->test) * specs->n_tests);
757   specs->test[specs->n_tests - 1] = nt;
758
759   return 1;
760 }
761
762 static int
763 npar_sign (struct lexer *lexer, struct dataset *ds,
764            struct npar_specs *specs)
765 {
766   struct two_sample_test *tp = pool_alloc (specs->pool, sizeof (*tp));
767   struct npar_test *nt = &tp->parent;
768
769   nt->execute = sign_execute;
770
771   if (!parse_two_sample_related_test (lexer, dataset_dict (ds),
772                                       tp, specs->pool) )
773     return 0;
774
775   specs->n_tests++;
776   specs->test = pool_realloc (specs->pool,
777                               specs->test,
778                               sizeof (*specs->test) * specs->n_tests);
779   specs->test[specs->n_tests - 1] = nt;
780
781   return 1;
782 }
783
784 /* Insert the variables for TEST into VAR_HASH */
785 static void
786 one_sample_insert_variables (const struct npar_test *test,
787                              struct const_hsh_table *var_hash)
788 {
789   int i;
790   struct one_sample_test *ost = UP_CAST (test, struct one_sample_test, parent);
791
792   for ( i = 0 ; i < ost->n_vars ; ++i )
793     const_hsh_insert (var_hash, ost->vars[i]);
794 }
795
796 static void
797 two_sample_insert_variables (const struct npar_test *test,
798                              struct const_hsh_table *var_hash)
799 {
800   int i;
801
802   const struct two_sample_test *tst = (const struct two_sample_test *) test;
803
804   for ( i = 0 ; i < tst->n_pairs ; ++i )
805     {
806       variable_pair *pair = &tst->pairs[i];
807
808       const_hsh_insert (var_hash, (*pair)[0]);
809       const_hsh_insert (var_hash, (*pair)[1]);
810     }
811 }
812
813 static int
814 npar_method (struct lexer *lexer,  struct npar_specs *specs)
815 {
816   if ( lex_match_id (lexer, "EXACT") )
817     {
818       specs->exact = true;
819       specs->timer = 0.0;
820       if (lex_match_id (lexer, "TIMER"))
821         {
822           specs->timer = 5.0;
823
824           if ( lex_match (lexer, '('))
825             {
826               if ( lex_force_num (lexer) )
827                 {
828                   specs->timer = lex_number (lexer);
829                   lex_get (lexer);
830                 }
831               lex_force_match (lexer, ')');
832             }
833         }
834     }
835
836   return 1;
837 }