From 1e0e76eaeb51ef0c15fdcfc4bd12d9310c16a88b Mon Sep 17 00:00:00 2001 From: John Darrington Date: Tue, 29 Apr 2014 15:32:35 +0200 Subject: [PATCH] Added result_class parameter to tab_double and updated all callers. Removed tab_fixed --- src/data/format.c | 3 + src/data/format.h | 3 + src/language/stats/binomial.c | 17 +-- src/language/stats/chisquare.c | 42 +++--- src/language/stats/cochran.c | 16 ++- src/language/stats/correlations.c | 13 +- src/language/stats/crosstabs.q | 73 ++++++----- src/language/stats/descriptives.c | 2 +- src/language/stats/examine.c | 62 ++++----- src/language/stats/factor.c | 45 +++---- src/language/stats/frequencies.c | 31 ++--- src/language/stats/friedman.c | 13 +- src/language/stats/glm.c | 45 +++---- src/language/stats/jonckheere-terpstra.c | 15 ++- src/language/stats/kruskal-wallis.c | 12 +- src/language/stats/ks-one-sample.c | 28 ++-- src/language/stats/logistic.c | 65 +++++----- src/language/stats/mann-whitney.c | 22 ++-- src/language/stats/mcnemar.c | 19 +-- src/language/stats/means.c | 8 +- src/language/stats/median.c | 16 ++- src/language/stats/npar-summary.c | 10 +- src/language/stats/oneway.c | 94 +++++++------- src/language/stats/quick-cluster.c | 4 +- src/language/stats/regression.c | 52 ++++---- src/language/stats/reliability.c | 63 +++++---- src/language/stats/roc.c | 24 ++-- src/language/stats/runs.c | 15 ++- src/language/stats/sign.c | 15 ++- src/language/stats/t-test-indep.c | 42 +++--- src/language/stats/t-test-one-sample.c | 23 ++-- src/language/stats/t-test-paired.c | 44 +++---- src/language/stats/wilcoxon.c | 25 ++-- src/math/covariance.c | 2 +- src/output/tab.c | 62 +++------ src/output/tab.h | 19 ++- tests/language/stats/correlations.at | 12 +- tests/language/stats/crosstabs.at | 35 ++--- tests/language/stats/factor.at | 11 +- tests/language/stats/npar.at | 64 +++++----- tests/language/stats/oneway.at | 156 ++++++++++++----------- tests/language/stats/regression.at | 8 +- tests/language/stats/t-test.at | 99 +++++++------- 43 files changed, 734 insertions(+), 695 deletions(-) diff --git a/src/data/format.c b/src/data/format.c index 3a380bda45..55e166e817 100644 --- a/src/data/format.c +++ b/src/data/format.c @@ -1158,3 +1158,6 @@ get_fmt_desc (enum fmt_type type) } const struct fmt_spec F_8_0 = {FMT_F, 8, 0}; +const struct fmt_spec F_8_2 = {FMT_F, 8, 2}; +const struct fmt_spec F_4_3 = {FMT_F, 4, 3}; +const struct fmt_spec F_5_1 = {FMT_F, 5, 1}; diff --git a/src/data/format.h b/src/data/format.h index 16ffc4b521..d05e443621 100644 --- a/src/data/format.h +++ b/src/data/format.h @@ -185,5 +185,8 @@ int fmt_affix_width (const struct fmt_number_style *); int fmt_neg_affix_width (const struct fmt_number_style *); extern const struct fmt_spec F_8_0 ; +extern const struct fmt_spec F_8_2 ; +extern const struct fmt_spec F_4_3 ; +extern const struct fmt_spec F_5_1 ; #endif /* data/format.h */ diff --git a/src/language/stats/binomial.c b/src/language/stats/binomial.c index 8439a71b93..697f3254ab 100644 --- a/src/language/stats/binomial.c +++ b/src/language/stats/binomial.c @@ -184,6 +184,7 @@ binomial_execute (const struct dataset *ds, var_get_print_format (wvar) : & F_8_0; struct tab_table *table = tab_create (7, ost->n_vars * 3 + 1); + tab_set_format (table, RC_WEIGHT, wfmt); tab_title (table, _("Binomial Test")); @@ -221,31 +222,31 @@ binomial_execute (const struct dataset *ds, tab_text (table, 1, 3 + v * 3, TAB_LEFT, _("Total")); /* Test Prop */ - tab_double (table, 5, 1 + v * 3, TAB_NONE, bst->p, NULL); + tab_double (table, 5, 1 + v * 3, TAB_NONE, bst->p, NULL, RC_OTHER); /* Category labels */ tab_text (table, 2, 1 + v * 3, TAB_NONE, ds_cstr (&catstr[0])); tab_text (table, 2, 2 + v * 3, TAB_NONE, ds_cstr (&catstr[1])); /* Observed N */ - tab_double (table, 3, 1 + v * 3, TAB_NONE, cat[0][v].count, wfmt); - tab_double (table, 3, 2 + v * 3, TAB_NONE, cat[1][v].count, wfmt); + tab_double (table, 3, 1 + v * 3, TAB_NONE, cat[0][v].count, NULL, RC_WEIGHT); + tab_double (table, 3, 2 + v * 3, TAB_NONE, cat[1][v].count, NULL, RC_WEIGHT); n_total = cat[0][v].count + cat[1][v].count; - tab_double (table, 3, 3 + v * 3, TAB_NONE, n_total, wfmt); + tab_double (table, 3, 3 + v * 3, TAB_NONE, n_total, NULL, RC_WEIGHT); /* Observed Proportions */ tab_double (table, 4, 1 + v * 3, TAB_NONE, - cat[0][v].count / n_total, NULL); + cat[0][v].count / n_total, NULL, RC_OTHER); tab_double (table, 4, 2 + v * 3, TAB_NONE, - cat[1][v].count / n_total, NULL); + cat[1][v].count / n_total, NULL, RC_OTHER); tab_double (table, 4, 3 + v * 3, TAB_NONE, - (cat[0][v].count + cat[1][v].count) / n_total, NULL); + (cat[0][v].count + cat[1][v].count) / n_total, NULL, RC_OTHER); /* Significance */ sig = calculate_binomial (cat[0][v].count, cat[1][v].count, bst->p); - tab_double (table, 6, 1 + v * 3, TAB_NONE, sig, NULL); + tab_double (table, 6, 1 + v * 3, TAB_NONE, sig, NULL, RC_PVALUE); ds_destroy (&catstr[0]); ds_destroy (&catstr[1]); diff --git a/src/language/stats/chisquare.c b/src/language/stats/chisquare.c index 2b5864ee1e..617bddba8f 100644 --- a/src/language/stats/chisquare.c +++ b/src/language/stats/chisquare.c @@ -138,6 +138,9 @@ create_variable_frequency_table (const struct dictionary *dict, struct tab_table *table ; const struct variable *var = ost->vars[v]; + const struct variable *wvar = dict_get_weight (dict); + const struct fmt_spec *wfmt = wvar ? var_get_print_format (wvar) : & F_8_0; + hmap_init (freq_hash); if (!create_freq_hash (dict, input, var, freq_hash)) { @@ -159,6 +162,7 @@ create_variable_frequency_table (const struct dictionary *dict, } table = tab_create(4, n_cells + 2); + tab_set_format (table, RC_WEIGHT, wfmt); tab_title (table, "%s", var_to_string(var)); tab_text (table, 1, 0, TAB_LEFT, _("Observed N")); @@ -184,16 +188,20 @@ create_variable_frequency_table (const struct dictionary *dict, static struct tab_table * -create_combo_frequency_table (const struct chisquare_test *test) +create_combo_frequency_table (const struct dictionary *dict, const struct chisquare_test *test) { int i; const struct one_sample_test *ost = (const struct one_sample_test*)test; struct tab_table *table ; + const struct variable *wvar = dict_get_weight (dict); + const struct fmt_spec *wfmt = wvar ? var_get_print_format (wvar) : & F_8_0; + int n_cells = test->hi - test->lo + 1; table = tab_create(1 + ost->n_vars * 4, n_cells + 3); + tab_set_format (table, RC_WEIGHT, wfmt); tab_title (table, _("Frequencies")); for ( i = 0 ; i < ost->n_vars ; ++i ) @@ -225,8 +233,7 @@ create_combo_frequency_table (const struct chisquare_test *test) } for ( i = test->lo ; i <= test->hi ; ++i ) - tab_fixed (table, 0, 2 + i - test->lo, - TAB_LEFT, 1 + i - test->lo, 8, 0); + tab_double (table, 0, 2 + i - test->lo, TAB_LEFT, 1 + i - test->lo, NULL, RC_INTEGER); tab_headers (table, 1, 0, 2, 0); @@ -286,9 +293,6 @@ chisquare_execute (const struct dataset *ds, struct one_sample_test *ost = &cst->parent; int n_cells = 0; double total_expected = 0.0; - const struct variable *wvar = dict_get_weight (dict); - const struct fmt_spec *wfmt = wvar ? - var_get_print_format (wvar) : & F_8_0; double *df = xzalloc (sizeof (*df) * ost->n_vars); double *xsq = xzalloc (sizeof (*df) * ost->n_vars); @@ -309,7 +313,7 @@ chisquare_execute (const struct dataset *ds, &var, 1, exclude, NULL, NULL); struct tab_table *freq_table = - create_variable_frequency_table(dict, reader, cst, v, &freq_hash); + create_variable_frequency_table (dict, reader, cst, v, &freq_hash); struct freq **ff; @@ -339,7 +343,7 @@ chisquare_execute (const struct dataset *ds, /* The observed N */ tab_double (freq_table, 1, i + 1, TAB_NONE, - ff[i]->count, wfmt); + ff[i]->count, NULL, RC_WEIGHT); if ( cst->n_expected > 0 ) exp = cst->expected[i] * total_obs / total_expected ; @@ -347,11 +351,11 @@ chisquare_execute (const struct dataset *ds, exp = total_obs / (double) n_cells; tab_double (freq_table, 2, i + 1, TAB_NONE, - exp, NULL); + exp, NULL, RC_OTHER); /* The residual */ tab_double (freq_table, 3, i + 1, TAB_NONE, - ff[i]->count - exp, NULL); + ff[i]->count - exp, NULL, RC_OTHER); xsq[v] += (ff[i]->count - exp) * (ff[i]->count - exp) / exp; } @@ -359,7 +363,7 @@ chisquare_execute (const struct dataset *ds, df[v] = n_cells - 1.0; tab_double (freq_table, 1, i + 1, TAB_NONE, - total_obs, wfmt); + total_obs, NULL, RC_WEIGHT); tab_submit (freq_table); @@ -369,7 +373,7 @@ chisquare_execute (const struct dataset *ds, } else /* ranged == true */ { - struct tab_table *freq_table = create_combo_frequency_table (cst); + struct tab_table *freq_table = create_combo_frequency_table (dict, cst); n_cells = cst->hi - cst->lo + 1; @@ -414,7 +418,7 @@ chisquare_execute (const struct dataset *ds, /* The observed N */ tab_double (freq_table, v * 4 + 2, i + 2 , TAB_NONE, - ff[i]->count, wfmt); + ff[i]->count, NULL, RC_WEIGHT); if ( cst->n_expected > 0 ) exp = cst->expected[i] * total_obs / total_expected ; @@ -423,18 +427,18 @@ chisquare_execute (const struct dataset *ds, /* The expected N */ tab_double (freq_table, v * 4 + 3, i + 2 , TAB_NONE, - exp, NULL); + exp, NULL, RC_OTHER); /* The residual */ tab_double (freq_table, v * 4 + 4, i + 2 , TAB_NONE, - ff[i]->count - exp, NULL); + ff[i]->count - exp, NULL, RC_OTHER); xsq[v] += (ff[i]->count - exp) * (ff[i]->count - exp) / exp; } tab_double (freq_table, v * 4 + 2, tab_nr (freq_table) - 1, TAB_NONE, - total_obs, wfmt); + total_obs, NULL, RC_WEIGHT); df[v] = n_cells - 1.0; @@ -458,11 +462,11 @@ chisquare_execute (const struct dataset *ds, tab_text (stats_table, 1 + v, 0, TAB_CENTER, var_get_name (var)); - tab_double (stats_table, 1 + v, 1, TAB_NONE, xsq[v], NULL); - tab_fixed (stats_table, 1 + v, 2, TAB_NONE, df[v], 8, 0); + tab_double (stats_table, 1 + v, 1, TAB_NONE, xsq[v], NULL, RC_OTHER); + tab_double (stats_table, 1 + v, 2, TAB_NONE, df[v], NULL, RC_INTEGER); tab_double (stats_table, 1 + v, 3, TAB_NONE, - gsl_cdf_chisq_Q (xsq[v], df[v]), NULL); + gsl_cdf_chisq_Q (xsq[v], df[v]), NULL, RC_PVALUE); } tab_submit (stats_table); } diff --git a/src/language/stats/cochran.c b/src/language/stats/cochran.c index 869e5f5c83..4274a583de 100644 --- a/src/language/stats/cochran.c +++ b/src/language/stats/cochran.c @@ -154,6 +154,7 @@ show_freqs_box (const struct one_sample_test *ost, const struct cochran *ct) const int column_headers = 2; struct tab_table *table = tab_create (row_headers + 2, column_headers + ost->n_vars); + tab_set_format (table, RC_WEIGHT, wfmt); tab_headers (table, row_headers, 0, column_headers, 0); @@ -184,10 +185,10 @@ show_freqs_box (const struct one_sample_test *ost, const struct cochran *ct) TAB_LEFT, var_to_string (ost->vars[i])); tab_double (table, 1, column_headers + i, 0, - ct->hits[i], wfmt); + ct->hits[i], NULL, RC_WEIGHT); tab_double (table, 2, column_headers + i, 0, - ct->misses[i], wfmt); + ct->misses[i], NULL, RC_WEIGHT); } tab_submit (table); @@ -206,6 +207,9 @@ show_sig_box (const struct cochran *ch) struct tab_table *table = tab_create (row_headers + 1, column_headers + 4); + + tab_set_format (table, RC_WEIGHT, wfmt); + tab_headers (table, row_headers, 0, column_headers, 0); tab_title (table, _("Test Statistics")); @@ -230,17 +234,17 @@ show_sig_box (const struct cochran *ch) tab_vline (table, TAL_2, row_headers, 0, tab_nr (table) - 1); tab_double (table, 1, column_headers, - 0, ch->cc, wfmt); + 0, ch->cc, NULL, RC_WEIGHT); tab_double (table, 1, column_headers + 1, - 0, ch->q, 0); + 0, ch->q, NULL, RC_OTHER); tab_double (table, 1, column_headers + 2, - 0, ch->df, &F_8_0); + 0, ch->df, NULL, RC_INTEGER); tab_double (table, 1, column_headers + 3, 0, gsl_cdf_chisq_Q (ch->q, ch->df), - 0); + NULL, RC_PVALUE); tab_submit (table); } diff --git a/src/language/stats/correlations.c b/src/language/stats/correlations.c index acb12fb322..133eece4f2 100644 --- a/src/language/stats/correlations.c +++ b/src/language/stats/correlations.c @@ -149,7 +149,7 @@ output_descriptives (const struct corr *corr, const gsl_matrix *means, NOT_REACHED (); }; - tab_double (t, c, r + heading_rows, 0, x, NULL); + tab_double (t, c, r + heading_rows, 0, x, NULL, RC_OTHER); } } @@ -188,6 +188,7 @@ output_correlation (const struct corr *corr, const struct corr_opts *opts, nr += heading_rows; t = tab_create (nc, nr); + tab_set_format (t, RC_WEIGHT, wfmt); tab_title (t, _("Correlations")); tab_headers (t, heading_columns, 0, heading_rows, 0); @@ -254,15 +255,15 @@ output_correlation (const struct corr *corr, const struct corr_opts *opts, double sig = opts->tails * significance_of_correlation (pearson, w); if ( opts->missing_type != CORR_LISTWISE ) - tab_double (t, c + heading_columns, row + rows_per_variable - 1, 0, w, wfmt); + tab_double (t, c + heading_columns, row + rows_per_variable - 1, 0, w, NULL, RC_WEIGHT); if ( col_index != r) - tab_double (t, c + heading_columns, row + 1, 0, sig, NULL); + tab_double (t, c + heading_columns, row + 1, 0, sig, NULL, RC_PVALUE); if ( opts->sig && col_index != r && sig < 0.05) flags = TAB_EMPH; - tab_double (t, c + heading_columns, row, flags, pearson, NULL); + tab_double (t, c + heading_columns, row, flags, pearson, NULL, RC_OTHER); if (opts->statistics & STATS_XPROD) { @@ -270,8 +271,8 @@ output_correlation (const struct corr *corr, const struct corr_opts *opts, const double xprod_dev = cov * w; cov *= w / (w - 1.0); - tab_double (t, c + heading_columns, row + 2, 0, xprod_dev, NULL); - tab_double (t, c + heading_columns, row + 3, 0, cov, NULL); + tab_double (t, c + heading_columns, row + 2, 0, xprod_dev, NULL, RC_OTHER); + tab_double (t, c + heading_columns, row + 3, 0, cov, NULL, RC_OTHER); } } } diff --git a/src/language/stats/crosstabs.q b/src/language/stats/crosstabs.q index a017b3c669..d973cdc795 100644 --- a/src/language/stats/crosstabs.q +++ b/src/language/stats/crosstabs.q @@ -867,6 +867,7 @@ make_summary_table (struct crosstabs_proc *proc) int i; summary = tab_create (7, 3 + proc->n_pivots); + tab_set_format (summary, RC_WEIGHT, &proc->weight_format); tab_title (summary, _("Summary.")); tab_headers (summary, 1, 0, 3, 0); tab_joint_text (summary, 1, 0, 6, 0, TAB_CENTER, _("Cases")); @@ -911,8 +912,7 @@ make_summary_table (struct crosstabs_proc *proc) n[2] = n[0] + n[1]; for (i = 0; i < 3; i++) { - tab_double (summary, i * 2 + 1, 0, TAB_RIGHT, n[i], - &proc->weight_format); + tab_double (summary, i * 2 + 1, 0, TAB_RIGHT, n[i], NULL, RC_WEIGHT); tab_text_format (summary, i * 2 + 2, 0, TAB_RIGHT, "%.1f%%", n[i] / n[2] * 100.); } @@ -928,10 +928,10 @@ make_summary_table (struct crosstabs_proc *proc) static struct tab_table *create_crosstab_table (struct crosstabs_proc *, struct pivot_table *); -static struct tab_table *create_chisq_table (struct pivot_table *); -static struct tab_table *create_sym_table (struct pivot_table *); -static struct tab_table *create_risk_table (struct pivot_table *); -static struct tab_table *create_direct_table (struct pivot_table *); +static struct tab_table *create_chisq_table (struct crosstabs_proc *proc, struct pivot_table *); +static struct tab_table *create_sym_table (struct crosstabs_proc *proc, struct pivot_table *); +static struct tab_table *create_risk_table (struct crosstabs_proc *proc, struct pivot_table *); +static struct tab_table *create_direct_table (struct crosstabs_proc *proc, struct pivot_table *); static void display_dimensions (struct crosstabs_proc *, struct pivot_table *, struct tab_table *, int first_difference); static void display_crosstabulation (struct crosstabs_proc *, @@ -987,17 +987,17 @@ output_pivot_table (struct crosstabs_proc *proc, struct pivot_table *pt) if (proc->cells) table = create_crosstab_table (proc, pt); if (proc->statistics & (1u << CRS_ST_CHISQ)) - chisq = create_chisq_table (pt); + chisq = create_chisq_table (proc, pt); if (proc->statistics & ((1u << CRS_ST_PHI) | (1u << CRS_ST_CC) | (1u << CRS_ST_BTAU) | (1u << CRS_ST_CTAU) | (1u << CRS_ST_GAMMA) | (1u << CRS_ST_CORR) | (1u << CRS_ST_KAPPA))) - sym = create_sym_table (pt); + sym = create_sym_table (proc, pt); if (proc->statistics & (1u << CRS_ST_RISK)) - risk = create_risk_table (pt); + risk = create_risk_table (proc, pt); if (proc->statistics & ((1u << CRS_ST_LAMBDA) | (1u << CRS_ST_UC) | (1u << CRS_ST_D) | (1u << CRS_ST_ETA))) - direct = create_direct_table (pt); + direct = create_direct_table (proc, pt); row0 = row1 = 0; while (find_crosstab (pt, &row0, &row1)) @@ -1198,6 +1198,7 @@ create_crosstab_table (struct crosstabs_proc *proc, struct pivot_table *pt) table = tab_create (x.n_consts + 1 + x.n_cols + 1, (x.n_entries / x.n_cols) * 3 / 2 * proc->n_cells + 10); tab_headers (table, x.n_consts + 1, 0, 2, 0); + tab_set_format (table, RC_WEIGHT, &proc->weight_format); /* First header line. */ tab_joint_text (table, x.n_consts + 1, 0, @@ -1263,13 +1264,14 @@ create_crosstab_table (struct crosstabs_proc *proc, struct pivot_table *pt) } static struct tab_table * -create_chisq_table (struct pivot_table *pt) +create_chisq_table (struct crosstabs_proc *proc, struct pivot_table *pt) { struct tab_table *chisq; chisq = tab_create (6 + (pt->n_vars - 2), pt->n_entries / pt->n_cols * 3 / 2 * N_CHISQ + 10); tab_headers (chisq, 1 + (pt->n_vars - 2), 0, 1, 0); + tab_set_format (chisq, RC_WEIGHT, &proc->weight_format); tab_title (chisq, _("Chi-square tests.")); @@ -1290,12 +1292,15 @@ create_chisq_table (struct pivot_table *pt) /* Symmetric measures. */ static struct tab_table * -create_sym_table (struct pivot_table *pt) +create_sym_table (struct crosstabs_proc *proc, struct pivot_table *pt) { struct tab_table *sym; sym = tab_create (6 + (pt->n_vars - 2), pt->n_entries / pt->n_cols * 7 + 10); + + tab_set_format (sym, RC_WEIGHT, &proc->weight_format); + tab_headers (sym, 2 + (pt->n_vars - 2), 0, 1, 0); tab_title (sym, _("Symmetric measures.")); @@ -1313,13 +1318,14 @@ create_sym_table (struct pivot_table *pt) /* Risk estimate. */ static struct tab_table * -create_risk_table (struct pivot_table *pt) +create_risk_table (struct crosstabs_proc *proc, struct pivot_table *pt) { struct tab_table *risk; risk = tab_create (4 + (pt->n_vars - 2), pt->n_entries / pt->n_cols * 4 + 10); tab_headers (risk, 1 + pt->n_vars - 2, 0, 2, 0); tab_title (risk, _("Risk estimate.")); + tab_set_format (risk, RC_WEIGHT, &proc->weight_format); tab_offset (risk, pt->n_vars - 2, 0); tab_joint_text_format (risk, 2, 0, 3, 0, TAB_CENTER | TAT_TITLE, @@ -1337,7 +1343,7 @@ create_risk_table (struct pivot_table *pt) /* Directional measures. */ static struct tab_table * -create_direct_table (struct pivot_table *pt) +create_direct_table (struct crosstabs_proc *proc, struct pivot_table *pt) { struct tab_table *direct; @@ -1345,6 +1351,7 @@ create_direct_table (struct pivot_table *pt) pt->n_entries / pt->n_cols * 7 + 10); tab_headers (direct, 3 + (pt->n_vars - 2), 0, 1, 0); tab_title (direct, _("Directional measures.")); + tab_set_format (direct, RC_WEIGHT, &proc->weight_format); tab_offset (direct, pt->n_vars - 2, 0); tab_text (direct, 0, 0, TAB_LEFT | TAT_TITLE, _("Category")); @@ -1807,22 +1814,22 @@ display_chisq (struct pivot_table *pt, struct tab_table *chisq, tab_text (chisq, 0, 0, TAB_LEFT, gettext (chisq_stats[i])); if (i != 2) { - tab_double (chisq, 1, 0, TAB_RIGHT, chisq_v[i], NULL); - tab_double (chisq, 2, 0, TAB_RIGHT, df[i], &pt->weight_format); + tab_double (chisq, 1, 0, TAB_RIGHT, chisq_v[i], NULL, RC_OTHER); + tab_double (chisq, 2, 0, TAB_RIGHT, df[i], NULL, RC_WEIGHT); tab_double (chisq, 3, 0, TAB_RIGHT, - gsl_cdf_chisq_Q (chisq_v[i], df[i]), NULL); + gsl_cdf_chisq_Q (chisq_v[i], df[i]), NULL, RC_PVALUE); } else { *showed_fisher = true; - tab_double (chisq, 4, 0, TAB_RIGHT, fisher2, NULL); - tab_double (chisq, 5, 0, TAB_RIGHT, fisher1, NULL); + tab_double (chisq, 4, 0, TAB_RIGHT, fisher2, NULL, RC_PVALUE); + tab_double (chisq, 5, 0, TAB_RIGHT, fisher1, NULL, RC_PVALUE); } tab_next_row (chisq); } tab_text (chisq, 0, 0, TAB_LEFT, _("N of Valid Cases")); - tab_double (chisq, 1, 0, TAB_RIGHT, pt->total, &pt->weight_format); + tab_double (chisq, 1, 0, TAB_RIGHT, pt->total, NULL, RC_WEIGHT); tab_next_row (chisq); tab_offset (chisq, 0, -1); @@ -1887,17 +1894,17 @@ display_symmetric (struct crosstabs_proc *proc, struct pivot_table *pt, } tab_text (sym, 1, 0, TAB_LEFT, gettext (stats[i])); - tab_double (sym, 2, 0, TAB_RIGHT, sym_v[i], NULL); + tab_double (sym, 2, 0, TAB_RIGHT, sym_v[i], NULL, RC_OTHER); if (sym_ase[i] != SYSMIS) - tab_double (sym, 3, 0, TAB_RIGHT, sym_ase[i], NULL); + tab_double (sym, 3, 0, TAB_RIGHT, sym_ase[i], NULL, RC_OTHER); if (sym_t[i] != SYSMIS) - tab_double (sym, 4, 0, TAB_RIGHT, sym_t[i], NULL); - /*tab_double (sym, 5, 0, TAB_RIGHT, normal_sig (sym_v[i]), NULL);*/ + tab_double (sym, 4, 0, TAB_RIGHT, sym_t[i], NULL, RC_OTHER); + /*tab_double (sym, 5, 0, TAB_RIGHT, normal_sig (sym_v[i]), NULL, RC_PVALUE);*/ tab_next_row (sym); } tab_text (sym, 0, 0, TAB_LEFT, _("N of Valid Cases")); - tab_double (sym, 2, 0, TAB_RIGHT, pt->total, &pt->weight_format); + tab_double (sym, 2, 0, TAB_RIGHT, pt->total, NULL, RC_WEIGHT); tab_next_row (sym); tab_offset (sym, 0, -1); @@ -1955,14 +1962,14 @@ display_risk (struct pivot_table *pt, struct tab_table *risk) } tab_text (risk, 0, 0, TAB_LEFT, buf); - tab_double (risk, 1, 0, TAB_RIGHT, risk_v[i], NULL); - tab_double (risk, 2, 0, TAB_RIGHT, lower[i], NULL); - tab_double (risk, 3, 0, TAB_RIGHT, upper[i], NULL); + tab_double (risk, 1, 0, TAB_RIGHT, risk_v[i], NULL, RC_OTHER); + tab_double (risk, 2, 0, TAB_RIGHT, lower[i], NULL, RC_OTHER); + tab_double (risk, 3, 0, TAB_RIGHT, upper[i], NULL, RC_OTHER); tab_next_row (risk); } tab_text (risk, 0, 0, TAB_LEFT, _("N of Valid Cases")); - tab_double (risk, 1, 0, TAB_RIGHT, pt->total, &pt->weight_format); + tab_double (risk, 1, 0, TAB_RIGHT, pt->total, NULL, RC_WEIGHT); tab_next_row (risk); tab_offset (risk, 0, -1); @@ -2077,12 +2084,12 @@ display_directional (struct crosstabs_proc *proc, struct pivot_table *pt, } } - tab_double (direct, 3, 0, TAB_RIGHT, direct_v[i], NULL); + tab_double (direct, 3, 0, TAB_RIGHT, direct_v[i], NULL, RC_OTHER); if (direct_ase[i] != SYSMIS) - tab_double (direct, 4, 0, TAB_RIGHT, direct_ase[i], NULL); + tab_double (direct, 4, 0, TAB_RIGHT, direct_ase[i], NULL, RC_OTHER); if (direct_t[i] != SYSMIS) - tab_double (direct, 5, 0, TAB_RIGHT, direct_t[i], NULL); - /*tab_double (direct, 6, 0, TAB_RIGHT, normal_sig (direct_v[i]), NULL);*/ + tab_double (direct, 5, 0, TAB_RIGHT, direct_t[i], NULL, RC_OTHER); + /*tab_double (direct, 6, 0, TAB_RIGHT, normal_sig (direct_v[i]), NULL, RC_PVALUE);*/ tab_next_row (direct); } diff --git a/src/language/stats/descriptives.c b/src/language/stats/descriptives.c index beb5ec0b41..1ffe861552 100644 --- a/src/language/stats/descriptives.c +++ b/src/language/stats/descriptives.c @@ -1044,7 +1044,7 @@ display (struct dsc_proc *dsc) for (j = 0; j < DSC_N_STATS; j++) if (dsc->show_stats & (1ul << j)) - tab_double (t, nc++, i + 1, TAB_NONE, dv->stats[j], NULL); + tab_double (t, nc++, i + 1, TAB_NONE, dv->stats[j], NULL, RC_OTHER); } tab_title (t, _("Valid cases = %.*g; cases with missing value(s) = %.*g."), diff --git a/src/language/stats/examine.c b/src/language/stats/examine.c index f4f49f329f..6ab64897e9 100644 --- a/src/language/stats/examine.c +++ b/src/language/stats/examine.c @@ -605,6 +605,7 @@ percentiles_report (const struct examine *cmd, int iact_idx) const int nc = heading_columns + cmd->n_percentiles; t = tab_create (nc, nr); + tab_title (t, _("Percentiles")); tab_headers (t, heading_columns, 0, heading_rows, 0); @@ -724,7 +725,7 @@ percentiles_report (const struct examine *cmd, int iact_idx) heading_rows + v * rows_per_var + i * rows_per_cat, 0, percentile_calculate (es->percentiles[p], cmd->pc_alg), - 0); + NULL, RC_OTHER); if (cmd->ptiles[p] == 25.0) { @@ -732,7 +733,7 @@ percentiles_report (const struct examine *cmd, int iact_idx) heading_rows + v * rows_per_var + i * rows_per_cat + 1, 0, hinges[0], - 0); + NULL, RC_OTHER); } else if (cmd->ptiles[p] == 50.0) { @@ -740,7 +741,7 @@ percentiles_report (const struct examine *cmd, int iact_idx) heading_rows + v * rows_per_var + i * rows_per_cat + 1, 0, hinges[1], - 0); + NULL, RC_OTHER); } else if (cmd->ptiles[p] == 75.0) { @@ -748,7 +749,7 @@ percentiles_report (const struct examine *cmd, int iact_idx) heading_rows + v * rows_per_var + i * rows_per_cat + 1, 0, hinges[2], - 0); + NULL, RC_OTHER); } } @@ -784,6 +785,7 @@ descriptives_report (const struct examine *cmd, int iact_idx) const int nc = 2 + heading_columns; t = tab_create (nc, nr); + tab_title (t, _("Descriptives")); tab_headers (t, heading_columns, 0, heading_rows, 0); @@ -889,12 +891,12 @@ descriptives_report (const struct examine *cmd, int iact_idx) tab_double (t, 1 + iact->n_vars + 2, heading_rows + v * rows_per_var + i * rows_per_cat, - 0, m1, 0); + 0, m1, NULL, RC_OTHER); tab_double (t, 1 + iact->n_vars + 3, heading_rows + v * rows_per_var + i * rows_per_cat, - 0, calc_semean (m2, m0), 0); + 0, calc_semean (m2, m0), NULL, RC_OTHER); tab_text_format (t, 1 + iact->n_vars, @@ -914,7 +916,7 @@ descriptives_report (const struct examine *cmd, int iact_idx) tab_double (t, 1 + iact->n_vars + 2, heading_rows + v * rows_per_var + i * rows_per_cat + 1, - 0, m1 - tval * calc_semean (m2, m0), 0); + 0, m1 - tval * calc_semean (m2, m0), NULL, RC_OTHER); tab_text (t, @@ -927,7 +929,7 @@ descriptives_report (const struct examine *cmd, int iact_idx) tab_double (t, 1 + iact->n_vars + 2, heading_rows + v * rows_per_var + i * rows_per_cat + 2, - 0, m1 + tval * calc_semean (m2, m0), 0); + 0, m1 + tval * calc_semean (m2, m0), NULL, RC_OTHER); tab_text (t, @@ -942,7 +944,7 @@ descriptives_report (const struct examine *cmd, int iact_idx) heading_rows + v * rows_per_var + i * rows_per_cat + 3, 0, trimmed_mean_calculate (es->trimmed_mean), - 0); + NULL, RC_OTHER); tab_text (t, 1 + iact->n_vars, @@ -956,7 +958,7 @@ descriptives_report (const struct examine *cmd, int iact_idx) heading_rows + v * rows_per_var + i * rows_per_cat + 4, 0, percentile_calculate (es->quartiles[1], cmd->pc_alg), - 0); + NULL, RC_OTHER); tab_text (t, @@ -969,7 +971,7 @@ descriptives_report (const struct examine *cmd, int iact_idx) tab_double (t, 1 + iact->n_vars + 2, heading_rows + v * rows_per_var + i * rows_per_cat + 5, - 0, m2, 0); + 0, m2, NULL, RC_OTHER); tab_text (t, 1 + iact->n_vars, @@ -981,7 +983,7 @@ descriptives_report (const struct examine *cmd, int iact_idx) tab_double (t, 1 + iact->n_vars + 2, heading_rows + v * rows_per_var + i * rows_per_cat + 6, - 0, sqrt (m2), 0); + 0, sqrt (m2), NULL, RC_OTHER); tab_text (t, 1 + iact->n_vars, @@ -995,7 +997,7 @@ descriptives_report (const struct examine *cmd, int iact_idx) heading_rows + v * rows_per_var + i * rows_per_cat + 7, 0, es->minima[0].val, - 0); + NULL, RC_OTHER); tab_text (t, 1 + iact->n_vars, @@ -1009,7 +1011,7 @@ descriptives_report (const struct examine *cmd, int iact_idx) heading_rows + v * rows_per_var + i * rows_per_cat + 8, 0, es->maxima[0].val, - 0); + NULL, RC_OTHER); tab_text (t, 1 + iact->n_vars, @@ -1023,7 +1025,7 @@ descriptives_report (const struct examine *cmd, int iact_idx) heading_rows + v * rows_per_var + i * rows_per_cat + 9, 0, es->maxima[0].val - es->minima[0].val, - 0); + NULL, RC_OTHER); tab_text (t, 1 + iact->n_vars, @@ -1039,7 +1041,7 @@ descriptives_report (const struct examine *cmd, int iact_idx) 0, percentile_calculate (es->quartiles[2], cmd->pc_alg) - percentile_calculate (es->quartiles[0], cmd->pc_alg), - 0); + NULL, RC_OTHER); @@ -1054,12 +1056,12 @@ descriptives_report (const struct examine *cmd, int iact_idx) tab_double (t, 1 + iact->n_vars + 2, heading_rows + v * rows_per_var + i * rows_per_cat + 11, - 0, m3, 0); + 0, m3, NULL, RC_OTHER); tab_double (t, 1 + iact->n_vars + 3, heading_rows + v * rows_per_var + i * rows_per_cat + 11, - 0, calc_seskew (m0), 0); + 0, calc_seskew (m0), NULL, RC_OTHER); tab_text (t, 1 + iact->n_vars, @@ -1071,12 +1073,12 @@ descriptives_report (const struct examine *cmd, int iact_idx) tab_double (t, 1 + iact->n_vars + 2, heading_rows + v * rows_per_var + i * rows_per_cat + 12, - 0, m4, 0); + 0, m4, NULL, RC_OTHER); tab_double (t, 1 + iact->n_vars + 3, heading_rows + v * rows_per_var + i * rows_per_cat + 12, - 0, calc_sekurt (m0), 0); + 0, calc_sekurt (m0), NULL, RC_OTHER); } free (prev_val); @@ -1103,6 +1105,7 @@ extremes_report (const struct examine *cmd, int iact_idx) const int nc = 2 + heading_columns; t = tab_create (nc, nr); + tab_title (t, _("Extreme Values")); tab_headers (t, heading_columns, 0, heading_rows, 0); @@ -1219,7 +1222,7 @@ extremes_report (const struct examine *cmd, int iact_idx) heading_rows + v * rows_per_var + i * rows_per_cat + e, TAB_RIGHT, e + 1, - &F_8_0); + NULL, RC_INTEGER); /* The casenumber */ if (cmd->id_var) @@ -1236,14 +1239,14 @@ extremes_report (const struct examine *cmd, int iact_idx) heading_rows + v * rows_per_var + i * rows_per_cat + e, TAB_RIGHT, es->maxima[e].identity.f, - &F_8_0); + NULL, RC_INTEGER); tab_double (t, heading_columns + 1, heading_rows + v * rows_per_var + i * rows_per_cat + e, 0, es->maxima[e].val, - var_get_print_format (cmd->dep_vars[v])); + var_get_print_format (cmd->dep_vars[v]), RC_OTHER); tab_double (t, @@ -1251,7 +1254,7 @@ extremes_report (const struct examine *cmd, int iact_idx) heading_rows + v * rows_per_var + i * rows_per_cat + cmd->disp_extremes + e, TAB_RIGHT, e + 1, - &F_8_0); + NULL, RC_INTEGER); /* The casenumber */ if (cmd->id_var) @@ -1268,14 +1271,14 @@ extremes_report (const struct examine *cmd, int iact_idx) heading_rows + v * rows_per_var + i * rows_per_cat + cmd->disp_extremes + e, TAB_RIGHT, es->minima[e].identity.f, - &F_8_0); + NULL, RC_INTEGER); tab_double (t, heading_columns + 1, heading_rows + v * rows_per_var + i * rows_per_cat + cmd->disp_extremes + e, 0, es->minima[e].val, - var_get_print_format (cmd->dep_vars[v])); + var_get_print_format (cmd->dep_vars[v]), RC_OTHER); } } free (prev_val); @@ -1302,6 +1305,7 @@ summary_report (const struct examine *cmd, int iact_idx) const int nc = 6 + heading_columns; t = tab_create (nc, nr); + tab_set_format (t, RC_WEIGHT, wfmt); tab_title (t, _("Case Processing Summary")); tab_headers (t, heading_columns, 0, heading_rows, 0); @@ -1416,7 +1420,7 @@ summary_report (const struct examine *cmd, int iact_idx) heading_rows + n_cats * v + i, 0, es[v].non_missing, - wfmt); + NULL, RC_WEIGHT); tab_text_format (t, @@ -1433,7 +1437,7 @@ summary_report (const struct examine *cmd, int iact_idx) heading_rows + n_cats * v + i, 0, es[v].missing, - wfmt); + NULL, RC_WEIGHT); tab_text_format (t, heading_columns + 3, @@ -1447,7 +1451,7 @@ summary_report (const struct examine *cmd, int iact_idx) heading_rows + n_cats * v + i, 0, total, - wfmt); + NULL, RC_WEIGHT); /* This can only be 100% can't it? */ tab_text_format (t, diff --git a/src/language/stats/factor.c b/src/language/stats/factor.c index 1ab2618dfe..4094a22b43 100644 --- a/src/language/stats/factor.c +++ b/src/language/stats/factor.c @@ -1323,10 +1323,10 @@ show_communalities (const struct cmd_factor * factor, tab_text (t, c++, i + heading_rows, TAT_TITLE, var_to_string (factor->vars[i])); if (factor->print & PRINT_INITIAL) - tab_double (t, c++, i + heading_rows, 0, gsl_vector_get (initial, i), NULL); + tab_double (t, c++, i + heading_rows, 0, gsl_vector_get (initial, i), NULL, RC_OTHER); if (factor->print & PRINT_EXTRACTION) - tab_double (t, c++, i + heading_rows, 0, gsl_vector_get (extracted, i), NULL); + tab_double (t, c++, i + heading_rows, 0, gsl_vector_get (extracted, i), NULL, RC_OTHER); } tab_submit (t); @@ -1415,7 +1415,7 @@ show_factor_matrix (const struct cmd_factor *factor, struct idata *idata, const if ( fabs (x) < factor->blank) continue; - tab_double (t, heading_columns + j, heading_rows + i, 0, x, NULL); + tab_double (t, heading_columns + j, heading_rows + i, 0, x, NULL, RC_OTHER); } } @@ -1552,9 +1552,9 @@ show_explained_variance (const struct cmd_factor * factor, struct idata *idata, /* Initial Eigenvalues */ if (factor->print & PRINT_INITIAL) { - tab_double (t, c++, i + heading_rows, 0, i_lambda, NULL); - tab_double (t, c++, i + heading_rows, 0, i_percent, NULL); - tab_double (t, c++, i + heading_rows, 0, i_cum, NULL); + tab_double (t, c++, i + heading_rows, 0, i_lambda, NULL, RC_OTHER); + tab_double (t, c++, i + heading_rows, 0, i_percent, NULL, RC_OTHER); + tab_double (t, c++, i + heading_rows, 0, i_cum, NULL, RC_OTHER); } @@ -1563,9 +1563,9 @@ show_explained_variance (const struct cmd_factor * factor, struct idata *idata, if (i < idata->n_extractions) { /* Sums of squared loadings */ - tab_double (t, c++, i + heading_rows, 0, e_lambda, NULL); - tab_double (t, c++, i + heading_rows, 0, e_percent, NULL); - tab_double (t, c++, i + heading_rows, 0, e_cum, NULL); + tab_double (t, c++, i + heading_rows, 0, e_lambda, NULL, RC_OTHER); + tab_double (t, c++, i + heading_rows, 0, e_percent, NULL, RC_OTHER); + tab_double (t, c++, i + heading_rows, 0, e_cum, NULL, RC_OTHER); } } @@ -1579,9 +1579,9 @@ show_explained_variance (const struct cmd_factor * factor, struct idata *idata, if (i < idata->n_extractions) { r_cum += r_percent; - tab_double (t, c++, i + heading_rows, 0, r_lambda, NULL); - tab_double (t, c++, i + heading_rows, 0, r_percent, NULL); - tab_double (t, c++, i + heading_rows, 0, r_cum, NULL); + tab_double (t, c++, i + heading_rows, 0, r_lambda, NULL, RC_OTHER); + tab_double (t, c++, i + heading_rows, 0, r_percent, NULL, RC_OTHER); + tab_double (t, c++, i + heading_rows, 0, r_cum, NULL, RC_OTHER); } } } @@ -1679,7 +1679,7 @@ show_correlation_matrix (const struct cmd_factor *factor, const struct idata *id for (i = 0; i < factor->n_vars; ++i) { for (j = 0; j < factor->n_vars; ++j) - tab_double (t, heading_columns + i, y + j, 0, gsl_matrix_get (idata->corr, i, j), NULL); + tab_double (t, heading_columns + i, y + j, 0, gsl_matrix_get (idata->corr, i, j), NULL, RC_OTHER); } } @@ -1698,7 +1698,7 @@ show_correlation_matrix (const struct cmd_factor *factor, const struct idata *id if (i == j) continue; - tab_double (t, heading_columns + i, y + j, 0, significance_of_correlation (rho, w), NULL); + tab_double (t, heading_columns + i, y + j, 0, significance_of_correlation (rho, w), NULL, RC_PVALUE); } } } @@ -1708,7 +1708,7 @@ show_correlation_matrix (const struct cmd_factor *factor, const struct idata *id { tab_text (t, 0, nr, TAB_LEFT | TAT_TITLE, _("Determinant")); - tab_double (t, 1, nr, 0, idata->detR, NULL); + tab_double (t, 1, nr, 0, idata->detR, NULL, RC_OTHER); } tab_submit (t); @@ -1786,6 +1786,7 @@ do_factor (const struct cmd_factor *factor, struct casereader *r) const int nr = heading_rows + factor->n_vars; struct tab_table *t = tab_create (nc, nr); + tab_set_format (t, RC_WEIGHT, wfmt); tab_title (t, _("Descriptive Statistics")); tab_headers (t, heading_columns, 0, heading_rows, 0); @@ -1816,9 +1817,9 @@ do_factor (const struct cmd_factor *factor, struct casereader *r) const struct variable *v = factor->vars[i]; tab_text (t, 0, i + heading_rows, TAB_LEFT | TAT_TITLE, var_to_string (v)); - tab_double (t, 1, i + heading_rows, 0, gsl_matrix_get (mean_matrix, i, i), NULL); - tab_double (t, 2, i + heading_rows, 0, sqrt (gsl_matrix_get (var_matrix, i, i)), NULL); - tab_double (t, 3, i + heading_rows, 0, gsl_matrix_get (idata->n, i, i), wfmt); + tab_double (t, 1, i + heading_rows, 0, gsl_matrix_get (mean_matrix, i, i), NULL, RC_OTHER); + tab_double (t, 2, i + heading_rows, 0, sqrt (gsl_matrix_get (var_matrix, i, i)), NULL, RC_OTHER); + tab_double (t, 3, i + heading_rows, 0, gsl_matrix_get (idata->n, i, i), NULL, RC_WEIGHT); } tab_submit (t); @@ -1876,7 +1877,7 @@ do_factor (const struct cmd_factor *factor, struct casereader *r) 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_double (t, 2, 0, 0, sum_ssq_r / (sum_ssq_r + sum_ssq_a), NULL, RC_OTHER); tab_text (t, 0, 1, TAT_TITLE | TAB_LEFT, _("Bartlett's Test of Sphericity")); @@ -1896,9 +1897,9 @@ do_factor (const struct cmd_factor *factor, struct casereader *r) 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_double (t, 2, 1, 0, xsq, NULL, RC_OTHER); + tab_double (t, 2, 2, 0, df, NULL, RC_INTEGER); + tab_double (t, 2, 3, 0, gsl_cdf_chisq_Q (xsq, df), NULL, RC_PVALUE); tab_submit (t); diff --git a/src/language/stats/frequencies.c b/src/language/stats/frequencies.c index 7bda6a13e0..7cd604c1f6 100644 --- a/src/language/stats/frequencies.c +++ b/src/language/stats/frequencies.c @@ -286,6 +286,7 @@ dump_freq_table (const struct var_freqs *vf, const struct variable *wv) n_categories = ft->n_valid + ft->n_missing; t = tab_create (6, n_categories + 2); + tab_set_format (t, RC_WEIGHT, wfmt); tab_headers (t, 0, 0, 1, 0); for (x = 0; x < 6; x++) @@ -308,10 +309,10 @@ dump_freq_table (const struct var_freqs *vf, const struct variable *wv) tab_text (t, 0, r, TAB_LEFT, label); tab_value (t, 1, r, TAB_NONE, &f->value, vf->var, NULL); - tab_double (t, 2, r, TAB_NONE, f->count, wfmt); - tab_double (t, 3, r, TAB_NONE, percent, NULL); - tab_double (t, 4, r, TAB_NONE, valid_percent, NULL); - tab_double (t, 5, r, TAB_NONE, cum_total, NULL); + tab_double (t, 2, r, TAB_NONE, f->count, NULL, RC_WEIGHT); + tab_double (t, 3, r, TAB_NONE, percent, NULL, RC_OTHER); + tab_double (t, 4, r, TAB_NONE, valid_percent, NULL, RC_OTHER); + tab_double (t, 5, r, TAB_NONE, cum_total, NULL, RC_OTHER); r++; } for (; f < &ft->valid[n_categories]; f++) @@ -325,9 +326,9 @@ dump_freq_table (const struct var_freqs *vf, const struct variable *wv) tab_text (t, 0, r, TAB_LEFT, label); tab_value (t, 1, r, TAB_NONE, &f->value, vf->var, NULL); - tab_double (t, 2, r, TAB_NONE, f->count, wfmt); + tab_double (t, 2, r, TAB_NONE, f->count, NULL, RC_WEIGHT); tab_double (t, 3, r, TAB_NONE, - f->count / ft->total_cases * 100.0, NULL); + f->count / ft->total_cases * 100.0, NULL, RC_OTHER); tab_text (t, 4, r, TAB_NONE, _("Missing")); r++; } @@ -337,9 +338,9 @@ dump_freq_table (const struct var_freqs *vf, const struct variable *wv) tab_hline (t, TAL_2, 0, 5, r); tab_joint_text (t, 0, r, 1, r, TAB_RIGHT | TAT_TITLE, _("Total")); tab_vline (t, TAL_0, 1, r, r); - tab_double (t, 2, r, TAB_NONE, cum_freq, wfmt); - tab_fixed (t, 3, r, TAB_NONE, 100.0, 5, 1); - tab_fixed (t, 4, r, TAB_NONE, 100.0, 5, 1); + tab_double (t, 2, r, TAB_NONE, cum_freq, NULL, RC_WEIGHT); + tab_double (t, 3, r, TAB_NONE, 100.0, &F_5_1, RC_OTHER); + tab_double (t, 4, r, TAB_NONE, 100.0, &F_5_1, RC_OTHER); tab_title (t, "%s", var_to_string (vf->var)); tab_submit (t); @@ -1364,7 +1365,7 @@ dump_statistics (const struct frq_proc *frq, const struct var_freqs *vf, t = tab_create (3, ((frq->stats & FRQ_ST_MEDIAN) ? frq->n_stats - 1 : frq->n_stats) + frq->n_show_percentiles + 2); - + tab_set_format (t, RC_WEIGHT, wfmt); tab_box (t, TAL_1, TAL_1, -1, -1 , 0 , 0 , 2, tab_nr(t) - 1) ; @@ -1382,7 +1383,7 @@ dump_statistics (const struct frq_proc *frq, const struct var_freqs *vf, { tab_text (t, 0, r, TAB_LEFT | TAT_TITLE, gettext (st_name[i])); - tab_double (t, 2, r, TAB_NONE, stat_value[i], NULL); + tab_double (t, 2, r, TAB_NONE, stat_value[i], NULL, RC_OTHER); r++; } } @@ -1391,8 +1392,8 @@ dump_statistics (const struct frq_proc *frq, const struct var_freqs *vf, tab_text (t, 1, 0, TAB_LEFT | TAT_TITLE, _("Valid")); tab_text (t, 1, 1, TAB_LEFT | TAT_TITLE, _("Missing")); - tab_double (t, 2, 0, TAB_NONE, ft->valid_cases, wfmt); - tab_double (t, 2, 1, TAB_NONE, ft->total_cases - ft->valid_cases, wfmt); + tab_double (t, 2, 0, TAB_NONE, ft->valid_cases, NULL, RC_WEIGHT); + tab_double (t, 2, 1, TAB_NONE, ft->total_cases - ft->valid_cases, NULL, RC_WEIGHT); for (i = 0; i < frq->n_percentiles; i++) { @@ -1409,9 +1410,9 @@ dump_statistics (const struct frq_proc *frq, const struct var_freqs *vf, if (pc->p == 0.5) tab_text (t, 1, r, TAB_LEFT, _("50 (Median)")); else - tab_fixed (t, 1, r, TAB_LEFT, pc->p * 100, 3, 0); + tab_double (t, 1, r, TAB_LEFT, pc->p * 100, NULL, RC_INTEGER); tab_double (t, 2, r, TAB_NONE, pc->value, - var_get_print_format (vf->var)); + var_get_print_format (vf->var), RC_OTHER); r++; } diff --git a/src/language/stats/friedman.c b/src/language/stats/friedman.c index 5ef3083f62..03a3e65e55 100644 --- a/src/language/stats/friedman.c +++ b/src/language/stats/friedman.c @@ -246,7 +246,7 @@ show_ranks_box (const struct one_sample_test *ost, const struct friedman *fr) TAB_LEFT, var_to_string (ost->vars[i])); tab_double (table, 1, row_headers + i, - 0, fr->rank_sum[i] / fr->cc, 0); + 0, fr->rank_sum[i] / fr->cc, NULL, RC_OTHER); } tab_submit (table); @@ -266,6 +266,7 @@ show_sig_box (const struct one_sample_test *ost, const struct friedman *fr) const int column_headers = 0; struct tab_table *table = tab_create (row_headers + 1, column_headers + (ft->kendalls_w ? 5 : 4)); + tab_set_format (table, RC_WEIGHT, wfmt); tab_headers (table, row_headers, 0, column_headers, 0); @@ -297,21 +298,21 @@ show_sig_box (const struct one_sample_test *ost, const struct friedman *fr) row = 0; tab_double (table, 1, column_headers + row++, - 0, fr->cc, wfmt); + 0, fr->cc, NULL, RC_WEIGHT); if (ft->kendalls_w) tab_double (table, 1, column_headers + row++, - 0, fr->w, 0); + 0, fr->w, NULL, RC_OTHER); tab_double (table, 1, column_headers + row++, - 0, fr->chi_sq, 0); + 0, fr->chi_sq, NULL, RC_OTHER); tab_double (table, 1, column_headers + row++, - 0, ost->n_vars - 1, &F_8_0); + 0, ost->n_vars - 1, NULL, RC_INTEGER); tab_double (table, 1, column_headers + row++, 0, gsl_cdf_chisq_Q (fr->chi_sq, ost->n_vars - 1), - 0); + NULL, RC_PVALUE); tab_submit (table); } diff --git a/src/language/stats/glm.c b/src/language/stats/glm.c index 13d878176e..e4b3c17b21 100644 --- a/src/language/stats/glm.c +++ b/src/language/stats/glm.c @@ -732,6 +732,7 @@ output_glm (const struct glm_spec *cmd, const struct glm_workspace *ws) msg (MW, "GLM is experimental. Do not rely on these results."); t = tab_create (nc, nr); + tab_set_format (t, RC_WEIGHT, wfmt); tab_title (t, _("Tests of Between-Subjects Effects")); tab_headers (t, heading_columns, 0, heading_rows, 0); @@ -774,12 +775,12 @@ output_glm (const struct glm_spec *cmd, const struct glm_workspace *ws) const double df = 1.0; const double F = intercept_ssq / df / mse; tab_text (t, 0, r, TAB_LEFT | TAT_TITLE, _("Intercept")); - tab_double (t, 1, r, 0, intercept_ssq, NULL); - tab_double (t, 2, r, 0, 1.00, wfmt); - tab_double (t, 3, r, 0, intercept_ssq / df, NULL); - tab_double (t, 4, r, 0, F, NULL); + tab_double (t, 1, r, 0, intercept_ssq, NULL, RC_OTHER); + tab_double (t, 2, r, 0, 1.00, NULL, RC_WEIGHT); + tab_double (t, 3, r, 0, intercept_ssq / df, NULL, RC_OTHER); + tab_double (t, 4, r, 0, F, NULL, RC_OTHER); tab_double (t, 5, r, 0, gsl_cdf_fdist_Q (F, df, n_total - df_corr), - NULL); + NULL, RC_PVALUE); r++; } @@ -804,13 +805,13 @@ output_glm (const struct glm_spec *cmd, const struct glm_workspace *ws) tab_text (t, 0, r, TAB_LEFT | TAT_TITLE, ds_cstr (&str)); ds_destroy (&str); - tab_double (t, 1, r, 0, ssq, NULL); - tab_double (t, 2, r, 0, df, wfmt); - tab_double (t, 3, r, 0, ssq / df, NULL); - tab_double (t, 4, r, 0, F, NULL); + tab_double (t, 1, r, 0, ssq, NULL, RC_OTHER); + tab_double (t, 2, r, 0, df, NULL, RC_WEIGHT); + tab_double (t, 3, r, 0, ssq / df, NULL, RC_OTHER); + tab_double (t, 4, r, 0, F, NULL, RC_OTHER); tab_double (t, 5, r, 0, gsl_cdf_fdist_Q (F, df, n_total - df_corr), - NULL); + NULL, RC_PVALUE); r++; } @@ -826,13 +827,13 @@ output_glm (const struct glm_spec *cmd, const struct glm_workspace *ws) ssq += intercept_ssq; F = ssq / df / mse; - tab_double (t, 1, heading_rows, 0, ssq, NULL); - tab_double (t, 2, heading_rows, 0, df, wfmt); - tab_double (t, 3, heading_rows, 0, ssq / df, NULL); - tab_double (t, 4, heading_rows, 0, F, NULL); + tab_double (t, 1, heading_rows, 0, ssq, NULL, RC_OTHER); + tab_double (t, 2, heading_rows, 0, df, NULL, RC_WEIGHT); + tab_double (t, 3, heading_rows, 0, ssq / df, NULL, RC_OTHER); + tab_double (t, 4, heading_rows, 0, F, NULL, RC_OTHER); tab_double (t, 5, heading_rows, 0, - gsl_cdf_fdist_Q (F, df, n_total - df_corr), NULL); + gsl_cdf_fdist_Q (F, df, n_total - df_corr), NULL, RC_PVALUE); } { @@ -840,15 +841,15 @@ output_glm (const struct glm_spec *cmd, const struct glm_workspace *ws) const double ssq = gsl_vector_get (ws->ssq, 0); const double mse = ssq / df; tab_text (t, 0, r, TAB_LEFT | TAT_TITLE, _("Error")); - tab_double (t, 1, r, 0, ssq, NULL); - tab_double (t, 2, r, 0, df, wfmt); - tab_double (t, 3, r++, 0, mse, NULL); + tab_double (t, 1, r, 0, ssq, NULL, RC_OTHER); + tab_double (t, 2, r, 0, df, NULL, RC_WEIGHT); + tab_double (t, 3, r++, 0, mse, NULL, RC_OTHER); } { tab_text (t, 0, r, TAB_LEFT | TAT_TITLE, _("Total")); - tab_double (t, 1, r, 0, ws->total_ssq + intercept_ssq, NULL); - tab_double (t, 2, r, 0, n_total, wfmt); + tab_double (t, 1, r, 0, ws->total_ssq + intercept_ssq, NULL, RC_OTHER); + tab_double (t, 2, r, 0, n_total, NULL, RC_WEIGHT); r++; } @@ -856,8 +857,8 @@ output_glm (const struct glm_spec *cmd, const struct glm_workspace *ws) if (cmd->intercept) { tab_text (t, 0, r, TAB_LEFT | TAT_TITLE, _("Corrected Total")); - tab_double (t, 1, r, 0, ws->total_ssq, NULL); - tab_double (t, 2, r, 0, n_total - 1.0, wfmt); + tab_double (t, 1, r, 0, ws->total_ssq, NULL, RC_OTHER); + tab_double (t, 2, r, 0, n_total - 1.0, NULL, RC_WEIGHT); } tab_submit (t); diff --git a/src/language/stats/jonckheere-terpstra.c b/src/language/stats/jonckheere-terpstra.c index 796168a8ee..86e705d250 100644 --- a/src/language/stats/jonckheere-terpstra.c +++ b/src/language/stats/jonckheere-terpstra.c @@ -358,6 +358,7 @@ show_jt (const struct n_sample_test *nst, const struct jt *jt, const struct vari struct tab_table *table = tab_create (row_headers + 7, column_headers + nst->n_vars); + tab_set_format (table, RC_WEIGHT, wfmt); tab_headers (table, row_headers, 0, column_headers, 0); @@ -393,26 +394,26 @@ show_jt (const struct n_sample_test *nst, const struct jt *jt, const struct vari var_to_string (nst->vars[i]) ); tab_double (table, 1, i + row_headers, TAT_TITLE, - jt[0].levels, &F_8_0); + jt[0].levels, NULL, RC_INTEGER); tab_double (table, 2, i + row_headers, TAT_TITLE, - jt[0].n, wfmt); + jt[0].n, NULL, RC_WEIGHT); tab_double (table, 3, i + row_headers, TAT_TITLE, - jt[0].obs, 0); + jt[0].obs, NULL, RC_OTHER); tab_double (table, 4, i + row_headers, TAT_TITLE, - jt[0].mean, 0); + jt[0].mean, NULL, RC_OTHER); tab_double (table, 5, i + row_headers, TAT_TITLE, - jt[0].stddev, 0); + jt[0].stddev, NULL, RC_OTHER); std_jt = (jt[0].obs - jt[0].mean) / jt[0].stddev; tab_double (table, 6, i + row_headers, TAT_TITLE, - std_jt, 0); + std_jt, NULL, RC_OTHER); tab_double (table, 7, i + row_headers, TAT_TITLE, - 2.0 * ((std_jt > 0) ? gsl_cdf_ugaussian_Q (std_jt) : gsl_cdf_ugaussian_P (std_jt)), 0); + 2.0 * ((std_jt > 0) ? gsl_cdf_ugaussian_Q (std_jt) : gsl_cdf_ugaussian_P (std_jt)), NULL, RC_PVALUE); } tab_submit (table); diff --git a/src/language/stats/kruskal-wallis.c b/src/language/stats/kruskal-wallis.c index cea302bcb9..65ce7865a3 100644 --- a/src/language/stats/kruskal-wallis.c +++ b/src/language/stats/kruskal-wallis.c @@ -312,8 +312,8 @@ show_ranks_box (const struct n_sample_test *nst, const struct kw *kw, int n_grou var_append_value_name (nst->indep_var, &re->group, &str); tab_text (table, 1, row, TAB_LEFT, ds_cstr (&str)); - tab_double (table, 2, row, TAB_LEFT, re->n, &F_8_0); - tab_double (table, 3, row, TAB_LEFT, re->sum_of_ranks / re->n, 0); + tab_double (table, 2, row, TAB_LEFT, re->n, NULL, RC_INTEGER); + tab_double (table, 3, row, TAB_LEFT, re->sum_of_ranks / re->n, NULL, RC_OTHER); tot += re->n; row++; @@ -321,7 +321,7 @@ show_ranks_box (const struct n_sample_test *nst, const struct kw *kw, int n_grou } tab_double (table, 2, row, TAB_LEFT, - tot, &F_8_0); + tot, NULL, RC_INTEGER); tab_text (table, 1, row++, TAB_LEFT, _("Total")); } @@ -367,14 +367,14 @@ show_sig_box (const struct n_sample_test *nst, const struct kw *kw) ); tab_double (table, column_headers + 1 + i, 1, 0, - kw[i].h, 0); + kw[i].h, NULL, RC_OTHER); tab_double (table, column_headers + 1 + i, 2, 0, - df, &F_8_0); + df, NULL, RC_INTEGER); tab_double (table, column_headers + 1 + i, 3, 0, gsl_cdf_chisq_Q (kw[i].h, df), - 0); + NULL, RC_PVALUE); } tab_submit (table); diff --git a/src/language/stats/ks-one-sample.c b/src/language/stats/ks-one-sample.c index aaab53fa89..d571693cd8 100644 --- a/src/language/stats/ks-one-sample.c +++ b/src/language/stats/ks-one-sample.c @@ -276,7 +276,7 @@ show_results (const struct ks *ks, const int nc = kst->parent.n_vars + column_headers; const int nr = 8 + row_headers; struct tab_table *table = tab_create (nc, nr); - + tab_set_format (table, RC_WEIGHT, wfmt); tab_headers (table, row_headers, 0, column_headers, 0); tab_title (table, _("One-Sample Kolmogorov-Smirnov Test")); @@ -344,21 +344,21 @@ show_results (const struct ks *ks, switch (kst->dist) { case KS_UNIFORM: - tab_double (table, col, 1, 0, ks[i].obs_cc, wfmt); - tab_double (table, col, 2, 0, ks[i].test_min, NULL); - tab_double (table, col, 3, 0, ks[i].test_max, NULL); + tab_double (table, col, 1, 0, ks[i].obs_cc, NULL, RC_WEIGHT); + tab_double (table, col, 2, 0, ks[i].test_min, NULL, RC_OTHER); + tab_double (table, col, 3, 0, ks[i].test_max, NULL, RC_OTHER); break; case KS_NORMAL: - tab_double (table, col, 1, 0, ks[i].obs_cc, wfmt); - tab_double (table, col, 2, 0, ks[i].mu, NULL); - tab_double (table, col, 3, 0, ks[i].sigma, NULL); + tab_double (table, col, 1, 0, ks[i].obs_cc, NULL, RC_WEIGHT); + tab_double (table, col, 2, 0, ks[i].mu, NULL, RC_OTHER); + tab_double (table, col, 3, 0, ks[i].sigma, NULL, RC_OTHER); break; case KS_POISSON: case KS_EXPONENTIAL: - tab_double (table, col, 1, 0, ks[i].obs_cc, wfmt); - tab_double (table, col, 2, 0, ks[i].mu, NULL); + tab_double (table, col, 1, 0, ks[i].obs_cc, NULL, RC_WEIGHT); + tab_double (table, col, 2, 0, ks[i].mu, NULL, RC_OTHER); break; default: @@ -370,13 +370,13 @@ show_results (const struct ks *ks, z = sqrt (ks[i].obs_cc) * abs; - tab_double (table, col, 5, 0, ks[i].diff_pos, NULL); - tab_double (table, col, 6, 0, ks[i].diff_neg, NULL); + tab_double (table, col, 5, 0, ks[i].diff_pos, NULL, RC_OTHER); + tab_double (table, col, 6, 0, ks[i].diff_neg, NULL, RC_OTHER); - tab_double (table, col, 4, 0, abs, NULL); + tab_double (table, col, 4, 0, abs, NULL, RC_OTHER); - tab_double (table, col, 7, 0, z, NULL); - tab_double (table, col, 8, 0, ks_asymp_sig (z), NULL); + tab_double (table, col, 7, 0, z, NULL, RC_OTHER); + tab_double (table, col, 8, 0, ks_asymp_sig (z), NULL, RC_PVALUE); } diff --git a/src/language/stats/logistic.c b/src/language/stats/logistic.c index c3a152afc8..d5dbad3605 100644 --- a/src/language/stats/logistic.c +++ b/src/language/stats/logistic.c @@ -1168,8 +1168,8 @@ output_depvarmap (const struct lr_spec *cmd, const struct lr_result *res) tab_text (t, 0, 1 + heading_rows, 0, ds_cstr (&str)); - tab_double (t, 1, 0 + heading_rows, 0, map_dependent_var (cmd, res, &res->y0), &F_8_0); - tab_double (t, 1, 1 + heading_rows, 0, map_dependent_var (cmd, res, &res->y1), &F_8_0); + tab_double (t, 1, 0 + heading_rows, 0, map_dependent_var (cmd, res, &res->y0), NULL, RC_INTEGER); + tab_double (t, 1, 1 + heading_rows, 0, map_dependent_var (cmd, res, &res->y1), NULL, RC_INTEGER); ds_destroy (&str); tab_submit (t); @@ -1279,9 +1279,9 @@ output_variables (const struct lr_spec *cmd, gsl_blas_dgemv (CblasTrans, 1.0, subhessian, &vv.vector, 0, temp); gsl_blas_ddot (temp, &vv.vector, &wald); - tab_double (t, 4, row, 0, wald, 0); - tab_double (t, 5, row, 0, df, &F_8_0); - tab_double (t, 6, row, 0, gsl_cdf_chisq_Q (wald, df), 0); + tab_double (t, 4, row, 0, wald, NULL, RC_OTHER); + tab_double (t, 5, row, 0, df, NULL, RC_INTEGER); + tab_double (t, 6, row, 0, gsl_cdf_chisq_Q (wald, df), NULL, RC_PVALUE); idx_correction ++; summary = true; @@ -1310,12 +1310,12 @@ output_variables (const struct lr_spec *cmd, tab_text (t, 1, row, TAB_LEFT | TAT_TITLE, _("Constant")); } - tab_double (t, 2, row, 0, b, 0); - tab_double (t, 3, row, 0, sqrt (sigma2), 0); - tab_double (t, 4, row, 0, wald, 0); - tab_double (t, 5, row, 0, df, &F_8_0); - tab_double (t, 6, row, 0, gsl_cdf_chisq_Q (wald, df), 0); - tab_double (t, 7, row, 0, exp (b), 0); + tab_double (t, 2, row, 0, b, NULL, RC_OTHER); + tab_double (t, 3, row, 0, sqrt (sigma2), NULL, RC_OTHER); + tab_double (t, 4, row, 0, wald, NULL, RC_OTHER); + tab_double (t, 5, row, 0, df, NULL, RC_INTEGER); + tab_double (t, 6, row, 0, gsl_cdf_chisq_Q (wald, df), NULL, RC_PVALUE); + tab_double (t, 7, row, 0, exp (b), NULL, RC_OTHER); if (cmd->print & PRINT_CI) { @@ -1328,8 +1328,8 @@ output_variables (const struct lr_spec *cmd, if (row < last_ci) { - tab_double (t, 8, row, 0, exp (b - wc), 0); - tab_double (t, 9, row, 0, exp (b + wc), 0); + tab_double (t, 8, row, 0, exp (b - wc), NULL, RC_OTHER); + tab_double (t, 9, row, 0, exp (b + wc), NULL, RC_OTHER); } } } @@ -1363,15 +1363,15 @@ output_model_summary (const struct lr_result *res, tab_text (t, 0, 0, TAB_LEFT | TAT_TITLE, _("Step 1")); tab_text (t, 1, 0, TAB_CENTER | TAT_TITLE, _("-2 Log likelihood")); - tab_double (t, 1, 1, 0, -2 * log_likelihood, 0); + tab_double (t, 1, 1, 0, -2 * log_likelihood, NULL, RC_OTHER); tab_text (t, 2, 0, TAB_CENTER | TAT_TITLE, _("Cox & Snell R Square")); cox = 1.0 - exp((initial_log_likelihood - log_likelihood) * (2 / res->cc)); - tab_double (t, 2, 1, 0, cox, 0); + tab_double (t, 2, 1, 0, cox, NULL, RC_OTHER); tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("Nagelkerke R Square")); - tab_double (t, 3, 1, 0, cox / ( 1.0 - exp(initial_log_likelihood * (2 / res->cc))), 0); + tab_double (t, 3, 1, 0, cox / ( 1.0 - exp(initial_log_likelihood * (2 / res->cc))), NULL, RC_OTHER); tab_submit (t); @@ -1408,15 +1408,15 @@ case_processing_summary (const struct lr_result *res) tab_text (t, 0, 2, TAB_LEFT | TAT_TITLE, _("Missing Cases")); tab_text (t, 0, 3, TAB_LEFT | TAT_TITLE, _("Total")); - tab_double (t, 1, 1, 0, res->n_nonmissing, &F_8_0); - tab_double (t, 1, 2, 0, res->n_missing, &F_8_0); + tab_double (t, 1, 1, 0, res->n_nonmissing, NULL, RC_INTEGER); + tab_double (t, 1, 2, 0, res->n_missing, NULL, RC_INTEGER); total = res->n_nonmissing + res->n_missing; - tab_double (t, 1, 3, 0, total , &F_8_0); + tab_double (t, 1, 3, 0, total , NULL, RC_INTEGER); - tab_double (t, 2, 1, 0, 100 * res->n_nonmissing / (double) total, 0); - tab_double (t, 2, 2, 0, 100 * res->n_missing / (double) total, 0); - tab_double (t, 2, 3, 0, 100 * total / (double) total, 0); + tab_double (t, 2, 1, 0, 100 * res->n_nonmissing / (double) total, NULL, RC_OTHER); + tab_double (t, 2, 2, 0, 100 * res->n_missing / (double) total, NULL, RC_OTHER); + tab_double (t, 2, 3, 0, 100 * total / (double) total, NULL, RC_OTHER); tab_submit (t); } @@ -1454,6 +1454,8 @@ output_categories (const struct lr_spec *cmd, const struct lr_result *res) nr = heading_rows + total_cats; t = tab_create (nc, nr); + tab_set_format (t, RC_WEIGHT, wfmt); + tab_title (t, _("Categorical Variables' Codings")); tab_headers (t, heading_columns, 0, heading_rows, 0); @@ -1511,11 +1513,11 @@ output_categories (const struct lr_spec *cmd, const struct lr_result *res) tab_text (t, 1, heading_rows + r, 0, ds_cstr (&str)); ds_destroy (&str); - tab_double (t, 2, heading_rows + r, 0, *freq, wfmt); + tab_double (t, 2, heading_rows + r, 0, *freq, NULL, RC_WEIGHT); for (x = 0; x < df; ++x) { - tab_double (t, heading_columns + 1 + x, heading_rows + r, 0, (cat == x), &F_8_0); + tab_double (t, heading_columns + 1 + x, heading_rows + r, 0, (cat == x), NULL, RC_INTEGER); } ++r; } @@ -1542,6 +1544,7 @@ output_classification_table (const struct lr_spec *cmd, const struct lr_result * const int nr = heading_rows + 3; struct tab_table *t = tab_create (nc, nr); + tab_set_format (t, RC_WEIGHT, wfmt); ds_init_empty (&sv0); ds_init_empty (&sv1); @@ -1593,17 +1596,17 @@ output_classification_table (const struct lr_spec *cmd, const struct lr_result * ds_destroy (&sv0); ds_destroy (&sv1); - tab_double (t, heading_columns, 3, 0, res->tn, wfmt); - tab_double (t, heading_columns + 1, 4, 0, res->tp, wfmt); + tab_double (t, heading_columns, 3, 0, res->tn, NULL, RC_WEIGHT); + tab_double (t, heading_columns + 1, 4, 0, res->tp, NULL, RC_WEIGHT); - tab_double (t, heading_columns + 1, 3, 0, res->fp, wfmt); - tab_double (t, heading_columns, 4, 0, res->fn, wfmt); + tab_double (t, heading_columns + 1, 3, 0, res->fp, NULL, RC_WEIGHT); + tab_double (t, heading_columns, 4, 0, res->fn, NULL, RC_WEIGHT); - tab_double (t, heading_columns + 2, 3, 0, 100 * res->tn / (res->tn + res->fp), 0); - tab_double (t, heading_columns + 2, 4, 0, 100 * res->tp / (res->tp + res->fn), 0); + tab_double (t, heading_columns + 2, 3, 0, 100 * res->tn / (res->tn + res->fp), NULL, RC_OTHER); + tab_double (t, heading_columns + 2, 4, 0, 100 * res->tp / (res->tp + res->fn), NULL, RC_OTHER); tab_double (t, heading_columns + 2, 5, 0, - 100 * (res->tp + res->tn) / (res->tp + res->tn + res->fp + res->fn), 0); + 100 * (res->tp + res->tn) / (res->tp + res->tn + res->fp + res->fn), NULL, RC_OTHER); tab_submit (t); diff --git a/src/language/stats/mann-whitney.c b/src/language/stats/mann-whitney.c index 60f251ba98..81fe033af5 100644 --- a/src/language/stats/mann-whitney.c +++ b/src/language/stats/mann-whitney.c @@ -211,27 +211,27 @@ show_ranks_box (const struct n_sample_test *nst, const struct mw *mwv) var_to_string (nst->vars[i])); tab_double (table, 1, column_headers + i, 0, - mw->n[0], 0); + mw->n[0], NULL, RC_OTHER); tab_double (table, 2, column_headers + i, 0, - mw->n[1], 0); + mw->n[1], NULL, RC_OTHER); tab_double (table, 3, column_headers + i, 0, - mw->n[1] + mw->n[0], 0); + mw->n[1] + mw->n[0], NULL, RC_OTHER); /* Mean Ranks */ tab_double (table, 4, column_headers + i, 0, - mw->rank_sum[0] / mw->n[0], 0); + mw->rank_sum[0] / mw->n[0], NULL, RC_OTHER); tab_double (table, 5, column_headers + i, 0, - mw->rank_sum[1] / mw->n[1], 0); + mw->rank_sum[1] / mw->n[1], NULL, RC_OTHER); /* Sum of Ranks */ tab_double (table, 6, column_headers + i, 0, - mw->rank_sum[0], 0); + mw->rank_sum[0], NULL, RC_OTHER); tab_double (table, 7, column_headers + i, 0, - mw->rank_sum[1], 0); + mw->rank_sum[1], NULL, RC_OTHER); } tab_submit (table); @@ -280,16 +280,16 @@ show_statistics_box (const struct n_sample_test *nst, const struct mw *mwv, bool var_to_string (nst->vars[i])); tab_double (table, 1, column_headers + i, 0, - mw->u, 0); + mw->u, NULL, RC_OTHER); tab_double (table, 2, column_headers + i, 0, - mw->w, 0); + mw->w, NULL, RC_OTHER); tab_double (table, 3, column_headers + i, 0, - mw->z, 0); + mw->z, NULL, RC_OTHER); tab_double (table, 4, column_headers + i, 0, - 2.0 * gsl_cdf_ugaussian_P (mw->z), 0); + 2.0 * gsl_cdf_ugaussian_P (mw->z), NULL, RC_PVALUE); } tab_submit (table); diff --git a/src/language/stats/mcnemar.c b/src/language/stats/mcnemar.c index 4f64bbb492..56fe088de6 100644 --- a/src/language/stats/mcnemar.c +++ b/src/language/stats/mcnemar.c @@ -174,6 +174,8 @@ output_freq_table (variable_pair *vp, struct string val1str ; struct string val0str ; + tab_set_format (table, RC_WEIGHT, wfmt); + ds_init_empty (&val0str); ds_init_empty (&val1str); @@ -213,10 +215,10 @@ output_freq_table (variable_pair *vp, tab_text (table, header_cols + 0, 1, TAB_LEFT, ds_cstr (&val0str)); tab_text (table, header_cols + 1, 1, TAB_LEFT, ds_cstr (&val1str)); - tab_double (table, header_cols + 0, header_rows + 0, TAB_RIGHT, param->n00, wfmt); - tab_double (table, header_cols + 0, header_rows + 1, TAB_RIGHT, param->n01, wfmt); - tab_double (table, header_cols + 1, header_rows + 0, TAB_RIGHT, param->n10, wfmt); - tab_double (table, header_cols + 1, header_rows + 1, TAB_RIGHT, param->n11, wfmt); + tab_double (table, header_cols + 0, header_rows + 0, TAB_RIGHT, param->n00, NULL, RC_WEIGHT); + tab_double (table, header_cols + 0, header_rows + 1, TAB_RIGHT, param->n01, NULL, RC_WEIGHT); + tab_double (table, header_cols + 1, header_rows + 0, TAB_RIGHT, param->n10, NULL, RC_WEIGHT); + tab_double (table, header_cols + 1, header_rows + 1, TAB_RIGHT, param->n11, NULL, RC_WEIGHT); tab_submit (table); @@ -238,6 +240,7 @@ output_statistics_table (const struct two_sample_test *t2s, const struct fmt_spec *wfmt = wv ? var_get_print_format (wv) : & F_8_0; tab_title (table, _("Test Statistics")); + tab_set_format (table, RC_WEIGHT, wfmt); tab_headers (table, 0, 1, 0, 1); @@ -280,15 +283,15 @@ output_statistics_table (const struct two_sample_test *t2s, tab_text (table, 0, 1 + i, TAB_LEFT, ds_cstr (&pair_name)); ds_destroy (&pair_name); - tab_double (table, 1, 1 + i, TAB_RIGHT, mc[i].n00 + mc[i].n01 + mc[i].n10 + mc[i].n11, wfmt); + tab_double (table, 1, 1 + i, TAB_RIGHT, mc[i].n00 + mc[i].n01 + mc[i].n10 + mc[i].n11, NULL, RC_WEIGHT); sig = gsl_cdf_binomial_P (mc[i].n01, 0.5, mc[i].n01 + mc[i].n10); - tab_double (table, 2, 1 + i, TAB_RIGHT, 2 * sig, NULL); - tab_double (table, 3, 1 + i, TAB_RIGHT, sig, NULL); + tab_double (table, 2, 1 + i, TAB_RIGHT, 2 * sig, NULL, RC_PVALUE); + tab_double (table, 3, 1 + i, TAB_RIGHT, sig, NULL, RC_PVALUE); tab_double (table, 4, 1 + i, TAB_RIGHT, gsl_ran_binomial_pdf (mc[i].n01, 0.5, mc[i].n01 + mc[i].n10), - NULL); + NULL, RC_OTHER); } tab_submit (table); diff --git a/src/language/stats/means.c b/src/language/stats/means.c index 9a07a14bb6..f1726b9af1 100644 --- a/src/language/stats/means.c +++ b/src/language/stats/means.c @@ -1114,7 +1114,7 @@ output_case_processing_summary (const struct mtable *table) table->summary[row].non_missing; tab_double (t, 1, row + heading_rows, - 0, table->summary[row].non_missing, &F_8_0); + 0, table->summary[row].non_missing, NULL, RC_INTEGER); tab_text_format (t, 2, row + heading_rows, 0, _("%g%%"), @@ -1122,7 +1122,7 @@ output_case_processing_summary (const struct mtable *table) tab_double (t, 3, row + heading_rows, - 0, table->summary[row].missing, &F_8_0); + 0, table->summary[row].missing, NULL, RC_INTEGER); tab_text_format (t, 4, row + heading_rows, @@ -1132,7 +1132,7 @@ output_case_processing_summary (const struct mtable *table) tab_double (t, 5, row + heading_rows, 0, table->summary[row].missing + - table->summary[row].non_missing, &F_8_0); + table->summary[row].non_missing, NULL, RC_INTEGER); tab_text_format (t, 6, row + heading_rows, 0, _("%g%%"), @@ -1241,7 +1241,7 @@ output_report (const struct means *cmd, int iact_idx, tab_double (t, heading_columns + i, heading_rows + grp + dv * n_cats, - 0, result, 0); + 0, result, NULL, RC_OTHER); } } } diff --git a/src/language/stats/median.c b/src/language/stats/median.c index a894f017a7..20e414259f 100644 --- a/src/language/stats/median.c +++ b/src/language/stats/median.c @@ -313,6 +313,7 @@ show_frequencies (const struct n_sample_test *nst, const struct results *results const int nr = column_headers + nst->n_vars * 2; struct tab_table *table = tab_create (nc, nr); + tab_set_format (table, RC_WEIGHT, wfmt); tab_headers (table, row_headers, 0, column_headers, 0); @@ -373,10 +374,10 @@ show_frequencies (const struct n_sample_test *nst, const struct results *results { const struct val_node *vn = rs->sorted_array[i]; tab_double (table, row_headers + i, column_headers + v * 2, - 0, vn->gt, wfmt); + 0, vn->gt, NULL, RC_WEIGHT); tab_double (table, row_headers + i, column_headers + v * 2 + 1, - 0, vn->le, wfmt); + 0, vn->le, NULL, RC_WEIGHT); } } @@ -401,6 +402,7 @@ show_test_statistics (const struct n_sample_test *nst, const int nr = column_headers + nst->n_vars; struct tab_table *table = tab_create (nc, nr); + tab_set_format (table, RC_WEIGHT, wfmt); tab_headers (table, row_headers, 0, column_headers, 0); @@ -438,19 +440,19 @@ show_test_statistics (const struct n_sample_test *nst, tab_double (table, row_headers + 0, column_headers + v, - 0, rs->n, wfmt); + 0, rs->n, NULL, RC_WEIGHT); tab_double (table, row_headers + 1, column_headers + v, - 0, rs->median, NULL); + 0, rs->median, NULL, RC_OTHER); tab_double (table, row_headers + 2, column_headers + v, - 0, rs->chisq, NULL); + 0, rs->chisq, NULL, RC_OTHER); tab_double (table, row_headers + 3, column_headers + v, - 0, df, wfmt); + 0, df, NULL, RC_WEIGHT); tab_double (table, row_headers + 4, column_headers + v, - 0, gsl_cdf_chisq_Q (rs->chisq, df), NULL); + 0, gsl_cdf_chisq_Q (rs->chisq, df), NULL, RC_PVALUE); } tab_submit (table); diff --git a/src/language/stats/npar-summary.c b/src/language/stats/npar-summary.c index e1870f62fd..332486adc8 100644 --- a/src/language/stats/npar-summary.c +++ b/src/language/stats/npar-summary.c @@ -164,11 +164,11 @@ do_summary_box (const struct descriptives *desc, col = 1; if (desc != NULL) { - tab_double (table, col++, 2 + v, 0, desc[v].n, fmt); - tab_double (table, col++, 2 + v, 0, desc[v].mean, fmt); - tab_double (table, col++, 2 + v, 0, desc[v].std_dev, fmt); - tab_double (table, col++, 2 + v, 0, desc[v].min, fmt); - tab_double (table, col++, 2 + v, 0, desc[v].max, fmt); + tab_double (table, col++, 2 + v, 0, desc[v].n, fmt, RC_OTHER); + tab_double (table, col++, 2 + v, 0, desc[v].mean, fmt, RC_OTHER); + tab_double (table, col++, 2 + v, 0, desc[v].std_dev, fmt, RC_OTHER); + tab_double (table, col++, 2 + v, 0, desc[v].min, fmt, RC_OTHER); + tab_double (table, col++, 2 + v, 0, desc[v].max, fmt, RC_OTHER); } } diff --git a/src/language/stats/oneway.c b/src/language/stats/oneway.c index a64b760eb9..f2214e49e2 100644 --- a/src/language/stats/oneway.c +++ b/src/language/stats/oneway.c @@ -1003,28 +1003,28 @@ show_anova_table (const struct oneway_spec *cmd, const struct oneway_workspace * /* Sums of Squares */ - tab_double (t, 2, i * 3 + 1, 0, pvw->ssa, NULL); - tab_double (t, 2, i * 3 + 3, 0, pvw->sst, NULL); - tab_double (t, 2, i * 3 + 2, 0, pvw->sse, NULL); + tab_double (t, 2, i * 3 + 1, 0, pvw->ssa, NULL, RC_OTHER); + tab_double (t, 2, i * 3 + 3, 0, pvw->sst, NULL, RC_OTHER); + tab_double (t, 2, i * 3 + 2, 0, pvw->sse, NULL, RC_OTHER); /* Degrees of freedom */ - tab_fixed (t, 3, i * 3 + 1, 0, df1, 4, 0); - tab_fixed (t, 3, i * 3 + 2, 0, df2, 4, 0); - tab_fixed (t, 3, i * 3 + 3, 0, n - 1, 4, 0); + tab_double (t, 3, i * 3 + 1, 0, df1, NULL, RC_INTEGER); + tab_double (t, 3, i * 3 + 2, 0, df2, NULL, RC_INTEGER); + tab_double (t, 3, i * 3 + 3, 0, n - 1, NULL, RC_INTEGER); /* Mean Squares */ - tab_double (t, 4, i * 3 + 1, TAB_RIGHT, msa, NULL); - tab_double (t, 4, i * 3 + 2, TAB_RIGHT, pvw->mse, NULL); + tab_double (t, 4, i * 3 + 1, TAB_RIGHT, msa, NULL, RC_OTHER); + tab_double (t, 4, i * 3 + 2, TAB_RIGHT, pvw->mse, NULL, RC_OTHER); { const double F = msa / pvw->mse ; /* The F value */ - tab_double (t, 5, i * 3 + 1, 0, F, NULL); + tab_double (t, 5, i * 3 + 1, 0, F, NULL, RC_OTHER); /* The significance */ - tab_double (t, 6, i * 3 + 1, 0, gsl_cdf_fdist_Q (F, df1, df2), NULL); + tab_double (t, 6, i * 3 + 1, 0, gsl_cdf_fdist_Q (F, df1, df2), NULL, RC_PVALUE); } } @@ -1053,6 +1053,7 @@ show_descriptives (const struct oneway_spec *cmd, const struct oneway_workspace n_rows += ws->actual_number_of_groups + 1; t = tab_create (n_cols, n_rows); + tab_set_format (t, RC_WEIGHT, wfmt); tab_headers (t, 2, 0, 2, 0); /* Put a frame around the entire box, and vertical lines inside */ @@ -1129,29 +1130,29 @@ show_descriptives (const struct oneway_spec *cmd, const struct oneway_workspace /* Now fill in the numbers ... */ - tab_double (t, 2, row + count, 0, n, wfmt); + tab_double (t, 2, row + count, 0, n, NULL, RC_WEIGHT); - tab_double (t, 3, row + count, 0, mean, NULL); + tab_double (t, 3, row + count, 0, mean, NULL, RC_OTHER); - tab_double (t, 4, row + count, 0, std_dev, NULL); + tab_double (t, 4, row + count, 0, std_dev, NULL, RC_OTHER); - tab_double (t, 5, row + count, 0, std_error, NULL); + tab_double (t, 5, row + count, 0, std_error, NULL, RC_OTHER); /* Now the confidence interval */ T = gsl_cdf_tdist_Qinv (q, n - 1); tab_double (t, 6, row + count, 0, - mean - T * std_error, NULL); + mean - T * std_error, NULL, RC_OTHER); tab_double (t, 7, row + count, 0, - mean + T * std_error, NULL); + mean + T * std_error, NULL, RC_OTHER); /* Min and Max */ - tab_double (t, 8, row + count, 0, dd->minimum, fmt); - tab_double (t, 9, row + count, 0, dd->maximum, fmt); + tab_double (t, 8, row + count, 0, dd->minimum, fmt, RC_OTHER); + tab_double (t, 9, row + count, 0, dd->maximum, fmt, RC_OTHER); } if (categoricals_is_complete (cats)) @@ -1169,27 +1170,27 @@ show_descriptives (const struct oneway_spec *cmd, const struct oneway_workspace tab_text (t, 1, row + count, TAB_LEFT | TAT_TITLE, _("Total")); - tab_double (t, 2, row + count, 0, n, wfmt); + tab_double (t, 2, row + count, 0, n, NULL, RC_WEIGHT); - tab_double (t, 3, row + count, 0, mean, NULL); + tab_double (t, 3, row + count, 0, mean, NULL, RC_OTHER); - tab_double (t, 4, row + count, 0, std_dev, NULL); + tab_double (t, 4, row + count, 0, std_dev, NULL, RC_OTHER); - tab_double (t, 5, row + count, 0, std_error, NULL); + tab_double (t, 5, row + count, 0, std_error, NULL, RC_OTHER); /* Now the confidence interval */ T = gsl_cdf_tdist_Qinv (q, n - 1); tab_double (t, 6, row + count, 0, - mean - T * std_error, NULL); + mean - T * std_error, NULL, RC_OTHER); tab_double (t, 7, row + count, 0, - mean + T * std_error, NULL); + mean + T * std_error, NULL, RC_OTHER); /* Min and Max */ - tab_double (t, 8, row + count, 0, ws->dd_total[v]->minimum, fmt); - tab_double (t, 9, row + count, 0, ws->dd_total[v]->maximum, fmt); + tab_double (t, 8, row + count, 0, ws->dd_total[v]->minimum, fmt, RC_OTHER); + tab_double (t, 9, row + count, 0, ws->dd_total[v]->maximum, fmt, RC_OTHER); } row += categoricals_n_total (cats) + 1; @@ -1244,12 +1245,12 @@ show_homogeneity (const struct oneway_spec *cmd, const struct oneway_workspace * tab_text (t, 0, v + 1, TAB_LEFT | TAT_TITLE, s); - tab_double (t, 1, v + 1, TAB_RIGHT, F, NULL); - tab_fixed (t, 2, v + 1, TAB_RIGHT, df1, 8, 0); - tab_fixed (t, 3, v + 1, TAB_RIGHT, df2, 8, 0); + tab_double (t, 1, v + 1, TAB_RIGHT, F, NULL, RC_OTHER); + tab_double (t, 2, v + 1, TAB_RIGHT, df1, NULL, RC_INTEGER); + tab_double (t, 3, v + 1, TAB_RIGHT, df2, NULL, RC_INTEGER); /* Now the significance */ - tab_double (t, 4, v + 1, TAB_RIGHT, gsl_cdf_fdist_Q (F, df1, df2), NULL); + tab_double (t, 4, v + 1, TAB_RIGHT, gsl_cdf_fdist_Q (F, df1, df2), NULL, RC_PVALUE); } tab_submit (t); @@ -1474,18 +1475,18 @@ show_contrast_tests (const struct oneway_spec *cmd, const struct oneway_workspac df_numerator = pow2 (df_numerator); tab_double (t, 3, (v * lines_per_variable) + i + 1, - TAB_RIGHT, contrast_value, NULL); + TAB_RIGHT, contrast_value, NULL, RC_OTHER); tab_double (t, 3, (v * lines_per_variable) + i + 1 + n_contrasts, - TAB_RIGHT, contrast_value, NULL); + TAB_RIGHT, contrast_value, NULL, RC_OTHER); std_error_contrast = sqrt (pvw->mse * coef_msq); /* Std. Error */ tab_double (t, 4, (v * lines_per_variable) + i + 1, TAB_RIGHT, std_error_contrast, - NULL); + NULL, RC_OTHER); T = fabs (contrast_value / std_error_contrast); @@ -1493,19 +1494,18 @@ show_contrast_tests (const struct oneway_spec *cmd, const struct oneway_workspac tab_double (t, 5, (v * lines_per_variable) + i + 1, TAB_RIGHT, T, - NULL); + NULL, RC_OTHER); /* Degrees of Freedom */ - tab_fixed (t, 6, (v * lines_per_variable) + i + 1, - TAB_RIGHT, df, - 8, 0); + tab_double (t, 6, (v * lines_per_variable) + i + 1, + TAB_RIGHT, df, NULL, RC_INTEGER); /* Significance TWO TAILED !!*/ tab_double (t, 7, (v * lines_per_variable) + i + 1, TAB_RIGHT, 2 * gsl_cdf_tdist_Q (T, df), - NULL); + NULL, RC_PVALUE); /* Now for the Variances NOT Equal case */ @@ -1513,20 +1513,20 @@ show_contrast_tests (const struct oneway_spec *cmd, const struct oneway_workspac tab_double (t, 4, (v * lines_per_variable) + i + 1 + n_contrasts, TAB_RIGHT, sec_vneq, - NULL); + NULL, RC_OTHER); T = contrast_value / sec_vneq; tab_double (t, 5, (v * lines_per_variable) + i + 1 + n_contrasts, TAB_RIGHT, T, - NULL); + NULL, RC_OTHER); df = df_numerator / df_denominator; tab_double (t, 6, (v * lines_per_variable) + i + 1 + n_contrasts, TAB_RIGHT, df, - NULL); + NULL, RC_OTHER); { double p = gsl_cdf_tdist_P (T, df); @@ -1535,7 +1535,7 @@ show_contrast_tests (const struct oneway_spec *cmd, const struct oneway_workspac /* The Significance */ tab_double (t, 7, (v * lines_per_variable) + i + 1 + n_contrasts, TAB_RIGHT, 2 * ((T > 0) ? q : p), - NULL); + NULL, RC_PVALUE); } } @@ -1643,24 +1643,24 @@ show_comparisons (const struct oneway_spec *cmd, const struct oneway_workspace * moments1_calculate (dd_j->mom, &weight_j, &mean_j, &var_j, 0, 0); - tab_double (t, 3, r + rx, 0, mean_i - mean_j, 0); + tab_double (t, 3, r + rx, 0, mean_i - mean_j, NULL, RC_OTHER); std_err = pvw->mse; std_err *= weight_i + weight_j; std_err /= weight_i * weight_j; std_err = sqrt (std_err); - tab_double (t, 4, r + rx, 0, std_err, 0); + tab_double (t, 4, r + rx, 0, std_err, NULL, RC_OTHER); - tab_double (t, 5, r + rx, 0, 2 * multiple_comparison_sig (std_err, pvw, dd_i, dd_j, ph), 0); + tab_double (t, 5, r + rx, 0, 2 * multiple_comparison_sig (std_err, pvw, dd_i, dd_j, ph), NULL, RC_PVALUE); half_range = mc_half_range (cmd, pvw, std_err, dd_i, dd_j, ph); tab_double (t, 6, r + rx, 0, - (mean_i - mean_j) - half_range, 0 ); + (mean_i - mean_j) - half_range, NULL, RC_OTHER); tab_double (t, 7, r + rx, 0, - (mean_i - mean_j) + half_range, 0 ); + (mean_i - mean_j) + half_range, NULL, RC_OTHER); rx++; } diff --git a/src/language/stats/quick-cluster.c b/src/language/stats/quick-cluster.c index 946181b01a..68b5012314 100644 --- a/src/language/stats/quick-cluster.c +++ b/src/language/stats/quick-cluster.c @@ -432,14 +432,14 @@ quick_cluster_show_centers (struct Kmeans *kmeans, bool initial, const struct qc tab_double (t, i + 1, j + 4, TAB_CENTER, gsl_matrix_get (kmeans->centers, kmeans->group_order->data[i], j), - var_get_print_format (qc->vars[j])); + var_get_print_format (qc->vars[j]), RC_OTHER); } else { tab_double (t, i + 1, j + 4, TAB_CENTER, gsl_matrix_get (kmeans->initial_centers, kmeans->group_order->data[i], j), - var_get_print_format (qc->vars[j])); + var_get_print_format (qc->vars[j]), RC_OTHER); } } } diff --git a/src/language/stats/regression.c b/src/language/stats/regression.c index 0ef739a4e0..ef5a9f28d1 100644 --- a/src/language/stats/regression.c +++ b/src/language/stats/regression.c @@ -775,10 +775,10 @@ reg_stats_r (const linreg * c, const struct variable *var) tab_text (t, 2, 0, TAB_CENTER | TAT_TITLE, _("R Square")); tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("Adjusted R Square")); tab_text (t, 4, 0, TAB_CENTER | TAT_TITLE, _("Std. Error of the Estimate")); - tab_double (t, 1, 1, TAB_RIGHT, sqrt (rsq), NULL); - tab_double (t, 2, 1, TAB_RIGHT, rsq, NULL); - tab_double (t, 3, 1, TAB_RIGHT, adjrsq, NULL); - tab_double (t, 4, 1, TAB_RIGHT, std_error, NULL); + tab_double (t, 1, 1, TAB_RIGHT, sqrt (rsq), NULL, RC_OTHER); + tab_double (t, 2, 1, TAB_RIGHT, rsq, NULL, RC_OTHER); + tab_double (t, 3, 1, TAB_RIGHT, adjrsq, NULL, RC_OTHER); + tab_double (t, 4, 1, TAB_RIGHT, std_error, NULL, RC_OTHER); tab_title (t, _("Model Summary (%s)"), var_to_string (var)); tab_submit (t); } @@ -830,29 +830,29 @@ reg_stats_coeff (const linreg * c, const gsl_matrix *cov, const struct variable tab_text (t, 5, 1, TAB_CENTER | TAT_TITLE, _("t")); tab_text (t, 6, 1, TAB_CENTER | TAT_TITLE, _("Sig.")); tab_text (t, 1, heading_rows, TAB_LEFT | TAT_TITLE, _("(Constant)")); - tab_double (t, 2, heading_rows, 0, linreg_intercept (c), NULL); + tab_double (t, 2, heading_rows, 0, linreg_intercept (c), NULL, RC_OTHER); std_err = sqrt (gsl_matrix_get (linreg_cov (c), 0, 0)); if (cmd->stats & STATS_CI) { double lower = linreg_intercept (c) - tval * std_err ; double upper = linreg_intercept (c) + tval * std_err ; - tab_double (t, 7, heading_rows, 0, lower, NULL); - tab_double (t, 8, heading_rows, 0, upper, NULL); + tab_double (t, 7, heading_rows, 0, lower, NULL, RC_OTHER); + tab_double (t, 8, heading_rows, 0, upper, NULL, RC_OTHER); tab_joint_text_format (t, 7, 0, 8, 0, TAB_CENTER | TAT_TITLE, _("%g%% Confidence Interval for B"), cmd->ci * 100); tab_hline (t, TAL_1, 7, 8, 1); tab_text (t, 7, 1, TAB_CENTER | TAT_TITLE, _("Lower Bound")); tab_text (t, 8, 1, TAB_CENTER | TAT_TITLE, _("Upper Bound")); } - tab_double (t, 3, heading_rows, 0, std_err, NULL); - tab_double (t, 4, heading_rows, 0, 0.0, NULL); + tab_double (t, 3, heading_rows, 0, std_err, NULL, RC_OTHER); + tab_double (t, 4, heading_rows, 0, 0.0, NULL, RC_OTHER); t_stat = linreg_intercept (c) / std_err; - tab_double (t, 5, heading_rows, 0, t_stat, NULL); + tab_double (t, 5, heading_rows, 0, t_stat, NULL, RC_OTHER); pval = 2 * gsl_cdf_tdist_Q (fabs (t_stat), (double) (linreg_n_obs (c) - linreg_n_coeffs (c))); - tab_double (t, 6, heading_rows, 0, pval, NULL); + tab_double (t, 6, heading_rows, 0, pval, NULL, RC_PVALUE); for (j = 0; j < linreg_n_coeffs (c); j++) { @@ -868,12 +868,12 @@ reg_stats_coeff (const linreg * c, const gsl_matrix *cov, const struct variable /* Regression coefficients. */ - tab_double (t, 2, this_row, 0, linreg_coeff (c, j), NULL); + tab_double (t, 2, this_row, 0, linreg_coeff (c, j), NULL, RC_OTHER); /* Standard error of the coefficients. */ std_err = sqrt (gsl_matrix_get (linreg_cov (c), j + 1, j + 1)); - tab_double (t, 3, this_row, 0, std_err, NULL); + tab_double (t, 3, this_row, 0, std_err, NULL, RC_OTHER); /* Standardized coefficient, i.e., regression coefficient if all variables had unit variance. @@ -881,18 +881,18 @@ reg_stats_coeff (const linreg * c, const gsl_matrix *cov, const struct variable beta = sqrt (gsl_matrix_get (cov, j, j)); beta *= linreg_coeff (c, j) / sqrt (gsl_matrix_get (cov, cov->size1 - 1, cov->size2 - 1)); - tab_double (t, 4, this_row, 0, beta, NULL); + tab_double (t, 4, this_row, 0, beta, NULL, RC_OTHER); /* Test statistic for H0: coefficient is 0. */ t_stat = linreg_coeff (c, j) / std_err; - tab_double (t, 5, this_row, 0, t_stat, NULL); + tab_double (t, 5, this_row, 0, t_stat, NULL, RC_OTHER); /* P values for the test statistic above. */ pval = 2 * gsl_cdf_tdist_Q (fabs (t_stat), df); - tab_double (t, 6, this_row, 0, pval, NULL); + tab_double (t, 6, this_row, 0, pval, NULL, RC_PVALUE); ds_destroy (&tstr); if (cmd->stats & STATS_CI) @@ -900,8 +900,8 @@ reg_stats_coeff (const linreg * c, const gsl_matrix *cov, const struct variable double lower = linreg_coeff (c, j) - tval * std_err ; double upper = linreg_coeff (c, j) + tval * std_err ; - tab_double (t, 7, this_row, 0, lower, NULL); - tab_double (t, 8, this_row, 0, upper, NULL); + tab_double (t, 7, this_row, 0, lower, NULL, RC_OTHER); + tab_double (t, 8, this_row, 0, upper, NULL, RC_OTHER); } } tab_title (t, _("Coefficients (%s)"), var_to_string (var)); @@ -944,9 +944,9 @@ reg_stats_anova (const linreg * c, const struct variable *var) tab_text (t, 1, 3, TAB_LEFT | TAT_TITLE, _("Total")); /* Sums of Squares */ - tab_double (t, 2, 1, 0, linreg_ssreg (c), NULL); - tab_double (t, 2, 3, 0, linreg_sst (c), NULL); - tab_double (t, 2, 2, 0, linreg_sse (c), NULL); + tab_double (t, 2, 1, 0, linreg_ssreg (c), NULL, RC_OTHER); + tab_double (t, 2, 3, 0, linreg_sst (c), NULL, RC_OTHER); + tab_double (t, 2, 2, 0, linreg_sse (c), NULL, RC_OTHER); /* Degrees of freedom */ @@ -955,12 +955,12 @@ reg_stats_anova (const linreg * c, const struct variable *var) tab_text_format (t, 3, 3, TAB_RIGHT, "%.*g", DBL_DIG + 1, c->dft); /* Mean Squares */ - tab_double (t, 4, 1, TAB_RIGHT, msm, NULL); - tab_double (t, 4, 2, TAB_RIGHT, mse, NULL); + tab_double (t, 4, 1, TAB_RIGHT, msm, NULL, RC_OTHER); + tab_double (t, 4, 2, TAB_RIGHT, mse, NULL, RC_OTHER); - tab_double (t, 5, 1, 0, F, NULL); + tab_double (t, 5, 1, 0, F, NULL, RC_OTHER); - tab_double (t, 6, 1, 0, pval, NULL); + tab_double (t, 6, 1, 0, pval, NULL, RC_OTHER); tab_title (t, _("ANOVA (%s)"), var_to_string (var)); tab_submit (t); @@ -1001,7 +1001,7 @@ reg_stats_bcov (const linreg * c, const struct variable *var) col = (i <= k) ? k : i; row = (i <= k) ? i : k; tab_double (t, k + 2, i, TAB_CENTER, - gsl_matrix_get (c->cov, row, col), NULL); + gsl_matrix_get (c->cov, row, col), NULL, RC_OTHER); } } tab_title (t, _("Coefficient Correlations (%s)"), var_to_string (var)); diff --git a/src/language/stats/reliability.c b/src/language/stats/reliability.c index a4c4b862fd..8975e4f908 100644 --- a/src/language/stats/reliability.c +++ b/src/language/stats/reliability.c @@ -537,6 +537,7 @@ case_processing_summary (casenumber n_valid, casenumber n_missing, int heading_rows = 1; struct tab_table *tbl; tbl = tab_create (n_cols, n_rows); + tab_set_format (tbl, RC_WEIGHT, wfmt); tab_headers (tbl, heading_columns, 0, heading_rows, 0); tab_title (tbl, _("Case Processing Summary")); @@ -581,27 +582,27 @@ case_processing_summary (casenumber n_valid, casenumber n_missing, total = n_missing + n_valid; tab_double (tbl, 2, heading_rows, TAB_RIGHT, - n_valid, wfmt); + n_valid, NULL, RC_WEIGHT); tab_double (tbl, 2, heading_rows + 1, TAB_RIGHT, - n_missing, wfmt); + n_missing, NULL, RC_WEIGHT); tab_double (tbl, 2, heading_rows + 2, TAB_RIGHT, - total, wfmt); + total, NULL, RC_WEIGHT); tab_double (tbl, 3, heading_rows, TAB_RIGHT, - 100 * n_valid / (double) total, NULL); + 100 * n_valid / (double) total, NULL, RC_OTHER); tab_double (tbl, 3, heading_rows + 1, TAB_RIGHT, - 100 * n_missing / (double) total, NULL); + 100 * n_missing / (double) total, NULL, RC_OTHER); tab_double (tbl, 3, heading_rows + 2, TAB_RIGHT, - 100 * total / (double) total, NULL); + 100 * total / (double) total, NULL, RC_OTHER); tab_submit (tbl); @@ -617,8 +618,10 @@ reliability_summary_total (const struct reliability *rel) const int heading_columns = 1; const int heading_rows = 1; const int n_rows = rel->sc[0].n_items + heading_rows ; - + const struct variable *wv = rel->wv; + const struct fmt_spec *wfmt = wv ? var_get_print_format (wv) : & F_8_0; struct tab_table *tbl = tab_create (n_cols, n_rows); + tab_set_format (tbl, RC_WEIGHT, wfmt); tab_headers (tbl, heading_columns, 0, heading_rows, 0); tab_title (tbl, _("Item-Total Statistics")); @@ -667,13 +670,13 @@ reliability_summary_total (const struct reliability *rel) moments1_calculate (s->total, &weight, &mean, &var, 0, 0); tab_double (tbl, 1, heading_rows + i, TAB_RIGHT, - mean, NULL); + mean, NULL, RC_OTHER); tab_double (tbl, 2, heading_rows + i, TAB_RIGHT, - s->variance_of_sums, NULL); + s->variance_of_sums, NULL, RC_OTHER); tab_double (tbl, 4, heading_rows + i, TAB_RIGHT, - s->alpha, NULL); + s->alpha, NULL, RC_OTHER); moments1_calculate (rel->sc[0].m[i], &weight, &mean, &var, 0,0); @@ -684,7 +687,7 @@ reliability_summary_total (const struct reliability *rel) tab_double (tbl, 3, heading_rows + i, TAB_RIGHT, - item_to_total_r, NULL); + item_to_total_r, NULL, RC_OTHER); } @@ -722,8 +725,11 @@ reliability_statistics (const struct reliability *rel) int n_rows = rol[rel->model].n_rows; int heading_columns = rol[rel->model].heading_cols; int heading_rows = rol[rel->model].heading_rows; - + const struct variable *wv = rel->wv; + const struct fmt_spec *wfmt = wv ? var_get_print_format (wv) : & F_8_0; struct tab_table *tbl = tab_create (n_cols, n_rows); + tab_set_format (tbl, RC_WEIGHT, wfmt); + tab_headers (tbl, heading_columns, 0, heading_rows, 0); tab_title (tbl, _("Reliability Statistics")); @@ -760,9 +766,6 @@ static void reliability_statistics_model_alpha (struct tab_table *tbl, const struct reliability *rel) { - const struct variable *wv = rel->wv; - const struct fmt_spec *wfmt = wv ? var_get_print_format (wv) : & F_8_0; - const struct cronbach *s = &rel->sc[0]; tab_text (tbl, 0, 0, TAB_CENTER | TAT_TITLE, @@ -771,9 +774,9 @@ reliability_statistics_model_alpha (struct tab_table *tbl, tab_text (tbl, 1, 0, TAB_CENTER | TAT_TITLE, _("N of Items")); - tab_double (tbl, 0, 1, TAB_RIGHT, s->alpha, NULL); + tab_double (tbl, 0, 1, TAB_RIGHT, s->alpha, NULL, RC_OTHER); - tab_double (tbl, 1, 1, TAB_RIGHT, s->n_items, wfmt); + tab_double (tbl, 1, 1, TAB_RIGHT, s->n_items, NULL, RC_WEIGHT); } @@ -781,9 +784,6 @@ static void reliability_statistics_model_split (struct tab_table *tbl, const struct reliability *rel) { - const struct variable *wv = rel->wv; - const struct fmt_spec *wfmt = wv ? var_get_print_format (wv) : & F_8_0; - tab_text (tbl, 0, 0, TAB_LEFT, _("Cronbach's Alpha")); @@ -796,8 +796,6 @@ reliability_statistics_model_split (struct tab_table *tbl, tab_text (tbl, 2, 1, TAB_LEFT, _("N of Items")); - - tab_text (tbl, 1, 2, TAB_LEFT, _("Part 2")); @@ -807,15 +805,12 @@ reliability_statistics_model_split (struct tab_table *tbl, 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")); @@ -831,14 +826,14 @@ reliability_statistics_model_split (struct tab_table *tbl, - tab_double (tbl, 3, 0, TAB_RIGHT, rel->sc[1].alpha, NULL); - tab_double (tbl, 3, 2, TAB_RIGHT, rel->sc[2].alpha, NULL); + 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, wfmt); - tab_double (tbl, 3, 3, TAB_RIGHT, rel->sc[2].n_items, wfmt); + 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, wfmt); + rel->sc[1].n_items + rel->sc[2].n_items, NULL, RC_WEIGHT); { /* R is the correlation between the two parts */ @@ -857,12 +852,12 @@ reliability_statistics_model_split (struct tab_table *tbl, r /= sqrt (rel->sc[2].variance_of_sums); r /= 2.0; - tab_double (tbl, 3, 5, TAB_RIGHT, r, NULL); + 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); + tab_double (tbl, 3, 6, TAB_RIGHT, 2 * r / (1.0 + r), NULL, RC_OTHER); - tab_double (tbl, 3, 8, TAB_RIGHT, g, NULL); + 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); @@ -871,7 +866,7 @@ reliability_statistics_model_split (struct tab_table *tbl, uly -= pow2 (r); uly /= 2 * tmp; - tab_double (tbl, 3, 7, TAB_RIGHT, uly, NULL); + tab_double (tbl, 3, 7, TAB_RIGHT, uly, NULL, RC_OTHER); } } diff --git a/src/language/stats/roc.c b/src/language/stats/roc.c index 031314cd39..d011bf547e 100644 --- a/src/language/stats/roc.c +++ b/src/language/stats/roc.c @@ -999,7 +999,7 @@ show_auc (struct roc_state *rs, const struct cmd_roc *roc) { tab_text (tbl, 0, 2 + i, TAT_TITLE, var_to_string (roc->vars[i])); - tab_double (tbl, n_cols - n_fields, 2 + i, 0, rs[i].auc, NULL); + tab_double (tbl, n_cols - n_fields, 2 + i, 0, rs[i].auc, NULL, RC_OTHER); if ( roc->print_se ) { @@ -1018,22 +1018,22 @@ show_auc (struct roc_state *rs, const struct cmd_roc *roc) tab_double (tbl, n_cols - 4, 2 + i, 0, se, - NULL); + NULL, RC_OTHER); ci = 1 - roc->ci / 100.0; yy = gsl_cdf_gaussian_Qinv (ci, se) ; tab_double (tbl, n_cols - 2, 2 + i, 0, rs[i].auc - yy, - NULL); + NULL, RC_OTHER); tab_double (tbl, n_cols - 1, 2 + i, 0, rs[i].auc + yy, - NULL); + NULL, RC_OTHER); tab_double (tbl, n_cols - 3, 2 + i, 0, 2.0 * gsl_cdf_ugaussian_Q (fabs ((rs[i].auc - 0.5 ) / sd_0_5)), - NULL); + NULL, RC_PVALUE); } } @@ -1080,11 +1080,11 @@ show_summary (const struct cmd_roc *roc) tab_text (tbl, 0, 3, TAB_LEFT, _("Negative")); - tab_double (tbl, 1, 2, 0, roc->pos, &F_8_0); - tab_double (tbl, 1, 3, 0, roc->neg, &F_8_0); + tab_double (tbl, 1, 2, 0, roc->pos, NULL, RC_INTEGER); + tab_double (tbl, 1, 3, 0, roc->neg, NULL, RC_INTEGER); - tab_double (tbl, 2, 2, 0, roc->pos_weighted, 0); - tab_double (tbl, 2, 3, 0, roc->neg_weighted, 0); + tab_double (tbl, 2, 2, 0, roc->pos_weighted, NULL, RC_OTHER); + tab_double (tbl, 2, 3, 0, roc->neg_weighted, NULL, RC_OTHER); tab_submit (tbl); } @@ -1161,10 +1161,10 @@ show_coords (struct roc_state *rs, const struct cmd_roc *roc) ); tab_double (tbl, n_cols - 3, x, 0, case_data_idx (cc, ROC_CUTPOINT)->f, - var_get_print_format (roc->vars[i])); + var_get_print_format (roc->vars[i]), RC_OTHER); - tab_double (tbl, n_cols - 2, x, 0, se, NULL); - tab_double (tbl, n_cols - 1, x, 0, 1 - sp, NULL); + tab_double (tbl, n_cols - 2, x, 0, se, NULL, RC_OTHER); + tab_double (tbl, n_cols - 1, x, 0, 1 - sp, NULL, RC_OTHER); } casereader_destroy (r); diff --git a/src/language/stats/runs.c b/src/language/stats/runs.c index 788aae0d13..f5eec1e89e 100644 --- a/src/language/stats/runs.c +++ b/src/language/stats/runs.c @@ -318,6 +318,7 @@ show_runs_result (const struct runs_test *rt, const struct run_state *rs, const const int column_headers = 1; struct tab_table *table = tab_create (row_headers + otp->n_vars, column_headers + 7); + tab_set_format (table, RC_WEIGHT, wfmt); tab_headers (table, row_headers, 0, column_headers, 0); @@ -341,25 +342,25 @@ show_runs_result (const struct runs_test *rt, const struct run_state *rs, const var_to_string (otp->vars[i])); tab_double (table, row_headers +i, 1, 0, - run->cutpoint, 0); + run->cutpoint, NULL, RC_OTHER); tab_double (table, row_headers +i, 2, 0, - run->nn, wfmt); + run->nn, NULL, RC_WEIGHT); tab_double (table, row_headers +i, 3, 0, - run->np, wfmt); + run->np, NULL, RC_WEIGHT); tab_double (table, row_headers +i, 4, 0, - run->n, wfmt); + run->n, NULL, RC_WEIGHT); tab_double (table, row_headers +i, 5, 0, - run->runs, &F_8_0); + run->runs, NULL, RC_INTEGER); tab_double (table, row_headers +i, 6, 0, - z, 0); + z, NULL, RC_OTHER); tab_double (table, row_headers +i, 7, 0, - 2.0 * gsl_cdf_ugaussian_P (z), 0); + 2.0 * gsl_cdf_ugaussian_P (z), NULL, RC_PVALUE); } switch ( rt->cp_mode) diff --git a/src/language/stats/sign.c b/src/language/stats/sign.c index e208ce9d9e..5149489d11 100644 --- a/src/language/stats/sign.c +++ b/src/language/stats/sign.c @@ -59,6 +59,7 @@ output_frequency_table (const struct two_sample_test *t2s, const struct variable *wv = dict_get_weight (dict); const struct fmt_spec *wfmt = wv ? var_get_print_format (wv) : & F_8_0; + tab_set_format (table, RC_WEIGHT, wfmt); tab_title (table, _("Frequencies")); tab_headers (table, 2, 0, 1, 0); @@ -94,11 +95,11 @@ output_frequency_table (const struct two_sample_test *t2s, tab_text (table, 1, 3 + i * 4, TAB_LEFT, _("Ties")); tab_text (table, 1, 4 + i * 4, TAB_LEFT, _("Total")); - tab_double (table, 2, 1 + i * 4, TAB_RIGHT, param[i].neg, wfmt); - tab_double (table, 2, 2 + i * 4, TAB_RIGHT, param[i].pos, wfmt); - tab_double (table, 2, 3 + i * 4, TAB_RIGHT, param[i].ties, wfmt); + tab_double (table, 2, 1 + i * 4, TAB_RIGHT, param[i].neg, NULL, RC_WEIGHT); + tab_double (table, 2, 2 + i * 4, TAB_RIGHT, param[i].pos, NULL, RC_WEIGHT); + tab_double (table, 2, 3 + i * 4, TAB_RIGHT, param[i].ties, NULL, RC_WEIGHT); tab_double (table, 2, 4 + i * 4, TAB_RIGHT, - param[i].ties + param[i].neg + param[i].pos, wfmt); + param[i].ties + param[i].neg + param[i].pos, NULL, RC_WEIGHT); } tab_submit (table); @@ -151,10 +152,10 @@ output_statistics_table (const struct two_sample_test *t2s, ds_destroy (&pair_name); tab_double (table, 1 + i, 1, TAB_RIGHT, - param[i].one_tailed_sig * 2, NULL); + param[i].one_tailed_sig * 2, NULL, RC_PVALUE); - tab_double (table, 1 + i, 2, TAB_RIGHT, param[i].one_tailed_sig, NULL); - tab_double (table, 1 + i, 3, TAB_RIGHT, param[i].point_prob, NULL); + tab_double (table, 1 + i, 2, TAB_RIGHT, param[i].one_tailed_sig, NULL, RC_PVALUE); + tab_double (table, 1 + i, 3, TAB_RIGHT, param[i].point_prob, NULL, RC_PVALUE); } tab_submit (table); diff --git a/src/language/stats/t-test-indep.c b/src/language/stats/t-test-indep.c index ca2c95d58f..f17a1d5b78 100644 --- a/src/language/stats/t-test-indep.c +++ b/src/language/stats/t-test-indep.c @@ -197,7 +197,7 @@ indep_summary (const struct tt *tt, struct indep_samples *is, const struct pair_ struct string vallab0 ; struct string vallab1 ; struct tab_table *t = tab_create (cols, rows); - + tab_set_format (t, RC_WEIGHT, wfmt); ds_init_empty (&vallab0); ds_init_empty (&vallab1); @@ -248,10 +248,10 @@ indep_summary (const struct tt *tt, struct indep_samples *is, const struct pair_ double cc, mean, sigma; moments_calculate (ps[v].mom[i], &cc, &mean, &sigma, NULL, NULL); - tab_double (t, 2, v * 2 + i + heading_rows, TAB_RIGHT, cc, wfmt); - tab_double (t, 3, v * 2 + i + heading_rows, TAB_RIGHT, mean, NULL); - tab_double (t, 4, v * 2 + i + heading_rows, TAB_RIGHT, sqrt (sigma), NULL); - tab_double (t, 5, v * 2 + i + heading_rows, TAB_RIGHT, sqrt (sigma / cc), NULL); + tab_double (t, 2, v * 2 + i + heading_rows, TAB_RIGHT, cc, NULL, RC_WEIGHT); + tab_double (t, 3, v * 2 + i + heading_rows, TAB_RIGHT, mean, NULL, RC_OTHER); + tab_double (t, 4, v * 2 + i + heading_rows, TAB_RIGHT, sqrt (sigma), NULL, RC_OTHER); + tab_double (t, 5, v * 2 + i + heading_rows, TAB_RIGHT, sqrt (sigma / cc), NULL, RC_OTHER); } } @@ -317,33 +317,33 @@ indep_test (const struct tt *tt, const struct pair_stats *ps) tab_text (t, 1, v * 2 + heading_rows, TAB_LEFT, _("Equal variances assumed")); df = cc0 + cc1 - 2.0; - tab_double (t, 5, v * 2 + heading_rows, TAB_RIGHT, df, NULL); + tab_double (t, 5, v * 2 + heading_rows, TAB_RIGHT, df, NULL, RC_OTHER); pooled_variance = ((cc0 - 1)* sigma0 + (cc1 - 1) * sigma1) / df ; tval = (mean0 - mean1) / sqrt (pooled_variance); tval /= sqrt ((cc0 + cc1) / (cc0 * cc1)); - tab_double (t, 4, v * 2 + heading_rows, TAB_RIGHT, tval, NULL); + tab_double (t, 4, v * 2 + heading_rows, TAB_RIGHT, tval, NULL, RC_OTHER); p = gsl_cdf_tdist_P (tval, df); q = gsl_cdf_tdist_Q (tval, df); mean_diff = mean0 - mean1; - tab_double (t, 6, v * 2 + heading_rows, TAB_RIGHT, 2.0 * (tval > 0 ? q : p), NULL); - tab_double (t, 7, v * 2 + heading_rows, TAB_RIGHT, mean_diff, NULL); + tab_double (t, 6, v * 2 + heading_rows, TAB_RIGHT, 2.0 * (tval > 0 ? q : p), NULL, RC_PVALUE); + tab_double (t, 7, v * 2 + heading_rows, TAB_RIGHT, mean_diff, NULL, RC_OTHER); std_err_diff = sqrt (pooled_variance * (1.0/cc0 + 1.0/cc1)); - tab_double (t, 8, v * 2 + heading_rows, TAB_RIGHT, std_err_diff, NULL); + tab_double (t, 8, v * 2 + heading_rows, TAB_RIGHT, std_err_diff, NULL, RC_OTHER); /* Now work out the confidence interval */ q = (1 - tt->confidence)/2.0; /* 2-tailed test */ tval = gsl_cdf_tdist_Qinv (q, df); - tab_double (t, 9, v * 2 + heading_rows, TAB_RIGHT, mean_diff - tval * std_err_diff, NULL); - tab_double (t, 10, v * 2 + heading_rows, TAB_RIGHT, mean_diff + tval * std_err_diff, NULL); + tab_double (t, 9, v * 2 + heading_rows, TAB_RIGHT, mean_diff - tval * std_err_diff, NULL, RC_OTHER); + tab_double (t, 10, v * 2 + heading_rows, TAB_RIGHT, mean_diff + tval * std_err_diff, NULL, RC_OTHER); /* Equal variances not assumed */ tab_text (t, 1, v * 2 + heading_rows + 1, TAB_LEFT, _("Equal variances not assumed")); @@ -351,7 +351,7 @@ indep_test (const struct tt *tt, const struct pair_stats *ps) se2 = sigma0 / cc0 + sigma1 / cc1; tval = mean_diff / sqrt (se2); - tab_double (t, 4, v * 2 + heading_rows + 1, TAB_RIGHT, tval, NULL); + tab_double (t, 4, v * 2 + heading_rows + 1, TAB_RIGHT, tval, NULL, RC_OTHER); { double p, q; @@ -360,12 +360,12 @@ indep_test (const struct tt *tt, const struct pair_stats *ps) double df = pow2 (s0 + s1) ; df /= pow2 (s0) / (cc0 - 1) + pow2 (s1) / (cc1 - 1); - tab_double (t, 5, v * 2 + heading_rows + 1, TAB_RIGHT, df, NULL); + tab_double (t, 5, v * 2 + heading_rows + 1, TAB_RIGHT, df, NULL, RC_OTHER); p = gsl_cdf_tdist_P (tval, df); q = gsl_cdf_tdist_Q (tval, df); - tab_double (t, 6, v * 2 + heading_rows + 1, TAB_RIGHT, 2.0 * (tval > 0 ? q : p), NULL); + tab_double (t, 6, v * 2 + heading_rows + 1, TAB_RIGHT, 2.0 * (tval > 0 ? q : p), NULL, RC_PVALUE); /* Now work out the confidence interval */ q = (1 - tt->confidence) / 2.0; /* 2-tailed test */ @@ -373,12 +373,12 @@ indep_test (const struct tt *tt, const struct pair_stats *ps) tval = gsl_cdf_tdist_Qinv (q, df); } - tab_double (t, 7, v * 2 + heading_rows + 1, TAB_RIGHT, mean_diff, NULL); - tab_double (t, 8, v * 2 + heading_rows + 1, TAB_RIGHT, std_err_diff, NULL); - tab_double (t, 9, v * 2 + heading_rows + 1, TAB_RIGHT, mean_diff - tval * std_err_diff, NULL); - tab_double (t, 10, v * 2 + heading_rows + 1, TAB_RIGHT, mean_diff + tval * std_err_diff, NULL); + tab_double (t, 7, v * 2 + heading_rows + 1, TAB_RIGHT, mean_diff, NULL, RC_OTHER); + tab_double (t, 8, v * 2 + heading_rows + 1, TAB_RIGHT, std_err_diff, NULL, RC_OTHER); + tab_double (t, 9, v * 2 + heading_rows + 1, TAB_RIGHT, mean_diff - tval * std_err_diff, NULL, RC_OTHER); + tab_double (t, 10, v * 2 + heading_rows + 1, TAB_RIGHT, mean_diff + tval * std_err_diff, NULL, RC_OTHER); - tab_double (t, 2, v * 2 + heading_rows, TAB_CENTER, ps[v].lev, NULL); + tab_double (t, 2, v * 2 + heading_rows, TAB_CENTER, ps[v].lev, NULL, RC_OTHER); { @@ -386,7 +386,7 @@ indep_test (const struct tt *tt, const struct pair_stats *ps) double df1 = 1; double df2 = cc0 + cc1 - 2; double q = gsl_cdf_fdist_Q (ps[v].lev, df1, df2); - tab_double (t, 3, v * 2 + heading_rows, TAB_CENTER, q, NULL); + tab_double (t, 3, v * 2 + heading_rows, TAB_CENTER, q, NULL, RC_OTHER); } } diff --git a/src/language/stats/t-test-one-sample.c b/src/language/stats/t-test-one-sample.c index 38c1eff6e4..73356e4e87 100644 --- a/src/language/stats/t-test-one-sample.c +++ b/src/language/stats/t-test-one-sample.c @@ -71,6 +71,7 @@ one_sample_test (const struct tt *tt, const struct one_samp *os) const struct fmt_spec *wfmt = tt->wv ? var_get_print_format (tt->wv) : & F_8_0; struct tab_table *t = tab_create (cols, rows); + tab_set_format (t, RC_WEIGHT, wfmt); tab_headers (t, 0, 0, heading_rows, 0); tab_box (t, TAL_2, TAL_2, TAL_0, TAL_0, 0, 0, cols - 1, rows - 1); @@ -119,19 +120,19 @@ one_sample_test (const struct tt *tt, const struct one_samp *os) q = gsl_cdf_tdist_Q (tval, df); tab_text (t, 0, v + heading_rows, TAB_LEFT, var_to_string (per_var_stats->var)); - tab_double (t, 1, v + heading_rows, TAB_RIGHT, tval, NULL); - tab_double (t, 2, v + heading_rows, TAB_RIGHT, df, wfmt); + tab_double (t, 1, v + heading_rows, TAB_RIGHT, tval, NULL, RC_OTHER); + tab_double (t, 2, v + heading_rows, TAB_RIGHT, df, NULL, RC_WEIGHT); /* Multiply by 2 to get 2-tailed significance, makeing sure we've got the correct tail*/ - tab_double (t, 3, v + heading_rows, TAB_RIGHT, 2.0 * (tval > 0 ? q : p), NULL); + tab_double (t, 3, v + heading_rows, TAB_RIGHT, 2.0 * (tval > 0 ? q : p), NULL, RC_PVALUE); - tab_double (t, 4, v + heading_rows, TAB_RIGHT, mean_diff, NULL); + tab_double (t, 4, v + heading_rows, TAB_RIGHT, mean_diff, NULL, RC_OTHER); tval = gsl_cdf_tdist_Qinv ( (1.0 - tt->confidence) / 2.0, df); - tab_double (t, 5, v + heading_rows, TAB_RIGHT, mean_diff - tval * se_mean, NULL); - tab_double (t, 6, v + heading_rows, TAB_RIGHT, mean_diff + tval * se_mean, NULL); + tab_double (t, 5, v + heading_rows, TAB_RIGHT, mean_diff - tval * se_mean, NULL, RC_OTHER); + tab_double (t, 6, v + heading_rows, TAB_RIGHT, mean_diff + tval * se_mean, NULL, RC_OTHER); } tab_submit (t); @@ -148,7 +149,7 @@ one_sample_summary (const struct tt *tt, const struct one_samp *os) const int rows = tt->n_vars + heading_rows; struct tab_table *t = tab_create (cols, rows); const struct fmt_spec *wfmt = tt->wv ? var_get_print_format (tt->wv) : & F_8_0; - + tab_set_format (t, RC_WEIGHT, wfmt); tab_headers (t, 0, 0, heading_rows, 0); tab_box (t, TAL_2, TAL_2, TAL_0, TAL_1, 0, 0, cols - 1, rows - 1); tab_hline (t, TAL_2, 0, cols - 1, 1); @@ -168,10 +169,10 @@ one_sample_summary (const struct tt *tt, const struct one_samp *os) moments_calculate (m, &cc, &mean, &sigma, NULL, NULL); tab_text (t, 0, v + heading_rows, TAB_LEFT, var_to_string (per_var_stats->var)); - tab_double (t, 1, v + heading_rows, TAB_RIGHT, cc, wfmt); - tab_double (t, 2, v + heading_rows, TAB_RIGHT, mean, NULL); - tab_double (t, 3, v + heading_rows, TAB_RIGHT, sqrt (sigma), NULL); - tab_double (t, 4, v + heading_rows, TAB_RIGHT, sqrt (sigma / cc), NULL); + tab_double (t, 1, v + heading_rows, TAB_RIGHT, cc, NULL, RC_WEIGHT); + tab_double (t, 2, v + heading_rows, TAB_RIGHT, mean, NULL, RC_OTHER); + tab_double (t, 3, v + heading_rows, TAB_RIGHT, sqrt (sigma), NULL, RC_OTHER); + tab_double (t, 4, v + heading_rows, TAB_RIGHT, sqrt (sigma / cc), NULL, RC_OTHER); } tab_submit (t); diff --git a/src/language/stats/t-test-paired.c b/src/language/stats/t-test-paired.c index 02067190fb..55a31a2521 100644 --- a/src/language/stats/t-test-paired.c +++ b/src/language/stats/t-test-paired.c @@ -167,7 +167,7 @@ paired_summary (const struct tt *tt, struct paired_samp *os) const int rows = n_pairs * 2 + heading_rows; struct tab_table *t = tab_create (cols, rows); const struct fmt_spec *wfmt = tt->wv ? var_get_print_format (tt->wv) : & F_8_0; - + tab_set_format (t, RC_WEIGHT, wfmt); tab_headers (t, 0, 0, heading_rows, 0); tab_box (t, TAL_2, TAL_2, TAL_0, TAL_0, 0, 0, cols - 1, rows - 1); tab_box (t, -1, -1, TAL_0, TAL_1, heading_cols, 0, cols - 1, rows - 1); @@ -191,18 +191,18 @@ paired_summary (const struct tt *tt, struct paired_samp *os) /* first var */ moments_calculate (pp->mom0, &cc, &mean, &sigma, NULL, NULL); tab_text (t, 1, v * 2 + heading_rows, TAB_LEFT, var_to_string (pp->var0)); - tab_double (t, 3, v * 2 + heading_rows, TAB_RIGHT, cc, wfmt); - tab_double (t, 2, v * 2 + heading_rows, TAB_RIGHT, mean, NULL); - tab_double (t, 4, v * 2 + heading_rows, TAB_RIGHT, sqrt (sigma), NULL); - tab_double (t, 5, v * 2 + heading_rows, TAB_RIGHT, sqrt (sigma / cc), NULL); + tab_double (t, 3, v * 2 + heading_rows, TAB_RIGHT, cc, NULL, RC_WEIGHT); + tab_double (t, 2, v * 2 + heading_rows, TAB_RIGHT, mean, NULL, RC_OTHER); + tab_double (t, 4, v * 2 + heading_rows, TAB_RIGHT, sqrt (sigma), NULL, RC_OTHER); + tab_double (t, 5, v * 2 + heading_rows, TAB_RIGHT, sqrt (sigma / cc), NULL, RC_OTHER); /* second var */ moments_calculate (pp->mom1, &cc, &mean, &sigma, NULL, NULL); tab_text (t, 1, v * 2 + 1 + heading_rows, TAB_LEFT, var_to_string (pp->var1)); - tab_double (t, 3, v * 2 + 1 + heading_rows, TAB_RIGHT, cc, wfmt); - tab_double (t, 2, v * 2 + 1 + heading_rows, TAB_RIGHT, mean, NULL); - tab_double (t, 4, v * 2 + 1 + heading_rows, TAB_RIGHT, sqrt (sigma), NULL); - tab_double (t, 5, v * 2 + 1 + heading_rows, TAB_RIGHT, sqrt (sigma / cc), NULL); + tab_double (t, 3, v * 2 + 1 + heading_rows, TAB_RIGHT, cc, NULL, RC_WEIGHT); + tab_double (t, 2, v * 2 + 1 + heading_rows, TAB_RIGHT, mean, NULL, RC_OTHER); + tab_double (t, 4, v * 2 + 1 + heading_rows, TAB_RIGHT, sqrt (sigma), NULL, RC_OTHER); + tab_double (t, 5, v * 2 + 1 + heading_rows, TAB_RIGHT, sqrt (sigma / cc), NULL, RC_OTHER); } tab_submit (t); @@ -222,7 +222,7 @@ paired_correlations (const struct tt *tt, struct paired_samp *os) const int rows = n_pairs + heading_rows; struct tab_table *t = tab_create (cols, rows); const struct fmt_spec *wfmt = tt->wv ? var_get_print_format (tt->wv) : & F_8_0; - + tab_set_format (t, RC_WEIGHT, wfmt); tab_headers (t, 0, 0, heading_rows, 0); tab_box (t, TAL_2, TAL_2, TAL_0, TAL_1, 0, 0, cols - 1, rows - 1); @@ -253,15 +253,15 @@ paired_correlations (const struct tt *tt, struct paired_samp *os) /* If this fails, then we're not dealing with missing values properly */ assert (cc0 == cc1); - tab_double (t, 2, v + heading_rows, TAB_RIGHT, cc0, wfmt); + tab_double (t, 2, v + heading_rows, TAB_RIGHT, cc0, NULL, RC_WEIGHT); corr = pp->sum_of_prod / cc0 - (mean0 * mean1); corr /= sqrt (sigma0 * sigma1); corr *= cc0 / (cc0 - 1); - tab_double (t, 3, v + heading_rows, TAB_RIGHT, corr, NULL); + tab_double (t, 3, v + heading_rows, TAB_RIGHT, corr, NULL, RC_OTHER); tab_double (t, 4, v + heading_rows, TAB_RIGHT, - 2.0 * significance_of_correlation (corr, cc0), NULL); + 2.0 * significance_of_correlation (corr, cc0), NULL, RC_OTHER); } tab_submit (t); @@ -282,7 +282,7 @@ paired_test (const struct tt *tt, const struct paired_samp *os) const struct fmt_spec *wfmt = tt->wv ? var_get_print_format (tt->wv) : & F_8_0; struct tab_table *t = tab_create (cols, rows); - + tab_set_format (t, RC_WEIGHT, wfmt); tab_headers (t, 0, 0, heading_rows, 0); tab_box (t, TAL_2, TAL_2, TAL_0, TAL_0, 0, 0, cols - 1, rows - 1); tab_hline (t, TAL_2, 0, cols - 1, 3); @@ -333,23 +333,23 @@ paired_test (const struct tt *tt, const struct paired_samp *os) tval = mean * sqrt (cc / sigma); se_mean = sqrt (sigma / cc); - tab_double (t, 2, v + heading_rows, TAB_RIGHT, mean, NULL); - tab_double (t, 3, v + heading_rows, TAB_RIGHT, sqrt (sigma), NULL); - tab_double (t, 4, v + heading_rows, TAB_RIGHT, se_mean, NULL); + tab_double (t, 2, v + heading_rows, TAB_RIGHT, mean, NULL, RC_OTHER); + tab_double (t, 3, v + heading_rows, TAB_RIGHT, sqrt (sigma), NULL, RC_OTHER); + tab_double (t, 4, v + heading_rows, TAB_RIGHT, se_mean, NULL, RC_OTHER); - tab_double (t, 7, v + heading_rows, TAB_RIGHT, tval, NULL); - tab_double (t, 8, v + heading_rows, TAB_RIGHT, df, wfmt); + tab_double (t, 7, v + heading_rows, TAB_RIGHT, tval, NULL, RC_OTHER); + tab_double (t, 8, v + heading_rows, TAB_RIGHT, df, NULL, RC_WEIGHT); p = gsl_cdf_tdist_P (tval, df); q = gsl_cdf_tdist_Q (tval, df); - tab_double (t, 9, v + heading_rows, TAB_RIGHT, 2.0 * (tval > 0 ? q : p), NULL); + tab_double (t, 9, v + heading_rows, TAB_RIGHT, 2.0 * (tval > 0 ? q : p), NULL, RC_PVALUE); tval = gsl_cdf_tdist_Qinv ( (1.0 - tt->confidence) / 2.0, df); - tab_double (t, 5, v + heading_rows, TAB_RIGHT, mean - tval * se_mean, NULL); - tab_double (t, 6, v + heading_rows, TAB_RIGHT, mean + tval * se_mean, NULL); + tab_double (t, 5, v + heading_rows, TAB_RIGHT, mean - tval * se_mean, NULL, RC_OTHER); + tab_double (t, 6, v + heading_rows, TAB_RIGHT, mean + tval * se_mean, NULL, RC_OTHER); } tab_submit (t); diff --git a/src/language/stats/wilcoxon.c b/src/language/stats/wilcoxon.c index 284e547556..2a8061dd91 100644 --- a/src/language/stats/wilcoxon.c +++ b/src/language/stats/wilcoxon.c @@ -221,6 +221,7 @@ show_ranks_box (const struct wilcoxon_state *ws, const struct fmt_spec *wfmt = wv ? var_get_print_format (wv) : & F_8_0; struct tab_table *table = tab_create (5, 1 + 4 * t2s->n_pairs); + tab_set_format (table, RC_WEIGHT, wfmt); tab_title (table, _("Ranks")); @@ -262,24 +263,24 @@ show_ranks_box (const struct wilcoxon_state *ws, /* N */ - tab_double (table, 2, 1 + i * 4, TAB_RIGHT, ws[i].negatives.n, wfmt); - tab_double (table, 2, 2 + i * 4, TAB_RIGHT, ws[i].positives.n, wfmt); - tab_double (table, 2, 3 + i * 4, TAB_RIGHT, ws[i].n_zeros, wfmt); + tab_double (table, 2, 1 + i * 4, TAB_RIGHT, ws[i].negatives.n, NULL, RC_WEIGHT); + tab_double (table, 2, 2 + i * 4, TAB_RIGHT, ws[i].positives.n, NULL, RC_WEIGHT); + tab_double (table, 2, 3 + i * 4, TAB_RIGHT, ws[i].n_zeros, NULL, RC_WEIGHT); tab_double (table, 2, 4 + i * 4, TAB_RIGHT, - ws[i].n_zeros + ws[i].positives.n + ws[i].negatives.n, wfmt); + ws[i].n_zeros + ws[i].positives.n + ws[i].negatives.n, NULL, RC_WEIGHT); /* Sums */ - tab_double (table, 4, 1 + i * 4, TAB_RIGHT, ws[i].negatives.sum, NULL); - tab_double (table, 4, 2 + i * 4, TAB_RIGHT, ws[i].positives.sum, NULL); + tab_double (table, 4, 1 + i * 4, TAB_RIGHT, ws[i].negatives.sum, NULL, RC_OTHER); + tab_double (table, 4, 2 + i * 4, TAB_RIGHT, ws[i].positives.sum, NULL, RC_OTHER); /* Means */ tab_double (table, 3, 1 + i * 4, TAB_RIGHT, - ws[i].negatives.sum / (double) ws[i].negatives.n, NULL); + ws[i].negatives.sum / (double) ws[i].negatives.n, NULL, RC_OTHER); tab_double (table, 3, 2 + i * 4, TAB_RIGHT, - ws[i].positives.sum / (double) ws[i].positives.n, NULL); + ws[i].positives.sum / (double) ws[i].positives.n, NULL, RC_OTHER); } @@ -347,11 +348,11 @@ show_tests_box (const struct wilcoxon_state *ws, z /= sqrt (n * (n + 1) * (2*n + 1)/24.0 - ws[i].tiebreaker / 48.0); - tab_double (table, 1 + i, 1, TAB_RIGHT, z, NULL); + tab_double (table, 1 + i, 1, TAB_RIGHT, z, NULL, RC_OTHER); tab_double (table, 1 + i, 2, TAB_RIGHT, 2.0 * gsl_cdf_ugaussian_P (z), - NULL); + NULL, RC_PVALUE); if (exact) { @@ -362,8 +363,8 @@ show_tests_box (const struct wilcoxon_state *ws, } else { - tab_double (table, 1 + i, 3, TAB_RIGHT, p, NULL); - tab_double (table, 1 + i, 4, TAB_RIGHT, p / 2.0, NULL); + tab_double (table, 1 + i, 3, TAB_RIGHT, p, NULL, RC_PVALUE); + tab_double (table, 1 + i, 4, TAB_RIGHT, p / 2.0, NULL, RC_PVALUE); } } } diff --git a/src/math/covariance.c b/src/math/covariance.c index c28dcb0358..3ec90efbba 100644 --- a/src/math/covariance.c +++ b/src/math/covariance.c @@ -813,6 +813,6 @@ covariance_dump_enc (const struct covariance *cov, const struct ccase *c, for (i = 0 ; i < cov->dim; ++i) { double v = get_val (cov, i, c); - tab_double (t, i, row, 0, v, i < cov->n_vars ? NULL : &F_8_0); + tab_double (t, i, row, 0, v, i < cov->n_vars ? NULL : &F_8_0, RC_OTHER); } } diff --git a/src/output/tab.c b/src/output/tab.c index 5bde1b7c41..f310319f59 100644 --- a/src/output/tab.c +++ b/src/output/tab.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997-9, 2000, 2006, 2009, 2010, 2011, 2013 Free Software Foundation, Inc. + Copyright (C) 1997-9, 2000, 2006, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -78,13 +78,27 @@ tab_create (int nc, int nr) memset (t->rh, 0, nc * (nr + 1)); t->rv = pool_nmalloc (t->container, nr, nc + 1); + memset (t->fmtmap, 0, sizeof (*t->fmtmap) * n_RC); + memset (t->rv, TAL_GAP, nr * (nc + 1)); + t->fmtmap[RC_PVALUE] = &F_4_3; + t->fmtmap[RC_INTEGER] = &F_8_0; + t->fmtmap[RC_OTHER] = settings_get_format (); + t->col_ofs = t->row_ofs = 0; return t; } + +void +tab_set_format (struct tab_table *t, enum result_class rc, const struct fmt_spec *fmt) +{ + t->fmtmap[rc] = fmt; +} + + /* Sets the width and height of a table, in columns and rows, respectively. Use only to reduce the size of a table, since it does not change the amount of allocated memory. @@ -386,51 +400,13 @@ tab_value (struct tab_table *table, int c, int r, unsigned char opt, table->ct[c + r * table->cf] = opt; } -/* Sets cell (C,R) in TABLE, with options OPT, to have value VAL - with NDEC decimal places. */ -void -tab_fixed (struct tab_table *table, int c, int r, unsigned char opt, - double val, int w, int d) -{ - struct fmt_spec f; - union value double_value; - char *s; - - assert (c >= 0); - assert (c < tab_nc (table)); - assert (r >= 0); - assert (r < tab_nr (table)); - - f = fmt_for_output (FMT_F, w, d); - -#if DEBUGGING - if (c + table->col_ofs < 0 || r + table->row_ofs < 0 - || c + table->col_ofs >= tab_nc (table) - || r + table->row_ofs >= tab_nr (table)) - { - printf ("tab_fixed(): bad cell (%d+%d=%d,%d+%d=%d) in table size " - "(%d,%d)\n", - c, table->col_ofs, c + table->col_ofs, - r, table->row_ofs, r + table->row_ofs, - tab_nc (table), tab_nr (table)); - return; - } -#endif - - double_value.f = val; - s = data_out_stretchy (&double_value, C_ENCODING, &f, table->container); - - table->cc[c + r * table->cf] = s + strspn (s, " "); - table->ct[c + r * table->cf] = opt; -} - /* Sets cell (C,R) in TABLE, with options OPT, to have value VAL as formatted by FMT. If FMT is null, then the default print format will be used. */ void tab_double (struct tab_table *table, int c, int r, unsigned char opt, - double val, const struct fmt_spec *fmt) + double val, const struct fmt_spec *fmt, enum result_class rc) { union value double_value ; char *s; @@ -440,9 +416,9 @@ tab_double (struct tab_table *table, int c, int r, unsigned char opt, assert (r >= 0); assert (r < tab_nr (table)); - if ( fmt == NULL) - fmt = settings_get_format (); - + if (fmt == NULL) + fmt = table->fmtmap[rc]; + fmt_check_output (fmt); #if DEBUGGING diff --git a/src/output/tab.h b/src/output/tab.h index dd6840c63c..d08cf48c28 100644 --- a/src/output/tab.h +++ b/src/output/tab.h @@ -41,6 +41,15 @@ #include "libpspp/compiler.h" #include "output/table.h" +enum result_class + { + RC_INTEGER, + RC_WEIGHT, + RC_PVALUE, + RC_OTHER, + n_RC + }; + /* A table. */ struct tab_table { @@ -68,6 +77,8 @@ struct tab_table /* X and Y offsets. */ int col_ofs, row_ofs; + + const struct fmt_spec *fmtmap [n_RC]; }; struct tab_table *tab_cast (const struct table *); @@ -106,6 +117,9 @@ void tab_box (struct tab_table *, int f_h, int f_v, int i_h, int i_v, /* Obsolete cell options. */ #define TAT_TITLE TAB_EMPH /* Title attributes. */ +void tab_set_format (struct tab_table *, enum result_class, const struct fmt_spec *); + + /* Cells. */ struct fmt_spec; struct dictionary; @@ -114,11 +128,8 @@ void tab_value (struct tab_table *, int c, int r, unsigned char opt, const union value *, const struct variable *, const struct fmt_spec *); -void tab_fixed (struct tab_table *, int c, int r, unsigned char opt, - double v, int w, int d); - void tab_double (struct tab_table *, int c, int r, unsigned char opt, - double v, const struct fmt_spec *); + double v, const struct fmt_spec *, enum result_class ); void tab_text (struct tab_table *, int c, int r, unsigned opt, const char *); void tab_text_format (struct tab_table *, int c, int r, unsigned opt, diff --git a/tests/language/stats/correlations.at b/tests/language/stats/correlations.at index 5033f1fedb..24fb63c6a6 100644 --- a/tests/language/stats/correlations.at +++ b/tests/language/stats/correlations.at @@ -325,25 +325,25 @@ AT_CHECK([pspp -O format=csv correlations.sps], [0], [Table: Correlations ,,var4,var5 var1,Pearson Correlation,.5693,-.0519 -,Sig. (2-tailed),.0000,.6232 +,Sig. (2-tailed),.000,.623 ,N,93,92 var2,Pearson Correlation,.3792,-.0407 -,Sig. (2-tailed),.0002,.6985 +,Sig. (2-tailed),.000,.698 ,N,95,93 var3,Pearson Correlation,.3699,-.0543 -,Sig. (2-tailed),.0002,.6029 +,Sig. (2-tailed),.000,.603 ,N,95,94 Table: Correlations ,,var1,var2 var3,Pearson Correlation,.6964,.5615 -,Sig. (2-tailed),.0000,.0000 +,Sig. (2-tailed),.000,.000 ,N,96,97 var4,Pearson Correlation,.5693,.3792 -,Sig. (2-tailed),.0000,.0002 +,Sig. (2-tailed),.000,.000 ,N,93,95 var5,Pearson Correlation,-.0519,-.0407 -,Sig. (2-tailed),.6232,.6985 +,Sig. (2-tailed),.623,.698 ,N,92,93 ]) diff --git a/tests/language/stats/crosstabs.at b/tests/language/stats/crosstabs.at index fbe9df6e3a..791dde2933 100644 --- a/tests/language/stats/crosstabs.at +++ b/tests/language/stats/crosstabs.at @@ -175,9 +175,9 @@ Total,2.00,2.00,4.00 Table: Chi-square tests. Statistic,Value,df,Asymp. Sig. (2-tailed) -Pearson Chi-Square,2.00,2,.37 -Likelihood Ratio,2.77,2,.25 -Linear-by-Linear Association,.27,1,.60 +Pearson Chi-Square,2.00,2,.368 +Likelihood Ratio,2.77,2,.250 +Linear-by-Linear Association,.27,1,.602 N of Valid Cases,4,, ]]) AT_CLEANUP @@ -207,6 +207,7 @@ CROSSTABS /STATISTICS=CHISQ /CELLS=COUNT ROW COLUMN TOTAL. ]) + AT_CHECK([pspp -O format=csv crosstabs.sps], [0], [[Variable,Value,Label v0,a , @@ -235,10 +236,10 @@ Total,4.00,2.00,6.00 Table: Chi-square tests. Statistic,Value,df,Asymp. Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed) -Pearson Chi-Square,.38,1,.54,, -Likelihood Ratio,.37,1,.54,, -Fisher's Exact Test,,,,1.00,.60 -Continuity Correction,.00,1,1.00,, +Pearson Chi-Square,.38,1,.540,, +Likelihood Ratio,.37,1,.545,, +Fisher's Exact Test,,,,1.000,.600 +Continuity Correction,.00,1,1.000,, N of Valid Cases,6,,,, Variable,Value,Label @@ -268,10 +269,10 @@ Total,1.00,3.00,4.00 Table: Chi-square tests. Statistic,Value,df,Asymp. Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed) -Pearson Chi-Square,.44,1,.50,, -Likelihood Ratio,.68,1,.41,, -Fisher's Exact Test,,,,1.00,.75 -Continuity Correction,.00,1,1.00,, +Pearson Chi-Square,.44,1,.505,, +Likelihood Ratio,.68,1,.410,, +Fisher's Exact Test,,,,1.000,.750 +Continuity Correction,.00,1,1.000,, N of Valid Cases,4,,,, ]]) AT_CLEANUP @@ -343,13 +344,13 @@ Total,,3.00,1.00,4.00 Table: Chi-square tests. z,Statistic,Value,df,Asymp. Sig. (2-tailed) -1,Pearson Chi-Square,5.00,4,.29 -,Likelihood Ratio,5.00,4,.29 -,Linear-by-Linear Association,.01,1,.94 +1,Pearson Chi-Square,5.00,4,.287 +,Likelihood Ratio,5.00,4,.287 +,Linear-by-Linear Association,.01,1,.938 ,N of Valid Cases,5,, -2,Pearson Chi-Square,4.00,3,.26 -,Likelihood Ratio,4.50,3,.21 -,Linear-by-Linear Association,1.58,1,.21 +2,Pearson Chi-Square,4.00,3,.261 +,Likelihood Ratio,4.50,3,.212 +,Linear-by-Linear Association,1.58,1,.209 ,N of Valid Cases,4,, Table: Symmetric measures. diff --git a/tests/language/stats/factor.at b/tests/language/stats/factor.at index d40cd28e92..e90e862f9a 100644 --- a/tests/language/stats/factor.at +++ b/tests/language/stats/factor.at @@ -1818,6 +1818,7 @@ FACTOR /VARIABLES=TRAIT1 TO TRAIT5 /EXTRACTION=PC /PRINT=DEFAULT DET UNIVARIATE ROTATION SIG CORRELATION. ]) + AT_CHECK([pspp -O format=csv factor-norotate.sps], [0], [dnl Table: Descriptive Statistics ,Mean,Std. Deviation,Analysis N @@ -1834,11 +1835,11 @@ Correlations,TRAIT1,1.00,.30,.88,1.00,.54 ,TRAIT3,.88,-.02,1.00,.87,.13 ,TRAIT4,1.00,.33,.87,1.00,.54 ,TRAIT5,.54,.84,.13,.54,1.00 -Sig. (1-tailed),TRAIT1,,.26,.00,.00,.10 -,TRAIT2,.26,,.48,.24,.01 -,TRAIT3,.00,.48,,.01,.39 -,TRAIT4,.00,.24,.01,,.10 -,TRAIT5,.10,.01,.39,.10, +Sig. (1-tailed),TRAIT1,,.260,.004,.000,.103 +,TRAIT2,.260,,.482,.238,.009 +,TRAIT3,.004,.482,,.006,.390 +,TRAIT4,.000,.238,.006,,.103 +,TRAIT5,.103,.009,.390,.103, Determinant,.00,,,,, Table: Communalities diff --git a/tests/language/stats/npar.at b/tests/language/stats/npar.at index 2e5d886f3f..328c0e6041 100644 --- a/tests/language/stats/npar.at +++ b/tests/language/stats/npar.at @@ -325,6 +325,7 @@ NPAR TESTS /EXPECTED = 6 10 3 . ]) + AT_CHECK([pspp -O format=csv npar.sps], [0], [dnl Table: x ,Observed N,Expected N,Residual @@ -348,7 +349,7 @@ Table: Test Statistics ,x,y Chi-Square,3.14,6.00 df,5,3 -Asymp. Sig.,.68,.11 +Asymp. Sig.,.678,.112 Table: y ,Observed N,Expected N,Residual @@ -362,7 +363,7 @@ Table: Test Statistics ,y Chi-Square,10.61 df,3 -Asymp. Sig.,.01 +Asymp. Sig.,.014 Table: Frequencies ,x,,,,y,,, @@ -376,8 +377,9 @@ Table: Test Statistics ,x,y Chi-Square,.13,4.13 df,2,2 -Asymp. Sig.,.94,.13 +Asymp. Sig.,.936,.127 ]) + AT_CLEANUP AT_SETUP([NPAR TESTS CHISQUARE expected values missing]) @@ -400,6 +402,7 @@ NPAR TESTS /EXPECTED = 3 4 5 4 3 1 . ]) + AT_CHECK([pspp -O format=csv npar.sps], [1], [dnl "error: CHISQUARE test specified 6 expected values, but 4 distinct values were encountered in variable y." @@ -407,8 +410,9 @@ Table: Test Statistics ,y Chi-Square,.00 df,0 -Asymp. Sig.,1.00 +Asymp. Sig.,1.000 ]) + AT_CLEANUP AT_SETUP([NPAR TESTS CHISQUARE with DESCRIPTIVES]) @@ -435,6 +439,7 @@ NPAR TESTS /STATISTICS=DESCRIPTIVES . ]) + AT_CHECK([pspp -O format=csv npar.sps], [0], [dnl Table: Frequencies ,x,,,,y,,, @@ -453,7 +458,7 @@ Table: Test Statistics ,x,y Chi-Square,17.33,22.87 df,7,7 -Asymp. Sig.,.02,.00 +Asymp. Sig.,.015,.002 Table: Descriptive Statistics ,N,Mean,Std. Deviation,Minimum,Maximum @@ -487,6 +492,7 @@ NPAR TESTS /STATISTICS=DESCRIPTIVES . ]) + AT_CHECK([pspp -O format=csv npar.sps], [0], [dnl Table: Frequencies ,x,,,,y,,, @@ -505,7 +511,7 @@ Table: Test Statistics ,x,y Chi-Square,13.43,26.00 df,7,7 -Asymp. Sig.,.06,.00 +Asymp. Sig.,.062,.001 Table: Descriptive Statistics ,N,Mean,Std. Deviation,Minimum,Maximum @@ -544,8 +550,8 @@ npar test /missing analysis /method=exact. ]) -AT_CHECK([pspp -o pspp.csv npar.sps]) -AT_CHECK([cat pspp.csv], [0], [dnl + +AT_CHECK([pspp -O format=csv npar.sps], [0], [dnl Table: Ranks ,,N,Mean Rank,Sum of Ranks first - second,Negative Ranks,8,6.00,48.00 @@ -556,10 +562,11 @@ first - second,Negative Ranks,8,6.00,48.00 Table: Test Statistics ,first - second Z,-.18 -Asymp. Sig. (2-tailed),.86 -Exact Sig. (2-tailed),.89 -Exact Sig. (1-tailed),.45 +Asymp. Sig. (2-tailed),.861 +Exact Sig. (2-tailed),.893 +Exact Sig. (1-tailed),.446 ]) + AT_CLEANUP AT_SETUP([NPAR TESTS WILCOXON with missing values]) @@ -590,11 +597,10 @@ npar test /wilcoxon=foo with bar (paired) /missing analysis /method=exact. - ]) -AT_CHECK([pspp -o pspp.csv npar.sps]) + dnl This is the same output as the previous test. -AT_CHECK([cat pspp.csv], [0], [dnl +AT_CHECK([pspp -O format=csv npar.sps], [0], [dnl Table: Ranks ,,N,Mean Rank,Sum of Ranks first - second,Negative Ranks,8,6.00,48.00 @@ -605,9 +611,9 @@ first - second,Negative Ranks,8,6.00,48.00 Table: Test Statistics ,first - second Z,-.18 -Asymp. Sig. (2-tailed),.86 -Exact Sig. (2-tailed),.89 -Exact Sig. (1-tailed),.45 +Asymp. Sig. (2-tailed),.861 +Exact Sig. (2-tailed),.893 +Exact Sig. (1-tailed),.446 ]) AT_CLEANUP @@ -869,10 +875,8 @@ npar tests . ]) -AT_CHECK([pspp -o pspp.csv npar-runs.sps]) - -AT_CHECK([cat pspp.csv], [0], [dnl -Table: Runs Test +AT_CHECK([pspp -O format=csv npar-runs.sps], [0], +[Table: Runs Test ,score Test Value (median),3.0000 Cases < Test Value,177.0000 @@ -880,7 +884,7 @@ Cases ≥ Test Value,309.0000 Total Cases,486.0000 Number of Runs,12 Z,-20.9931 -Asymp. Sig. (2-tailed),.0000 +Asymp. Sig. (2-tailed),.000 Table: Runs Test ,score @@ -890,7 +894,7 @@ Cases ≥ Test Value,227.0000 Total Cases,486.0000 Number of Runs,12 Z,-21.0650 -Asymp. Sig. (2-tailed),.0000 +Asymp. Sig. (2-tailed),.000 Table: Runs Test ,score @@ -900,7 +904,7 @@ Cases ≥ Test Value,170.0000 Total Cases,486.0000 Number of Runs,11 Z,-21.0742 -Asymp. Sig. (2-tailed),.0000 +Asymp. Sig. (2-tailed),.000 ]) AT_CLEANUP @@ -927,9 +931,7 @@ npar tests /friedman = x y z. ]) -AT_CHECK([pspp -o pspp.csv npar-friedman.sps]) - -AT_CHECK([cat pspp.csv], [0], [dnl +AT_CHECK([pspp -O format=csv npar-friedman.sps], [0], [dnl Table: Ranks ,Mean Rank x,2.6500 @@ -940,7 +942,7 @@ Table: Test Statistics N,10 Chi-Square,10.4737 df,2 -Asymp. Sig.,.0053 +Asymp. Sig.,.005 ]) AT_CLEANUP @@ -989,9 +991,7 @@ NPAR TESTS /M-W = height BY sex (0,1). ]) -AT_CHECK([pspp -o pspp.csv npar-mann-whitney.sps]) - -AT_CHECK([cat pspp.csv], [0], [dnl +AT_CHECK([pspp -O format=csv npar-mann-whitney.sps], [0], [dnl Table: Ranks ,N,,,Mean Rank,,Sum of Ranks, ,0,1,Total,0,1,0,1 @@ -999,7 +999,7 @@ height,15.0000,15.0000,30.0000,14.5333,16.4667,218.0000,247.0000 Table: Test Statistics ,Mann-Whitney U,Wilcoxon W,Z,Asymp. Sig. (2-tailed) -height,98.0000,218.0000,-.6020,.5472 +height,98.0000,218.0000,-.6020,.547 ]) diff --git a/tests/language/stats/oneway.at b/tests/language/stats/oneway.at index 03e8145d16..c686f27c17 100644 --- a/tests/language/stats/oneway.at +++ b/tests/language/stats/oneway.at @@ -34,8 +34,8 @@ ONEWAY . ]) -AT_CHECK([pspp -O format=csv oneway.sps], [0], -[Table: Descriptives +AT_CHECK([pspp -O format=csv oneway.sps], [0], [dnl +Table: Descriptives ,,,,,,95% Confidence Interval for Mean,,, ,,N,Mean,Std. Deviation,Std. Error,Lower Bound,Upper Bound,Minimum,Maximum Breaking Strain,Aspeger,5,2.20,1.30,.58,.58,3.82,1.00,4.00 @@ -45,11 +45,11 @@ Breaking Strain,Aspeger,5,2.20,1.30,.58,.58,3.82,1.00,4.00 Table: Test of Homogeneity of Variances ,Levene Statistic,df1,df2,Sig. -Breaking Strain,.09,2,12,.91 +Breaking Strain,.09,2,12,.913 Table: ANOVA ,,Sum of Squares,df,Mean Square,F,Sig. -Breaking Strain,Between Groups,20.13,2,10.07,5.12,.02 +Breaking Strain,Between Groups,20.13,2,10.07,5.12,.025 ,Within Groups,23.60,12,1.97,, ,Total,43.73,14,,, @@ -61,10 +61,10 @@ Contrast,1,-2,1,1 Table: Contrast Tests ,,Contrast,Value of Contrast,Std. Error,t,df,Sig. (2-tailed) -Breaking Strain,Assume equal variances,1,3.80,1.54,2.47,12,.03 -,,2,1.80,.89,2.03,12,.07 -,Does not assume equal,1,3.80,1.48,2.56,8.74,.03 -,,2,1.80,.92,1.96,7.72,.09 +Breaking Strain,Assume equal variances,1,3.80,1.54,2.47,12,.029 +,,2,1.80,.89,2.03,12,.065 +,Does not assume equal,1,3.80,1.48,2.56,8.74,.031 +,,2,1.80,.92,1.96,7.72,.086 ]) AT_CLEANUP @@ -118,11 +118,11 @@ Breaking Strain,Aspeger,5,2.20,1.30,.58,.58,3.82,1.00,4.00 Table: Test of Homogeneity of Variances ,Levene Statistic,df1,df2,Sig. -Breaking Strain,1.09,1,5,.35 +Breaking Strain,1.09,1,5,.345 Table: ANOVA ,,Sum of Squares,df,Mean Square,F,Sig. -Breaking Strain,Between Groups,2.41,1,2.41,1.07,.35 +Breaking Strain,Between Groups,2.41,1,2.41,1.07,.349 ,Within Groups,11.30,5,2.26,, ,Total,13.71,6,,, @@ -134,10 +134,10 @@ Contrast,1,-2,2 Table: Contrast Tests ,,Contrast,Value of Contrast,Std. Error,t,df,Sig. (2-tailed) -Breaking Strain,Assume equal variances,1,2.60,2.52,1.03,5,.35 -,,2,1.30,1.26,1.03,5,.35 -,Does not assume equal,1,2.60,3.22,.81,1.32,.54 -,,2,1.30,1.61,.81,1.32,.54 +Breaking Strain,Assume equal variances,1,2.60,2.52,1.03,5,.349 +,,2,1.30,1.26,1.03,5,.349 +,Does not assume equal,1,2.60,3.22,.81,1.32,.539 +,,2,1.30,1.61,.81,1.32,.539 Variable,Value,Label S,2.00, @@ -151,11 +151,11 @@ Breaking Strain,Bloggs,3,3.00,1.00,.58,.52,5.48,2.00,4.00 Table: Test of Homogeneity of Variances ,Levene Statistic,df1,df2,Sig. -Breaking Strain,.92,1,6,.37 +Breaking Strain,.92,1,6,.374 Table: ANOVA ,,Sum of Squares,df,Mean Square,F,Sig. -Breaking Strain,Between Groups,7.50,1,7.50,3.75,.10 +Breaking Strain,Between Groups,7.50,1,7.50,3.75,.101 ,Within Groups,12.00,6,2.00,, ,Total,19.50,7,,, @@ -167,10 +167,10 @@ Contrast,1,-2,2 Table: Contrast Tests ,,Contrast,Value of Contrast,Std. Error,t,df,Sig. (2-tailed) -Breaking Strain,Assume equal variances,1,4.00,2.07,1.94,6,.10 -,,2,2.00,1.03,1.94,6,.10 -,Does not assume equal,1,4.00,1.83,2.19,5.88,.07 -,,2,2.00,.91,2.19,5.88,.07 +Breaking Strain,Assume equal variances,1,4.00,2.07,1.94,6,.101 +,,2,2.00,1.03,1.94,6,.101 +,Does not assume equal,1,4.00,1.83,2.19,5.88,.072 +,,2,2.00,.91,2.19,5.88,.072 ]) AT_CLEANUP @@ -321,7 +321,7 @@ QUALITY,11.00,5,12.20,1.30,.58,10.58,13.82,11.00,14.00 Table: ANOVA ,,Sum of Squares,df,Mean Square,F,Sig. -QUALITY,Between Groups,20.13,2,10.07,5.12,.02 +QUALITY,Between Groups,20.13,2,10.07,5.12,.025 ,Within Groups,23.60,12,1.97,, ,Total,43.73,14,,, ]) @@ -362,11 +362,11 @@ ONEWAY AT_CHECK([pspp -O format=csv oneway-homogeneity.sps], [0], [Table: Test of Homogeneity of Variances ,Levene Statistic,df1,df2,Sig. -QUALITY,.09,2,12,.91 +QUALITY,.09,2,12,.913 Table: ANOVA ,,Sum of Squares,df,Mean Square,F,Sig. -QUALITY,Between Groups,20.13,2,10.07,5.12,.02 +QUALITY,Between Groups,20.13,2,10.07,5.12,.025 ,Within Groups,23.60,12,1.97,, ,Total,43.73,14,,, ]) @@ -414,10 +414,12 @@ ONEWAY x y z by g /CONTRAST 2 -9 7 0 . ]) + AT_CHECK([pspp -o pspp.csv multivar.sps]) + dnl Some machines return 3.88 instead of 3.87 below (see bug #31611). -AT_CHECK([sed 's/^,Within Groups,3.88/,Within Groups,3.87/' pspp.csv], [0], -[Table: Descriptives +AT_CHECK([sed 's/^,Within Groups,3.88/,Within Groups,3.87/' pspp.csv], [0], [dnl +Table: Descriptives ,,,,,,95% Confidence Interval for Mean,,, ,,N,Mean,Std. Deviation,Std. Error,Lower Bound,Upper Bound,Minimum,Maximum x,10.00,3,3.67,4.62,2.67,-7.81,15.14,1.00,9.00 @@ -438,19 +440,19 @@ z,10.00,3,3.67,4.73,2.73,-8.07,15.41,.00,9.00 Table: Test of Homogeneity of Variances ,Levene Statistic,df1,df2,Sig. -x,18.76,3,20,.00 -y,71.41,3,20,.00 -z,.89,3,20,.46 +x,18.76,3,20,.000 +y,71.41,3,20,.000 +z,.89,3,20,.463 Table: ANOVA ,,Sum of Squares,df,Mean Square,F,Sig. -x,Between Groups,56.16,3,18.72,2.92,.06 +x,Between Groups,56.16,3,18.72,2.92,.059 ,Within Groups,128.34,20,6.42,, ,Total,184.50,23,,, -y,Between Groups,7.75,3,2.58,13.33,.00 +y,Between Groups,7.75,3,2.58,13.33,.000 ,Within Groups,3.87,20,.19,, ,Total,11.63,23,,, -z,Between Groups,17.47,3,5.82,.62,.61 +z,Between Groups,17.47,3,5.82,.62,.610 ,Within Groups,187.87,20,9.39,, ,Total,205.33,23,,, @@ -462,18 +464,18 @@ Contrast,1,3,2,0,-5 Table: Contrast Tests ,,Contrast,Value of Contrast,Std. Error,t,df,Sig. (2-tailed) -x,Assume equal variances,1,-7.40,6.67,1.11,20,.28 -,,2,6.26,12.32,.51,20,.62 -,Does not assume equal,1,-7.40,10.04,-.74,4.53,.50 -,,2,6.26,5.85,1.07,2.87,.37 -y,Assume equal variances,1,-6.88,1.16,5.94,20,.00 -,,2,3.50,2.14,1.63,20,.12 -,Does not assume equal,1,-6.88,.91,-7.51,7.00,.00 -,,2,3.50,1.32,2.65,7.00,.03 -z,Assume equal variances,1,-9.70,8.07,1.20,20,.24 -,,2,11.73,14.91,.79,20,.44 -,Does not assume equal,1,-9.70,9.57,-1.01,3.64,.37 -,,2,11.73,14.53,.81,9.88,.44 +x,Assume equal variances,1,-7.40,6.67,1.11,20,.280 +,,2,6.26,12.32,.51,20,.617 +,Does not assume equal,1,-7.40,10.04,-.74,4.53,.497 +,,2,6.26,5.85,1.07,2.87,.366 +y,Assume equal variances,1,-6.88,1.16,5.94,20,.000 +,,2,3.50,2.14,1.63,20,.118 +,Does not assume equal,1,-6.88,.91,-7.51,7.00,.000 +,,2,3.50,1.32,2.65,7.00,.033 +z,Assume equal variances,1,-9.70,8.07,1.20,20,.243 +,,2,11.73,14.91,.79,20,.440 +,Does not assume equal,1,-9.70,9.57,-1.01,3.64,.373 +,,2,11.73,14.53,.81,9.88,.438 ]) AT_CLEANUP @@ -727,25 +729,25 @@ ONEWAY AT_CHECK([pspp -O format=csv oneway-sidak.sps], [0], [Table: ANOVA ,,Sum of Squares,df,Mean Square,F,Sig. -score,Between Groups,54.9500,3,18.3167,7.0449,.0031 +score,Between Groups,54.9500,3,18.3167,7.0449,.003 ,Within Groups,41.6000,16,2.6000,, ,Total,96.5500,19,,, Table: Multiple Comparisons (score) ,,,Mean Difference,,,95% Confidence Interval, ,(I) program,(J) program,(I - J),Std. Error,Sig.,Lower Bound,Upper Bound -Šidák,1.0000,2.0000,3.0000,1.0198,.0561,-.0575,6.0575 -,,3.0000,-.4000,1.0198,.9993,-3.4575,2.6575 -,,4.0000,3.2000,1.0198,.0375,.1425,6.2575 -,2.0000,1.0000,-3.0000,1.0198,.0561,-6.0575,.0575 -,,3.0000,-3.4000,1.0198,.0250,-6.4575,-.3425 -,,4.0000,.2000,1.0198,1.0000,-2.8575,3.2575 -,3.0000,1.0000,.4000,1.0198,.9993,-2.6575,3.4575 -,,2.0000,3.4000,1.0198,.0250,.3425,6.4575 -,,4.0000,3.6000,1.0198,.0166,.5425,6.6575 -,4.0000,1.0000,-3.2000,1.0198,.0375,-6.2575,-.1425 -,,2.0000,-.2000,1.0198,1.0000,-3.2575,2.8575 -,,3.0000,-3.6000,1.0198,.0166,-6.6575,-.5425 +Šidák,1.0000,2.0000,3.0000,1.0198,.056,-.0575,6.0575 +,,3.0000,-.4000,1.0198,.999,-3.4575,2.6575 +,,4.0000,3.2000,1.0198,.038,.1425,6.2575 +,2.0000,1.0000,-3.0000,1.0198,.056,-6.0575,.0575 +,,3.0000,-3.4000,1.0198,.025,-6.4575,-.3425 +,,4.0000,.2000,1.0198,1.000,-2.8575,3.2575 +,3.0000,1.0000,.4000,1.0198,.999,-2.6575,3.4575 +,,2.0000,3.4000,1.0198,.025,.3425,6.4575 +,,4.0000,3.6000,1.0198,.017,.5425,6.6575 +,4.0000,1.0000,-3.2000,1.0198,.038,-6.2575,-.1425 +,,2.0000,-.2000,1.0198,1.000,-3.2575,2.8575 +,,3.0000,-3.6000,1.0198,.017,-6.6575,-.5425 ]) AT_CLEANUP @@ -861,13 +863,13 @@ AT_CHECK([pspp -O format=csv oneway-bad-contrast.sps], [0], [dnl Table: ANOVA ,,Sum of Squares,df,Mean Square,F,Sig. -height,Between Groups,92629.63,1,92629.63,120.77,.00 +height,Between Groups,92629.63,1,92629.63,120.77,.000 ,Within Groups,4601.87,6,766.98,, ,Total,97231.50,7,,, -weight,Between Groups,2451.65,1,2451.65,174.59,.00 +weight,Between Groups,2451.65,1,2451.65,174.59,.000 ,Within Groups,84.25,6,14.04,, ,Total,2535.90,7,,, -temperature,Between Groups,1.80,1,1.80,.13,.73 +temperature,Between Groups,1.80,1,1.80,.13,.733 ,Within Groups,84.55,6,14.09,, ,Total,86.36,7,,, @@ -880,24 +882,24 @@ Contrast,1,-1,1 Table: Contrast Tests ,,Contrast,Value of Contrast,Std. Error,t,df,Sig. (2-tailed) -height,Assume equal variances,1,-222.27,20.23,10.99,6,.00 -,,2,-666.80,60.68,10.99,6,.00 -,,3,-2000.40,182.03,10.99,6,.00 -,Does not assume equal,1,-222.27,27.67,-8.03,2.00,.02 -,,2,-666.80,83.02,-8.03,2.00,.02 -,,3,-2000.40,249.07,-8.03,2.00,.02 -weight,Assume equal variances,1,-36.16,2.74,13.21,6,.00 -,,2,-108.48,8.21,13.21,6,.00 -,,3,-325.44,24.63,13.21,6,.00 -,Does not assume equal,1,-36.16,2.19,-16.48,5.42,.00 -,,2,-108.48,6.58,-16.48,5.42,.00 -,,3,-325.44,19.75,-16.48,5.42,.00 -temperature,Assume equal variances,1,-.98,2.74,.36,6,.73 -,,2,-2.94,8.22,.36,6,.73 -,,3,-8.83,24.67,.36,6,.73 -,Does not assume equal,1,-.98,2.07,-.47,4.19,.66 -,,2,-2.94,6.22,-.47,4.19,.66 -,,3,-8.83,18.66,-.47,4.19,.66 +height,Assume equal variances,1,-222.27,20.23,10.99,6,.000 +,,2,-666.80,60.68,10.99,6,.000 +,,3,-2000.40,182.03,10.99,6,.000 +,Does not assume equal,1,-222.27,27.67,-8.03,2.00,.015 +,,2,-666.80,83.02,-8.03,2.00,.015 +,,3,-2000.40,249.07,-8.03,2.00,.015 +weight,Assume equal variances,1,-36.16,2.74,13.21,6,.000 +,,2,-108.48,8.21,13.21,6,.000 +,,3,-325.44,24.63,13.21,6,.000 +,Does not assume equal,1,-36.16,2.19,-16.48,5.42,.000 +,,2,-108.48,6.58,-16.48,5.42,.000 +,,3,-325.44,19.75,-16.48,5.42,.000 +temperature,Assume equal variances,1,-.98,2.74,.36,6,.733 +,,2,-2.94,8.22,.36,6,.733 +,,3,-8.83,24.67,.36,6,.733 +,Does not assume equal,1,-.98,2.07,-.47,4.19,.660 +,,2,-2.94,6.22,-.47,4.19,.660 +,,3,-8.83,18.66,-.47,4.19,.660 ]) AT_CLEANUP diff --git a/tests/language/stats/regression.at b/tests/language/stats/regression.at index 60d077d29b..46b2b09eac 100644 --- a/tests/language/stats/regression.at +++ b/tests/language/stats/regression.at @@ -1687,9 +1687,8 @@ begin data end data regression /variables=v0 v1 /statistics defaults /dependent=v0 /method=enter. ]) -AT_CHECK([pspp -o pspp.csv regression.sps]) -AT_CHECK([cat pspp.csv], [0], [dnl +AT_CHECK([pspp -O format=csv regression.sps], [0], [dnl Table: Reading free-form data from INLINE. Variable,Format v0,F8.0 @@ -1708,9 +1707,10 @@ Table: ANOVA (v0) Table: Coefficients (v0) ,,Unstandardized Coefficients,,Standardized Coefficients,, ,,B,Std. Error,Beta,t,Sig. -,(Constant),1.24,.42,.00,2.95,.00 -,v1,1.37,.72,.05,1.89,.06 +,(Constant),1.24,.42,.00,2.95,.003 +,v1,1.37,.72,.05,1.89,.059 ]) + AT_CLEANUP AT_SETUP([LINEAR REGRESSION no crash on all missing]) diff --git a/tests/language/stats/t-test.at b/tests/language/stats/t-test.at index de551607f8..24b00f2309 100644 --- a/tests/language/stats/t-test.at +++ b/tests/language/stats/t-test.at @@ -1,4 +1,4 @@ -/AT_BANNER([T-TEST]) +AT_BANNER([T-TEST]) AT_SETUP([T-TEST /PAIRS]) AT_DATA([t-test.sps], [dnl @@ -13,8 +13,8 @@ end data. t-test /PAIRS a with b (PAIRED). ]) -AT_CHECK([pspp -o pspp.csv t-test.sps]) -AT_CHECK([cat pspp.csv], [0], [dnl + +AT_CHECK([pspp -O format=csv t-test.sps], [0], [dnl Table: Reading free-form data from INLINE. Variable,Format ID,F8.0 @@ -34,11 +34,14 @@ Table: Paired Samples Test ,,Paired Differences,,,,,,, ,,,,,95% Confidence Interval of the Difference,,,, ,,Mean,Std. Deviation,Std. Error Mean,Lower,Upper,t,df,Sig. (2-tailed) -Pair 1,A - B,-2.00,.94,.42,-3.16,-.84,-4.78,4,.01 +Pair 1,A - B,-2.00,.94,.42,-3.16,-.84,-4.78,4,.009 ]) + AT_CLEANUP + AT_SETUP([T-TEST /PAIRS with per-analysis missing values]) + AT_DATA([ref.sps], [dnl data list list /id * a * b * c * d *. begin data. @@ -51,6 +54,7 @@ end data. t-test /PAIRS a c with b d (PAIRED). ]) + AT_DATA([expout], [dnl Table: Reading free-form data from INLINE. Variable,Format @@ -76,9 +80,10 @@ Table: Paired Samples Test ,,Paired Differences,,,,,,, ,,,,,95% Confidence Interval of the Difference,,,, ,,Mean,Std. Deviation,Std. Error Mean,Lower,Upper,t,df,Sig. (2-tailed) -Pair 1,a - b,-2.00,.94,.42,-3.16,-.84,-4.78,4,.01 -Pair 2,c - d,1.30,.84,.37,.26,2.34,3.47,4,.03 +Pair 1,a - b,-2.00,.94,.42,-3.16,-.84,-4.78,4,.009 +Pair 2,c - d,1.30,.84,.37,.26,2.34,3.47,4,.025 ]) + AT_CHECK([pspp -o ref.csv ref.sps]) AT_CHECK([cat ref.csv], [0], [expout]) AT_DATA([missing.sps], [dnl @@ -95,6 +100,7 @@ end data. t-test /MISSING=analysis /PAIRS a c with b d (PAIRED) /CRITERIA=CIN(0.95). ]) + AT_CHECK([pspp -o missing.csv missing.sps]) AT_CHECK([cat missing.csv], [0], [expout]) AT_CLEANUP @@ -137,11 +143,14 @@ Table: Paired Samples Test ,,Paired Differences,,,,,,, ,,,,,95% Confidence Interval of the Difference,,,, ,,Mean,Std. Deviation,Std. Error Mean,Lower,Upper,t,df,Sig. (2-tailed) -Pair 1,a - c,-3.10,.76,.34,-4.04,-2.16,-9.14,4,.00 -Pair 2,b - d,.20,1.68,.75,-1.89,2.29,.27,4,.80 +Pair 1,a - c,-3.10,.76,.34,-4.04,-2.16,-9.14,4,.001 +Pair 2,b - d,.20,1.68,.75,-1.89,2.29,.27,4,.803 ]) + AT_CHECK([pspp -o ref.csv ref.sps]) + AT_CHECK([cat ref.csv], [0], [expout]) + AT_DATA([missing.sps], [dnl data list list /id * a * b * c * d *. begin data. @@ -220,8 +229,8 @@ end data. t-test /GROUPS=indep(1.1,2.1) /var=dep1 dep2. ]) -AT_CHECK([pspp -o pspp.csv t-test.sps]) -AT_CHECK([cat pspp.csv], [0], [dnl + +AT_CHECK([pspp -O format=csv t-test.sps], [0], [dnl Table: Reading free-form data from INLINE. Variable,Format ID,F8.0 @@ -240,11 +249,12 @@ Table: Independent Samples Test ,,Levene's Test for Equality of Variances,,t-test for Equality of Means,,,,,, ,,,,,,,,,95% Confidence Interval of the Difference, ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,Lower,Upper -DEP1,Equal variances assumed,.00,1.00,-4.47,8.00,.00,-2.00,.45,-3.03,-.97 -,Equal variances not assumed,,,-4.47,8.00,.00,-2.00,.45,-3.03,-.97 -DEP2,Equal variances assumed,.00,1.00,4.47,8.00,.00,2.00,.45,.97,3.03 -,Equal variances not assumed,,,4.47,8.00,.00,2.00,.45,.97,3.03 +DEP1,Equal variances assumed,.00,1.00,-4.47,8.00,.002,-2.00,.45,-3.03,-.97 +,Equal variances not assumed,,,-4.47,8.00,.002,-2.00,.45,-3.03,-.97 +DEP2,Equal variances assumed,.00,1.00,4.47,8.00,.002,2.00,.45,.97,3.03 +,Equal variances not assumed,,,4.47,8.00,.002,2.00,.45,.97,3.03 ]) + AT_CLEANUP AT_SETUP([T-TEST /GROUPS with one value for independent variable]) @@ -276,8 +286,7 @@ begin data. end data. t-test /groups=indep(1.514) /var=dep. ]) -AT_CHECK([pspp -o pspp.csv t-test.sps]) -AT_CHECK([cat pspp.csv], [0], [dnl +AT_CHECK([pspp -O format=csv t-test.sps], [0], [dnl Table: Reading free-form data from INLINE. Variable,Format INDEP,F8.0 @@ -292,8 +301,8 @@ Table: Independent Samples Test ,,Levene's Test for Equality of Variances,,t-test for Equality of Means,,,,,, ,,,,,,,,,95% Confidence Interval of the Difference, ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,Lower,Upper -DEP,Equal variances assumed,.17,.68,.69,20.00,.50,1.00,1.44,-2.00,4.00 -,Equal variances not assumed,,,.69,18.54,.50,1.00,1.44,-2.02,4.02 +DEP,Equal variances assumed,.17,.68,.69,20.00,.495,1.00,1.44,-2.00,4.00 +,Equal variances not assumed,,,.69,18.54,.496,1.00,1.44,-2.02,4.02 ]) AT_CLEANUP @@ -329,10 +338,10 @@ Table: Independent Samples Test ,,Levene's Test for Equality of Variances,,t-test for Equality of Means,,,,,, ,,,,,,,,,95% Confidence Interval of the Difference, ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,Lower,Upper -dep1,Equal variances assumed,3.75,.15,-1.12,3.00,.35,-.75,.67,-2.89,1.39 -,Equal variances not assumed,,,-1.34,2.78,.28,-.75,.56,-2.61,1.11 -dep2,Equal variances assumed,.60,.50,2.85,3.00,.07,3.00,1.05,-.35,6.35 -,Equal variances not assumed,,,2.60,1.68,.14,3.00,1.15,-2.98,8.98 +dep1,Equal variances assumed,3.75,.15,-1.12,3.00,.346,-.75,.67,-2.89,1.39 +,Equal variances not assumed,,,-1.34,2.78,.279,-.75,.56,-2.61,1.11 +dep2,Equal variances assumed,.60,.50,2.85,3.00,.065,3.00,1.05,-.35,6.35 +,Equal variances not assumed,,,2.60,1.68,.144,3.00,1.15,-2.98,8.98 ]) AT_CHECK([pspp -o ref.csv ref.sps]) AT_CHECK([cat ref.csv], [0], [expout]) @@ -371,6 +380,7 @@ end data. t-test /group=indep /var=dep1 dep2. ]) + AT_DATA([expout], [dnl Table: Reading free-form data from INLINE. Variable,Format @@ -390,11 +400,12 @@ Table: Independent Samples Test ,,Levene's Test for Equality of Variances,,t-test for Equality of Means,,,,,, ,,,,,,,,,95% Confidence Interval of the Difference, ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,Lower,Upper -dep1,Equal variances assumed,2.00,.23,-1.73,4.00,.16,-1.00,.58,-2.60,.60 -,Equal variances not assumed,,,-1.73,3.20,.18,-1.00,.58,-2.77,.77 -dep2,Equal variances assumed,.00,1.00,3.67,4.00,.02,3.00,.82,.73,5.27 -,Equal variances not assumed,,,3.67,4.00,.02,3.00,.82,.73,5.27 +dep1,Equal variances assumed,2.00,.23,-1.73,4.00,.158,-1.00,.58,-2.60,.60 +,Equal variances not assumed,,,-1.73,3.20,.176,-1.00,.58,-2.77,.77 +dep2,Equal variances assumed,.00,1.00,3.67,4.00,.021,3.00,.82,.73,5.27 +,Equal variances not assumed,,,3.67,4.00,.021,3.00,.82,.73,5.27 ]) + AT_CHECK([pspp -o ref.csv ref.sps]) AT_CHECK([cat ref.csv], [0], [expout]) AT_DATA([missing.sps], [dnl @@ -429,8 +440,7 @@ end data. t-test /testval=2.0 /var=abc. ]) -AT_CHECK([pspp -o pspp.csv t-test.sps]) -AT_CHECK([cat pspp.csv], [0], [dnl +AT_CHECK([pspp -O format=csv t-test.sps], [0], [dnl Table: Reading free-form data from INLINE. Variable,Format ID,F8.0 @@ -444,7 +454,7 @@ Table: One-Sample Test ,Test Value = 2.000000,,,,, ,,,,,95% Confidence Interval of the Difference, ,t,df,Sig. (2-tailed),Mean Difference,Lower,Upper -ABC,2.93,5,.03,1.00,.12,1.88 +ABC,2.93,5,.033,1.00,.12,1.88 ]) AT_CLEANUP @@ -478,8 +488,8 @@ Table: One-Sample Test ,Test Value = 3.000000,,,,, ,,,,,95% Confidence Interval of the Difference, ,t,df,Sig. (2-tailed),Mean Difference,Lower,Upper -x1,.00,5,1.00,.00,-.88,.88 -x2,2.18,5,.08,29.67,-5.39,64.72 +x1,.00,5,1.000,.00,-.88,.88 +x2,2.18,5,.082,29.67,-5.39,64.72 ]) AT_CHECK([pspp -o ref.csv ref.sps]) AT_CHECK([cat ref.csv], [0], [expout]) @@ -530,8 +540,8 @@ Table: One-Sample Test ,Test Value = 3.000000,,,,, ,,,,,95% Confidence Interval of the Difference, ,t,df,Sig. (2-tailed),Mean Difference,Lower,Upper -x1,-.59,4,.59,-.20,-1.14,.74 -x2,2.22,4,.09,34.60,-8.63,77.83 +x1,-.59,4,.587,-.20,-1.14,.74 +x2,2.22,4,.090,34.60,-8.63,77.83 ]) AT_CHECK([pspp -o ref.csv ref.sps]) AT_CHECK([cat ref.csv], [0], [expout]) @@ -583,8 +593,8 @@ Table: Independent Samples Test ,,Levene's Test for Equality of Variances,,t-test for Equality of Means,,,,,, ,,,,,,,,,95% Confidence Interval of the Difference, ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,Lower,Upper -x,Equal variances assumed,2.00,.23,-1.73,4.00,.16,-1.00,.58,-2.60,.60 -,Equal variances not assumed,,,-1.73,3.20,.18,-1.00,.58,-2.77,.77 +x,Equal variances assumed,2.00,.23,-1.73,4.00,.158,-1.00,.58,-2.60,.60 +,Equal variances not assumed,,,-1.73,3.20,.176,-1.00,.58,-2.77,.77 ]) AT_CHECK([pspp -o ref.csv ref.sps]) AT_CHECK([cat ref.csv], [0], [expout]) @@ -653,8 +663,8 @@ end data. t-test /GROUPS=indep('a','b') /var=dep1 dep2. ]) -AT_CHECK([pspp -o pspp.csv t-test.sps]) -AT_CHECK([cat pspp.csv], [0], [dnl + +AT_CHECK([pspp -O format=csv t-test.sps], [0], [dnl Table: Reading free-form data from INLINE. Variable,Format ID,F8.0 @@ -673,10 +683,10 @@ Table: Independent Samples Test ,,Levene's Test for Equality of Variances,,t-test for Equality of Means,,,,,, ,,,,,,,,,95% Confidence Interval of the Difference, ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,Lower,Upper -DEP1,Equal variances assumed,.00,1.00,-4.47,8.00,.00,-2.00,.45,-3.03,-.97 -,Equal variances not assumed,,,-4.47,8.00,.00,-2.00,.45,-3.03,-.97 -DEP2,Equal variances assumed,.00,1.00,4.47,8.00,.00,2.00,.45,.97,3.03 -,Equal variances not assumed,,,4.47,8.00,.00,2.00,.45,.97,3.03 +DEP1,Equal variances assumed,.00,1.00,-4.47,8.00,.002,-2.00,.45,-3.03,-.97 +,Equal variances not assumed,,,-4.47,8.00,.002,-2.00,.45,-3.03,-.97 +DEP2,Equal variances assumed,.00,1.00,4.47,8.00,.002,2.00,.45,.97,3.03 +,Equal variances not assumed,,,4.47,8.00,.002,2.00,.45,.97,3.03 ]) AT_CLEANUP @@ -723,8 +733,7 @@ end data. t-test group=gv('One', 'Two') /variables = x. ]) -AT_CHECK([pspp -o pspp.csv t-test.sps]) -AT_CHECK([cat pspp.csv], [0], [dnl +AT_CHECK([pspp -O format=csv t-test.sps], [0], [dnl Table: Reading free-form data from INLINE. Variable,Format x,F8.0 @@ -739,8 +748,8 @@ Table: Independent Samples Test ,,Levene's Test for Equality of Variances,,t-test for Equality of Means,,,,,, ,,,,,,,,,95% Confidence Interval of the Difference, ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,Lower,Upper -x,Equal variances assumed,1.13,.33,-2.32,6.00,.06,-.90,.39,-1.85,.05 -,Equal variances not assumed,,,-2.38,4.70,.07,-.90,.38,-1.89,.09 +x,Equal variances assumed,1.13,.33,-2.32,6.00,.060,-.90,.39,-1.85,.05 +,Equal variances not assumed,,,-2.38,4.70,.067,-.90,.38,-1.89,.09 ]) AT_CLEANUP -- 2.30.2