- tab_text (tbl, 2, 1, TAB_LEFT,
- _("N of Items"));
-
- tab_text (tbl, 1, 2, TAB_LEFT,
- _("Part 2"));
-
- tab_text (tbl, 2, 2, TAB_LEFT,
- _("Value"));
-
- tab_text (tbl, 2, 3, TAB_LEFT,
- _("N of Items"));
-
- tab_text (tbl, 1, 4, TAB_LEFT,
- _("Total N of Items"));
-
- tab_text (tbl, 0, 5, TAB_LEFT,
- _("Correlation Between Forms"));
-
- tab_text (tbl, 0, 6, TAB_LEFT,
- _("Spearman-Brown Coefficient"));
-
- tab_text (tbl, 1, 6, TAB_LEFT,
- _("Equal Length"));
-
- tab_text (tbl, 1, 7, TAB_LEFT,
- _("Unequal Length"));
-
-
- tab_text (tbl, 0, 8, TAB_LEFT,
- _("Guttman Split-Half Coefficient"));
-
-
-
- tab_double (tbl, 3, 0, TAB_RIGHT, rel->sc[1].alpha, NULL, RC_OTHER);
- tab_double (tbl, 3, 2, TAB_RIGHT, rel->sc[2].alpha, NULL, RC_OTHER);
-
- tab_double (tbl, 3, 1, TAB_RIGHT, rel->sc[1].n_items, NULL, RC_WEIGHT);
- tab_double (tbl, 3, 3, TAB_RIGHT, rel->sc[2].n_items, NULL, RC_WEIGHT);
-
- tab_double (tbl, 3, 4, TAB_RIGHT,
- rel->sc[1].n_items + rel->sc[2].n_items, NULL, RC_WEIGHT);
-
- {
- /* R is the correlation between the two parts */
- double r = rel->sc[0].variance_of_sums -
- rel->sc[1].variance_of_sums -
- rel->sc[2].variance_of_sums ;
-
- /* Guttman Split Half Coefficient */
- double g = 2 * r / rel->sc[0].variance_of_sums;
-
- /* Unequal Length Spearman Brown Coefficient, and
- intermediate value used in the computation thereof */
- double uly, tmp;
-
- r /= sqrt (rel->sc[1].variance_of_sums);
- r /= sqrt (rel->sc[2].variance_of_sums);
- r /= 2.0;
-
- tab_double (tbl, 3, 5, TAB_RIGHT, r, NULL, RC_OTHER);
-
- /* Equal length Spearman-Brown Coefficient */
- tab_double (tbl, 3, 6, TAB_RIGHT, 2 * r / (1.0 + r), NULL, RC_OTHER);
-
- tab_double (tbl, 3, 8, TAB_RIGHT, g, NULL, RC_OTHER);
-
- tmp = (1.0 - r*r) * rel->sc[1].n_items * rel->sc[2].n_items /
- pow2 (rel->sc[0].n_items);
-
- uly = sqrt( pow4 (r) + 4 * pow2 (r) * tmp);
- uly -= pow2 (r);
- uly /= 2 * tmp;
+ if (rel->model == MODEL_ALPHA)
+ {
+ pivot_dimension_create (table, PIVOT_AXIS_COLUMN,
+ N_("Statistics"),
+ N_("Cronbach's Alpha"), PIVOT_RC_OTHER,
+ N_("N of Items"), PIVOT_RC_COUNT);
+
+ const struct cronbach *s = &rel->sc[0];
+ pivot_table_put1 (table, 0, pivot_value_new_number (s->alpha));
+ pivot_table_put1 (table, 1, pivot_value_new_number (s->n_items));
+ }
+ else
+ {
+ struct pivot_dimension *statistics = pivot_dimension_create (
+ table, PIVOT_AXIS_ROW, N_("Statistics"));
+ struct pivot_category *alpha = pivot_category_create_group (
+ statistics->root, N_("Cronbach's Alpha"));
+ pivot_category_create_group (alpha, N_("Part 1"),
+ N_("Value"), PIVOT_RC_OTHER,
+ N_("N of Items"), PIVOT_RC_COUNT);
+ pivot_category_create_group (alpha, N_("Part 2"),
+ N_("Value"), PIVOT_RC_OTHER,
+ N_("N of Items"), PIVOT_RC_COUNT);
+ pivot_category_create_leaves (alpha,
+ N_("Total N of Items"), PIVOT_RC_COUNT);
+ pivot_category_create_leaves (statistics->root,
+ N_("Correlation Between Forms"),
+ PIVOT_RC_OTHER);
+ pivot_category_create_group (statistics->root,
+ N_("Spearman-Brown Coefficient"),
+ N_("Equal Length"), PIVOT_RC_OTHER,
+ N_("Unequal Length"), PIVOT_RC_OTHER);
+ pivot_category_create_leaves (statistics->root,
+ N_("Guttman Split-Half Coefficient"),
+ PIVOT_RC_OTHER);
+
+ /* R is the correlation between the two parts */
+ double r0 = rel->sc[0].variance_of_sums -
+ rel->sc[1].variance_of_sums -
+ rel->sc[2].variance_of_sums ;
+ double r1 = (r0 / sqrt (rel->sc[1].variance_of_sums)
+ / sqrt (rel->sc[2].variance_of_sums)
+ / 2.0);
+
+ /* Guttman Split Half Coefficient */
+ double g = 2 * r0 / rel->sc[0].variance_of_sums;
+
+ double tmp = (1.0 - r1*r1) * rel->sc[1].n_items * rel->sc[2].n_items /
+ pow2 (rel->sc[0].n_items);
+
+ double entries[] = {
+ rel->sc[1].alpha,
+ rel->sc[1].n_items,
+ rel->sc[2].alpha,
+ rel->sc[2].n_items,
+ rel->sc[1].n_items + rel->sc[2].n_items,
+ r1,
+ 2 * r1 / (1.0 + r1),
+ (sqrt (pow4 (r1) + 4 * pow2 (r1) * tmp) - pow2 (r1)) / (2 * tmp),
+ g,
+ };
+ for (size_t i = 0; i < sizeof entries / sizeof *entries; i++)
+ pivot_table_put1 (table, i, pivot_value_new_number (entries[i]));
+ }