X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Ft-test.q;h=c2fc85d7f774bdf5308cd458f5684efc65518536;hb=d69833d7d425cd98c3793a89945153306dfa7ab3;hp=1df4581a8b37b8de7ffd0061da700cb0c45fa03d;hpb=aaa565535e0fd686483acad6026fe47005aca4ae;p=pspp-builds.git diff --git a/src/t-test.q b/src/t-test.q index 1df4581a..c2fc85d7 100644 --- a/src/t-test.q +++ b/src/t-test.q @@ -99,6 +99,9 @@ void ssbox_populate(struct ssbox *ssb, struct cmd_t_test *cmd); /* Submit and destroy a ssbox */ void ssbox_finalize(struct ssbox *ssb); +/* A function to create, populate and submit the Paired Samples Correlation + box */ +void pscbox(struct cmd_t_test *cmd); /* Structures and Functions for the Test Results Box */ @@ -189,12 +192,16 @@ cmd_t_test(void) t_test_pool = pool_create (); ssbox_create(&stat_summary_box,&cmd,mode); - trbox_create(&test_results_box,&cmd,mode); - ssbox_populate(&stat_summary_box,&cmd); - trbox_populate(&test_results_box,&cmd); - ssbox_finalize(&stat_summary_box); + + if ( mode == T_PAIRED) + { + pscbox(&cmd); + } + + trbox_create(&test_results_box,&cmd,mode); + trbox_populate(&test_results_box,&cmd); trbox_finalize(&test_results_box); pool_destroy (t_test_pool); @@ -908,7 +915,11 @@ trbox_one_sample_populate(struct trbox *trb, struct cmd_t_test *cmd) cdft(&which, &p, &q, &t, &df, &status, &bound); - assert(status == 0 ); /* FIXME: use proper error message */ + if ( 0 != status ) + { + msg( SE, _("Error calculating T statistic (cdft returned %d)."),status); + } + /* Multiply by 2 to get 2-tailed significance */ tab_float (trb->t, 3, i+3, TAB_RIGHT, q*2.0, 8,3); @@ -920,7 +931,10 @@ trbox_one_sample_populate(struct trbox *trb, struct cmd_t_test *cmd) p = 1 - q ; which=2; /* Calc T from p,q and df */ cdft(&which, &p, &q, &t, &df, &status, &bound); - assert(status == 0 ); /* FIXME: proper error message */ + if ( 0 != status ) + { + msg( SE, _("Error calculating T statistic (cdft returned %d)."),status); + } tab_float (trb->t, 5, i+3, TAB_RIGHT, ttp->mean_diff - t * ttp->se_mean, 8,4); @@ -953,6 +967,57 @@ trbox_base_finalize(struct trbox *trb) } +/* Create , populate and submit the Paired Samples Correlation box */ +void +pscbox(struct cmd_t_test *cmd) +{ + const int rows=1+n_pairs; + const int cols=5; + int i; + + struct tab_table *table; + + table = tab_create (cols,rows,0); + + tab_columns (table, SOM_COL_DOWN, 1); + tab_headers (table,0,0,1,0); + tab_box (table, TAL_2, TAL_2, TAL_0, TAL_1, 0, 0, cols -1, rows -1 ); + tab_hline(table, TAL_2, 0, cols - 1, 1); + tab_vline(table, TAL_2, 2, 0, rows - 1); + tab_dim(table, tab_natural_dimensions); + tab_title(table, 0, _("Paired Samples Correlations")); + + /* column headings */ + tab_text(table, 2,0, TAB_CENTER | TAT_TITLE, _("N")); + tab_text(table, 3,0, TAB_CENTER | TAT_TITLE, _("Correlation")); + tab_text(table, 4,0, TAB_CENTER | TAT_TITLE, _("Sig.")); + + /* row headings */ + { + struct string ds; + + ds_init(t_test_pool,&ds,15); + + for (i=0; i < n_pairs; ++i) + { + ds_clear(&ds); + ds_printf(&ds,_("Pair %d"),i); + tab_text(table, 0,i+1, TAB_LEFT | TAT_TITLE, ds.string); + + ds_clear(&ds); + ds_printf(&ds,_("%s & %s"),pairs[i][0]->name,pairs[i][1]->name); + tab_text(table, 1,i+1, TAB_LEFT | TAT_TITLE, ds.string); + } + + ds_destroy(&ds); + } + + + tab_submit(table); +} + + + /* Calculation Implementation */ /* Per case calculations common to all variants of the T test */