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;
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;
299 multipass_procedure_with_splits (calculate, &cmd);
305 if ( mode == T_IND_SAMPLES)
308 /* Destroy any group statistics we created */
309 for (i= 0 ; i < cmd.n_variables ; ++i )
311 free(cmd.v_variables[i]->p.t_t.gs);
319 tts_custom_groups (struct cmd_t_test *cmd UNUSED)
324 if (token != T_ALL &&
325 (token != T_ID || dict_lookup_var (default_dict, tokid) == NULL)
328 msg(SE,_("`%s' is not a variable name"),tokid);
332 indep_var = parse_variable ();
335 lex_error ("expecting variable name in GROUPS subcommand");
339 if (indep_var->type == T_STRING && indep_var->width > MAX_SHORT_STRING)
341 msg (SE, _("Long string variable %s is not valid here."),
346 if (!lex_match ('('))
348 if (indep_var->type == NUMERIC)
350 groups_values[0].f = 1;
351 groups_values[1].f = 2;
352 criteria[0] = criteria[1] = CMP_EQ;
358 msg (SE, _("When applying GROUPS to a string variable, at "
359 "least one value must be specified."));
364 if (!parse_value (&groups_values[0],indep_var->type))
370 criteria[0] = CMP_LE;
371 criteria[1] = CMP_GT;
372 groups_values[1] = groups_values[0];
377 if (!parse_value (&groups_values[1],indep_var->type))
381 if (!lex_force_match (')'))
384 criteria[0] = criteria[1] = CMP_EQ;
390 tts_custom_pairs (struct cmd_t_test *cmd UNUSED)
392 struct variable **vars;
397 int n_after_WITH = -1;
398 int paired ; /* Was the PAIRED keyword given ? */
402 if ((token != T_ID || dict_lookup_var (default_dict, tokid) == NULL)
405 msg(SE,_("`%s' is not a variable name"),tokid);
410 if (!parse_variables (default_dict, &vars, &n_vars,
411 PV_DUPLICATE | PV_NUMERIC | PV_NO_SCRATCH))
419 if (lex_match (T_WITH))
421 n_before_WITH = n_vars;
422 if (!parse_variables (default_dict, &vars, &n_vars,
423 PV_DUPLICATE | PV_APPEND
424 | PV_NUMERIC | PV_NO_SCRATCH))
429 n_after_WITH = n_vars - n_before_WITH;
432 paired = (lex_match ('(') && lex_match_id ("PAIRED") && lex_match (')'));
434 /* Determine the number of pairs needed */
437 if (n_before_WITH != n_after_WITH)
440 msg (SE, _("PAIRED was specified but the number of variables "
441 "preceding WITH (%d) did not match the number "
443 n_before_WITH, n_after_WITH );
446 n_pairs_local=n_before_WITH;
448 else if (n_before_WITH > 0) /* WITH keyword given, but not PAIRED keyword */
450 n_pairs_local=n_before_WITH * n_after_WITH ;
452 else /* Neither WITH nor PAIRED keyword given */
457 msg (SE, _("At least two variables must be specified "
462 /* how many ways can you pick 2 from n_vars ? */
463 n_pairs_local = n_vars * (n_vars -1 ) /2 ;
467 /* Allocate storage for the pairs */
468 pairs = xrealloc(pairs, sizeof(struct pair) * (n_pairs + n_pairs_local) );
470 /* Populate the pairs with the appropriate variables */
475 assert(n_pairs_local == n_vars/2);
476 for (i = 0; i < n_pairs_local ; ++i)
478 pairs[i].v[n_pairs+0] = vars[i];
479 pairs[i].v[n_pairs+1] = vars[i+n_pairs_local];
482 else if (n_before_WITH > 0) /* WITH keyword given, but not PAIRED keyword */
487 for(i=0 ; i < n_before_WITH ; ++i )
489 for(j=0 ; j < n_after_WITH ; ++j)
491 pairs[p].v[0] = vars[i];
492 pairs[p].v[1] = vars[j+n_before_WITH];
497 else /* Neither WITH nor PAIRED given */
502 for(i=0 ; i < n_vars ; ++i )
504 for(j=i+1 ; j < n_vars ; ++j)
506 pairs[p].v[0] = vars[i];
507 pairs[p].v[1] = vars[j];
513 n_pairs+=n_pairs_local;
518 /* Parses the current token (numeric or string, depending on type)
519 value v and returns success. */
521 parse_value (union value * v, int type )
525 if (!lex_force_num ())
531 if (!lex_force_string ())
533 strncpy (v->s, ds_value (&tokstr), ds_length (&tokstr));
542 /* Implementation of the SSBOX object */
544 void ssbox_base_init(struct ssbox *this, int cols,int rows);
546 void ssbox_base_finalize(struct ssbox *ssb);
548 void ssbox_one_sample_init(struct ssbox *this,
549 struct cmd_t_test *cmd );
551 void ssbox_independent_samples_init(struct ssbox *this,
552 struct cmd_t_test *cmd);
554 void ssbox_paired_init(struct ssbox *this,
555 struct cmd_t_test *cmd);
557 /* Factory to create an ssbox */
559 ssbox_create(struct ssbox *ssb, struct cmd_t_test *cmd, int mode)
564 ssbox_one_sample_init(ssb,cmd);
567 ssbox_independent_samples_init(ssb,cmd);
570 ssbox_paired_init(ssb,cmd);
578 /* Despatcher for the populate method */
580 ssbox_populate(struct ssbox *ssb,struct cmd_t_test *cmd)
582 ssb->populate(ssb,cmd);
586 /* Despatcher for finalize */
588 ssbox_finalize(struct ssbox *ssb)
594 /* Submit the box and clear up */
596 ssbox_base_finalize(struct ssbox *ssb)
601 /* Initialize a ssbox struct */
603 ssbox_base_init(struct ssbox *this, int cols,int rows)
605 this->finalize = ssbox_base_finalize;
606 this->t = tab_create (cols, rows, 0);
608 tab_columns (this->t, SOM_COL_DOWN, 1);
609 tab_headers (this->t,0,0,1,0);
610 tab_box (this->t, TAL_2, TAL_2, TAL_0, TAL_1, 0, 0, cols -1, rows -1 );
611 tab_hline(this->t, TAL_2,0,cols-1,1);
612 tab_dim (this->t, tab_natural_dimensions);
615 void ssbox_one_sample_populate(struct ssbox *ssb,
616 struct cmd_t_test *cmd);
618 /* Initialize the one_sample ssbox */
620 ssbox_one_sample_init(struct ssbox *this,
621 struct cmd_t_test *cmd )
624 const int vsize=cmd->n_variables+1;
626 this->populate = ssbox_one_sample_populate;
628 ssbox_base_init(this, hsize,vsize);
629 tab_title (this->t, 0, _("One-Sample Statistics"));
630 tab_vline(this->t, TAL_2, 1,0,vsize);
631 tab_text (this->t, 1, 0, TAB_CENTER | TAT_TITLE, _("N"));
632 tab_text (this->t, 2, 0, TAB_CENTER | TAT_TITLE, _("Mean"));
633 tab_text (this->t, 3, 0, TAB_CENTER | TAT_TITLE, _("Std. Deviation"));
634 tab_text (this->t, 4, 0, TAB_CENTER | TAT_TITLE, _("SE. Mean"));
637 void ssbox_independent_samples_populate(struct ssbox *ssb,
638 struct cmd_t_test *cmd);
640 /* Initialize the independent samples ssbox */
642 ssbox_independent_samples_init(struct ssbox *this,
643 struct cmd_t_test *cmd)
646 int vsize = cmd->n_variables*2 +1;
648 this->populate = ssbox_independent_samples_populate;
650 ssbox_base_init(this, hsize,vsize);
651 tab_title (this->t, 0, _("Group Statistics"));
652 tab_vline(this->t,0,1,0,vsize);
653 tab_text (this->t, 1, 0, TAB_CENTER | TAT_TITLE, indep_var->name);
654 tab_text (this->t, 2, 0, TAB_CENTER | TAT_TITLE, _("N"));
655 tab_text (this->t, 3, 0, TAB_CENTER | TAT_TITLE, _("Mean"));
656 tab_text (this->t, 4, 0, TAB_CENTER | TAT_TITLE, _("Std. Deviation"));
657 tab_text (this->t, 5, 0, TAB_CENTER | TAT_TITLE, _("SE. Mean"));
661 /* Populate the ssbox for independent samples */
663 ssbox_independent_samples_populate(struct ssbox *ssb,
664 struct cmd_t_test *cmd)
671 char prefix[2][3]={"",""};
673 if ( indep_var->type == NUMERIC )
675 val_lab0 = val_labs_find( indep_var->val_labs,groups_values[0]);
676 val_lab1 = val_labs_find( indep_var->val_labs,groups_values[1]);
680 val_lab0 = groups_values[0].s;
681 val_lab1 = groups_values[1].s;
684 if (n_group_values == 1)
686 strcpy(prefix[0],"< ");
687 strcpy(prefix[1],">=");
692 for (i=0; i < cmd->n_variables; ++i)
696 tab_text (ssb->t, 0, i*2+1, TAB_LEFT, cmd->v_variables[i]->name);
699 tab_text (ssb->t, 1, i*2+1, TAB_LEFT | TAT_PRINTF,
700 "%s%s", prefix[0], val_lab0);
702 tab_text (ssb->t, 1, i*2+1, TAB_LEFT | TAT_PRINTF,
703 "%s%g", prefix[0], groups_values[0].f);
707 tab_text (ssb->t, 1, i*2+1+1, TAB_LEFT | TAT_PRINTF,
708 "%s%s", prefix[1], val_lab1);
710 tab_text (ssb->t, 1, i*2+1+1, TAB_LEFT | TAT_PRINTF,
711 "%s%g", prefix[1], groups_values[1].f);
713 /* Fill in the group statistics */
714 for ( g=0; g < 2 ; ++g )
716 struct group_statistics *gs = &cmd->v_variables[i]->p.t_t.gs[g];
718 tab_float(ssb->t, 2 ,i*2+g+1, TAB_RIGHT, gs->n, 2, 0);
719 tab_float(ssb->t, 3 ,i*2+g+1, TAB_RIGHT, gs->mean, 8, 2);
720 tab_float(ssb->t, 4 ,i*2+g+1, TAB_RIGHT, gs->std_dev, 8, 3);
721 tab_float(ssb->t, 5 ,i*2+g+1, TAB_RIGHT, gs->se_mean, 8, 3);
727 void ssbox_paired_populate(struct ssbox *ssb,
728 struct cmd_t_test *cmd);
730 /* Initialize the paired values ssbox */
732 ssbox_paired_init(struct ssbox *this, struct cmd_t_test *cmd UNUSED)
736 int vsize = n_pairs*2+1;
738 this->populate = ssbox_paired_populate;
740 ssbox_base_init(this, hsize,vsize);
741 tab_title (this->t, 0, _("Paired Sample Statistics"));
742 tab_vline(this->t,TAL_0,1,0,vsize-1);
743 tab_vline(this->t,TAL_2,2,0,vsize-1);
744 tab_text (this->t, 2, 0, TAB_CENTER | TAT_TITLE, _("Mean"));
745 tab_text (this->t, 3, 0, TAB_CENTER | TAT_TITLE, _("N"));
746 tab_text (this->t, 4, 0, TAB_CENTER | TAT_TITLE, _("Std. Deviation"));
747 tab_text (this->t, 5, 0, TAB_CENTER | TAT_TITLE, _("SE. Mean"));
751 /* Populate the ssbox for paired values */
753 ssbox_paired_populate(struct ssbox *ssb,struct cmd_t_test *cmd UNUSED)
759 for (i=0; i < n_pairs; ++i)
763 tab_text (ssb->t, 0, i*2+1, TAB_LEFT | TAT_PRINTF , _("Pair %d"),i);
765 for (j=0 ; j < 2 ; ++j)
767 struct group_statistics *gs;
769 gs=&pairs[i].v[j]->p.t_t.ugs;
773 tab_text (ssb->t, 1, i*2+j+1, TAB_LEFT, pairs[i].v[j]->name);
776 tab_float (ssb->t,2, i*2+j+1, TAB_RIGHT, pairs[i].mean[j], 8, 2);
777 tab_float (ssb->t,3, i*2+j+1, TAB_RIGHT, pairs[i].n, 2, 0);
778 tab_float (ssb->t,4, i*2+j+1, TAB_RIGHT, pairs[i].std_dev[j], 8, 3);
779 tab_float (ssb->t,5, i*2+j+1, TAB_RIGHT, pairs[i].std_dev[j]/sqrt(pairs[i].n), 8, 3);
785 /* Populate the one sample ssbox */
787 ssbox_one_sample_populate(struct ssbox *ssb, struct cmd_t_test *cmd)
793 for (i=0; i < cmd->n_variables; ++i)
795 struct group_statistics *gs;
796 gs= &cmd->v_variables[i]->p.t_t.ugs;
798 tab_text (ssb->t, 0, i+1, TAB_LEFT, cmd->v_variables[i]->name);
799 tab_float (ssb->t,1, i+1, TAB_RIGHT, gs->n, 2, 0);
800 tab_float (ssb->t,2, i+1, TAB_RIGHT, gs->mean, 8, 2);
801 tab_float (ssb->t,3, i+1, TAB_RIGHT, gs->std_dev, 8, 2);
802 tab_float (ssb->t,4, i+1, TAB_RIGHT, gs->se_mean, 8, 3);
809 /* Implementation of the Test Results box struct */
811 void trbox_base_init(struct trbox *self,int n_vars, int cols);
812 void trbox_base_finalize(struct trbox *trb);
814 void trbox_independent_samples_init(struct trbox *trb,
815 struct cmd_t_test *cmd );
817 void trbox_independent_samples_populate(struct trbox *trb,
818 struct cmd_t_test *cmd);
820 void trbox_one_sample_init(struct trbox *self,
821 struct cmd_t_test *cmd );
823 void trbox_one_sample_populate(struct trbox *trb,
824 struct cmd_t_test *cmd);
826 void trbox_paired_init(struct trbox *self,
827 struct cmd_t_test *cmd );
829 void trbox_paired_populate(struct trbox *trb,
830 struct cmd_t_test *cmd);
834 /* Create a trbox according to mode*/
836 trbox_create(struct trbox *trb,
837 struct cmd_t_test *cmd, int mode)
842 trbox_one_sample_init(trb,cmd);
845 trbox_independent_samples_init(trb,cmd);
848 trbox_paired_init(trb,cmd);
855 /* Populate a trbox according to cmd */
857 trbox_populate(struct trbox *trb, struct cmd_t_test *cmd)
859 trb->populate(trb,cmd);
862 /* Submit and destroy a trbox */
864 trbox_finalize(struct trbox *trb)
869 /* Initialize the independent samples trbox */
871 trbox_independent_samples_init(struct trbox *self,
872 struct cmd_t_test *cmd UNUSED)
875 const int vsize=cmd->n_variables*2+3;
878 self->populate = trbox_independent_samples_populate;
880 trbox_base_init(self,cmd->n_variables*2,hsize);
881 tab_title(self->t,0,_("Independent Samples Test"));
882 tab_hline(self->t,TAL_1,2,hsize-1,1);
883 tab_vline(self->t,TAL_2,2,0,vsize-1);
884 tab_vline(self->t,TAL_1,4,0,vsize-1);
885 tab_box(self->t,-1,-1,-1,TAL_1, 2,1,hsize-2,vsize-1);
886 tab_hline(self->t,TAL_1, hsize-2,hsize-1,2);
887 tab_box(self->t,-1,-1,-1,TAL_1, hsize-2,2,hsize-1,vsize-1);
888 tab_joint_text(self->t, 2, 0, 3, 0,
889 TAB_CENTER,_("Levene's Test for Equality of Variances"));
890 tab_joint_text(self->t, 4,0,hsize-1,0,
891 TAB_CENTER,_("t-test for Equality of Means"));
893 tab_text(self->t,2,2, TAB_CENTER | TAT_TITLE,_("F"));
894 tab_text(self->t,3,2, TAB_CENTER | TAT_TITLE,_("Sig."));
895 tab_text(self->t,4,2, TAB_CENTER | TAT_TITLE,_("t"));
896 tab_text(self->t,5,2, TAB_CENTER | TAT_TITLE,_("df"));
897 tab_text(self->t,6,2, TAB_CENTER | TAT_TITLE,_("Sig. (2-tailed)"));
898 tab_text(self->t,7,2, TAB_CENTER | TAT_TITLE,_("Mean Difference"));
899 tab_text(self->t,8,2, TAB_CENTER | TAT_TITLE,_("Std. Error Difference"));
900 tab_text(self->t,9,2, TAB_CENTER | TAT_TITLE,_("Lower"));
901 tab_text(self->t,10,2, TAB_CENTER | TAT_TITLE,_("Upper"));
903 tab_joint_text(self->t, 9, 1, 10, 1, TAB_CENTER | TAT_PRINTF,
904 _("%d%% Confidence Interval of the Difference"),
905 (int)round(cmd->criteria*100.0));
909 /* Populate the independent samples trbox */
911 trbox_independent_samples_populate(struct trbox *self,
912 struct cmd_t_test *cmd )
917 for (i=0; i < cmd->n_variables; ++i)
926 double pooled_variance;
930 struct group_statistics *gs0 = &cmd->v_variables[i]->p.t_t.gs[0];
931 struct group_statistics *gs1 = &cmd->v_variables[i]->p.t_t.gs[1];
933 tab_text (self->t, 0, i*2+3, TAB_LEFT, cmd->v_variables[i]->name);
935 tab_text (self->t, 1, i*2+3, TAB_LEFT, _("Equal variances assumed"));
938 tab_float(self->t, 2, i*2+3, TAB_CENTER,
939 cmd->v_variables[i]->p.t_t.levene, 8,3);
941 /* Now work out the significance of the Levene test */
942 df1 = 1; df2 = cmd->v_variables[i]->p.t_t.ugs.n - 2;
943 q = gsl_cdf_fdist_Q(cmd->v_variables[i]->p.t_t.levene, df1, df2);
945 tab_float(self->t, 3, i*2+3, TAB_CENTER, q, 8,3 );
947 df = gs0->n + gs1->n - 2.0 ;
948 tab_float (self->t, 5, i*2+3, TAB_RIGHT, df, 2, 0);
950 pooled_variance = ( (gs0->n )*pow2(gs0->s_std_dev)
952 (gs1->n )*pow2(gs1->s_std_dev)
955 t = (gs0->mean - gs1->mean) / sqrt(pooled_variance) ;
956 t /= sqrt((gs0->n + gs1->n)/(gs0->n*gs1->n));
958 tab_float (self->t, 4, i*2+3, TAB_RIGHT, t, 8, 3);
960 p = gsl_cdf_tdist_P(t, df);
961 q = gsl_cdf_tdist_Q(t, df);
963 tab_float(self->t, 6, i*2+3, TAB_RIGHT, 2.0*(t>0?q:p) , 8, 3);
965 mean_diff = gs0->mean - gs1->mean;
966 tab_float(self->t, 7, i*2+3, TAB_RIGHT, mean_diff, 8, 3);
969 std_err_diff = sqrt( pow2(gs0->se_mean) + pow2(gs1->se_mean));
970 tab_float(self->t, 8, i*2+3, TAB_RIGHT, std_err_diff, 8, 3);
973 /* Now work out the confidence interval */
974 q = (1 - cmd->criteria)/2.0; /* 2-tailed test */
976 t = gsl_cdf_tdist_Qinv(q,df);
977 tab_float(self->t, 9, i*2+3, TAB_RIGHT,
978 mean_diff - t * std_err_diff, 8, 3);
980 tab_float(self->t, 10, i*2+3, TAB_RIGHT,
981 mean_diff + t * std_err_diff, 8, 3);
986 /* Now for the \sigma_1 != \sigma_2 case */
987 tab_text (self->t, 1, i*2+3+1,
988 TAB_LEFT, _("Equal variances not assumed"));
991 se2 = (pow2(gs0->s_std_dev)/(gs0->n -1) ) +
992 (pow2(gs1->s_std_dev)/(gs1->n -1) );
994 t = mean_diff / sqrt(se2) ;
995 tab_float (self->t, 4, i*2+3+1, TAB_RIGHT, t, 8, 3);
998 (pow2(pow2(gs0->s_std_dev)/(gs0->n - 1 ))
1002 (pow2(pow2(gs1->s_std_dev)/(gs1->n - 1 ))
1006 tab_float (self->t, 5, i*2+3+1, TAB_RIGHT, df, 8, 3);
1008 p = gsl_cdf_tdist_P(t, df);
1009 q = gsl_cdf_tdist_Q(t, df);
1011 tab_float(self->t, 6, i*2+3+1, TAB_RIGHT, 2.0*(t>0?q:p) , 8, 3);
1013 /* Now work out the confidence interval */
1014 q = (1 - cmd->criteria)/2.0; /* 2-tailed test */
1016 t = gsl_cdf_tdist_Qinv(q, df);
1018 tab_float(self->t, 7, i*2+3+1, TAB_RIGHT, mean_diff, 8, 3);
1021 tab_float(self->t, 8, i*2+3+1, TAB_RIGHT, std_err_diff, 8, 3);
1024 tab_float(self->t, 9, i*2+3+1, TAB_RIGHT,
1025 mean_diff - t * std_err_diff, 8, 3);
1027 tab_float(self->t, 10, i*2+3+1, TAB_RIGHT,
1028 mean_diff + t * std_err_diff, 8, 3);
1034 /* Initialize the paired samples trbox */
1036 trbox_paired_init(struct trbox *self,
1037 struct cmd_t_test *cmd UNUSED)
1041 const int vsize=n_pairs+3;
1043 self->populate = trbox_paired_populate;
1045 trbox_base_init(self,n_pairs,hsize);
1046 tab_title (self->t, 0, _("Paired Samples Test"));
1047 tab_hline(self->t,TAL_1,2,6,1);
1048 tab_vline(self->t,TAL_2,2,0,vsize);
1049 tab_joint_text(self->t,2,0,6,0,TAB_CENTER,_("Paired Differences"));
1050 tab_box(self->t,-1,-1,-1,TAL_1, 2,1,6,vsize-1);
1051 tab_box(self->t,-1,-1,-1,TAL_1, 6,0,hsize-1,vsize-1);
1052 tab_hline(self->t,TAL_1,5,6, 2);
1053 tab_vline(self->t,TAL_0,6,0,1);
1055 tab_joint_text(self->t, 5, 1, 6, 1, TAB_CENTER | TAT_PRINTF,
1056 _("%d%% Confidence Interval of the Difference"),
1057 (int)round(cmd->criteria*100.0));
1059 tab_text (self->t, 2, 2, TAB_CENTER | TAT_TITLE, _("Mean"));
1060 tab_text (self->t, 3, 2, TAB_CENTER | TAT_TITLE, _("Std. Deviation"));
1061 tab_text (self->t, 4, 2, TAB_CENTER | TAT_TITLE, _("Std. Error Mean"));
1062 tab_text (self->t, 5, 2, TAB_CENTER | TAT_TITLE, _("Lower"));
1063 tab_text (self->t, 6, 2, TAB_CENTER | TAT_TITLE, _("Upper"));
1064 tab_text (self->t, 7, 2, TAB_CENTER | TAT_TITLE, _("t"));
1065 tab_text (self->t, 8, 2, TAB_CENTER | TAT_TITLE, _("df"));
1066 tab_text (self->t, 9, 2, TAB_CENTER | TAT_TITLE, _("Sig. (2-tailed)"));
1069 /* Populate the paired samples trbox */
1071 trbox_paired_populate(struct trbox *trb,
1072 struct cmd_t_test *cmd UNUSED)
1076 for (i=0; i < n_pairs; ++i)
1081 double n = pairs[i].n;
1085 tab_text (trb->t, 0, i+3, TAB_LEFT | TAT_PRINTF, _("Pair %d"),i);
1087 tab_text (trb->t, 1, i+3, TAB_LEFT | TAT_PRINTF, "%s - %s",
1088 pairs[i].v[0]->name, pairs[i].v[1]->name);
1090 tab_float(trb->t, 2, i+3, TAB_RIGHT, pairs[i].mean_diff, 8, 4);
1092 tab_float(trb->t, 3, i+3, TAB_RIGHT, pairs[i].std_dev_diff, 8, 5);
1095 se_mean = pairs[i].std_dev_diff / sqrt(n) ;
1096 tab_float(trb->t, 4, i+3, TAB_RIGHT, se_mean, 8,5 );
1098 /* Now work out the confidence interval */
1099 q = (1 - cmd->criteria)/2.0; /* 2-tailed test */
1101 t = gsl_cdf_tdist_Qinv(q, df);
1103 tab_float(trb->t, 5, i+3, TAB_RIGHT,
1104 pairs[i].mean_diff - t * se_mean , 8, 4);
1106 tab_float(trb->t, 6, i+3, TAB_RIGHT,
1107 pairs[i].mean_diff + t * se_mean , 8, 4);
1109 t = (pairs[i].mean[0] - pairs[i].mean[1])
1111 ( pow2 (pairs[i].s_std_dev[0]) + pow2 (pairs[i].s_std_dev[1]) -
1112 2 * pairs[i].correlation *
1113 pairs[i].s_std_dev[0] * pairs[i].s_std_dev[1] )
1117 tab_float(trb->t, 7, i+3, TAB_RIGHT, t , 8,3 );
1119 /* Degrees of freedom */
1120 tab_float(trb->t, 8, i+3, TAB_RIGHT, df , 2, 0 );
1122 p = gsl_cdf_tdist_P(t,df);
1123 q = gsl_cdf_tdist_P(t,df);
1125 tab_float(trb->t, 9, i+3, TAB_RIGHT, 2.0*(t>0?q:p) , 8, 3);
1130 /* Initialize the one sample trbox */
1132 trbox_one_sample_init(struct trbox *self, struct cmd_t_test *cmd )
1135 const int vsize=cmd->n_variables+3;
1137 self->populate = trbox_one_sample_populate;
1139 trbox_base_init(self, cmd->n_variables,hsize);
1140 tab_title (self->t, 0, _("One-Sample Test"));
1141 tab_hline(self->t, TAL_1, 1, hsize - 1, 1);
1142 tab_vline(self->t, TAL_2, 1, 0, vsize);
1144 tab_joint_text(self->t, 1, 0, hsize-1,0, TAB_CENTER | TAT_PRINTF,
1145 _("Test Value = %f"),cmd->n_testval);
1147 tab_box(self->t, -1, -1, -1, TAL_1, 1,1,hsize-1,vsize-1);
1150 tab_joint_text(self->t,5,1,6,1,TAB_CENTER | TAT_PRINTF,
1151 _("%d%% Confidence Interval of the Difference"),
1152 (int)round(cmd->criteria*100.0));
1154 tab_vline(self->t,TAL_0,6,1,1);
1155 tab_hline(self->t,TAL_1,5,6,2);
1156 tab_text (self->t, 1, 2, TAB_CENTER | TAT_TITLE, _("t"));
1157 tab_text (self->t, 2, 2, TAB_CENTER | TAT_TITLE, _("df"));
1158 tab_text (self->t, 3, 2, TAB_CENTER | TAT_TITLE, _("Sig. (2-tailed)"));
1159 tab_text (self->t, 4, 2, TAB_CENTER | TAT_TITLE, _("Mean Difference"));
1160 tab_text (self->t, 5, 2, TAB_CENTER | TAT_TITLE, _("Lower"));
1161 tab_text (self->t, 6, 2, TAB_CENTER | TAT_TITLE, _("Upper"));
1166 /* Populate the one sample trbox */
1168 trbox_one_sample_populate(struct trbox *trb, struct cmd_t_test *cmd)
1174 for (i=0; i < cmd->n_variables; ++i)
1179 struct group_statistics *gs;
1180 gs= &cmd->v_variables[i]->p.t_t.ugs;
1183 tab_text (trb->t, 0, i+3, TAB_LEFT, cmd->v_variables[i]->name);
1185 t = (gs->mean - cmd->n_testval ) * sqrt(gs->n) / gs->std_dev ;
1187 tab_float (trb->t, 1, i+3, TAB_RIGHT, t, 8,3);
1189 /* degrees of freedom */
1192 tab_float (trb->t, 2, i+3, TAB_RIGHT, df, 8,0);
1194 p = gsl_cdf_tdist_P(t, df);
1195 q = gsl_cdf_tdist_Q(t, df);
1197 /* Multiply by 2 to get 2-tailed significance, makeing sure we've got
1199 tab_float (trb->t, 3, i+3, TAB_RIGHT, 2.0*(t>0?q:p), 8,3);
1201 tab_float (trb->t, 4, i+3, TAB_RIGHT, gs->mean_diff, 8,3);
1204 q = (1 - cmd->criteria)/2.0; /* 2-tailed test */
1205 t = gsl_cdf_tdist_Qinv(q, df);
1207 tab_float (trb->t, 5, i+3, TAB_RIGHT,
1208 gs->mean_diff - t * gs->se_mean, 8,4);
1210 tab_float (trb->t, 6, i+3, TAB_RIGHT,
1211 gs->mean_diff + t * gs->se_mean, 8,4);
1215 /* Base initializer for the generalized trbox */
1217 trbox_base_init(struct trbox *self, int data_rows, int cols)
1219 const int rows = 3 + data_rows;
1221 self->finalize = trbox_base_finalize;
1222 self->t = tab_create (cols, rows, 0);
1223 tab_headers (self->t,0,0,3,0);
1224 tab_box (self->t, TAL_2, TAL_2, TAL_0, TAL_0, 0, 0, cols -1, rows -1);
1225 tab_hline(self->t, TAL_2,0,cols-1,3);
1226 tab_dim (self->t, tab_natural_dimensions);
1230 /* Base finalizer for the trbox */
1232 trbox_base_finalize(struct trbox *trb)
1238 /* Create , populate and submit the Paired Samples Correlation box */
1242 const int rows=1+n_pairs;
1246 struct tab_table *table;
1248 table = tab_create (cols,rows,0);
1250 tab_columns (table, SOM_COL_DOWN, 1);
1251 tab_headers (table,0,0,1,0);
1252 tab_box (table, TAL_2, TAL_2, TAL_0, TAL_1, 0, 0, cols -1, rows -1 );
1253 tab_hline(table, TAL_2, 0, cols - 1, 1);
1254 tab_vline(table, TAL_2, 2, 0, rows - 1);
1255 tab_dim(table, tab_natural_dimensions);
1256 tab_title(table, 0, _("Paired Samples Correlations"));
1258 /* column headings */
1259 tab_text(table, 2,0, TAB_CENTER | TAT_TITLE, _("N"));
1260 tab_text(table, 3,0, TAB_CENTER | TAT_TITLE, _("Correlation"));
1261 tab_text(table, 4,0, TAB_CENTER | TAT_TITLE, _("Sig."));
1263 for (i=0; i < n_pairs; ++i)
1267 double df = pairs[i].n -2;
1269 double correlation_t =
1270 pairs[i].correlation * sqrt(df) /
1271 sqrt(1 - pow2(pairs[i].correlation));
1275 tab_text(table, 0,i+1, TAB_LEFT | TAT_TITLE | TAT_PRINTF,
1278 tab_text(table, 1,i+1, TAB_LEFT | TAT_TITLE | TAT_PRINTF,
1279 _("%s & %s"), pairs[i].v[0]->name, pairs[i].v[1]->name);
1283 tab_float(table, 2, i+1, TAB_RIGHT, pairs[i].n, 4, 0);
1284 tab_float(table, 3, i+1, TAB_RIGHT, pairs[i].correlation, 8, 3);
1286 p = gsl_cdf_tdist_P(correlation_t, df);
1287 q = gsl_cdf_tdist_Q(correlation_t, df);
1289 tab_float(table, 4, i+1, TAB_RIGHT, 2.0*(correlation_t>0?q:p), 8, 3);
1297 /* Calculation Implementation */
1299 /* Per case calculations common to all variants of the T test */
1301 common_calc (const struct ccase *c, void *_cmd)
1304 struct cmd_t_test *cmd = (struct cmd_t_test *)_cmd;
1306 double weight = dict_get_case_weight(default_dict,c);
1309 /* Skip the entire case if /MISSING=LISTWISE is set */
1310 if ( cmd->miss == TTS_LISTWISE )
1312 for(i=0; i< cmd->n_variables ; ++i)
1314 struct variable *v = cmd->v_variables[i];
1315 const union value *val = &c->data[v->fv];
1317 if (value_is_missing(val,v) )
1324 /* Listwise has to be implicit if the independent variable is missing ?? */
1325 if ( cmd->sbc_groups )
1327 const union value *gv = &c->data[indep_var->fv];
1328 if ( value_is_missing(gv,indep_var) )
1335 for(i=0; i< cmd->n_variables ; ++i)
1337 struct group_statistics *gs;
1338 struct variable *v = cmd->v_variables[i];
1339 const union value *val = &c->data[v->fv];
1341 gs= &cmd->v_variables[i]->p.t_t.ugs;
1343 if (! value_is_missing(val,v) )
1346 gs->sum+=weight * val->f;
1347 gs->ssq+=weight * val->f * val->f;
1353 /* Pre calculations common to all variants of the T test */
1355 common_precalc ( struct cmd_t_test *cmd )
1359 for(i=0; i< cmd->n_variables ; ++i)
1361 struct group_statistics *gs;
1362 gs= &cmd->v_variables[i]->p.t_t.ugs;
1371 /* Post calculations common to all variants of the T test */
1373 common_postcalc ( struct cmd_t_test *cmd )
1378 for(i=0; i< cmd->n_variables ; ++i)
1380 struct group_statistics *gs;
1381 gs= &cmd->v_variables[i]->p.t_t.ugs;
1383 gs->mean=gs->sum / gs->n;
1384 gs->s_std_dev= sqrt(
1385 ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
1390 ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
1393 gs->se_mean = gs->std_dev / sqrt(gs->n);
1394 gs->mean_diff= gs->sum_diff / gs->n;
1398 /* Per case calculations for one sample t test */
1400 one_sample_calc (const struct ccase *c, void *cmd_)
1403 struct cmd_t_test *cmd = (struct cmd_t_test *)cmd_;
1406 double weight = dict_get_case_weight(default_dict,c);
1408 /* Skip the entire case if /MISSING=LISTWISE is set */
1409 if ( cmd->miss == TTS_LISTWISE )
1411 for(i=0; i< cmd->n_variables ; ++i)
1413 struct variable *v = cmd->v_variables[i];
1414 const union value *val = &c->data[v->fv];
1416 if (value_is_missing(val,v) )
1423 for(i=0; i< cmd->n_variables ; ++i)
1425 struct group_statistics *gs;
1426 struct variable *v = cmd->v_variables[i];
1427 const union value *val = &c->data[v->fv];
1429 gs= &cmd->v_variables[i]->p.t_t.ugs;
1431 if ( ! value_is_missing(val,v))
1432 gs->sum_diff += weight * (val->f - cmd->n_testval);
1438 /* Pre calculations for one sample t test */
1440 one_sample_precalc ( struct cmd_t_test *cmd )
1444 for(i=0; i< cmd->n_variables ; ++i)
1446 struct group_statistics *gs;
1447 gs= &cmd->v_variables[i]->p.t_t.ugs;
1453 /* Post calculations for one sample t test */
1455 one_sample_postcalc (struct cmd_t_test *cmd)
1459 for(i=0; i< cmd->n_variables ; ++i)
1461 struct group_statistics *gs;
1462 gs= &cmd->v_variables[i]->p.t_t.ugs;
1464 gs->mean_diff = gs->sum_diff / gs->n ;
1471 compare_var_name (const void *a_, const void *b_, void *v_ UNUSED)
1473 const struct variable *a = a_;
1474 const struct variable *b = b_;
1476 return strcmp(a->name,b->name);
1480 hash_var_name (const void *a_, void *v_ UNUSED)
1482 const struct variable *a = a_;
1484 return hsh_hash_bytes (a->name, strlen(a->name));
1490 paired_precalc (struct cmd_t_test *cmd UNUSED)
1494 for(i=0; i < n_pairs ; ++i )
1497 pairs[i].sum[0] = 0; pairs[i].sum[1] = 0;
1498 pairs[i].ssq[0] = 0; pairs[i].ssq[1] = 0;
1499 pairs[i].sum_of_prod = 0;
1500 pairs[i].correlation = 0;
1501 pairs[i].sum_of_diffs = 0;
1502 pairs[i].ssq_diffs = 0;
1509 paired_calc (const struct ccase *c, void *cmd_)
1513 struct cmd_t_test *cmd = (struct cmd_t_test *) cmd_;
1515 double weight = dict_get_case_weight(default_dict,c);
1517 /* Skip the entire case if /MISSING=LISTWISE is set ,
1518 AND one member of a pair is missing */
1519 if ( cmd->miss == TTS_LISTWISE )
1521 for(i=0; i < n_pairs ; ++i )
1523 struct variable *v0 = pairs[i].v[0];
1524 struct variable *v1 = pairs[i].v[1];
1526 const union value *val0 = &c->data[v0->fv];
1527 const union value *val1 = &c->data[v1->fv];
1529 if ( value_is_missing(val0,v0) ||
1530 value_is_missing(val1,v1) )
1537 for(i=0; i < n_pairs ; ++i )
1539 struct variable *v0 = pairs[i].v[0];
1540 struct variable *v1 = pairs[i].v[1];
1542 const union value *val0 = &c->data[v0->fv];
1543 const union value *val1 = &c->data[v1->fv];
1545 if ( ( !value_is_missing(val0,v0) && !value_is_missing(val1,v1) ) )
1547 pairs[i].n += weight;
1548 pairs[i].sum[0] += weight * val0->f;
1549 pairs[i].sum[1] += weight * val1->f;
1551 pairs[i].ssq[0] += weight * pow2(val0->f);
1552 pairs[i].ssq[1] += weight * pow2(val1->f);
1554 pairs[i].sum_of_prod += weight * val0->f * val1->f ;
1556 pairs[i].sum_of_diffs += weight * ( val0->f - val1->f ) ;
1557 pairs[i].ssq_diffs += weight * pow2(val0->f - val1->f);
1565 paired_postcalc (struct cmd_t_test *cmd UNUSED)
1569 for(i=0; i < n_pairs ; ++i )
1572 const double n = pairs[i].n;
1574 for (j=0; j < 2 ; ++j)
1576 pairs[i].mean[j] = pairs[i].sum[j] / n ;
1577 pairs[i].s_std_dev[j] = sqrt((pairs[i].ssq[j] / n -
1578 pow2(pairs[i].mean[j]))
1581 pairs[i].std_dev[j] = sqrt(n/(n-1)*(pairs[i].ssq[j] / n -
1582 pow2(pairs[i].mean[j]))
1586 pairs[i].correlation = pairs[i].sum_of_prod / pairs[i].n -
1587 pairs[i].mean[0] * pairs[i].mean[1] ;
1588 /* correlation now actually contains the covariance */
1590 pairs[i].correlation /= pairs[i].std_dev[0] * pairs[i].std_dev[1];
1591 pairs[i].correlation *= pairs[i].n / ( pairs[i].n - 1 );
1593 pairs[i].mean_diff = pairs[i].sum_of_diffs / n ;
1595 pairs[i].std_dev_diff = sqrt ( n / (n - 1) * (
1596 ( pairs[i].ssq_diffs / n )
1598 pow2(pairs[i].mean_diff )
1603 /* Return the group # corresponding to the
1604 independent variable with the value val
1607 get_group(const union value *val, struct variable *indep)
1611 for (i = 0; i < 2 ; ++i )
1613 const int cmp = compare_values(val,&groups_values[i],indep->width) ;
1614 switch ( criteria[i])
1617 if ( 0 == cmp ) return i;
1620 if ( 0 > cmp ) return i;
1623 if ( cmp <= 0 ) return i;
1626 if ( cmp > 0 ) return i;
1629 if ( cmp >= 0 ) return i;
1636 /* No groups matched */
1642 group_precalc (struct cmd_t_test *cmd )
1647 for(i=0; i< cmd->n_variables ; ++i)
1649 struct t_test_proc *ttpr = &cmd->v_variables[i]->p.t_t;
1651 /* There's always 2 groups for a T - TEST */
1653 ttpr->gs = xmalloc(sizeof(struct group_statistics) * 2) ;
1655 for (j=0 ; j < 2 ; ++j)
1657 ttpr->gs[j].sum = 0;
1659 ttpr->gs[j].ssq = 0;
1661 if ( n_group_values == 2 )
1662 ttpr->gs[j].id = groups_values[j];
1664 ttpr->gs[j].id = groups_values[0];
1665 ttpr->gs[j].criterion = criteria[j];
1672 group_calc (const struct ccase *c, struct cmd_t_test *cmd)
1677 const union value *gv = &c->data[indep_var->fv];
1679 const double weight = dict_get_case_weight(default_dict,c);
1681 if ( value_is_missing(gv,indep_var) )
1686 if ( cmd->miss == TTS_LISTWISE )
1688 for(i=0; i< cmd->n_variables ; ++i)
1690 struct variable *v = cmd->v_variables[i];
1691 const union value *val = &c->data[v->fv];
1693 if (value_is_missing(val,v) )
1701 gv = &c->data[indep_var->fv];
1703 g = get_group(gv,indep_var);
1706 /* If the independent variable doesn't match either of the values
1707 for this case then move on to the next case */
1711 for(i=0; i< cmd->n_variables ; ++i)
1713 struct variable *var = cmd->v_variables[i];
1715 struct group_statistics *gs = &var->p.t_t.gs[g];
1717 const union value *val=&c->data[var->fv];
1719 if ( !value_is_missing(val,var) )
1722 gs->sum+=weight * val->f;
1723 gs->ssq+=weight * pow2(val->f);
1732 group_postcalc ( struct cmd_t_test *cmd )
1737 for(i=0; i< cmd->n_variables ; ++i)
1739 for (j=0 ; j < 2 ; ++j)
1741 struct group_statistics *gs;
1742 gs=&cmd->v_variables[i]->p.t_t.gs[j];
1744 gs->mean = gs->sum / gs->n;
1746 gs->s_std_dev= sqrt(
1747 ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
1752 ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
1755 gs->se_mean = gs->std_dev / sqrt(gs->n);
1763 calculate(const struct casefile *cf, void *cmd_)
1765 struct ssbox stat_summary_box;
1766 struct trbox test_results_box;
1768 struct casereader *r;
1769 const struct ccase *c;
1771 struct cmd_t_test *cmd = (struct cmd_t_test *) cmd_;
1773 common_precalc(cmd);
1774 for(r = casefile_get_reader (cf);
1775 casereader_read (r, &c) ; )
1779 casereader_destroy (r);
1780 common_postcalc(cmd);
1785 one_sample_precalc(cmd);
1786 for(r = casefile_get_reader (cf);
1787 casereader_read (r, &c) ; )
1789 one_sample_calc(c,cmd);
1791 casereader_destroy (r);
1792 one_sample_postcalc(cmd);
1796 paired_precalc(cmd);
1797 for(r = casefile_get_reader (cf);
1798 casereader_read (r, &c) ; )
1802 casereader_destroy (r);
1803 paired_postcalc(cmd);
1809 for(r = casefile_get_reader (cf);
1810 casereader_read (r, &c) ; )
1814 casereader_destroy (r);
1815 group_postcalc(cmd);
1818 levene(cf, indep_var, cmd->n_variables, cmd->v_variables,
1819 (cmd->miss == TTS_LISTWISE)?LEV_LISTWISE:LEV_ANALYSIS ,
1824 ssbox_create(&stat_summary_box,cmd,mode);
1825 ssbox_populate(&stat_summary_box,cmd);
1826 ssbox_finalize(&stat_summary_box);
1828 if ( mode == T_PAIRED)
1831 trbox_create(&test_results_box,cmd,mode);
1832 trbox_populate(&test_results_box,cmd);
1833 trbox_finalize(&test_results_box);