T-TEST: Fixed a bug in reporting the independent samples std err of the difference
[pspp] / src / language / stats / t-test-indep.c
index 876b9857d5bbea9efa19ccc6137feea7c205b043..ca2c95d58fde7345a7aeb453d05d92aa412a20df 100644 (file)
@@ -82,7 +82,7 @@ indep_run (struct tt *tt, const struct variable *gvar,
   struct ccase *c;
   struct casereader *r;
 
-  struct pair_stats *ps = xcalloc (sizeof (*ps), tt->n_vars);
+  struct pair_stats *ps = xcalloc (tt->n_vars, sizeof *ps);
 
   int v;
 
@@ -215,8 +215,7 @@ indep_summary (const struct tt *tt, struct indep_samples *is, const struct pair_
 
   if (is->cut)
     {
-      /*      ds_put_cstr (&vallab0, "≥"); */
-      ds_put_cstr (&vallab0, ">=");
+      ds_put_cstr (&vallab0, "≥");
       ds_put_cstr (&vallab1, "<");
 
       var_append_value_name (is->gvar, is->gval0, &vallab0);
@@ -228,6 +227,8 @@ indep_summary (const struct tt *tt, struct indep_samples *is, const struct pair_
       var_append_value_name (is->gvar, is->gval1, &vallab1);
     }
 
+  tab_vline (t, TAL_1, 1, heading_rows,  rows - 1);
+
   for (v = 0; v < tt->n_vars; ++v)
     {
       int i;
@@ -300,6 +301,8 @@ indep_test (const struct tt *tt, const struct pair_stats *ps)
                          _("%g%% Confidence Interval of the Difference"),
                          tt->confidence * 100.0);
 
+  tab_vline (t, TAL_1, 1, heading_rows,  rows - 1);
+
   for (v = 0; v < tt->n_vars; ++v)
   {
     double df, pooled_variance, mean_diff, tval;
@@ -331,7 +334,7 @@ indep_test (const struct tt *tt, const struct pair_stats *ps)
     tab_double (t, 6, v * 2 + heading_rows, TAB_RIGHT, 2.0 * (tval > 0 ? q : p),   NULL);
     tab_double (t, 7, v * 2 + heading_rows, TAB_RIGHT, mean_diff, NULL);
 
-    std_err_diff = sqrt ((sigma0 / cc0) + (sigma1 / cc1));
+    std_err_diff = sqrt (pooled_variance * (1.0/cc0 + 1.0/cc1));
     tab_double (t, 8, v * 2 + heading_rows, TAB_RIGHT, std_err_diff, NULL);
 
 
@@ -344,6 +347,7 @@ indep_test (const struct tt *tt, const struct pair_stats *ps)
 
     /* Equal variances not assumed */
     tab_text (t, 1, v * 2 + heading_rows + 1,  TAB_LEFT, _("Equal variances not assumed"));
+    std_err_diff = sqrt ((sigma0 / cc0) + (sigma1 / cc1));
 
     se2 = sigma0 / cc0 + sigma1 / cc1;
     tval = mean_diff / sqrt (se2);