From: John Darrington Date: Sun, 2 Feb 2020 10:51:42 +0000 (+0100) Subject: Fix bug #57722. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=513a8d92d1679e51701c579d66a912b531e4ec7d;p=pspp Fix bug #57722. The McNemar binomial probability should use the minimum of the two dissimilar group counts. --- diff --git a/src/language/stats/mcnemar.c b/src/language/stats/mcnemar.c index ef84b77a4e..7ee52f4313 100644 --- a/src/language/stats/mcnemar.c +++ b/src/language/stats/mcnemar.c @@ -235,7 +235,9 @@ output_statistics_table (const struct two_sample_test *t2s, pairs->root, pivot_value_new_user_text_nocopy (make_pair_name (vp))); double n = mc[i].n00 + mc[i].n01 + mc[i].n10 + mc[i].n11; - double sig = gsl_cdf_binomial_P (mc[i].n01, 0.5, mc[i].n01 + mc[i].n10); + double sig = gsl_cdf_binomial_P ((mc[i].n01 > mc[i].n10) ? mc[i].n10: mc[i].n01, + 0.5, mc[i].n01 + mc[i].n10); + double point = gsl_ran_binomial_pdf (mc[i].n01, 0.5, mc[i].n01 + mc[i].n10); double entries[] = { n, 2.0 * sig, sig, point }; diff --git a/tests/language/stats/npar.at b/tests/language/stats/npar.at index 377832cfe9..820b28ad0f 100644 --- a/tests/language/stats/npar.at +++ b/tests/language/stats/npar.at @@ -1261,6 +1261,50 @@ v1 & junk,20,.453,.227,.164 AT_CLEANUP +AT_SETUP([NPAR TESTS McNemar Symetricity]) + +AT_DATA([mcnemar.sps], [dnl +data list notable list /var1 var2 w (F2.0). +begin data +0 0 9 +0 1 8 +1 0 1 +1 1 5 +end data. + +weight by w. + +NPAR TEST + /MCNEMAR var1 WITH var2 (PAIRED). + +NPAR TEST + /MCNEMAR var2 WITH var1 (PAIRED). +]) + +AT_CHECK([pspp -O format=csv mcnemar.sps], [0], [dnl +Table: var1 & var2 +,var2, +var1,0,1 +0,9,8 +1,1,5 + +Table: Test Statistics +,N,Exact Sig. (2-tailed),Exact Sig. (1-tailed),Point Probability +var1 & var2,23,.039,.020,.02 + +Table: var2 & var1 +,var1, +var2,0,1 +0,9,1 +1,8,5 + +Table: Test Statistics +,N,Exact Sig. (2-tailed),Exact Sig. (1-tailed),Point Probability +var2 & var1,23,.039,.020,.02 +]) + +AT_CLEANUP + AT_SETUP([NPAR TESTS Kolmogorov-Smirnov Uniform parameters given]) AT_DATA([ks-uniform.sps], [dnl