X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fstats%2Fmcnemar.c;h=a12800726dfec6ae94af4b0ff724e7785f6c021d;hb=1a73ef6db75f41bf209b9aff8d42c0cb579338ad;hp=0456b909c59a75688d97ada4a109ec71775caab8;hpb=5cab4cf3322f29c0ed7134d23740e07382914f20;p=pspp diff --git a/src/language/stats/mcnemar.c b/src/language/stats/mcnemar.c index 0456b909c5..a12800726d 100644 --- a/src/language/stats/mcnemar.c +++ b/src/language/stats/mcnemar.c @@ -83,9 +83,9 @@ mcnemar_execute (const struct dataset *ds, struct casereader *r = input; - struct mcnemar *mc = xcalloc (t2s->n_pairs, sizeof *mc); + struct mcnemar *mc = XCALLOC (t2s->n_pairs, struct mcnemar); - for (i = 0 ; i < t2s->n_pairs; ++i ) + for (i = 0 ; i < t2s->n_pairs; ++i) { mc[i].val0.f = mc[i].val1.f = SYSMIS; } @@ -94,20 +94,20 @@ mcnemar_execute (const struct dataset *ds, { const double weight = dict_get_case_weight (dict, c, &warn); - for (i = 0 ; i < t2s->n_pairs; ++i ) + for (i = 0 ; i < t2s->n_pairs; ++i) { variable_pair *vp = &t2s->pairs[i]; const union value *value0 = case_data (c, (*vp)[0]); const union value *value1 = case_data (c, (*vp)[1]); - if (var_is_value_missing ((*vp)[0], value0, exclude)) + if (var_is_value_missing ((*vp)[0], value0) & exclude) continue; - if (var_is_value_missing ((*vp)[1], value1, exclude)) + if (var_is_value_missing ((*vp)[1], value1) & exclude) continue; - if ( mc[i].val0.f == SYSMIS) + if (mc[i].val0.f == SYSMIS) { if (mc[i].val1.f != value0->f) mc[i].val0.f = value0->f; @@ -115,7 +115,7 @@ mcnemar_execute (const struct dataset *ds, mc[i].val0.f = value1->f; } - if ( mc[i].val1.f == SYSMIS) + if (mc[i].val1.f == SYSMIS) { if (mc[i].val0.f != value1->f) mc[i].val1.f = value1->f; @@ -127,15 +127,15 @@ mcnemar_execute (const struct dataset *ds, { mc[i].n00 += weight; } - else if ( mc[i].val0.f == value0->f && mc[i].val1.f == value1->f) + else if (mc[i].val0.f == value0->f && mc[i].val1.f == value1->f) { mc[i].n10 += weight; } - else if ( mc[i].val1.f == value0->f && mc[i].val0.f == value1->f) + else if (mc[i].val1.f == value0->f && mc[i].val0.f == value1->f) { mc[i].n01 += weight; } - else if ( mc[i].val1.f == value0->f && mc[i].val1.f == value1->f) + else if (mc[i].val1.f == value0->f && mc[i].val1.f == value1->f) { mc[i].n11 += weight; } @@ -169,7 +169,7 @@ output_freq_table (variable_pair *vp, const struct dictionary *dict) { struct pivot_table *table = pivot_table_create__ ( - pivot_value_new_user_text_nocopy (make_pair_name (vp))); + pivot_value_new_user_text_nocopy (make_pair_name (vp)), "Frequencies"); pivot_table_set_weight_var (table, dict_get_weight (dict)); struct pivot_dimension *vars[2]; @@ -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 };