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>
38 #include "value-labels.h"
50 variables=varlist("PV_NO_SCRATCH | PV_NUMERIC");
52 +missing=miss:!analysis/listwise,
53 incl:include/!exclude;
54 format=fmt:!labels/nolabels;
55 criteria=:cin(d:criteria,"%s > 0. && %s < 1.").
63 /* Function to use for testing for missing values */
64 static is_missing_func value_is_missing;
66 /* Variable for the GROUPS subcommand, if given. */
67 static struct variable *indep_var;
69 /* GROUPS: Number of values specified by the user; the values
72 static int n_group_values;
73 static union value groups_values[2];
74 static enum comparison criteria[2];
78 /* PAIRS: Number of pairs to be compared ; each pair. */
79 static int n_pairs = 0 ;
82 /* The variables comprising the pair */
83 struct variable *v[2];
85 /* The number of valid variable pairs */
88 /* The sum of the members */
91 /* sum of squares of the members */
94 /* Std deviation of the members */
98 /* Sample Std deviation of the members */
101 /* The means of the members */
104 /* The correlation coefficient between the variables */
107 /* The sum of the differences */
110 /* The sum of the products */
113 /* The mean of the differences */
116 /* The sum of the squares of the differences */
119 /* The std deviation of the differences */
123 static struct pair *pairs=0;
125 static int parse_value (union value * v, int type) ;
127 /* Structures and Functions for the Statistics Summary Box */
129 typedef void populate_ssbox_func(struct ssbox *ssb,
130 struct cmd_t_test *cmd);
131 typedef void finalize_ssbox_func(struct ssbox *ssb);
137 populate_ssbox_func *populate;
138 finalize_ssbox_func *finalize;
143 void ssbox_create(struct ssbox *ssb, struct cmd_t_test *cmd, int mode);
145 /* Populate a ssbox according to cmd */
146 void ssbox_populate(struct ssbox *ssb, struct cmd_t_test *cmd);
148 /* Submit and destroy a ssbox */
149 void ssbox_finalize(struct ssbox *ssb);
151 /* A function to create, populate and submit the Paired Samples Correlation
156 /* Structures and Functions for the Test Results Box */
159 typedef void populate_trbox_func(struct trbox *trb,
160 struct cmd_t_test *cmd);
161 typedef void finalize_trbox_func(struct trbox *trb);
165 populate_trbox_func *populate;
166 finalize_trbox_func *finalize;
170 void trbox_create(struct trbox *trb, struct cmd_t_test *cmd, int mode);
172 /* Populate a ssbox according to cmd */
173 void trbox_populate(struct trbox *trb, struct cmd_t_test *cmd);
175 /* Submit and destroy a ssbox */
176 void trbox_finalize(struct trbox *trb);
178 /* Which mode was T-TEST invoked */
186 static int common_calc (const struct ccase *, void *);
187 static void common_precalc (struct cmd_t_test *);
188 static void common_postcalc (struct cmd_t_test *);
190 static int one_sample_calc (const struct ccase *, void *);
191 static void one_sample_precalc (struct cmd_t_test *);
192 static void one_sample_postcalc (struct cmd_t_test *);
194 static int paired_calc (const struct ccase *, void *);
195 static void paired_precalc (struct cmd_t_test *);
196 static void paired_postcalc (struct cmd_t_test *);
198 static void group_precalc (struct cmd_t_test *);
199 static int group_calc (const struct ccase *, struct cmd_t_test *);
200 static void group_postcalc (struct cmd_t_test *);
203 static int compare_var_name (const void *a_, const void *b_, void *v_ UNUSED);
204 static unsigned hash_var_name (const void *a_, void *v_ UNUSED);
206 static void calculate(const struct casefile *cf, void *_mode);
210 static struct cmd_t_test cmd;
212 static int bad_weight_warn;
220 if ( !parse_t_test(&cmd) )
223 if (! cmd.sbc_criteria)
228 if (cmd.sbc_testval) ++m;
229 if (cmd.sbc_groups) ++m;
230 if (cmd.sbc_pairs) ++m;
235 _("TESTVAL, GROUPS and PAIRS subcommands are mutually exclusive.")
243 else if (cmd.sbc_groups)
248 if ( mode == T_PAIRED)
250 if (cmd.sbc_variables)
252 msg(SE, _("VARIABLES subcommand is not appropriate with PAIRS"));
257 /* Iterate through the pairs and put each variable that is a
258 member of a pair into cmd.v_variables */
261 struct hsh_iterator hi;
262 struct hsh_table *hash;
265 hash=hsh_create(n_pairs,compare_var_name,hash_var_name,0,0);
267 for (i=0; i < n_pairs; ++i)
269 hsh_insert(hash,pairs[i].v[0]);
270 hsh_insert(hash,pairs[i].v[1]);
273 assert(cmd.n_variables == 0);
274 cmd.n_variables = hsh_count(hash);
276 cmd.v_variables = xrealloc(cmd.v_variables,
277 sizeof(struct variable) * cmd.n_variables);
278 /* Iterate through the hash */
279 for (i=0,v = (struct variable *) hsh_first(hash,&hi);
281 v=hsh_next(hash,&hi) )
282 cmd.v_variables[i++]=v;
287 else if ( !cmd.sbc_variables)
289 msg(SE, _("One or more VARIABLES must be specified."));
294 /* If /MISSING=INCLUDE is set, then user missing values are ignored */
295 if (cmd.incl == TTS_INCLUDE )
296 value_is_missing = is_system_missing;
298 value_is_missing = is_missing;
302 multipass_procedure_with_splits (calculate, &cmd);
308 if ( mode == T_IND_SAMPLES)
311 /* Destroy any group statistics we created */
312 for (i= 0 ; i < cmd.n_variables ; ++i )
314 free(cmd.v_variables[i]->p.t_t.gs);
322 tts_custom_groups (struct cmd_t_test *cmd UNUSED)
327 if (token != T_ALL &&
328 (token != T_ID || dict_lookup_var (default_dict, tokid) == NULL)
331 msg(SE,_("`%s' is not a variable name"),tokid);
335 indep_var = parse_variable ();
338 lex_error ("expecting variable name in GROUPS subcommand");
342 if (indep_var->type == T_STRING && indep_var->width > MAX_SHORT_STRING)
344 msg (SE, _("Long string variable %s is not valid here."),
349 if (!lex_match ('('))
351 if (indep_var->type == NUMERIC)
353 groups_values[0].f = 1;
354 groups_values[1].f = 2;
355 criteria[0] = criteria[1] = CMP_EQ;
361 msg (SE, _("When applying GROUPS to a string variable, at "
362 "least one value must be specified."));
367 if (!parse_value (&groups_values[0],indep_var->type))
373 criteria[0] = CMP_LE;
374 criteria[1] = CMP_GT;
375 groups_values[1] = groups_values[0];
380 if (!parse_value (&groups_values[1],indep_var->type))
384 if (!lex_force_match (')'))
387 criteria[0] = criteria[1] = CMP_EQ;
393 tts_custom_pairs (struct cmd_t_test *cmd UNUSED)
395 struct variable **vars;
400 int n_after_WITH = -1;
401 int paired ; /* Was the PAIRED keyword given ? */
405 if ((token != T_ID || dict_lookup_var (default_dict, tokid) == NULL)
408 msg(SE,_("`%s' is not a variable name"),tokid);
413 if (!parse_variables (default_dict, &vars, &n_vars,
414 PV_DUPLICATE | PV_NUMERIC | PV_NO_SCRATCH))
422 if (lex_match (T_WITH))
424 n_before_WITH = n_vars;
425 if (!parse_variables (default_dict, &vars, &n_vars,
426 PV_DUPLICATE | PV_APPEND
427 | PV_NUMERIC | PV_NO_SCRATCH))
432 n_after_WITH = n_vars - n_before_WITH;
435 paired = (lex_match ('(') && lex_match_id ("PAIRED") && lex_match (')'));
437 /* Determine the number of pairs needed */
440 if (n_before_WITH != n_after_WITH)
443 msg (SE, _("PAIRED was specified but the number of variables "
444 "preceding WITH (%d) did not match the number "
446 n_before_WITH, n_after_WITH );
449 n_pairs_local=n_before_WITH;
451 else if (n_before_WITH > 0) /* WITH keyword given, but not PAIRED keyword */
453 n_pairs_local=n_before_WITH * n_after_WITH ;
455 else /* Neither WITH nor PAIRED keyword given */
460 msg (SE, _("At least two variables must be specified "
465 /* how many ways can you pick 2 from n_vars ? */
466 n_pairs_local = n_vars * (n_vars -1 ) /2 ;
470 /* Allocate storage for the pairs */
471 pairs = xrealloc(pairs, sizeof(struct pair) * (n_pairs + n_pairs_local) );
473 /* Populate the pairs with the appropriate variables */
478 assert(n_pairs_local == n_vars/2);
479 for (i = 0; i < n_pairs_local ; ++i)
481 pairs[i].v[n_pairs+0] = vars[i];
482 pairs[i].v[n_pairs+1] = vars[i+n_pairs_local];
485 else if (n_before_WITH > 0) /* WITH keyword given, but not PAIRED keyword */
490 for(i=0 ; i < n_before_WITH ; ++i )
492 for(j=0 ; j < n_after_WITH ; ++j)
494 pairs[p].v[0] = vars[i];
495 pairs[p].v[1] = vars[j+n_before_WITH];
500 else /* Neither WITH nor PAIRED given */
505 for(i=0 ; i < n_vars ; ++i )
507 for(j=i+1 ; j < n_vars ; ++j)
509 pairs[p].v[0] = vars[i];
510 pairs[p].v[1] = vars[j];
516 n_pairs+=n_pairs_local;
522 /* Parses the current token (numeric or string, depending on type)
523 value v and returns success. */
525 parse_value (union value * v, int type )
529 if (!lex_force_num ())
535 if (!lex_force_string ())
537 strncpy (v->s, ds_c_str (&tokstr), ds_length (&tokstr));
546 /* Implementation of the SSBOX object */
548 void ssbox_base_init(struct ssbox *this, int cols,int rows);
550 void ssbox_base_finalize(struct ssbox *ssb);
552 void ssbox_one_sample_init(struct ssbox *this,
553 struct cmd_t_test *cmd );
555 void ssbox_independent_samples_init(struct ssbox *this,
556 struct cmd_t_test *cmd);
558 void ssbox_paired_init(struct ssbox *this,
559 struct cmd_t_test *cmd);
561 /* Factory to create an ssbox */
563 ssbox_create(struct ssbox *ssb, struct cmd_t_test *cmd, int mode)
568 ssbox_one_sample_init(ssb,cmd);
571 ssbox_independent_samples_init(ssb,cmd);
574 ssbox_paired_init(ssb,cmd);
582 /* Despatcher for the populate method */
584 ssbox_populate(struct ssbox *ssb,struct cmd_t_test *cmd)
586 ssb->populate(ssb,cmd);
590 /* Despatcher for finalize */
592 ssbox_finalize(struct ssbox *ssb)
598 /* Submit the box and clear up */
600 ssbox_base_finalize(struct ssbox *ssb)
605 /* Initialize a ssbox struct */
607 ssbox_base_init(struct ssbox *this, int cols,int rows)
609 this->finalize = ssbox_base_finalize;
610 this->t = tab_create (cols, rows, 0);
612 tab_columns (this->t, SOM_COL_DOWN, 1);
613 tab_headers (this->t,0,0,1,0);
614 tab_box (this->t, TAL_2, TAL_2, TAL_0, TAL_1, 0, 0, cols -1, rows -1 );
615 tab_hline(this->t, TAL_2,0,cols-1,1);
616 tab_dim (this->t, tab_natural_dimensions);
619 void ssbox_one_sample_populate(struct ssbox *ssb,
620 struct cmd_t_test *cmd);
622 /* Initialize the one_sample ssbox */
624 ssbox_one_sample_init(struct ssbox *this,
625 struct cmd_t_test *cmd )
628 const int vsize=cmd->n_variables+1;
630 this->populate = ssbox_one_sample_populate;
632 ssbox_base_init(this, hsize,vsize);
633 tab_title (this->t, 0, _("One-Sample Statistics"));
634 tab_vline(this->t, TAL_2, 1,0,vsize - 1);
635 tab_text (this->t, 1, 0, TAB_CENTER | TAT_TITLE, _("N"));
636 tab_text (this->t, 2, 0, TAB_CENTER | TAT_TITLE, _("Mean"));
637 tab_text (this->t, 3, 0, TAB_CENTER | TAT_TITLE, _("Std. Deviation"));
638 tab_text (this->t, 4, 0, TAB_CENTER | TAT_TITLE, _("SE. Mean"));
641 void ssbox_independent_samples_populate(struct ssbox *ssb,
642 struct cmd_t_test *cmd);
644 /* Initialize the independent samples ssbox */
646 ssbox_independent_samples_init(struct ssbox *this,
647 struct cmd_t_test *cmd)
650 int vsize = cmd->n_variables*2 +1;
652 this->populate = ssbox_independent_samples_populate;
654 ssbox_base_init(this, hsize,vsize);
655 tab_title (this->t, 0, _("Group Statistics"));
656 tab_vline(this->t,0,1,0,vsize - 1);
657 tab_text (this->t, 1, 0, TAB_CENTER | TAT_TITLE, indep_var->name);
658 tab_text (this->t, 2, 0, TAB_CENTER | TAT_TITLE, _("N"));
659 tab_text (this->t, 3, 0, TAB_CENTER | TAT_TITLE, _("Mean"));
660 tab_text (this->t, 4, 0, TAB_CENTER | TAT_TITLE, _("Std. Deviation"));
661 tab_text (this->t, 5, 0, TAB_CENTER | TAT_TITLE, _("SE. Mean"));
665 /* Populate the ssbox for independent samples */
667 ssbox_independent_samples_populate(struct ssbox *ssb,
668 struct cmd_t_test *cmd)
675 char prefix[2][3]={"",""};
677 if ( indep_var->type == NUMERIC )
679 val_lab0 = val_labs_find( indep_var->val_labs,groups_values[0]);
680 val_lab1 = val_labs_find( indep_var->val_labs,groups_values[1]);
684 val_lab0 = groups_values[0].s;
685 val_lab1 = groups_values[1].s;
688 if (n_group_values == 1)
690 strcpy(prefix[0],"< ");
691 strcpy(prefix[1],">=");
696 for (i=0; i < cmd->n_variables; ++i)
700 tab_text (ssb->t, 0, i*2+1, TAB_LEFT, cmd->v_variables[i]->name);
703 tab_text (ssb->t, 1, i*2+1, TAB_LEFT | TAT_PRINTF,
704 "%s%s", prefix[0], val_lab0);
706 tab_text (ssb->t, 1, i*2+1, TAB_LEFT | TAT_PRINTF,
707 "%s%g", prefix[0], groups_values[0].f);
711 tab_text (ssb->t, 1, i*2+1+1, TAB_LEFT | TAT_PRINTF,
712 "%s%s", prefix[1], val_lab1);
714 tab_text (ssb->t, 1, i*2+1+1, TAB_LEFT | TAT_PRINTF,
715 "%s%g", prefix[1], groups_values[1].f);
717 /* Fill in the group statistics */
718 for ( g=0; g < 2 ; ++g )
720 struct group_statistics *gs = &cmd->v_variables[i]->p.t_t.gs[g];
722 tab_float(ssb->t, 2 ,i*2+g+1, TAB_RIGHT, gs->n, 2, 0);
723 tab_float(ssb->t, 3 ,i*2+g+1, TAB_RIGHT, gs->mean, 8, 2);
724 tab_float(ssb->t, 4 ,i*2+g+1, TAB_RIGHT, gs->std_dev, 8, 3);
725 tab_float(ssb->t, 5 ,i*2+g+1, TAB_RIGHT, gs->se_mean, 8, 3);
731 void ssbox_paired_populate(struct ssbox *ssb,
732 struct cmd_t_test *cmd);
734 /* Initialize the paired values ssbox */
736 ssbox_paired_init(struct ssbox *this, struct cmd_t_test *cmd UNUSED)
740 int vsize = n_pairs*2+1;
742 this->populate = ssbox_paired_populate;
744 ssbox_base_init(this, hsize,vsize);
745 tab_title (this->t, 0, _("Paired Sample Statistics"));
746 tab_vline(this->t,TAL_0,1,0,vsize-1);
747 tab_vline(this->t,TAL_2,2,0,vsize-1);
748 tab_text (this->t, 2, 0, TAB_CENTER | TAT_TITLE, _("Mean"));
749 tab_text (this->t, 3, 0, TAB_CENTER | TAT_TITLE, _("N"));
750 tab_text (this->t, 4, 0, TAB_CENTER | TAT_TITLE, _("Std. Deviation"));
751 tab_text (this->t, 5, 0, TAB_CENTER | TAT_TITLE, _("SE. Mean"));
755 /* Populate the ssbox for paired values */
757 ssbox_paired_populate(struct ssbox *ssb,struct cmd_t_test *cmd UNUSED)
763 for (i=0; i < n_pairs; ++i)
767 tab_text (ssb->t, 0, i*2+1, TAB_LEFT | TAT_PRINTF , _("Pair %d"),i);
769 for (j=0 ; j < 2 ; ++j)
771 struct group_statistics *gs;
773 gs=&pairs[i].v[j]->p.t_t.ugs;
777 tab_text (ssb->t, 1, i*2+j+1, TAB_LEFT, pairs[i].v[j]->name);
780 tab_float (ssb->t,2, i*2+j+1, TAB_RIGHT, pairs[i].mean[j], 8, 2);
781 tab_float (ssb->t,3, i*2+j+1, TAB_RIGHT, pairs[i].n, 2, 0);
782 tab_float (ssb->t,4, i*2+j+1, TAB_RIGHT, pairs[i].std_dev[j], 8, 3);
783 tab_float (ssb->t,5, i*2+j+1, TAB_RIGHT, pairs[i].std_dev[j]/sqrt(pairs[i].n), 8, 3);
789 /* Populate the one sample ssbox */
791 ssbox_one_sample_populate(struct ssbox *ssb, struct cmd_t_test *cmd)
797 for (i=0; i < cmd->n_variables; ++i)
799 struct group_statistics *gs;
800 gs= &cmd->v_variables[i]->p.t_t.ugs;
802 tab_text (ssb->t, 0, i+1, TAB_LEFT, cmd->v_variables[i]->name);
803 tab_float (ssb->t,1, i+1, TAB_RIGHT, gs->n, 2, 0);
804 tab_float (ssb->t,2, i+1, TAB_RIGHT, gs->mean, 8, 2);
805 tab_float (ssb->t,3, i+1, TAB_RIGHT, gs->std_dev, 8, 2);
806 tab_float (ssb->t,4, i+1, TAB_RIGHT, gs->se_mean, 8, 3);
813 /* Implementation of the Test Results box struct */
815 void trbox_base_init(struct trbox *self,int n_vars, int cols);
816 void trbox_base_finalize(struct trbox *trb);
818 void trbox_independent_samples_init(struct trbox *trb,
819 struct cmd_t_test *cmd );
821 void trbox_independent_samples_populate(struct trbox *trb,
822 struct cmd_t_test *cmd);
824 void trbox_one_sample_init(struct trbox *self,
825 struct cmd_t_test *cmd );
827 void trbox_one_sample_populate(struct trbox *trb,
828 struct cmd_t_test *cmd);
830 void trbox_paired_init(struct trbox *self,
831 struct cmd_t_test *cmd );
833 void trbox_paired_populate(struct trbox *trb,
834 struct cmd_t_test *cmd);
838 /* Create a trbox according to mode*/
840 trbox_create(struct trbox *trb,
841 struct cmd_t_test *cmd, int mode)
846 trbox_one_sample_init(trb,cmd);
849 trbox_independent_samples_init(trb,cmd);
852 trbox_paired_init(trb,cmd);
859 /* Populate a trbox according to cmd */
861 trbox_populate(struct trbox *trb, struct cmd_t_test *cmd)
863 trb->populate(trb,cmd);
866 /* Submit and destroy a trbox */
868 trbox_finalize(struct trbox *trb)
873 /* Initialize the independent samples trbox */
875 trbox_independent_samples_init(struct trbox *self,
876 struct cmd_t_test *cmd UNUSED)
879 const int vsize=cmd->n_variables*2+3;
882 self->populate = trbox_independent_samples_populate;
884 trbox_base_init(self,cmd->n_variables*2,hsize);
885 tab_title(self->t,0,_("Independent Samples Test"));
886 tab_hline(self->t,TAL_1,2,hsize-1,1);
887 tab_vline(self->t,TAL_2,2,0,vsize-1);
888 tab_vline(self->t,TAL_1,4,0,vsize-1);
889 tab_box(self->t,-1,-1,-1,TAL_1, 2,1,hsize-2,vsize-1);
890 tab_hline(self->t,TAL_1, hsize-2,hsize-1,2);
891 tab_box(self->t,-1,-1,-1,TAL_1, hsize-2,2,hsize-1,vsize-1);
892 tab_joint_text(self->t, 2, 0, 3, 0,
893 TAB_CENTER,_("Levene's Test for Equality of Variances"));
894 tab_joint_text(self->t, 4,0,hsize-1,0,
895 TAB_CENTER,_("t-test for Equality of Means"));
897 tab_text(self->t,2,2, TAB_CENTER | TAT_TITLE,_("F"));
898 tab_text(self->t,3,2, TAB_CENTER | TAT_TITLE,_("Sig."));
899 tab_text(self->t,4,2, TAB_CENTER | TAT_TITLE,_("t"));
900 tab_text(self->t,5,2, TAB_CENTER | TAT_TITLE,_("df"));
901 tab_text(self->t,6,2, TAB_CENTER | TAT_TITLE,_("Sig. (2-tailed)"));
902 tab_text(self->t,7,2, TAB_CENTER | TAT_TITLE,_("Mean Difference"));
903 tab_text(self->t,8,2, TAB_CENTER | TAT_TITLE,_("Std. Error Difference"));
904 tab_text(self->t,9,2, TAB_CENTER | TAT_TITLE,_("Lower"));
905 tab_text(self->t,10,2, TAB_CENTER | TAT_TITLE,_("Upper"));
907 tab_joint_text(self->t, 9, 1, 10, 1, TAB_CENTER | TAT_PRINTF,
908 _("%g%% Confidence Interval of the Difference"),
909 cmd->criteria*100.0);
913 /* Populate the independent samples trbox */
915 trbox_independent_samples_populate(struct trbox *self,
916 struct cmd_t_test *cmd )
921 for (i=0; i < cmd->n_variables; ++i)
930 double pooled_variance;
934 struct group_statistics *gs0 = &cmd->v_variables[i]->p.t_t.gs[0];
935 struct group_statistics *gs1 = &cmd->v_variables[i]->p.t_t.gs[1];
937 tab_text (self->t, 0, i*2+3, TAB_LEFT, cmd->v_variables[i]->name);
939 tab_text (self->t, 1, i*2+3, TAB_LEFT, _("Equal variances assumed"));
942 tab_float(self->t, 2, i*2+3, TAB_CENTER,
943 cmd->v_variables[i]->p.t_t.levene, 8,3);
945 /* Now work out the significance of the Levene test */
946 df1 = 1; df2 = cmd->v_variables[i]->p.t_t.ugs.n - 2;
947 q = gsl_cdf_fdist_Q(cmd->v_variables[i]->p.t_t.levene, df1, df2);
949 tab_float(self->t, 3, i*2+3, TAB_CENTER, q, 8,3 );
951 df = gs0->n + gs1->n - 2.0 ;
952 tab_float (self->t, 5, i*2+3, TAB_RIGHT, df, 2, 0);
954 pooled_variance = ( (gs0->n )*pow2(gs0->s_std_dev)
956 (gs1->n )*pow2(gs1->s_std_dev)
959 t = (gs0->mean - gs1->mean) / sqrt(pooled_variance) ;
960 t /= sqrt((gs0->n + gs1->n)/(gs0->n*gs1->n));
962 tab_float (self->t, 4, i*2+3, TAB_RIGHT, t, 8, 3);
964 p = gsl_cdf_tdist_P(t, df);
965 q = gsl_cdf_tdist_Q(t, df);
967 tab_float(self->t, 6, i*2+3, TAB_RIGHT, 2.0*(t>0?q:p) , 8, 3);
969 mean_diff = gs0->mean - gs1->mean;
970 tab_float(self->t, 7, i*2+3, TAB_RIGHT, mean_diff, 8, 3);
973 std_err_diff = sqrt( pow2(gs0->se_mean) + pow2(gs1->se_mean));
974 tab_float(self->t, 8, i*2+3, TAB_RIGHT, std_err_diff, 8, 3);
977 /* Now work out the confidence interval */
978 q = (1 - cmd->criteria)/2.0; /* 2-tailed test */
980 t = gsl_cdf_tdist_Qinv(q,df);
981 tab_float(self->t, 9, i*2+3, TAB_RIGHT,
982 mean_diff - t * std_err_diff, 8, 3);
984 tab_float(self->t, 10, i*2+3, TAB_RIGHT,
985 mean_diff + t * std_err_diff, 8, 3);
990 /* Now for the \sigma_1 != \sigma_2 case */
991 tab_text (self->t, 1, i*2+3+1,
992 TAB_LEFT, _("Equal variances not assumed"));
995 se2 = (pow2(gs0->s_std_dev)/(gs0->n -1) ) +
996 (pow2(gs1->s_std_dev)/(gs1->n -1) );
998 t = mean_diff / sqrt(se2) ;
999 tab_float (self->t, 4, i*2+3+1, TAB_RIGHT, t, 8, 3);
1002 (pow2(pow2(gs0->s_std_dev)/(gs0->n - 1 ))
1006 (pow2(pow2(gs1->s_std_dev)/(gs1->n - 1 ))
1010 tab_float (self->t, 5, i*2+3+1, TAB_RIGHT, df, 8, 3);
1012 p = gsl_cdf_tdist_P(t, df);
1013 q = gsl_cdf_tdist_Q(t, df);
1015 tab_float(self->t, 6, i*2+3+1, TAB_RIGHT, 2.0*(t>0?q:p) , 8, 3);
1017 /* Now work out the confidence interval */
1018 q = (1 - cmd->criteria)/2.0; /* 2-tailed test */
1020 t = gsl_cdf_tdist_Qinv(q, df);
1022 tab_float(self->t, 7, i*2+3+1, TAB_RIGHT, mean_diff, 8, 3);
1025 tab_float(self->t, 8, i*2+3+1, TAB_RIGHT, std_err_diff, 8, 3);
1028 tab_float(self->t, 9, i*2+3+1, TAB_RIGHT,
1029 mean_diff - t * std_err_diff, 8, 3);
1031 tab_float(self->t, 10, i*2+3+1, TAB_RIGHT,
1032 mean_diff + t * std_err_diff, 8, 3);
1038 /* Initialize the paired samples trbox */
1040 trbox_paired_init(struct trbox *self,
1041 struct cmd_t_test *cmd UNUSED)
1045 const int vsize=n_pairs+3;
1047 self->populate = trbox_paired_populate;
1049 trbox_base_init(self,n_pairs,hsize);
1050 tab_title (self->t, 0, _("Paired Samples Test"));
1051 tab_hline(self->t,TAL_1,2,6,1);
1052 tab_vline(self->t,TAL_2,2,0,vsize - 1);
1053 tab_joint_text(self->t,2,0,6,0,TAB_CENTER,_("Paired Differences"));
1054 tab_box(self->t,-1,-1,-1,TAL_1, 2,1,6,vsize-1);
1055 tab_box(self->t,-1,-1,-1,TAL_1, 6,0,hsize-1,vsize-1);
1056 tab_hline(self->t,TAL_1,5,6, 2);
1057 tab_vline(self->t,TAL_0,6,0,1);
1059 tab_joint_text(self->t, 5, 1, 6, 1, TAB_CENTER | TAT_PRINTF,
1060 _("%g%% Confidence Interval of the Difference"),
1061 cmd->criteria*100.0);
1063 tab_text (self->t, 2, 2, TAB_CENTER | TAT_TITLE, _("Mean"));
1064 tab_text (self->t, 3, 2, TAB_CENTER | TAT_TITLE, _("Std. Deviation"));
1065 tab_text (self->t, 4, 2, TAB_CENTER | TAT_TITLE, _("Std. Error Mean"));
1066 tab_text (self->t, 5, 2, TAB_CENTER | TAT_TITLE, _("Lower"));
1067 tab_text (self->t, 6, 2, TAB_CENTER | TAT_TITLE, _("Upper"));
1068 tab_text (self->t, 7, 2, TAB_CENTER | TAT_TITLE, _("t"));
1069 tab_text (self->t, 8, 2, TAB_CENTER | TAT_TITLE, _("df"));
1070 tab_text (self->t, 9, 2, TAB_CENTER | TAT_TITLE, _("Sig. (2-tailed)"));
1073 /* Populate the paired samples trbox */
1075 trbox_paired_populate(struct trbox *trb,
1076 struct cmd_t_test *cmd UNUSED)
1080 for (i=0; i < n_pairs; ++i)
1085 double n = pairs[i].n;
1089 tab_text (trb->t, 0, i+3, TAB_LEFT | TAT_PRINTF, _("Pair %d"),i);
1091 tab_text (trb->t, 1, i+3, TAB_LEFT | TAT_PRINTF, "%s - %s",
1092 pairs[i].v[0]->name, pairs[i].v[1]->name);
1094 tab_float(trb->t, 2, i+3, TAB_RIGHT, pairs[i].mean_diff, 8, 4);
1096 tab_float(trb->t, 3, i+3, TAB_RIGHT, pairs[i].std_dev_diff, 8, 5);
1099 se_mean = pairs[i].std_dev_diff / sqrt(n) ;
1100 tab_float(trb->t, 4, i+3, TAB_RIGHT, se_mean, 8,5 );
1102 /* Now work out the confidence interval */
1103 q = (1 - cmd->criteria)/2.0; /* 2-tailed test */
1105 t = gsl_cdf_tdist_Qinv(q, df);
1107 tab_float(trb->t, 5, i+3, TAB_RIGHT,
1108 pairs[i].mean_diff - t * se_mean , 8, 4);
1110 tab_float(trb->t, 6, i+3, TAB_RIGHT,
1111 pairs[i].mean_diff + t * se_mean , 8, 4);
1113 t = (pairs[i].mean[0] - pairs[i].mean[1])
1115 ( pow2 (pairs[i].s_std_dev[0]) + pow2 (pairs[i].s_std_dev[1]) -
1116 2 * pairs[i].correlation *
1117 pairs[i].s_std_dev[0] * pairs[i].s_std_dev[1] )
1121 tab_float(trb->t, 7, i+3, TAB_RIGHT, t , 8,3 );
1123 /* Degrees of freedom */
1124 tab_float(trb->t, 8, i+3, TAB_RIGHT, df , 2, 0 );
1126 p = gsl_cdf_tdist_P(t,df);
1127 q = gsl_cdf_tdist_P(t,df);
1129 tab_float(trb->t, 9, i+3, TAB_RIGHT, 2.0*(t>0?q:p) , 8, 3);
1134 /* Initialize the one sample trbox */
1136 trbox_one_sample_init(struct trbox *self, struct cmd_t_test *cmd )
1139 const int vsize=cmd->n_variables+3;
1141 self->populate = trbox_one_sample_populate;
1143 trbox_base_init(self, cmd->n_variables,hsize);
1144 tab_title (self->t, 0, _("One-Sample Test"));
1145 tab_hline(self->t, TAL_1, 1, hsize - 1, 1);
1146 tab_vline(self->t, TAL_2, 1, 0, vsize - 1);
1148 tab_joint_text(self->t, 1, 0, hsize-1,0, TAB_CENTER | TAT_PRINTF,
1149 _("Test Value = %f"),cmd->n_testval);
1151 tab_box(self->t, -1, -1, -1, TAL_1, 1,1,hsize-1,vsize-1);
1154 tab_joint_text(self->t,5,1,6,1,TAB_CENTER | TAT_PRINTF,
1155 _("%g%% Confidence Interval of the Difference"),
1156 cmd->criteria*100.0);
1158 tab_vline(self->t,TAL_0,6,1,1);
1159 tab_hline(self->t,TAL_1,5,6,2);
1160 tab_text (self->t, 1, 2, TAB_CENTER | TAT_TITLE, _("t"));
1161 tab_text (self->t, 2, 2, TAB_CENTER | TAT_TITLE, _("df"));
1162 tab_text (self->t, 3, 2, TAB_CENTER | TAT_TITLE, _("Sig. (2-tailed)"));
1163 tab_text (self->t, 4, 2, TAB_CENTER | TAT_TITLE, _("Mean Difference"));
1164 tab_text (self->t, 5, 2, TAB_CENTER | TAT_TITLE, _("Lower"));
1165 tab_text (self->t, 6, 2, TAB_CENTER | TAT_TITLE, _("Upper"));
1170 /* Populate the one sample trbox */
1172 trbox_one_sample_populate(struct trbox *trb, struct cmd_t_test *cmd)
1178 for (i=0; i < cmd->n_variables; ++i)
1183 struct group_statistics *gs;
1184 gs= &cmd->v_variables[i]->p.t_t.ugs;
1187 tab_text (trb->t, 0, i+3, TAB_LEFT, cmd->v_variables[i]->name);
1189 t = (gs->mean - cmd->n_testval ) * sqrt(gs->n) / gs->std_dev ;
1191 tab_float (trb->t, 1, i+3, TAB_RIGHT, t, 8,3);
1193 /* degrees of freedom */
1196 tab_float (trb->t, 2, i+3, TAB_RIGHT, df, 8,0);
1198 p = gsl_cdf_tdist_P(t, df);
1199 q = gsl_cdf_tdist_Q(t, df);
1201 /* Multiply by 2 to get 2-tailed significance, makeing sure we've got
1203 tab_float (trb->t, 3, i+3, TAB_RIGHT, 2.0*(t>0?q:p), 8,3);
1205 tab_float (trb->t, 4, i+3, TAB_RIGHT, gs->mean_diff, 8,3);
1208 q = (1 - cmd->criteria)/2.0; /* 2-tailed test */
1209 t = gsl_cdf_tdist_Qinv(q, df);
1211 tab_float (trb->t, 5, i+3, TAB_RIGHT,
1212 gs->mean_diff - t * gs->se_mean, 8,4);
1214 tab_float (trb->t, 6, i+3, TAB_RIGHT,
1215 gs->mean_diff + t * gs->se_mean, 8,4);
1219 /* Base initializer for the generalized trbox */
1221 trbox_base_init(struct trbox *self, int data_rows, int cols)
1223 const int rows = 3 + data_rows;
1225 self->finalize = trbox_base_finalize;
1226 self->t = tab_create (cols, rows, 0);
1227 tab_headers (self->t,0,0,3,0);
1228 tab_box (self->t, TAL_2, TAL_2, TAL_0, TAL_0, 0, 0, cols -1, rows -1);
1229 tab_hline(self->t, TAL_2,0,cols-1,3);
1230 tab_dim (self->t, tab_natural_dimensions);
1234 /* Base finalizer for the trbox */
1236 trbox_base_finalize(struct trbox *trb)
1242 /* Create , populate and submit the Paired Samples Correlation box */
1246 const int rows=1+n_pairs;
1250 struct tab_table *table;
1252 table = tab_create (cols,rows,0);
1254 tab_columns (table, SOM_COL_DOWN, 1);
1255 tab_headers (table,0,0,1,0);
1256 tab_box (table, TAL_2, TAL_2, TAL_0, TAL_1, 0, 0, cols -1, rows -1 );
1257 tab_hline(table, TAL_2, 0, cols - 1, 1);
1258 tab_vline(table, TAL_2, 2, 0, rows - 1);
1259 tab_dim(table, tab_natural_dimensions);
1260 tab_title(table, 0, _("Paired Samples Correlations"));
1262 /* column headings */
1263 tab_text(table, 2,0, TAB_CENTER | TAT_TITLE, _("N"));
1264 tab_text(table, 3,0, TAB_CENTER | TAT_TITLE, _("Correlation"));
1265 tab_text(table, 4,0, TAB_CENTER | TAT_TITLE, _("Sig."));
1267 for (i=0; i < n_pairs; ++i)
1271 double df = pairs[i].n -2;
1273 double correlation_t =
1274 pairs[i].correlation * sqrt(df) /
1275 sqrt(1 - pow2(pairs[i].correlation));
1279 tab_text(table, 0,i+1, TAB_LEFT | TAT_TITLE | TAT_PRINTF,
1282 tab_text(table, 1,i+1, TAB_LEFT | TAT_TITLE | TAT_PRINTF,
1283 _("%s & %s"), pairs[i].v[0]->name, pairs[i].v[1]->name);
1287 tab_float(table, 2, i+1, TAB_RIGHT, pairs[i].n, 4, 0);
1288 tab_float(table, 3, i+1, TAB_RIGHT, pairs[i].correlation, 8, 3);
1290 p = gsl_cdf_tdist_P(correlation_t, df);
1291 q = gsl_cdf_tdist_Q(correlation_t, df);
1293 tab_float(table, 4, i+1, TAB_RIGHT, 2.0*(correlation_t>0?q:p), 8, 3);
1301 /* Calculation Implementation */
1303 /* Per case calculations common to all variants of the T test */
1305 common_calc (const struct ccase *c, void *_cmd)
1308 struct cmd_t_test *cmd = (struct cmd_t_test *)_cmd;
1310 double weight = dict_get_case_weight(default_dict,c,&bad_weight_warn);
1313 /* Skip the entire case if /MISSING=LISTWISE is set */
1314 if ( cmd->miss == TTS_LISTWISE )
1316 for(i=0; i< cmd->n_variables ; ++i)
1318 struct variable *v = cmd->v_variables[i];
1319 const union value *val = case_data (c, v->fv);
1321 if (value_is_missing(val,v) )
1328 /* Listwise has to be implicit if the independent variable is missing ?? */
1329 if ( cmd->sbc_groups )
1331 const union value *gv = case_data (c, indep_var->fv);
1332 if ( value_is_missing(gv,indep_var) )
1339 for(i=0; i< cmd->n_variables ; ++i)
1341 struct group_statistics *gs;
1342 struct variable *v = cmd->v_variables[i];
1343 const union value *val = case_data (c, v->fv);
1345 gs= &cmd->v_variables[i]->p.t_t.ugs;
1347 if (! value_is_missing(val,v) )
1350 gs->sum+=weight * val->f;
1351 gs->ssq+=weight * val->f * val->f;
1357 /* Pre calculations common to all variants of the T test */
1359 common_precalc ( struct cmd_t_test *cmd )
1363 for(i=0; i< cmd->n_variables ; ++i)
1365 struct group_statistics *gs;
1366 gs= &cmd->v_variables[i]->p.t_t.ugs;
1375 /* Post calculations common to all variants of the T test */
1377 common_postcalc ( struct cmd_t_test *cmd )
1382 for(i=0; i< cmd->n_variables ; ++i)
1384 struct group_statistics *gs;
1385 gs= &cmd->v_variables[i]->p.t_t.ugs;
1387 gs->mean=gs->sum / gs->n;
1388 gs->s_std_dev= sqrt(
1389 ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
1394 ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
1397 gs->se_mean = gs->std_dev / sqrt(gs->n);
1398 gs->mean_diff= gs->sum_diff / gs->n;
1402 /* Per case calculations for one sample t test */
1404 one_sample_calc (const struct ccase *c, void *cmd_)
1407 struct cmd_t_test *cmd = (struct cmd_t_test *)cmd_;
1410 double weight = dict_get_case_weight(default_dict,c,&bad_weight_warn);
1412 /* Skip the entire case if /MISSING=LISTWISE is set */
1413 if ( cmd->miss == TTS_LISTWISE )
1415 for(i=0; i< cmd->n_variables ; ++i)
1417 struct variable *v = cmd->v_variables[i];
1418 const union value *val = case_data (c, v->fv);
1420 if (value_is_missing(val,v) )
1427 for(i=0; i< cmd->n_variables ; ++i)
1429 struct group_statistics *gs;
1430 struct variable *v = cmd->v_variables[i];
1431 const union value *val = case_data (c, v->fv);
1433 gs= &cmd->v_variables[i]->p.t_t.ugs;
1435 if ( ! value_is_missing(val,v))
1436 gs->sum_diff += weight * (val->f - cmd->n_testval);
1442 /* Pre calculations for one sample t test */
1444 one_sample_precalc ( struct cmd_t_test *cmd )
1448 for(i=0; i< cmd->n_variables ; ++i)
1450 struct group_statistics *gs;
1451 gs= &cmd->v_variables[i]->p.t_t.ugs;
1457 /* Post calculations for one sample t test */
1459 one_sample_postcalc (struct cmd_t_test *cmd)
1463 for(i=0; i< cmd->n_variables ; ++i)
1465 struct group_statistics *gs;
1466 gs= &cmd->v_variables[i]->p.t_t.ugs;
1468 gs->mean_diff = gs->sum_diff / gs->n ;
1475 compare_var_name (const void *a_, const void *b_, void *v_ UNUSED)
1477 const struct variable *a = a_;
1478 const struct variable *b = b_;
1480 return strcmp(a->name,b->name);
1484 hash_var_name (const void *a_, void *v_ UNUSED)
1486 const struct variable *a = a_;
1488 return hsh_hash_bytes (a->name, strlen(a->name));
1494 paired_precalc (struct cmd_t_test *cmd UNUSED)
1498 for(i=0; i < n_pairs ; ++i )
1501 pairs[i].sum[0] = 0; pairs[i].sum[1] = 0;
1502 pairs[i].ssq[0] = 0; pairs[i].ssq[1] = 0;
1503 pairs[i].sum_of_prod = 0;
1504 pairs[i].correlation = 0;
1505 pairs[i].sum_of_diffs = 0;
1506 pairs[i].ssq_diffs = 0;
1513 paired_calc (const struct ccase *c, void *cmd_)
1517 struct cmd_t_test *cmd = (struct cmd_t_test *) cmd_;
1519 double weight = dict_get_case_weight(default_dict,c,&bad_weight_warn);
1521 /* Skip the entire case if /MISSING=LISTWISE is set ,
1522 AND one member of a pair is missing */
1523 if ( cmd->miss == TTS_LISTWISE )
1525 for(i=0; i < n_pairs ; ++i )
1527 struct variable *v0 = pairs[i].v[0];
1528 struct variable *v1 = pairs[i].v[1];
1530 const union value *val0 = case_data (c, v0->fv);
1531 const union value *val1 = case_data (c, v1->fv);
1533 if ( value_is_missing(val0,v0) ||
1534 value_is_missing(val1,v1) )
1541 for(i=0; i < n_pairs ; ++i )
1543 struct variable *v0 = pairs[i].v[0];
1544 struct variable *v1 = pairs[i].v[1];
1546 const union value *val0 = case_data (c, v0->fv);
1547 const union value *val1 = case_data (c, v1->fv);
1549 if ( ( !value_is_missing(val0,v0) && !value_is_missing(val1,v1) ) )
1551 pairs[i].n += weight;
1552 pairs[i].sum[0] += weight * val0->f;
1553 pairs[i].sum[1] += weight * val1->f;
1555 pairs[i].ssq[0] += weight * pow2(val0->f);
1556 pairs[i].ssq[1] += weight * pow2(val1->f);
1558 pairs[i].sum_of_prod += weight * val0->f * val1->f ;
1560 pairs[i].sum_of_diffs += weight * ( val0->f - val1->f ) ;
1561 pairs[i].ssq_diffs += weight * pow2(val0->f - val1->f);
1569 paired_postcalc (struct cmd_t_test *cmd UNUSED)
1573 for(i=0; i < n_pairs ; ++i )
1576 const double n = pairs[i].n;
1578 for (j=0; j < 2 ; ++j)
1580 pairs[i].mean[j] = pairs[i].sum[j] / n ;
1581 pairs[i].s_std_dev[j] = sqrt((pairs[i].ssq[j] / n -
1582 pow2(pairs[i].mean[j]))
1585 pairs[i].std_dev[j] = sqrt(n/(n-1)*(pairs[i].ssq[j] / n -
1586 pow2(pairs[i].mean[j]))
1590 pairs[i].correlation = pairs[i].sum_of_prod / pairs[i].n -
1591 pairs[i].mean[0] * pairs[i].mean[1] ;
1592 /* correlation now actually contains the covariance */
1594 pairs[i].correlation /= pairs[i].std_dev[0] * pairs[i].std_dev[1];
1595 pairs[i].correlation *= pairs[i].n / ( pairs[i].n - 1 );
1597 pairs[i].mean_diff = pairs[i].sum_of_diffs / n ;
1599 pairs[i].std_dev_diff = sqrt ( n / (n - 1) * (
1600 ( pairs[i].ssq_diffs / n )
1602 pow2(pairs[i].mean_diff )
1607 /* Return the group # corresponding to the
1608 independent variable with the value val
1611 get_group(const union value *val, struct variable *indep)
1615 for (i = 0; i < 2 ; ++i )
1617 const int cmp = compare_values(val,&groups_values[i],indep->width) ;
1618 switch ( criteria[i])
1621 if ( 0 == cmp ) return i;
1624 if ( 0 > cmp ) return i;
1627 if ( cmp <= 0 ) return i;
1630 if ( cmp > 0 ) return i;
1633 if ( cmp >= 0 ) return i;
1640 /* No groups matched */
1646 group_precalc (struct cmd_t_test *cmd )
1651 for(i=0; i< cmd->n_variables ; ++i)
1653 struct t_test_proc *ttpr = &cmd->v_variables[i]->p.t_t;
1655 /* There's always 2 groups for a T - TEST */
1657 ttpr->gs = xmalloc(sizeof(struct group_statistics) * 2) ;
1659 for (j=0 ; j < 2 ; ++j)
1661 ttpr->gs[j].sum = 0;
1663 ttpr->gs[j].ssq = 0;
1665 if ( n_group_values == 2 )
1666 ttpr->gs[j].id = groups_values[j];
1668 ttpr->gs[j].id = groups_values[0];
1669 ttpr->gs[j].criterion = criteria[j];
1676 group_calc (const struct ccase *c, struct cmd_t_test *cmd)
1681 const union value *gv = case_data (c, indep_var->fv);
1683 const double weight = dict_get_case_weight(default_dict,c,&bad_weight_warn);
1685 if ( value_is_missing(gv,indep_var) )
1690 if ( cmd->miss == TTS_LISTWISE )
1692 for(i=0; i< cmd->n_variables ; ++i)
1694 struct variable *v = cmd->v_variables[i];
1695 const union value *val = case_data (c, v->fv);
1697 if (value_is_missing(val,v) )
1705 gv = case_data (c, indep_var->fv);
1707 g = get_group(gv,indep_var);
1710 /* If the independent variable doesn't match either of the values
1711 for this case then move on to the next case */
1715 for(i=0; i< cmd->n_variables ; ++i)
1717 struct variable *var = cmd->v_variables[i];
1719 struct group_statistics *gs = &var->p.t_t.gs[g];
1721 const union value *val = case_data (c, var->fv);
1723 if ( !value_is_missing(val,var) )
1726 gs->sum+=weight * val->f;
1727 gs->ssq+=weight * pow2(val->f);
1736 group_postcalc ( struct cmd_t_test *cmd )
1741 for(i=0; i< cmd->n_variables ; ++i)
1743 for (j=0 ; j < 2 ; ++j)
1745 struct group_statistics *gs;
1746 gs=&cmd->v_variables[i]->p.t_t.gs[j];
1748 gs->mean = gs->sum / gs->n;
1750 gs->s_std_dev= sqrt(
1751 ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
1756 ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
1759 gs->se_mean = gs->std_dev / sqrt(gs->n);
1767 calculate(const struct casefile *cf, void *cmd_)
1769 struct ssbox stat_summary_box;
1770 struct trbox test_results_box;
1772 struct casereader *r;
1775 struct cmd_t_test *cmd = (struct cmd_t_test *) cmd_;
1777 common_precalc(cmd);
1778 for(r = casefile_get_reader (cf);
1779 casereader_read (r, &c) ;
1782 common_calc(&c,cmd);
1784 casereader_destroy (r);
1785 common_postcalc(cmd);
1790 one_sample_precalc(cmd);
1791 for(r = casefile_get_reader (cf);
1792 casereader_read (r, &c) ;
1795 one_sample_calc(&c,cmd);
1797 casereader_destroy (r);
1798 one_sample_postcalc(cmd);
1802 paired_precalc(cmd);
1803 for(r = casefile_get_reader (cf);
1804 casereader_read (r, &c) ;
1807 paired_calc(&c,cmd);
1809 casereader_destroy (r);
1810 paired_postcalc(cmd);
1816 for(r = casefile_get_reader (cf);
1817 casereader_read (r, &c) ;
1822 casereader_destroy (r);
1823 group_postcalc(cmd);
1826 levene(cf, indep_var, cmd->n_variables, cmd->v_variables,
1827 (cmd->miss == TTS_LISTWISE)?LEV_LISTWISE:LEV_ANALYSIS ,
1832 ssbox_create(&stat_summary_box,cmd,mode);
1833 ssbox_populate(&stat_summary_box,cmd);
1834 ssbox_finalize(&stat_summary_box);
1836 if ( mode == T_PAIRED)
1839 trbox_create(&test_results_box,cmd,mode);
1840 trbox_populate(&test_results_box,cmd);
1841 trbox_finalize(&test_results_box);