+ if (factor->print & PRINT_KMO)
+ {
+ int i;
+ double sum_ssq_r = 0;
+ double sum_ssq_a = 0;
+
+ double df = factor->n_vars * ( factor->n_vars - 1) / 2;
+
+ double w = 0;
+
+
+ double xsq;
+
+ const int heading_columns = 2;
+ const int heading_rows = 0;
+
+ const int nr = heading_rows + 4;
+ const int nc = heading_columns + 1;
+
+ gsl_matrix *a, *x;
+
+ struct tab_table *t = tab_create (nc, nr);
+ tab_title (t, _("KMO and Bartlett's Test"));
+
+ x = clone_matrix (idata->corr);
+ gsl_linalg_cholesky_decomp (x);
+ gsl_linalg_cholesky_invert (x);
+
+ a = anti_image (x);
+
+ for (i = 0; i < x->size1; ++i)
+ {
+ sum_ssq_r += ssq_od_n (x, i);
+ sum_ssq_a += ssq_od_n (a, i);
+ }
+
+ gsl_matrix_free (a);
+ gsl_matrix_free (x);
+
+ tab_headers (t, heading_columns, 0, heading_rows, 0);
+
+ /* Outline the box */
+ tab_box (t,
+ TAL_2, TAL_2,
+ -1, -1,
+ 0, 0,
+ nc - 1, nr - 1);
+
+ tab_vline (t, TAL_2, heading_columns, 0, nr - 1);
+
+ tab_text (t, 0, 0, TAT_TITLE | TAB_LEFT, _("Kaiser-Meyer-Olkin Measure of Sampling Adequacy"));
+
+ tab_double (t, 2, 0, 0, sum_ssq_r / (sum_ssq_r + sum_ssq_a), NULL);
+
+ tab_text (t, 0, 1, TAT_TITLE | TAB_LEFT, _("Bartlett's Test of Sphericity"));
+
+ tab_text (t, 1, 1, TAT_TITLE, _("Approx. Chi-Square"));
+ tab_text (t, 1, 2, TAT_TITLE, _("df"));
+ tab_text (t, 1, 3, TAT_TITLE, _("Sig."));
+
+
+ /* The literature doesn't say what to do for the value of W when
+ missing values are involved. The best thing I can think of
+ is to take the mean average. */
+ w = 0;
+ for (i = 0; i < idata->n->size1; ++i)
+ w += gsl_matrix_get (idata->n, i, i);
+ w /= idata->n->size1;
+
+ xsq = w - 1 - (2 * factor->n_vars + 5) / 6.0;
+ xsq *= -log (idata->detR);
+
+ tab_double (t, 2, 1, 0, xsq, NULL);
+ tab_double (t, 2, 2, 0, df, &F_8_0);
+ tab_double (t, 2, 3, 0, gsl_cdf_chisq_Q (xsq, df), NULL);
+
+
+ tab_submit (t);
+ }
+