+}
+
+/* Populate a trbox according to cmd */
+void
+trbox_populate(struct trbox *trb, struct cmd_t_test *cmd)
+{
+ trb->populate(trb,cmd);
+}
+
+/* Submit and destroy a trbox */
+void
+trbox_finalize(struct trbox *trb)
+{
+ trb->finalize(trb);
+}
+
+/* Initialize the independent samples trbox */
+void
+trbox_independent_samples_init(struct trbox *self,
+ struct cmd_t_test *cmd UNUSED)
+{
+ const int hsize=11;
+ const int vsize=cmd->n_variables*2+3;
+
+ assert(self);
+ self->populate = trbox_independent_samples_populate;
+
+ trbox_base_init(self,cmd->n_variables*2,hsize);
+ tab_title(self->t,0,_("Independent Samples Test"));
+ tab_hline(self->t,TAL_1,2,hsize-1,1);
+ tab_vline(self->t,TAL_2,2,0,vsize-1);
+ tab_vline(self->t,TAL_1,4,0,vsize-1);
+ tab_box(self->t,-1,-1,-1,TAL_1, 2,1,hsize-2,vsize-1);
+ tab_hline(self->t,TAL_1, hsize-2,hsize-1,2);
+ tab_box(self->t,-1,-1,-1,TAL_1, hsize-2,2,hsize-1,vsize-1);
+ tab_joint_text(self->t, 2, 0, 3, 0,
+ TAB_CENTER,_("Levene's Test for Equality of Variances"));
+ tab_joint_text(self->t, 4,0,hsize-1,0,
+ TAB_CENTER,_("t-test for Equality of Means"));
+
+ tab_text(self->t,2,2, TAB_CENTER | TAT_TITLE,_("F"));
+ tab_text(self->t,3,2, TAB_CENTER | TAT_TITLE,_("Sig."));
+ tab_text(self->t,4,2, TAB_CENTER | TAT_TITLE,_("t"));
+ tab_text(self->t,5,2, TAB_CENTER | TAT_TITLE,_("df"));
+ tab_text(self->t,6,2, TAB_CENTER | TAT_TITLE,_("Sig. (2-tailed)"));
+ tab_text(self->t,7,2, TAB_CENTER | TAT_TITLE,_("Mean Difference"));
+ tab_text(self->t,8,2, TAB_CENTER | TAT_TITLE,_("Std. Error Difference"));
+ tab_text(self->t,9,2, TAB_CENTER | TAT_TITLE,_("Lower"));
+ tab_text(self->t,10,2, TAB_CENTER | TAT_TITLE,_("Upper"));
+
+ tab_joint_text(self->t, 9, 1, 10, 1, TAB_CENTER | TAT_PRINTF,
+ _("%d%% Confidence Interval of the Difference"),
+ (int)round(cmd->criteria*100.0));
+
+}
+
+/* Populate the independent samples trbox */
+void
+trbox_independent_samples_populate(struct trbox *self,
+ struct cmd_t_test *cmd )
+{
+ int i;
+
+ assert(self);
+ for (i=0; i < cmd->n_variables; ++i)
+ {
+ int which =1;
+ double p,q;
+ int status;
+ double bound;
+
+ double t;
+ double df;
+
+ double df1, df2;
+
+ double pooled_variance;
+ double std_err_diff;
+ double mean_diff;
+
+ struct group_statistics *gs0 = &cmd->v_variables[i]->p.t_t.gs[0];
+ struct group_statistics *gs1 = &cmd->v_variables[i]->p.t_t.gs[1];
+
+ tab_text (self->t, 0, i*2+3, TAB_LEFT, cmd->v_variables[i]->name);
+
+ tab_text (self->t, 1, i*2+3, TAB_LEFT, _("Equal variances assumed"));
+
+
+ tab_float(self->t, 2, i*2+3, TAB_CENTER,
+ cmd->v_variables[i]->p.t_t.levene, 8,3);
+
+
+ /* Now work out the significance of the Levene test */
+
+ which=1; df1 = 1; df2 = cmd->v_variables[i]->p.t_t.ugs.n - 2;
+ cdff(&which,&p,&q,&cmd->v_variables[i]->p.t_t.levene,
+ &df1,&df2,&status,&bound);
+
+ if ( 0 != status )
+ {
+ msg( SE, _("Error calculating F statistic (cdff returned %d)."),status);
+ }
+
+ tab_float(self->t, 3, i*2+3, TAB_CENTER, q, 8,3 );
+
+ df = gs0->n + gs1->n - 2.0 ;
+ tab_float (self->t, 5, i*2+3, TAB_RIGHT, df, 2, 0);
+
+ pooled_variance = ( (gs0->n )*sqr(gs0->s_std_dev)
+ +
+ (gs1->n )*sqr(gs1->s_std_dev)
+ ) / df ;
+
+ t = (gs0->mean - gs1->mean) / sqrt(pooled_variance) ;
+ t /= sqrt((gs0->n + gs1->n)/(gs0->n*gs1->n));
+
+ tab_float (self->t, 4, i*2+3, TAB_RIGHT, t, 8, 3);
+
+
+ which=1; /* get p & q from t & df */
+ cdft(&which, &p, &q, &t, &df, &status, &bound);
+ if ( 0 != status )
+ {
+ msg( SE, _("Error calculating T statistic (cdft returned %d)."),status);
+ }
+
+ tab_float(self->t, 6, i*2+3, TAB_RIGHT, 2.0*(t>0?q:p) , 8, 3);
+
+ mean_diff = gs0->mean - gs1->mean;
+ tab_float(self->t, 7, i*2+3, TAB_RIGHT, mean_diff, 8, 3);
+
+
+ std_err_diff = sqrt( sqr(gs0->se_mean) + sqr(gs1->se_mean));
+ tab_float(self->t, 8, i*2+3, TAB_RIGHT, std_err_diff, 8, 3);
+
+
+ /* 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(self->t, 9, i*2+3, TAB_RIGHT,
+ mean_diff - t * std_err_diff, 8, 3);
+
+ tab_float(self->t, 10, i*2+3, TAB_RIGHT,
+ mean_diff + t * std_err_diff, 8, 3);
+
+