T-TEST: Fixed a bug in reporting the independent samples std err of the difference
authorJohn Darrington <john@darrington.wattle.id.au>
Sat, 29 Mar 2014 07:12:43 +0000 (08:12 +0100)
committerJohn Darrington <john@darrington.wattle.id.au>
Sat, 29 Mar 2014 07:12:43 +0000 (08:12 +0100)
The standard error of the difference and the confidence interval
for the unequal variances case was reported where the equal variances
case should have been.  This change fixes that.

Reported by: Michael Schneider <m-schneider.klh@uni-wuerzburg.de>

NEWS
src/language/stats/t-test-indep.c
tests/language/stats/t-test.at

diff --git a/NEWS b/NEWS
index e62e7fe48b08b6009896bd94236530444fb1d091..6cf918b8dbd7aa9e8f25a8e60ba42c83aa98fdac 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,10 @@ Please send PSPP bug reports to bug-gnu-pspp@gnu.org.
  
 Changes since 0.8.2:
 
+ * Independent T-Tests displayed the standard error of the difference
+   and the confidence interval for the unequal variances case, where
+   the equal variances case should have been.  This has been fixed.
+
  * REGRESSION now recognises /STATISTICS=CI(x) which causes confidence
    intervals for the coefficients to be printed.
 
index 115885d4b9750a661dba7d1f7ef33b9cd885f920..ca2c95d58fde7345a7aeb453d05d92aa412a20df 100644 (file)
@@ -334,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);
 
 
@@ -347,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);
index c8b2b6aed083b828f924652cb0de3aa518be8de6..de551607f8b48987ca0ae83757227256ceb4d4ca 100644 (file)
@@ -329,9 +329,9 @@ Table: Independent Samples Test
 ,,Levene's Test for Equality of Variances,,t-test for Equality of Means,,,,,,
 ,,,,,,,,,95% Confidence Interval of the Difference,
 ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,Lower,Upper
-dep1,Equal variances assumed,3.75,.15,-1.12,3.00,.35,-.75,.56,-2.53,1.03
+dep1,Equal variances assumed,3.75,.15,-1.12,3.00,.35,-.75,.67,-2.89,1.39
 ,Equal variances not assumed,,,-1.34,2.78,.28,-.75,.56,-2.61,1.11
-dep2,Equal variances assumed,.60,.50,2.85,3.00,.07,3.00,1.15,-.67,6.67
+dep2,Equal variances assumed,.60,.50,2.85,3.00,.07,3.00,1.05,-.35,6.35
 ,Equal variances not assumed,,,2.60,1.68,.14,3.00,1.15,-2.98,8.98
 ])
 AT_CHECK([pspp -o ref.csv ref.sps])
@@ -739,7 +739,7 @@ Table: Independent Samples Test
 ,,Levene's Test for Equality of Variances,,t-test for Equality of Means,,,,,,
 ,,,,,,,,,95% Confidence Interval of the Difference,
 ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,Lower,Upper
-x,Equal variances assumed,1.13,.33,-2.32,6.00,.06,-.90,.38,-1.83,.03
+x,Equal variances assumed,1.13,.33,-2.32,6.00,.06,-.90,.39,-1.85,.05
 ,Equal variances not assumed,,,-2.38,4.70,.07,-.90,.38,-1.89,.09
 ])
 AT_CLEANUP