+ int which =1;
+ double p,q;
+ int status;
+ double bound;
+ double se_mean;
+
+ struct variable *v0 = pairs[i].v[0];
+ struct variable *v1 = pairs[i].v[1];
+
+ struct t_test_proc *ttp0 = &v0->p.t_t;
+ struct t_test_proc *ttp1 = &v1->p.t_t;
+
+ double n = ttp0->n;
+ double t;
+ double df = n - 1;
+
+ tab_text (trb->t, 0, i+3, TAB_LEFT | TAT_PRINTF, _("Pair %d"),i);
+
+ tab_text (trb->t, 1, i+3, TAB_LEFT | TAT_PRINTF, "%s - %s",
+ pairs[i].v[0]->name, pairs[i].v[1]->name);
+
+ tab_float(trb->t, 2, i+3, TAB_RIGHT, pairs[i].mean_diff, 8, 4);
+
+ tab_float(trb->t, 3, i+3, TAB_RIGHT, pairs[i].std_dev_diff, 8, 5);
+
+ /* SE Mean */
+ se_mean = pairs[i].std_dev_diff / sqrt(n) ;
+ tab_float(trb->t, 4, i+3, TAB_RIGHT, se_mean, 8,5 );
+
+ /* Now work out the confidence interval */
+ q = (1 - cmd->criteria)/2.0; /* 2-tailed test */
+ p = 1 - q ;
+ which=2; /* Calc T from p,q and df */
+ cdft(&which, &p, &q, &t, &df, &status, &bound);
+
+ if ( 0 != status )
+ {
+ msg( SE, _("Error calculating T statistic (cdft returned %d)."),status);
+ }
+
+ tab_float(trb->t, 5, i+3, TAB_RIGHT,
+ pairs[i].mean_diff - t * se_mean , 8, 4);
+
+ tab_float(trb->t, 6, i+3, TAB_RIGHT,
+ pairs[i].mean_diff + t * se_mean , 8, 4);
+
+ t = ( ttp0->mean - ttp1->mean)
+ / sqrt (
+ ( sqr(ttp0->s_std_dev) + sqr(ttp1->s_std_dev) -
+ 2 * pairs[i].correlation * ttp0->s_std_dev * ttp1->s_std_dev )
+ / (n-1) )
+ ;
+
+ tab_float(trb->t, 7, i+3, TAB_RIGHT, t , 8,3 );
+
+ /* Degrees of freedom */
+ tab_float(trb->t, 8, i+3, TAB_RIGHT, df , 2, 0 );
+
+ which=1;
+ cdft(&which, &p, &q, &t, &df, &status, &bound);
+
+ if ( 0 != status )
+ {
+ msg( SE, _("Error calculating T statistic (cdft returned %d)."),status);
+ }
+
+
+ tab_float(trb->t, 9, i+3, TAB_RIGHT, p*2.0 , 8, 3);
+