+ /* degrees of freedom */
+ df = gs->n - 1;
+
+ tab_float (trb->t, 2, i+3, TAB_RIGHT, df, 8,0);
+
+ p = gsl_cdf_tdist_P(t, df);
+ q = gsl_cdf_tdist_Q(t, df);
+
+ /* Multiply by 2 to get 2-tailed significance, makeing sure we've got
+ the correct tail*/
+ tab_float (trb->t, 3, i+3, TAB_RIGHT, 2.0*(t>0?q:p), 8,3);
+
+ tab_float (trb->t, 4, i+3, TAB_RIGHT, gs->mean_diff, 8,3);
+
+
+ q = (1 - cmd->criteria)/2.0; /* 2-tailed test */
+ t = gsl_cdf_tdist_Qinv(q, df);
+
+ tab_float (trb->t, 5, i+3, TAB_RIGHT,
+ gs->mean_diff - t * gs->se_mean, 8,4);
+
+ tab_float (trb->t, 6, i+3, TAB_RIGHT,
+ gs->mean_diff + t * gs->se_mean, 8,4);
+ }
+}
+
+/* Base initializer for the generalized trbox */
+void
+trbox_base_init(struct trbox *self, size_t data_rows, int cols)
+{
+ const size_t rows = 3 + data_rows;
+
+ self->finalize = trbox_base_finalize;
+ self->t = tab_create (cols, rows, 0);
+ tab_headers (self->t,0,0,3,0);
+ tab_box (self->t, TAL_2, TAL_2, TAL_0, TAL_0, 0, 0, cols -1, rows -1);
+ tab_hline(self->t, TAL_2,0,cols-1,3);
+ tab_dim (self->t, tab_natural_dimensions);
+}
+
+
+/* Base finalizer for the trbox */
+void
+trbox_base_finalize(struct trbox *trb)
+{
+ tab_submit(trb->t);
+}
+
+
+/* Create , populate and submit the Paired Samples Correlation box */
+void
+pscbox(void)
+{
+ 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."));