1 /* PSPP - computes sample statistics. -*-c-*-
3 Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
4 Written by John Williams <johnr.williams@stonebow.otago.ac.nz>.
5 Almost completly re-written by John Darrington 2004
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the
10 License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23 #include <gsl/gsl_cdf.h>
37 #include "value-labels.h"
49 variables=varlist("PV_NO_SCRATCH | PV_NUMERIC");
51 +missing=miss:!analysis/listwise,
52 incl:include/!exclude;
53 format=fmt:!labels/nolabels;
54 criteria=:cin(d:criteria,"%s > 0. && %s < 1.").
62 /* Function to use for testing for missing values */
63 static is_missing_func value_is_missing;
65 /* Variable for the GROUPS subcommand, if given. */
66 static struct variable *indep_var;
68 /* GROUPS: Number of values specified by the user; the values
71 static int n_group_values;
72 static union value groups_values[2];
73 static enum comparison criteria[2];
77 /* PAIRS: Number of pairs to be compared ; each pair. */
78 static int n_pairs = 0 ;
81 /* The variables comprising the pair */
82 struct variable *v[2];
84 /* The number of valid variable pairs */
87 /* The sum of the members */
90 /* sum of squares of the members */
93 /* Std deviation of the members */
97 /* Sample Std deviation of the members */
100 /* The means of the members */
103 /* The correlation coefficient between the variables */
106 /* The sum of the differences */
109 /* The sum of the products */
112 /* The mean of the differences */
115 /* The sum of the squares of the differences */
118 /* The std deviation of the differences */
122 static struct pair *pairs=0;
124 static int parse_value (union value * v, int type) ;
126 /* Structures and Functions for the Statistics Summary Box */
128 typedef void populate_ssbox_func(struct ssbox *ssb,
129 struct cmd_t_test *cmd);
130 typedef void finalize_ssbox_func(struct ssbox *ssb);
136 populate_ssbox_func *populate;
137 finalize_ssbox_func *finalize;
142 void ssbox_create(struct ssbox *ssb, struct cmd_t_test *cmd, int mode);
144 /* Populate a ssbox according to cmd */
145 void ssbox_populate(struct ssbox *ssb, struct cmd_t_test *cmd);
147 /* Submit and destroy a ssbox */
148 void ssbox_finalize(struct ssbox *ssb);
150 /* A function to create, populate and submit the Paired Samples Correlation
155 /* Structures and Functions for the Test Results Box */
158 typedef void populate_trbox_func(struct trbox *trb,
159 struct cmd_t_test *cmd);
160 typedef void finalize_trbox_func(struct trbox *trb);
164 populate_trbox_func *populate;
165 finalize_trbox_func *finalize;
169 void trbox_create(struct trbox *trb, struct cmd_t_test *cmd, int mode);
171 /* Populate a ssbox according to cmd */
172 void trbox_populate(struct trbox *trb, struct cmd_t_test *cmd);
174 /* Submit and destroy a ssbox */
175 void trbox_finalize(struct trbox *trb);
177 /* Which mode was T-TEST invoked */
185 static int common_calc (const struct ccase *, void *);
186 static void common_precalc (struct cmd_t_test *);
187 static void common_postcalc (struct cmd_t_test *);
189 static int one_sample_calc (const struct ccase *, void *);
190 static void one_sample_precalc (struct cmd_t_test *);
191 static void one_sample_postcalc (struct cmd_t_test *);
193 static int paired_calc (const struct ccase *, void *);
194 static void paired_precalc (struct cmd_t_test *);
195 static void paired_postcalc (struct cmd_t_test *);
197 static void group_precalc (struct cmd_t_test *);
198 static int group_calc (const struct ccase *, struct cmd_t_test *);
199 static void group_postcalc (struct cmd_t_test *);
202 static int compare_var_name (const void *a_, const void *b_, void *v_ UNUSED);
203 static unsigned hash_var_name (const void *a_, void *v_ UNUSED);
205 static void calculate(const struct casefile *cf, void *_mode);
209 static struct cmd_t_test cmd;
211 static int bad_weight_warn;
219 if ( !parse_t_test(&cmd) )
222 if (! cmd.sbc_criteria)
227 if (cmd.sbc_testval) ++m;
228 if (cmd.sbc_groups) ++m;
229 if (cmd.sbc_pairs) ++m;
234 _("TESTVAL, GROUPS and PAIRS subcommands are mutually exclusive.")
242 else if (cmd.sbc_groups)
247 if ( mode == T_PAIRED)
249 if (cmd.sbc_variables)
251 msg(SE, _("VARIABLES subcommand is not appropriate with PAIRS"));
256 /* Iterate through the pairs and put each variable that is a
257 member of a pair into cmd.v_variables */
260 struct hsh_iterator hi;
261 struct hsh_table *hash;
264 hash=hsh_create(n_pairs,compare_var_name,hash_var_name,0,0);
266 for (i=0; i < n_pairs; ++i)
268 hsh_insert(hash,pairs[i].v[0]);
269 hsh_insert(hash,pairs[i].v[1]);
272 assert(cmd.n_variables == 0);
273 cmd.n_variables = hsh_count(hash);
275 cmd.v_variables = xrealloc(cmd.v_variables,
276 sizeof(struct variable) * cmd.n_variables);
277 /* Iterate through the hash */
278 for (i=0,v = (struct variable *) hsh_first(hash,&hi);
280 v=hsh_next(hash,&hi) )
281 cmd.v_variables[i++]=v;
286 else if ( !cmd.sbc_variables)
288 msg(SE, _("One or more VARIABLES must be specified."));
293 /* If /MISSING=INCLUDE is set, then user missing values are ignored */
294 if (cmd.incl == TTS_INCLUDE )
295 value_is_missing = is_system_missing;
297 value_is_missing = is_missing;
301 multipass_procedure_with_splits (calculate, &cmd);
307 if ( mode == T_IND_SAMPLES)
310 /* Destroy any group statistics we created */
311 for (i= 0 ; i < cmd.n_variables ; ++i )
313 free(cmd.v_variables[i]->p.t_t.gs);
321 tts_custom_groups (struct cmd_t_test *cmd UNUSED)
326 if (token != T_ALL &&
327 (token != T_ID || dict_lookup_var (default_dict, tokid) == NULL)
330 msg(SE,_("`%s' is not a variable name"),tokid);
334 indep_var = parse_variable ();
337 lex_error ("expecting variable name in GROUPS subcommand");
341 if (indep_var->type == T_STRING && indep_var->width > MAX_SHORT_STRING)
343 msg (SE, _("Long string variable %s is not valid here."),
348 if (!lex_match ('('))
350 if (indep_var->type == NUMERIC)
352 groups_values[0].f = 1;
353 groups_values[1].f = 2;
354 criteria[0] = criteria[1] = CMP_EQ;
360 msg (SE, _("When applying GROUPS to a string variable, at "
361 "least one value must be specified."));
366 if (!parse_value (&groups_values[0],indep_var->type))
372 criteria[0] = CMP_LE;
373 criteria[1] = CMP_GT;
374 groups_values[1] = groups_values[0];
379 if (!parse_value (&groups_values[1],indep_var->type))
383 if (!lex_force_match (')'))
386 criteria[0] = criteria[1] = CMP_EQ;
392 tts_custom_pairs (struct cmd_t_test *cmd UNUSED)
394 struct variable **vars;
399 int n_after_WITH = -1;
400 int paired ; /* Was the PAIRED keyword given ? */
404 if ((token != T_ID || dict_lookup_var (default_dict, tokid) == NULL)
407 msg(SE,_("`%s' is not a variable name"),tokid);
412 if (!parse_variables (default_dict, &vars, &n_vars,
413 PV_DUPLICATE | PV_NUMERIC | PV_NO_SCRATCH))
421 if (lex_match (T_WITH))
423 n_before_WITH = n_vars;
424 if (!parse_variables (default_dict, &vars, &n_vars,
425 PV_DUPLICATE | PV_APPEND
426 | PV_NUMERIC | PV_NO_SCRATCH))
431 n_after_WITH = n_vars - n_before_WITH;
434 paired = (lex_match ('(') && lex_match_id ("PAIRED") && lex_match (')'));
436 /* Determine the number of pairs needed */
439 if (n_before_WITH != n_after_WITH)
442 msg (SE, _("PAIRED was specified but the number of variables "
443 "preceding WITH (%d) did not match the number "
445 n_before_WITH, n_after_WITH );
448 n_pairs_local=n_before_WITH;
450 else if (n_before_WITH > 0) /* WITH keyword given, but not PAIRED keyword */
452 n_pairs_local=n_before_WITH * n_after_WITH ;
454 else /* Neither WITH nor PAIRED keyword given */
459 msg (SE, _("At least two variables must be specified "
464 /* how many ways can you pick 2 from n_vars ? */
465 n_pairs_local = n_vars * (n_vars -1 ) /2 ;
469 /* Allocate storage for the pairs */
470 pairs = xrealloc(pairs, sizeof(struct pair) * (n_pairs + n_pairs_local) );
472 /* Populate the pairs with the appropriate variables */
477 assert(n_pairs_local == n_vars/2);
478 for (i = 0; i < n_pairs_local ; ++i)
480 pairs[i].v[n_pairs+0] = vars[i];
481 pairs[i].v[n_pairs+1] = vars[i+n_pairs_local];
484 else if (n_before_WITH > 0) /* WITH keyword given, but not PAIRED keyword */
489 for(i=0 ; i < n_before_WITH ; ++i )
491 for(j=0 ; j < n_after_WITH ; ++j)
493 pairs[p].v[0] = vars[i];
494 pairs[p].v[1] = vars[j+n_before_WITH];
499 else /* Neither WITH nor PAIRED given */
504 for(i=0 ; i < n_vars ; ++i )
506 for(j=i+1 ; j < n_vars ; ++j)
508 pairs[p].v[0] = vars[i];
509 pairs[p].v[1] = vars[j];
515 n_pairs+=n_pairs_local;
520 /* Parses the current token (numeric or string, depending on type)
521 value v and returns success. */
523 parse_value (union value * v, int type )
527 if (!lex_force_num ())
533 if (!lex_force_string ())
535 strncpy (v->s, ds_c_str (&tokstr), ds_length (&tokstr));
544 /* Implementation of the SSBOX object */
546 void ssbox_base_init(struct ssbox *this, int cols,int rows);
548 void ssbox_base_finalize(struct ssbox *ssb);
550 void ssbox_one_sample_init(struct ssbox *this,
551 struct cmd_t_test *cmd );
553 void ssbox_independent_samples_init(struct ssbox *this,
554 struct cmd_t_test *cmd);
556 void ssbox_paired_init(struct ssbox *this,
557 struct cmd_t_test *cmd);
559 /* Factory to create an ssbox */
561 ssbox_create(struct ssbox *ssb, struct cmd_t_test *cmd, int mode)
566 ssbox_one_sample_init(ssb,cmd);
569 ssbox_independent_samples_init(ssb,cmd);
572 ssbox_paired_init(ssb,cmd);
580 /* Despatcher for the populate method */
582 ssbox_populate(struct ssbox *ssb,struct cmd_t_test *cmd)
584 ssb->populate(ssb,cmd);
588 /* Despatcher for finalize */
590 ssbox_finalize(struct ssbox *ssb)
596 /* Submit the box and clear up */
598 ssbox_base_finalize(struct ssbox *ssb)
603 /* Initialize a ssbox struct */
605 ssbox_base_init(struct ssbox *this, int cols,int rows)
607 this->finalize = ssbox_base_finalize;
608 this->t = tab_create (cols, rows, 0);
610 tab_columns (this->t, SOM_COL_DOWN, 1);
611 tab_headers (this->t,0,0,1,0);
612 tab_box (this->t, TAL_2, TAL_2, TAL_0, TAL_1, 0, 0, cols -1, rows -1 );
613 tab_hline(this->t, TAL_2,0,cols-1,1);
614 tab_dim (this->t, tab_natural_dimensions);
617 void ssbox_one_sample_populate(struct ssbox *ssb,
618 struct cmd_t_test *cmd);
620 /* Initialize the one_sample ssbox */
622 ssbox_one_sample_init(struct ssbox *this,
623 struct cmd_t_test *cmd )
626 const int vsize=cmd->n_variables+1;
628 this->populate = ssbox_one_sample_populate;
630 ssbox_base_init(this, hsize,vsize);
631 tab_title (this->t, 0, _("One-Sample Statistics"));
632 tab_vline(this->t, TAL_2, 1,0,vsize);
633 tab_text (this->t, 1, 0, TAB_CENTER | TAT_TITLE, _("N"));
634 tab_text (this->t, 2, 0, TAB_CENTER | TAT_TITLE, _("Mean"));
635 tab_text (this->t, 3, 0, TAB_CENTER | TAT_TITLE, _("Std. Deviation"));
636 tab_text (this->t, 4, 0, TAB_CENTER | TAT_TITLE, _("SE. Mean"));
639 void ssbox_independent_samples_populate(struct ssbox *ssb,
640 struct cmd_t_test *cmd);
642 /* Initialize the independent samples ssbox */
644 ssbox_independent_samples_init(struct ssbox *this,
645 struct cmd_t_test *cmd)
648 int vsize = cmd->n_variables*2 +1;
650 this->populate = ssbox_independent_samples_populate;
652 ssbox_base_init(this, hsize,vsize);
653 tab_title (this->t, 0, _("Group Statistics"));
654 tab_vline(this->t,0,1,0,vsize);
655 tab_text (this->t, 1, 0, TAB_CENTER | TAT_TITLE, indep_var->name);
656 tab_text (this->t, 2, 0, TAB_CENTER | TAT_TITLE, _("N"));
657 tab_text (this->t, 3, 0, TAB_CENTER | TAT_TITLE, _("Mean"));
658 tab_text (this->t, 4, 0, TAB_CENTER | TAT_TITLE, _("Std. Deviation"));
659 tab_text (this->t, 5, 0, TAB_CENTER | TAT_TITLE, _("SE. Mean"));
663 /* Populate the ssbox for independent samples */
665 ssbox_independent_samples_populate(struct ssbox *ssb,
666 struct cmd_t_test *cmd)
673 char prefix[2][3]={"",""};
675 if ( indep_var->type == NUMERIC )
677 val_lab0 = val_labs_find( indep_var->val_labs,groups_values[0]);
678 val_lab1 = val_labs_find( indep_var->val_labs,groups_values[1]);
682 val_lab0 = groups_values[0].s;
683 val_lab1 = groups_values[1].s;
686 if (n_group_values == 1)
688 strcpy(prefix[0],"< ");
689 strcpy(prefix[1],">=");
694 for (i=0; i < cmd->n_variables; ++i)
698 tab_text (ssb->t, 0, i*2+1, TAB_LEFT, cmd->v_variables[i]->name);
701 tab_text (ssb->t, 1, i*2+1, TAB_LEFT | TAT_PRINTF,
702 "%s%s", prefix[0], val_lab0);
704 tab_text (ssb->t, 1, i*2+1, TAB_LEFT | TAT_PRINTF,
705 "%s%g", prefix[0], groups_values[0].f);
709 tab_text (ssb->t, 1, i*2+1+1, TAB_LEFT | TAT_PRINTF,
710 "%s%s", prefix[1], val_lab1);
712 tab_text (ssb->t, 1, i*2+1+1, TAB_LEFT | TAT_PRINTF,
713 "%s%g", prefix[1], groups_values[1].f);
715 /* Fill in the group statistics */
716 for ( g=0; g < 2 ; ++g )
718 struct group_statistics *gs = &cmd->v_variables[i]->p.t_t.gs[g];
720 tab_float(ssb->t, 2 ,i*2+g+1, TAB_RIGHT, gs->n, 2, 0);
721 tab_float(ssb->t, 3 ,i*2+g+1, TAB_RIGHT, gs->mean, 8, 2);
722 tab_float(ssb->t, 4 ,i*2+g+1, TAB_RIGHT, gs->std_dev, 8, 3);
723 tab_float(ssb->t, 5 ,i*2+g+1, TAB_RIGHT, gs->se_mean, 8, 3);
729 void ssbox_paired_populate(struct ssbox *ssb,
730 struct cmd_t_test *cmd);
732 /* Initialize the paired values ssbox */
734 ssbox_paired_init(struct ssbox *this, struct cmd_t_test *cmd UNUSED)
738 int vsize = n_pairs*2+1;
740 this->populate = ssbox_paired_populate;
742 ssbox_base_init(this, hsize,vsize);
743 tab_title (this->t, 0, _("Paired Sample Statistics"));
744 tab_vline(this->t,TAL_0,1,0,vsize-1);
745 tab_vline(this->t,TAL_2,2,0,vsize-1);
746 tab_text (this->t, 2, 0, TAB_CENTER | TAT_TITLE, _("Mean"));
747 tab_text (this->t, 3, 0, TAB_CENTER | TAT_TITLE, _("N"));
748 tab_text (this->t, 4, 0, TAB_CENTER | TAT_TITLE, _("Std. Deviation"));
749 tab_text (this->t, 5, 0, TAB_CENTER | TAT_TITLE, _("SE. Mean"));
753 /* Populate the ssbox for paired values */
755 ssbox_paired_populate(struct ssbox *ssb,struct cmd_t_test *cmd UNUSED)
761 for (i=0; i < n_pairs; ++i)
765 tab_text (ssb->t, 0, i*2+1, TAB_LEFT | TAT_PRINTF , _("Pair %d"),i);
767 for (j=0 ; j < 2 ; ++j)
769 struct group_statistics *gs;
771 gs=&pairs[i].v[j]->p.t_t.ugs;
775 tab_text (ssb->t, 1, i*2+j+1, TAB_LEFT, pairs[i].v[j]->name);
778 tab_float (ssb->t,2, i*2+j+1, TAB_RIGHT, pairs[i].mean[j], 8, 2);
779 tab_float (ssb->t,3, i*2+j+1, TAB_RIGHT, pairs[i].n, 2, 0);
780 tab_float (ssb->t,4, i*2+j+1, TAB_RIGHT, pairs[i].std_dev[j], 8, 3);
781 tab_float (ssb->t,5, i*2+j+1, TAB_RIGHT, pairs[i].std_dev[j]/sqrt(pairs[i].n), 8, 3);
787 /* Populate the one sample ssbox */
789 ssbox_one_sample_populate(struct ssbox *ssb, struct cmd_t_test *cmd)
795 for (i=0; i < cmd->n_variables; ++i)
797 struct group_statistics *gs;
798 gs= &cmd->v_variables[i]->p.t_t.ugs;
800 tab_text (ssb->t, 0, i+1, TAB_LEFT, cmd->v_variables[i]->name);
801 tab_float (ssb->t,1, i+1, TAB_RIGHT, gs->n, 2, 0);
802 tab_float (ssb->t,2, i+1, TAB_RIGHT, gs->mean, 8, 2);
803 tab_float (ssb->t,3, i+1, TAB_RIGHT, gs->std_dev, 8, 2);
804 tab_float (ssb->t,4, i+1, TAB_RIGHT, gs->se_mean, 8, 3);
811 /* Implementation of the Test Results box struct */
813 void trbox_base_init(struct trbox *self,int n_vars, int cols);
814 void trbox_base_finalize(struct trbox *trb);
816 void trbox_independent_samples_init(struct trbox *trb,
817 struct cmd_t_test *cmd );
819 void trbox_independent_samples_populate(struct trbox *trb,
820 struct cmd_t_test *cmd);
822 void trbox_one_sample_init(struct trbox *self,
823 struct cmd_t_test *cmd );
825 void trbox_one_sample_populate(struct trbox *trb,
826 struct cmd_t_test *cmd);
828 void trbox_paired_init(struct trbox *self,
829 struct cmd_t_test *cmd );
831 void trbox_paired_populate(struct trbox *trb,
832 struct cmd_t_test *cmd);
836 /* Create a trbox according to mode*/
838 trbox_create(struct trbox *trb,
839 struct cmd_t_test *cmd, int mode)
844 trbox_one_sample_init(trb,cmd);
847 trbox_independent_samples_init(trb,cmd);
850 trbox_paired_init(trb,cmd);
857 /* Populate a trbox according to cmd */
859 trbox_populate(struct trbox *trb, struct cmd_t_test *cmd)
861 trb->populate(trb,cmd);
864 /* Submit and destroy a trbox */
866 trbox_finalize(struct trbox *trb)
871 /* Initialize the independent samples trbox */
873 trbox_independent_samples_init(struct trbox *self,
874 struct cmd_t_test *cmd UNUSED)
877 const int vsize=cmd->n_variables*2+3;
880 self->populate = trbox_independent_samples_populate;
882 trbox_base_init(self,cmd->n_variables*2,hsize);
883 tab_title(self->t,0,_("Independent Samples Test"));
884 tab_hline(self->t,TAL_1,2,hsize-1,1);
885 tab_vline(self->t,TAL_2,2,0,vsize-1);
886 tab_vline(self->t,TAL_1,4,0,vsize-1);
887 tab_box(self->t,-1,-1,-1,TAL_1, 2,1,hsize-2,vsize-1);
888 tab_hline(self->t,TAL_1, hsize-2,hsize-1,2);
889 tab_box(self->t,-1,-1,-1,TAL_1, hsize-2,2,hsize-1,vsize-1);
890 tab_joint_text(self->t, 2, 0, 3, 0,
891 TAB_CENTER,_("Levene's Test for Equality of Variances"));
892 tab_joint_text(self->t, 4,0,hsize-1,0,
893 TAB_CENTER,_("t-test for Equality of Means"));
895 tab_text(self->t,2,2, TAB_CENTER | TAT_TITLE,_("F"));
896 tab_text(self->t,3,2, TAB_CENTER | TAT_TITLE,_("Sig."));
897 tab_text(self->t,4,2, TAB_CENTER | TAT_TITLE,_("t"));
898 tab_text(self->t,5,2, TAB_CENTER | TAT_TITLE,_("df"));
899 tab_text(self->t,6,2, TAB_CENTER | TAT_TITLE,_("Sig. (2-tailed)"));
900 tab_text(self->t,7,2, TAB_CENTER | TAT_TITLE,_("Mean Difference"));
901 tab_text(self->t,8,2, TAB_CENTER | TAT_TITLE,_("Std. Error Difference"));
902 tab_text(self->t,9,2, TAB_CENTER | TAT_TITLE,_("Lower"));
903 tab_text(self->t,10,2, TAB_CENTER | TAT_TITLE,_("Upper"));
905 tab_joint_text(self->t, 9, 1, 10, 1, TAB_CENTER | TAT_PRINTF,
906 _("%g%% Confidence Interval of the Difference"),
907 cmd->criteria*100.0);
911 /* Populate the independent samples trbox */
913 trbox_independent_samples_populate(struct trbox *self,
914 struct cmd_t_test *cmd )
919 for (i=0; i < cmd->n_variables; ++i)
928 double pooled_variance;
932 struct group_statistics *gs0 = &cmd->v_variables[i]->p.t_t.gs[0];
933 struct group_statistics *gs1 = &cmd->v_variables[i]->p.t_t.gs[1];
935 tab_text (self->t, 0, i*2+3, TAB_LEFT, cmd->v_variables[i]->name);
937 tab_text (self->t, 1, i*2+3, TAB_LEFT, _("Equal variances assumed"));
940 tab_float(self->t, 2, i*2+3, TAB_CENTER,
941 cmd->v_variables[i]->p.t_t.levene, 8,3);
943 /* Now work out the significance of the Levene test */
944 df1 = 1; df2 = cmd->v_variables[i]->p.t_t.ugs.n - 2;
945 q = gsl_cdf_fdist_Q(cmd->v_variables[i]->p.t_t.levene, df1, df2);
947 tab_float(self->t, 3, i*2+3, TAB_CENTER, q, 8,3 );
949 df = gs0->n + gs1->n - 2.0 ;
950 tab_float (self->t, 5, i*2+3, TAB_RIGHT, df, 2, 0);
952 pooled_variance = ( (gs0->n )*pow2(gs0->s_std_dev)
954 (gs1->n )*pow2(gs1->s_std_dev)
957 t = (gs0->mean - gs1->mean) / sqrt(pooled_variance) ;
958 t /= sqrt((gs0->n + gs1->n)/(gs0->n*gs1->n));
960 tab_float (self->t, 4, i*2+3, TAB_RIGHT, t, 8, 3);
962 p = gsl_cdf_tdist_P(t, df);
963 q = gsl_cdf_tdist_Q(t, df);
965 tab_float(self->t, 6, i*2+3, TAB_RIGHT, 2.0*(t>0?q:p) , 8, 3);
967 mean_diff = gs0->mean - gs1->mean;
968 tab_float(self->t, 7, i*2+3, TAB_RIGHT, mean_diff, 8, 3);
971 std_err_diff = sqrt( pow2(gs0->se_mean) + pow2(gs1->se_mean));
972 tab_float(self->t, 8, i*2+3, TAB_RIGHT, std_err_diff, 8, 3);
975 /* Now work out the confidence interval */
976 q = (1 - cmd->criteria)/2.0; /* 2-tailed test */
978 t = gsl_cdf_tdist_Qinv(q,df);
979 tab_float(self->t, 9, i*2+3, TAB_RIGHT,
980 mean_diff - t * std_err_diff, 8, 3);
982 tab_float(self->t, 10, i*2+3, TAB_RIGHT,
983 mean_diff + t * std_err_diff, 8, 3);
988 /* Now for the \sigma_1 != \sigma_2 case */
989 tab_text (self->t, 1, i*2+3+1,
990 TAB_LEFT, _("Equal variances not assumed"));
993 se2 = (pow2(gs0->s_std_dev)/(gs0->n -1) ) +
994 (pow2(gs1->s_std_dev)/(gs1->n -1) );
996 t = mean_diff / sqrt(se2) ;
997 tab_float (self->t, 4, i*2+3+1, TAB_RIGHT, t, 8, 3);
1000 (pow2(pow2(gs0->s_std_dev)/(gs0->n - 1 ))
1004 (pow2(pow2(gs1->s_std_dev)/(gs1->n - 1 ))
1008 tab_float (self->t, 5, i*2+3+1, TAB_RIGHT, df, 8, 3);
1010 p = gsl_cdf_tdist_P(t, df);
1011 q = gsl_cdf_tdist_Q(t, df);
1013 tab_float(self->t, 6, i*2+3+1, TAB_RIGHT, 2.0*(t>0?q:p) , 8, 3);
1015 /* Now work out the confidence interval */
1016 q = (1 - cmd->criteria)/2.0; /* 2-tailed test */
1018 t = gsl_cdf_tdist_Qinv(q, df);
1020 tab_float(self->t, 7, i*2+3+1, TAB_RIGHT, mean_diff, 8, 3);
1023 tab_float(self->t, 8, i*2+3+1, TAB_RIGHT, std_err_diff, 8, 3);
1026 tab_float(self->t, 9, i*2+3+1, TAB_RIGHT,
1027 mean_diff - t * std_err_diff, 8, 3);
1029 tab_float(self->t, 10, i*2+3+1, TAB_RIGHT,
1030 mean_diff + t * std_err_diff, 8, 3);
1036 /* Initialize the paired samples trbox */
1038 trbox_paired_init(struct trbox *self,
1039 struct cmd_t_test *cmd UNUSED)
1043 const int vsize=n_pairs+3;
1045 self->populate = trbox_paired_populate;
1047 trbox_base_init(self,n_pairs,hsize);
1048 tab_title (self->t, 0, _("Paired Samples Test"));
1049 tab_hline(self->t,TAL_1,2,6,1);
1050 tab_vline(self->t,TAL_2,2,0,vsize);
1051 tab_joint_text(self->t,2,0,6,0,TAB_CENTER,_("Paired Differences"));
1052 tab_box(self->t,-1,-1,-1,TAL_1, 2,1,6,vsize-1);
1053 tab_box(self->t,-1,-1,-1,TAL_1, 6,0,hsize-1,vsize-1);
1054 tab_hline(self->t,TAL_1,5,6, 2);
1055 tab_vline(self->t,TAL_0,6,0,1);
1057 tab_joint_text(self->t, 5, 1, 6, 1, TAB_CENTER | TAT_PRINTF,
1058 _("%g%% Confidence Interval of the Difference"),
1059 cmd->criteria*100.0);
1061 tab_text (self->t, 2, 2, TAB_CENTER | TAT_TITLE, _("Mean"));
1062 tab_text (self->t, 3, 2, TAB_CENTER | TAT_TITLE, _("Std. Deviation"));
1063 tab_text (self->t, 4, 2, TAB_CENTER | TAT_TITLE, _("Std. Error Mean"));
1064 tab_text (self->t, 5, 2, TAB_CENTER | TAT_TITLE, _("Lower"));
1065 tab_text (self->t, 6, 2, TAB_CENTER | TAT_TITLE, _("Upper"));
1066 tab_text (self->t, 7, 2, TAB_CENTER | TAT_TITLE, _("t"));
1067 tab_text (self->t, 8, 2, TAB_CENTER | TAT_TITLE, _("df"));
1068 tab_text (self->t, 9, 2, TAB_CENTER | TAT_TITLE, _("Sig. (2-tailed)"));
1071 /* Populate the paired samples trbox */
1073 trbox_paired_populate(struct trbox *trb,
1074 struct cmd_t_test *cmd UNUSED)
1078 for (i=0; i < n_pairs; ++i)
1083 double n = pairs[i].n;
1087 tab_text (trb->t, 0, i+3, TAB_LEFT | TAT_PRINTF, _("Pair %d"),i);
1089 tab_text (trb->t, 1, i+3, TAB_LEFT | TAT_PRINTF, "%s - %s",
1090 pairs[i].v[0]->name, pairs[i].v[1]->name);
1092 tab_float(trb->t, 2, i+3, TAB_RIGHT, pairs[i].mean_diff, 8, 4);
1094 tab_float(trb->t, 3, i+3, TAB_RIGHT, pairs[i].std_dev_diff, 8, 5);
1097 se_mean = pairs[i].std_dev_diff / sqrt(n) ;
1098 tab_float(trb->t, 4, i+3, TAB_RIGHT, se_mean, 8,5 );
1100 /* Now work out the confidence interval */
1101 q = (1 - cmd->criteria)/2.0; /* 2-tailed test */
1103 t = gsl_cdf_tdist_Qinv(q, df);
1105 tab_float(trb->t, 5, i+3, TAB_RIGHT,
1106 pairs[i].mean_diff - t * se_mean , 8, 4);
1108 tab_float(trb->t, 6, i+3, TAB_RIGHT,
1109 pairs[i].mean_diff + t * se_mean , 8, 4);
1111 t = (pairs[i].mean[0] - pairs[i].mean[1])
1113 ( pow2 (pairs[i].s_std_dev[0]) + pow2 (pairs[i].s_std_dev[1]) -
1114 2 * pairs[i].correlation *
1115 pairs[i].s_std_dev[0] * pairs[i].s_std_dev[1] )
1119 tab_float(trb->t, 7, i+3, TAB_RIGHT, t , 8,3 );
1121 /* Degrees of freedom */
1122 tab_float(trb->t, 8, i+3, TAB_RIGHT, df , 2, 0 );
1124 p = gsl_cdf_tdist_P(t,df);
1125 q = gsl_cdf_tdist_P(t,df);
1127 tab_float(trb->t, 9, i+3, TAB_RIGHT, 2.0*(t>0?q:p) , 8, 3);
1132 /* Initialize the one sample trbox */
1134 trbox_one_sample_init(struct trbox *self, struct cmd_t_test *cmd )
1137 const int vsize=cmd->n_variables+3;
1139 self->populate = trbox_one_sample_populate;
1141 trbox_base_init(self, cmd->n_variables,hsize);
1142 tab_title (self->t, 0, _("One-Sample Test"));
1143 tab_hline(self->t, TAL_1, 1, hsize - 1, 1);
1144 tab_vline(self->t, TAL_2, 1, 0, vsize);
1146 tab_joint_text(self->t, 1, 0, hsize-1,0, TAB_CENTER | TAT_PRINTF,
1147 _("Test Value = %f"),cmd->n_testval);
1149 tab_box(self->t, -1, -1, -1, TAL_1, 1,1,hsize-1,vsize-1);
1152 tab_joint_text(self->t,5,1,6,1,TAB_CENTER | TAT_PRINTF,
1153 _("%g%% Confidence Interval of the Difference"),
1154 cmd->criteria*100.0);
1156 tab_vline(self->t,TAL_0,6,1,1);
1157 tab_hline(self->t,TAL_1,5,6,2);
1158 tab_text (self->t, 1, 2, TAB_CENTER | TAT_TITLE, _("t"));
1159 tab_text (self->t, 2, 2, TAB_CENTER | TAT_TITLE, _("df"));
1160 tab_text (self->t, 3, 2, TAB_CENTER | TAT_TITLE, _("Sig. (2-tailed)"));
1161 tab_text (self->t, 4, 2, TAB_CENTER | TAT_TITLE, _("Mean Difference"));
1162 tab_text (self->t, 5, 2, TAB_CENTER | TAT_TITLE, _("Lower"));
1163 tab_text (self->t, 6, 2, TAB_CENTER | TAT_TITLE, _("Upper"));
1168 /* Populate the one sample trbox */
1170 trbox_one_sample_populate(struct trbox *trb, struct cmd_t_test *cmd)
1176 for (i=0; i < cmd->n_variables; ++i)
1181 struct group_statistics *gs;
1182 gs= &cmd->v_variables[i]->p.t_t.ugs;
1185 tab_text (trb->t, 0, i+3, TAB_LEFT, cmd->v_variables[i]->name);
1187 t = (gs->mean - cmd->n_testval ) * sqrt(gs->n) / gs->std_dev ;
1189 tab_float (trb->t, 1, i+3, TAB_RIGHT, t, 8,3);
1191 /* degrees of freedom */
1194 tab_float (trb->t, 2, i+3, TAB_RIGHT, df, 8,0);
1196 p = gsl_cdf_tdist_P(t, df);
1197 q = gsl_cdf_tdist_Q(t, df);
1199 /* Multiply by 2 to get 2-tailed significance, makeing sure we've got
1201 tab_float (trb->t, 3, i+3, TAB_RIGHT, 2.0*(t>0?q:p), 8,3);
1203 tab_float (trb->t, 4, i+3, TAB_RIGHT, gs->mean_diff, 8,3);
1206 q = (1 - cmd->criteria)/2.0; /* 2-tailed test */
1207 t = gsl_cdf_tdist_Qinv(q, df);
1209 tab_float (trb->t, 5, i+3, TAB_RIGHT,
1210 gs->mean_diff - t * gs->se_mean, 8,4);
1212 tab_float (trb->t, 6, i+3, TAB_RIGHT,
1213 gs->mean_diff + t * gs->se_mean, 8,4);
1217 /* Base initializer for the generalized trbox */
1219 trbox_base_init(struct trbox *self, int data_rows, int cols)
1221 const int rows = 3 + data_rows;
1223 self->finalize = trbox_base_finalize;
1224 self->t = tab_create (cols, rows, 0);
1225 tab_headers (self->t,0,0,3,0);
1226 tab_box (self->t, TAL_2, TAL_2, TAL_0, TAL_0, 0, 0, cols -1, rows -1);
1227 tab_hline(self->t, TAL_2,0,cols-1,3);
1228 tab_dim (self->t, tab_natural_dimensions);
1232 /* Base finalizer for the trbox */
1234 trbox_base_finalize(struct trbox *trb)
1240 /* Create , populate and submit the Paired Samples Correlation box */
1244 const int rows=1+n_pairs;
1248 struct tab_table *table;
1250 table = tab_create (cols,rows,0);
1252 tab_columns (table, SOM_COL_DOWN, 1);
1253 tab_headers (table,0,0,1,0);
1254 tab_box (table, TAL_2, TAL_2, TAL_0, TAL_1, 0, 0, cols -1, rows -1 );
1255 tab_hline(table, TAL_2, 0, cols - 1, 1);
1256 tab_vline(table, TAL_2, 2, 0, rows - 1);
1257 tab_dim(table, tab_natural_dimensions);
1258 tab_title(table, 0, _("Paired Samples Correlations"));
1260 /* column headings */
1261 tab_text(table, 2,0, TAB_CENTER | TAT_TITLE, _("N"));
1262 tab_text(table, 3,0, TAB_CENTER | TAT_TITLE, _("Correlation"));
1263 tab_text(table, 4,0, TAB_CENTER | TAT_TITLE, _("Sig."));
1265 for (i=0; i < n_pairs; ++i)
1269 double df = pairs[i].n -2;
1271 double correlation_t =
1272 pairs[i].correlation * sqrt(df) /
1273 sqrt(1 - pow2(pairs[i].correlation));
1277 tab_text(table, 0,i+1, TAB_LEFT | TAT_TITLE | TAT_PRINTF,
1280 tab_text(table, 1,i+1, TAB_LEFT | TAT_TITLE | TAT_PRINTF,
1281 _("%s & %s"), pairs[i].v[0]->name, pairs[i].v[1]->name);
1285 tab_float(table, 2, i+1, TAB_RIGHT, pairs[i].n, 4, 0);
1286 tab_float(table, 3, i+1, TAB_RIGHT, pairs[i].correlation, 8, 3);
1288 p = gsl_cdf_tdist_P(correlation_t, df);
1289 q = gsl_cdf_tdist_Q(correlation_t, df);
1291 tab_float(table, 4, i+1, TAB_RIGHT, 2.0*(correlation_t>0?q:p), 8, 3);
1299 /* Calculation Implementation */
1301 /* Per case calculations common to all variants of the T test */
1303 common_calc (const struct ccase *c, void *_cmd)
1306 struct cmd_t_test *cmd = (struct cmd_t_test *)_cmd;
1308 double weight = dict_get_case_weight(default_dict,c,&bad_weight_warn);
1311 /* Skip the entire case if /MISSING=LISTWISE is set */
1312 if ( cmd->miss == TTS_LISTWISE )
1314 for(i=0; i< cmd->n_variables ; ++i)
1316 struct variable *v = cmd->v_variables[i];
1317 const union value *val = &c->data[v->fv];
1319 if (value_is_missing(val,v) )
1326 /* Listwise has to be implicit if the independent variable is missing ?? */
1327 if ( cmd->sbc_groups )
1329 const union value *gv = &c->data[indep_var->fv];
1330 if ( value_is_missing(gv,indep_var) )
1337 for(i=0; i< cmd->n_variables ; ++i)
1339 struct group_statistics *gs;
1340 struct variable *v = cmd->v_variables[i];
1341 const union value *val = &c->data[v->fv];
1343 gs= &cmd->v_variables[i]->p.t_t.ugs;
1345 if (! value_is_missing(val,v) )
1348 gs->sum+=weight * val->f;
1349 gs->ssq+=weight * val->f * val->f;
1355 /* Pre calculations common to all variants of the T test */
1357 common_precalc ( struct cmd_t_test *cmd )
1361 for(i=0; i< cmd->n_variables ; ++i)
1363 struct group_statistics *gs;
1364 gs= &cmd->v_variables[i]->p.t_t.ugs;
1373 /* Post calculations common to all variants of the T test */
1375 common_postcalc ( struct cmd_t_test *cmd )
1380 for(i=0; i< cmd->n_variables ; ++i)
1382 struct group_statistics *gs;
1383 gs= &cmd->v_variables[i]->p.t_t.ugs;
1385 gs->mean=gs->sum / gs->n;
1386 gs->s_std_dev= sqrt(
1387 ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
1392 ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
1395 gs->se_mean = gs->std_dev / sqrt(gs->n);
1396 gs->mean_diff= gs->sum_diff / gs->n;
1400 /* Per case calculations for one sample t test */
1402 one_sample_calc (const struct ccase *c, void *cmd_)
1405 struct cmd_t_test *cmd = (struct cmd_t_test *)cmd_;
1408 double weight = dict_get_case_weight(default_dict,c,&bad_weight_warn);
1410 /* Skip the entire case if /MISSING=LISTWISE is set */
1411 if ( cmd->miss == TTS_LISTWISE )
1413 for(i=0; i< cmd->n_variables ; ++i)
1415 struct variable *v = cmd->v_variables[i];
1416 const union value *val = &c->data[v->fv];
1418 if (value_is_missing(val,v) )
1425 for(i=0; i< cmd->n_variables ; ++i)
1427 struct group_statistics *gs;
1428 struct variable *v = cmd->v_variables[i];
1429 const union value *val = &c->data[v->fv];
1431 gs= &cmd->v_variables[i]->p.t_t.ugs;
1433 if ( ! value_is_missing(val,v))
1434 gs->sum_diff += weight * (val->f - cmd->n_testval);
1440 /* Pre calculations for one sample t test */
1442 one_sample_precalc ( struct cmd_t_test *cmd )
1446 for(i=0; i< cmd->n_variables ; ++i)
1448 struct group_statistics *gs;
1449 gs= &cmd->v_variables[i]->p.t_t.ugs;
1455 /* Post calculations for one sample t test */
1457 one_sample_postcalc (struct cmd_t_test *cmd)
1461 for(i=0; i< cmd->n_variables ; ++i)
1463 struct group_statistics *gs;
1464 gs= &cmd->v_variables[i]->p.t_t.ugs;
1466 gs->mean_diff = gs->sum_diff / gs->n ;
1473 compare_var_name (const void *a_, const void *b_, void *v_ UNUSED)
1475 const struct variable *a = a_;
1476 const struct variable *b = b_;
1478 return strcmp(a->name,b->name);
1482 hash_var_name (const void *a_, void *v_ UNUSED)
1484 const struct variable *a = a_;
1486 return hsh_hash_bytes (a->name, strlen(a->name));
1492 paired_precalc (struct cmd_t_test *cmd UNUSED)
1496 for(i=0; i < n_pairs ; ++i )
1499 pairs[i].sum[0] = 0; pairs[i].sum[1] = 0;
1500 pairs[i].ssq[0] = 0; pairs[i].ssq[1] = 0;
1501 pairs[i].sum_of_prod = 0;
1502 pairs[i].correlation = 0;
1503 pairs[i].sum_of_diffs = 0;
1504 pairs[i].ssq_diffs = 0;
1511 paired_calc (const struct ccase *c, void *cmd_)
1515 struct cmd_t_test *cmd = (struct cmd_t_test *) cmd_;
1517 double weight = dict_get_case_weight(default_dict,c,&bad_weight_warn);
1519 /* Skip the entire case if /MISSING=LISTWISE is set ,
1520 AND one member of a pair is missing */
1521 if ( cmd->miss == TTS_LISTWISE )
1523 for(i=0; i < n_pairs ; ++i )
1525 struct variable *v0 = pairs[i].v[0];
1526 struct variable *v1 = pairs[i].v[1];
1528 const union value *val0 = &c->data[v0->fv];
1529 const union value *val1 = &c->data[v1->fv];
1531 if ( value_is_missing(val0,v0) ||
1532 value_is_missing(val1,v1) )
1539 for(i=0; i < n_pairs ; ++i )
1541 struct variable *v0 = pairs[i].v[0];
1542 struct variable *v1 = pairs[i].v[1];
1544 const union value *val0 = &c->data[v0->fv];
1545 const union value *val1 = &c->data[v1->fv];
1547 if ( ( !value_is_missing(val0,v0) && !value_is_missing(val1,v1) ) )
1549 pairs[i].n += weight;
1550 pairs[i].sum[0] += weight * val0->f;
1551 pairs[i].sum[1] += weight * val1->f;
1553 pairs[i].ssq[0] += weight * pow2(val0->f);
1554 pairs[i].ssq[1] += weight * pow2(val1->f);
1556 pairs[i].sum_of_prod += weight * val0->f * val1->f ;
1558 pairs[i].sum_of_diffs += weight * ( val0->f - val1->f ) ;
1559 pairs[i].ssq_diffs += weight * pow2(val0->f - val1->f);
1567 paired_postcalc (struct cmd_t_test *cmd UNUSED)
1571 for(i=0; i < n_pairs ; ++i )
1574 const double n = pairs[i].n;
1576 for (j=0; j < 2 ; ++j)
1578 pairs[i].mean[j] = pairs[i].sum[j] / n ;
1579 pairs[i].s_std_dev[j] = sqrt((pairs[i].ssq[j] / n -
1580 pow2(pairs[i].mean[j]))
1583 pairs[i].std_dev[j] = sqrt(n/(n-1)*(pairs[i].ssq[j] / n -
1584 pow2(pairs[i].mean[j]))
1588 pairs[i].correlation = pairs[i].sum_of_prod / pairs[i].n -
1589 pairs[i].mean[0] * pairs[i].mean[1] ;
1590 /* correlation now actually contains the covariance */
1592 pairs[i].correlation /= pairs[i].std_dev[0] * pairs[i].std_dev[1];
1593 pairs[i].correlation *= pairs[i].n / ( pairs[i].n - 1 );
1595 pairs[i].mean_diff = pairs[i].sum_of_diffs / n ;
1597 pairs[i].std_dev_diff = sqrt ( n / (n - 1) * (
1598 ( pairs[i].ssq_diffs / n )
1600 pow2(pairs[i].mean_diff )
1605 /* Return the group # corresponding to the
1606 independent variable with the value val
1609 get_group(const union value *val, struct variable *indep)
1613 for (i = 0; i < 2 ; ++i )
1615 const int cmp = compare_values(val,&groups_values[i],indep->width) ;
1616 switch ( criteria[i])
1619 if ( 0 == cmp ) return i;
1622 if ( 0 > cmp ) return i;
1625 if ( cmp <= 0 ) return i;
1628 if ( cmp > 0 ) return i;
1631 if ( cmp >= 0 ) return i;
1638 /* No groups matched */
1644 group_precalc (struct cmd_t_test *cmd )
1649 for(i=0; i< cmd->n_variables ; ++i)
1651 struct t_test_proc *ttpr = &cmd->v_variables[i]->p.t_t;
1653 /* There's always 2 groups for a T - TEST */
1655 ttpr->gs = xmalloc(sizeof(struct group_statistics) * 2) ;
1657 for (j=0 ; j < 2 ; ++j)
1659 ttpr->gs[j].sum = 0;
1661 ttpr->gs[j].ssq = 0;
1663 if ( n_group_values == 2 )
1664 ttpr->gs[j].id = groups_values[j];
1666 ttpr->gs[j].id = groups_values[0];
1667 ttpr->gs[j].criterion = criteria[j];
1674 group_calc (const struct ccase *c, struct cmd_t_test *cmd)
1679 const union value *gv = &c->data[indep_var->fv];
1681 const double weight = dict_get_case_weight(default_dict,c,&bad_weight_warn);
1683 if ( value_is_missing(gv,indep_var) )
1688 if ( cmd->miss == TTS_LISTWISE )
1690 for(i=0; i< cmd->n_variables ; ++i)
1692 struct variable *v = cmd->v_variables[i];
1693 const union value *val = &c->data[v->fv];
1695 if (value_is_missing(val,v) )
1703 gv = &c->data[indep_var->fv];
1705 g = get_group(gv,indep_var);
1708 /* If the independent variable doesn't match either of the values
1709 for this case then move on to the next case */
1713 for(i=0; i< cmd->n_variables ; ++i)
1715 struct variable *var = cmd->v_variables[i];
1717 struct group_statistics *gs = &var->p.t_t.gs[g];
1719 const union value *val=&c->data[var->fv];
1721 if ( !value_is_missing(val,var) )
1724 gs->sum+=weight * val->f;
1725 gs->ssq+=weight * pow2(val->f);
1734 group_postcalc ( struct cmd_t_test *cmd )
1739 for(i=0; i< cmd->n_variables ; ++i)
1741 for (j=0 ; j < 2 ; ++j)
1743 struct group_statistics *gs;
1744 gs=&cmd->v_variables[i]->p.t_t.gs[j];
1746 gs->mean = gs->sum / gs->n;
1748 gs->s_std_dev= sqrt(
1749 ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
1754 ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
1757 gs->se_mean = gs->std_dev / sqrt(gs->n);
1765 calculate(const struct casefile *cf, void *cmd_)
1767 struct ssbox stat_summary_box;
1768 struct trbox test_results_box;
1770 struct casereader *r;
1771 const struct ccase *c;
1773 struct cmd_t_test *cmd = (struct cmd_t_test *) cmd_;
1775 common_precalc(cmd);
1776 for(r = casefile_get_reader (cf);
1777 casereader_read (r, &c) ; )
1781 casereader_destroy (r);
1782 common_postcalc(cmd);
1787 one_sample_precalc(cmd);
1788 for(r = casefile_get_reader (cf);
1789 casereader_read (r, &c) ; )
1791 one_sample_calc(c,cmd);
1793 casereader_destroy (r);
1794 one_sample_postcalc(cmd);
1798 paired_precalc(cmd);
1799 for(r = casefile_get_reader (cf);
1800 casereader_read (r, &c) ; )
1804 casereader_destroy (r);
1805 paired_postcalc(cmd);
1811 for(r = casefile_get_reader (cf);
1812 casereader_read (r, &c) ; )
1816 casereader_destroy (r);
1817 group_postcalc(cmd);
1820 levene(cf, indep_var, cmd->n_variables, cmd->v_variables,
1821 (cmd->miss == TTS_LISTWISE)?LEV_LISTWISE:LEV_ANALYSIS ,
1826 ssbox_create(&stat_summary_box,cmd,mode);
1827 ssbox_populate(&stat_summary_box,cmd);
1828 ssbox_finalize(&stat_summary_box);
1830 if ( mode == T_PAIRED)
1833 trbox_create(&test_results_box,cmd,mode);
1834 trbox_populate(&test_results_box,cmd);
1835 trbox_finalize(&test_results_box);