From 59d67c510f0ddc531cb9650836c9292b78f28fab Mon Sep 17 00:00:00 2001 From: John Darrington Date: Sat, 29 Mar 2014 08:12:43 +0100 Subject: [PATCH] T-TEST: Fixed a bug in reporting the independent samples std err of the difference 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 --- NEWS | 4 ++++ src/language/stats/t-test-indep.c | 3 ++- tests/language/stats/t-test.at | 6 +++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index e62e7fe48b..6cf918b8db 100644 --- 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. diff --git a/src/language/stats/t-test-indep.c b/src/language/stats/t-test-indep.c index 115885d4b9..ca2c95d58f 100644 --- a/src/language/stats/t-test-indep.c +++ b/src/language/stats/t-test-indep.c @@ -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); diff --git a/tests/language/stats/t-test.at b/tests/language/stats/t-test.at index c8b2b6aed0..de551607f8 100644 --- a/tests/language/stats/t-test.at +++ b/tests/language/stats/t-test.at @@ -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 -- 2.30.2