-/* PSPP - computes sample statistics.
- Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
- Written by Ben Pfaff <blp@gnu.org>.
+/* PSPP - a program for statistical analysis.
+ Copyright (C) 1997-9, 2000, 2006, 2009 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 the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
+ 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
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA. */
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <data/procedure.h>
#include <data/value-labels.h>
#include <data/variable.h>
#include <data/procedure.h>
#include <data/value-labels.h>
#include <data/variable.h>
#include <language/dictionary/split-file.h>
#include <language/lexer/lexer.h>
#include <language/lexer/variable-parser.h>
#include <language/dictionary/split-file.h>
#include <language/lexer/lexer.h>
#include <language/lexer/variable-parser.h>
#include <libpspp/message.h>
#include <libpspp/misc.h>
#include <libpspp/pool.h>
#include <libpspp/message.h>
#include <libpspp/misc.h>
#include <libpspp/pool.h>
int nvar; /* Number of variables. */
double missing; /* Missing cases count. */
int ofs; /* Integer mode: Offset into sorted_tab[]. */
int nvar; /* Number of variables. */
double missing; /* Missing cases count. */
int ofs; /* Integer mode: Offset into sorted_tab[]. */
-static int internal_cmd_crosstabs (void);
-static void precalc (const struct ccase *, void *);
-static bool calc_general (const struct ccase *, void *);
-static bool calc_integer (const struct ccase *, void *);
-static void postcalc (void *);
+static int internal_cmd_crosstabs (struct lexer *lexer, struct dataset *ds);
+static void precalc (struct casereader *, const struct dataset *);
+static void calc_general (const struct ccase *, const struct dataset *);
+static void calc_integer (const struct ccase *, const struct dataset *);
+static void postcalc (const struct dataset *);
+
static void submit (struct tab_table *);
static void format_short (char *s, const struct fmt_spec *fp,
static void submit (struct tab_table *);
static void format_short (char *s, const struct fmt_spec *fp,
+ cmd.a_write[CRS_WR_CELLS] == 0))
cmd.a_write[CRS_WR_CELLS] = 1;
if (cmd.a_write[CRS_WR_CELLS])
+ cmd.a_write[CRS_WR_CELLS] == 0))
cmd.a_write[CRS_WR_CELLS] = 1;
if (cmd.a_write[CRS_WR_CELLS])
- ok = procedure_with_splits (precalc,
- mode == GENERAL ? calc_general : calc_integer,
- postcalc, NULL);
+ input = casereader_create_filter_weight (proc_open (ds), dataset_dict (ds),
+ NULL, NULL);
+ grouper = casegrouper_create_splits (input, dataset_dict (ds));
+ while (casegrouper_get_next_group (grouper, &group))
+ {
+ struct ccase *c;
+
+ precalc (group, ds);
+
+ for (; (c = casereader_read (group)) != NULL; case_unref (c))
+ {
+ if (mode == GENERAL)
+ calc_general (c, ds);
+ else
+ calc_integer (c, ds);
+ }
+ casereader_destroy (group);
+
+ postcalc (ds);
+ }
+ ok = casegrouper_destroy (grouper);
+ ok = proc_commit (ds) && ok;
- if (!lex_match_id ("TABLES")
- && (token != T_ID || dict_lookup_var (default_dict, tokid) == NULL)
- && token != T_ALL)
+ if (!lex_match_id (lexer, "TABLES")
+ && (lex_token (lexer) != T_ID ||
+ dict_lookup_var (dataset_dict (ds), lex_tokid (lexer)) == NULL)
+ && lex_token (lexer) != T_ALL)
for (n_by = 0; ;)
{
by = xnrealloc (by, n_by + 1, sizeof *by);
by_nvar = xnrealloc (by_nvar, n_by + 1, sizeof *by_nvar);
for (n_by = 0; ;)
{
by = xnrealloc (by, n_by + 1, sizeof *by);
by_nvar = xnrealloc (by_nvar, n_by + 1, sizeof *by_nvar);
- if (!parse_var_set_vars (var_set, &by[n_by], &by_nvar[n_by],
+ if (!parse_const_var_set_vars (lexer, var_set, &by[n_by], &by_nvar[n_by],
-
- if (!parse_variables (default_dict, &variables, &variables_cnt,
+
+ if (!parse_variables_const (lexer, dataset_dict (ds),
+ &variables, &variables_cnt,
vr->count = max - min + 1;
var_attach_aux (variables[i], vr, var_dtor_free);
}
vr->count = max - min + 1;
var_attach_aux (variables[i], vr, var_dtor_free);
}
-static int compare_table_entry (const void *, const void *, void *);
-static unsigned hash_table_entry (const void *, void *);
+static int compare_table_entry (const void *, const void *, const void *);
+static unsigned hash_table_entry (const void *, const void *);
if (mode == GENERAL)
{
gen_tab = hsh_create (512, compare_table_entry, hash_table_entry,
NULL, NULL);
}
if (mode == GENERAL)
{
gen_tab = hsh_create (512, compare_table_entry, hash_table_entry,
NULL, NULL);
}
sorted_tab = xnrealloc (sorted_tab,
n_sorted_tab + count, sizeof *sorted_tab);
sorted_tab = xnrealloc (sorted_tab,
n_sorted_tab + count, sizeof *sorted_tab);
- v = local_alloc (sizeof *v * x->nvar);
- for (j = 2; j < x->nvar; j++)
- v[j] = get_var_range (x->vars[j])->min;
+ v = xmalloca (sizeof *v * x->nvar);
+ for (j = 2; j < x->nvar; j++)
+ v[j] = get_var_range (x->vars[j])->min;
{
int row_cnt = get_var_range (x->vars[0])->count;
int col_cnt = get_var_range (x->vars[1])->count;
const int mat_size = row_cnt * col_cnt;
int m;
{
int row_cnt = get_var_range (x->vars[0])->count;
int col_cnt = get_var_range (x->vars[1])->count;
const int mat_size = row_cnt * col_cnt;
int m;
te->u.data = xnmalloc (mat_size, sizeof *te->u.data);
for (m = 0; m < mat_size; m++)
te->u.data[m] = 0.;
}
te->u.data = xnmalloc (mat_size, sizeof *te->u.data);
for (m = 0; m < mat_size; m++)
te->u.data[m] = 0.;
}
}
sorted_tab = xnrealloc (sorted_tab,
n_sorted_tab + 1, sizeof *sorted_tab);
sorted_tab[n_sorted_tab] = NULL;
}
}
sorted_tab = xnrealloc (sorted_tab,
n_sorted_tab + 1, sizeof *sorted_tab);
sorted_tab[n_sorted_tab] = NULL;
}
struct crosstab *x = xtab[t];
const size_t entry_size = (sizeof (struct table_entry)
+ sizeof (union value) * (x->nvar - 1));
struct crosstab *x = xtab[t];
const size_t entry_size = (sizeof (struct table_entry)
+ sizeof (union value) * (x->nvar - 1));
- const union value *v = case_data (c, x->vars[j]->fv);
- const struct missing_values *mv = &x->vars[j]->miss;
- if ((cmd.miss == CRS_TABLE && mv_is_value_missing (mv, v))
- || (cmd.miss == CRS_INCLUDE
- && mv_is_value_system_missing (mv, v)))
+ const union value *v = case_data (c, x->vars[j]);
+ if (var_is_value_missing (x->vars[j], v, exclude))
-
- if (x->vars[j]->type == NUMERIC)
- te->values[j].f = case_num (c, x->vars[j]->fv);
+
+ if (var_is_numeric (x->vars[j]))
+ te->values[j].f = case_num (c, x->vars[j]);
- memcpy (te->values[j].s, case_str (c, x->vars[j]->fv),
- x->vars[j]->width);
-
+ size_t n = var_get_width (x->vars[j]);
+ if (n > MAX_SHORT_STRING)
+ n = MAX_SHORT_STRING;
+ memcpy (te->values[j].s, case_str (c, x->vars[j]), n);
+
- memset (&te->values[j].s[x->vars[j]->width], 0,
- sizeof (union value) - x->vars[j]->width);
+ memset (&te->values[j].s[var_get_width (x->vars[j])], 0,
+ sizeof (union value) - n);
/* Note that the first test also rules out SYSMIS. */
if ((value < vr->min || value >= vr->max)
|| (cmd.miss == CRS_TABLE
/* Note that the first test also rules out SYSMIS. */
if ((value < vr->min || value >= vr->max)
|| (cmd.miss == CRS_TABLE
- struct variable *row_var = x->vars[ROW_VAR];
- const int row = case_num (c, row_var->fv) - get_var_range (row_var)->min;
+ const struct variable *row_var = x->vars[ROW_VAR];
+ const int row = case_num (c, row_var) - get_var_range (row_var)->min;
- struct variable *col_var = x->vars[COL_VAR];
- const int col = case_num (c, col_var->fv) - get_var_range (col_var)->min;
+ const struct variable *col_var = x->vars[COL_VAR];
+ const int col = case_num (c, col_var) - get_var_range (col_var)->min;
const int col_dim = get_var_range (col_var)->count;
sorted_tab[ofs]->u.data[col + row * col_dim] += weight;
}
const int col_dim = get_var_range (col_var)->count;
sorted_tab[ofs]->u.data[col + row * col_dim] += weight;
}
- else
- {
- assert (x->vars[i]->type == ALPHA);
- {
- const int diffstr = strncmp (a->values[i].s, b->values[i].s,
- x->vars[i]->width);
- if (diffstr)
- return diffstr;
- }
- }
+ else
+ {
+ const int diffstr = strncmp (a->values[i].s, b->values[i].s,
+ var_get_width (x->vars[i]));
+ if (diffstr)
+ return diffstr;
+ }
int var_idx,
union value **values, int *value_cnt);
static void output_pivot_table (struct table_entry **, struct table_entry **,
int var_idx,
union value **values, int *value_cnt);
static void output_pivot_table (struct table_entry **, struct table_entry **,
double **, double **, double **,
int *, int *, int *);
double **, double **, double **,
int *, int *, int *);
-
- output_pivot_table (pb, pe, &mat, &row_tot, &col_tot,
+
+ output_pivot_table (pb, pe, dataset_dict (ds),
+ &mat, &row_tot, &col_tot,
-static void insert_summary (struct tab_table *, int tab_index, double valid);
+static void insert_summary (struct tab_table *, int tab_index,
+ const struct dictionary *,
+ double valid);
pe = find_pivot_extent (pb, &pc, cmd.pivot == CRS_PIVOT);
if (pe == NULL)
break;
while (cur_tab < (*pb)->table)
pe = find_pivot_extent (pb, &pc, cmd.pivot == CRS_PIVOT);
if (pe == NULL)
break;
while (cur_tab < (*pb)->table)
const int n_cols = get_var_range (x->vars[COL_VAR])->count;
const int n_rows = get_var_range (x->vars[ROW_VAR])->count;
const int count = n_cols * n_rows;
const int n_cols = get_var_range (x->vars[COL_VAR])->count;
const int n_rows = get_var_range (x->vars[ROW_VAR])->count;
const int count = n_cols * n_rows;
/* Inserts a line into T describing the crosstabulation at index
TAB_INDEX, which has VALID valid observations. */
static void
/* Inserts a line into T describing the crosstabulation at index
TAB_INDEX, which has VALID valid observations. */
static void
-insert_summary (struct tab_table *t, int tab_index, double valid)
+insert_summary (struct tab_table *t, int tab_index,
+ const struct dictionary *dict,
+ double valid)
tab_hline (t, TAL_1, 0, 6, 0);
tab_hline (t, TAL_1, 0, 6, 0);
}
tab_text (t, 0, 0, TAB_LEFT, buf);
}
tab_text (t, 0, 0, TAB_LEFT, buf);
- tab_float (t, i * 2 + 1, 0, TAB_RIGHT, n[i], 8, 0);
+ tab_double (t, i * 2 + 1, 0, TAB_RIGHT, n[i], wfmt);
tab_text (t, i * 2 + 2, 0, TAB_RIGHT | TAT_PRINTF, "%.1f%%",
n[i] / n[2] * 100.);
}
}
tab_text (t, i * 2 + 2, 0, TAB_RIGHT | TAT_PRINTF, "%.1f%%",
n[i] / n[2] * 100.);
}
}
/* Row values, number of rows. */
static union value *rows;
static int n_rows;
/* Row values, number of rows. */
static union value *rows;
static int n_rows;
/* Number of statistically interesting columns/rows (columns/rows with
data in them). */
static int ns_cols, ns_rows;
/* Crosstabulation. */
/* Number of statistically interesting columns/rows (columns/rows with
data in them). */
static int ns_cols, ns_rows;
/* Crosstabulation. */
/* Number of variables from the crosstabulation to consider. This is
either x->nvar, if pivoting is on, or 2, if pivoting is off. */
/* Number of variables from the crosstabulation to consider. This is
either x->nvar, if pivoting is on, or 2, if pivoting is off. */
static void display_dimensions (struct tab_table *, int first_difference,
struct table_entry *);
static void display_crosstabulation (void);
static void display_dimensions (struct tab_table *, int first_difference,
struct table_entry *);
static void display_crosstabulation (void);
-static void display_chisq (void);
-static void display_symmetric (void);
-static void display_risk (void);
+static void display_chisq (const struct dictionary *);
+static void display_symmetric (const struct dictionary *);
+static void display_risk (const struct dictionary *);
static void table_value_missing (struct tab_table *table, int c, int r,
unsigned char opt, const union value *v,
const struct variable *var);
static void table_value_missing (struct tab_table *table, int c, int r,
unsigned char opt, const union value *v,
const struct variable *var);
hold *MAXROWS entries. */
static void
output_pivot_table (struct table_entry **pb, struct table_entry **pe,
hold *MAXROWS entries. */
static void
output_pivot_table (struct table_entry **pb, struct table_entry **pe,
double **matp, double **row_totp, double **col_totp,
int *maxrows, int *maxcols, int *maxcells)
{
double **matp, double **row_totp, double **col_totp,
int *maxrows, int *maxcols, int *maxcells)
{
/* First header line. */
tab_joint_text (table, nvar - 1, 0, (nvar - 1) + (n_cols - 1), 0,
/* First header line. */
tab_joint_text (table, nvar - 1, 0, (nvar - 1) + (n_cols - 1), 0,
tab_hline (table, TAL_1, nvar - 1, nvar + n_cols - 2, 1);
tab_hline (table, TAL_1, nvar - 1, nvar + n_cols - 2, 1);
/* Second header line. */
{
int i;
for (i = 2; i < nvar; i++)
tab_joint_text (table, nvar - i - 1, 0, nvar - i - 1, 1,
/* Second header line. */
{
int i;
for (i = 2; i < nvar; i++)
tab_joint_text (table, nvar - i - 1, 0, nvar - i - 1, 1,
tab_text (table, nvar - 2, 1, TAB_RIGHT | TAT_TITLE,
tab_text (table, nvar - 2, 1, TAB_RIGHT | TAT_TITLE,
for (i = 0; i < n_cols; i++)
table_value_missing (table, nvar + i - 1, 1, TAB_RIGHT, &cols[i],
x->vars[COL_VAR]);
for (i = 0; i < n_cols; i++)
table_value_missing (table, nvar + i - 1, 1, TAB_RIGHT, &cols[i],
x->vars[COL_VAR]);
if (cmd.pivot == CRS_PIVOT)
for (i = 0; i < nvar; i++)
{
if (i)
cp = stpcpy (cp, " by ");
if (cmd.pivot == CRS_PIVOT)
for (i = 0; i < nvar; i++)
{
if (i)
cp = stpcpy (cp, " by ");
{
{CRS_CL_COUNT, N_("count")},
{CRS_CL_ROW, N_("row %")},
{
{CRS_CL_COUNT, N_("count")},
{CRS_CL_ROW, N_("row %")},
tab_headers (chisq, 1 + (nvar - 2), 0, 1, 0);
tab_title (chisq, _("Chi-square tests."));
tab_headers (chisq, 1 + (nvar - 2), 0, 1, 0);
tab_title (chisq, _("Chi-square tests."));
tab_offset (chisq, nvar - 2, 0);
tab_text (chisq, 0, 0, TAB_LEFT | TAT_TITLE, _("Statistic"));
tab_text (chisq, 1, 0, TAB_RIGHT | TAT_TITLE, _("Value"));
tab_offset (chisq, nvar - 2, 0);
tab_text (chisq, 0, 0, TAB_LEFT | TAT_TITLE, _("Statistic"));
tab_text (chisq, 1, 0, TAB_RIGHT | TAT_TITLE, _("Value"));
/* Symmetric measures. */
if (cmd.a_statistics[CRS_ST_PHI] || cmd.a_statistics[CRS_ST_CC]
|| cmd.a_statistics[CRS_ST_BTAU] || cmd.a_statistics[CRS_ST_CTAU]
/* Symmetric measures. */
if (cmd.a_statistics[CRS_ST_PHI] || cmd.a_statistics[CRS_ST_CC]
|| cmd.a_statistics[CRS_ST_BTAU] || cmd.a_statistics[CRS_ST_CTAU]
/* Allocate table space for the matrix. */
if (table && tab_row (table) + (n_rows + 1) * num_cells > tab_nr (table))
tab_realloc (table, -1,
/* Allocate table space for the matrix. */
if (table && tab_row (table) + (n_rows + 1) * num_cells > tab_nr (table))
tab_realloc (table, -1,
*matp = xnrealloc (*matp, n_cols * n_rows, sizeof **matp);
*maxcells = n_cols * n_rows;
}
*matp = xnrealloc (*matp, n_cols * n_rows, sizeof **matp);
*maxcells = n_cols * n_rows;
}
/* Find the first variable that differs from the last subtable,
then display the values of the dimensioning variables for
each table that needs it. */
{
int first_difference = nvar - 1;
/* Find the first variable that differs from the last subtable,
then display the values of the dimensioning variables for
each table that needs it. */
{
int first_difference = nvar - 1;
if (t != table)
for (i = 2; i < nvar; i++)
tab_text (t, nvar - i - 1, 0, TAB_RIGHT | TAT_TITLE,
if (t != table)
for (i = 2; i < nvar; i++)
tab_text (t, nvar - i - 1, 0, TAB_RIGHT | TAT_TITLE,
tab_box (t, TAL_2, TAL_2, -1, -1, 0, 0, tab_nc (t) - 1, tab_nr (t) - 1);
tab_box (t, -1, -1, -1, TAL_1, tab_l (t), tab_t (t) - 1, tab_nc (t) - 1,
tab_nr (t) - 1);
tab_box (t, -1, -1, -1, TAL_GAP, 0, tab_t (t), tab_l (t) - 1,
tab_nr (t) - 1);
tab_vline (t, TAL_2, tab_l (t), 0, tab_nr (t) - 1);
tab_box (t, TAL_2, TAL_2, -1, -1, 0, 0, tab_nc (t) - 1, tab_nr (t) - 1);
tab_box (t, -1, -1, -1, TAL_1, tab_l (t), tab_t (t) - 1, tab_nc (t) - 1,
tab_nr (t) - 1);
tab_box (t, -1, -1, -1, TAL_GAP, 0, tab_t (t), tab_l (t) - 1,
tab_nr (t) - 1);
tab_vline (t, TAL_2, tab_l (t), 0, tab_nr (t) - 1);
/* Width of a numerical column. */
int c = outp_string_width (d, "0.000000", OUTP_PROPORTIONAL);
if (cmd.miss == CRS_REPORT)
/* Width of a numerical column. */
int c = outp_string_width (d, "0.000000", OUTP_PROPORTIONAL);
if (cmd.miss == CRS_REPORT)
if (memcmp (&(*tp)->values[2], &fp->values[2],
sizeof (union value) * (x->nvar - 2)))
break;
if (memcmp (&(*tp)->values[2], &fp->values[2],
sizeof (union value) * (x->nvar - 2)))
break;
result. WIDTH_ points to an int which is either 0 for a
numeric value or a string width for a string value. */
static int
result. WIDTH_ points to an int which is either 0 for a
numeric value or a string width for a string value. */
static int
enum_var_values (struct table_entry **entries, int entry_cnt, int var_idx,
union value **values, int *value_cnt)
{
enum_var_values (struct table_entry **entries, int entry_cnt, int var_idx,
union value **values, int *value_cnt)
{
assert (mode == INTEGER);
*values = xnmalloc (vr->count, sizeof **values);
for (i = 0; i < vr->count; i++)
assert (mode == INTEGER);
*values = xnmalloc (vr->count, sizeof **values);
for (i = 0; i < vr->count; i++)
{
tab_text (table, c, r, TAB_LEFT, label);
return;
}
{
tab_text (table, c, r, TAB_LEFT, label);
return;
}
- s.string = tab_alloc (table, var->print.w);
- format_short (s.string, &var->print, v);
+ s.string = tab_alloc (table, print->w);
+ format_short (s.string, print, v);
additionally suffixed with a letter `M'. */
static void
format_cell_entry (struct tab_table *table, int c, int r, double value,
additionally suffixed with a letter `M'. */
static void
format_cell_entry (struct tab_table *table, int c, int r, double value,
for (r = 0; r < n_rows; r++)
table_value_missing (table, nvar - 2, r * num_cells,
TAB_RIGHT, &rows[r], x->vars[ROW_VAR]);
}
tab_text (table, nvar - 2, n_rows * num_cells,
TAB_LEFT, _("Total"));
for (r = 0; r < n_rows; r++)
table_value_missing (table, nvar - 2, r * num_cells,
TAB_RIGHT, &rows[r], x->vars[ROW_VAR]);
}
tab_text (table, nvar - 2, n_rows * num_cells,
TAB_LEFT, _("Total"));
tab_hline (table, TAL_1, -1, n_cols, 0);
for (c = 0; c < n_cols; c++)
{
tab_hline (table, TAL_1, -1, n_cols, 0);
for (c = 0; c < n_cols; c++)
{
- && (mv_is_num_user_missing (&x->vars[COL_VAR]->miss, cols[c].f)
- || mv_is_num_user_missing (&x->vars[ROW_VAR]->miss,
- rows[r].f)))
- mark_missing = 1;
+ && (var_is_num_missing (x->vars[COL_VAR], cols[c].f, MV_USER)
+ || var_is_num_missing (x->vars[ROW_VAR], rows[r].f,
+ MV_USER)))
+ mark_missing = true;
}
format_cell_entry (table, c, i, v, suffix, mark_missing);
}
format_cell_entry (table, c, i, v, suffix, mark_missing);
}
format_cell_entry (table, n_cols, 0, v, suffix, mark_missing);
tab_next_row (table);
}
format_cell_entry (table, n_cols, 0, v, suffix, mark_missing);
tab_next_row (table);
-
- if (cmd.miss == CRS_REPORT && c < n_cols
- && mv_is_num_user_missing (&x->vars[COL_VAR]->miss, cols[c].f))
- mark_missing = 1;
+
+ if (cmd.miss == CRS_REPORT && c < n_cols
+ && var_is_num_missing (x->vars[COL_VAR], cols[c].f, MV_USER))
+ mark_missing = true;
- format_cell_entry (table, c, i, v, suffix, mark_missing);
+ format_cell_entry (table, c, i, v, suffix, mark_missing);
- static const char *chisq_stats[N_CHISQ] =
+ const struct variable *wv = dict_get_weight (dict);
+ const struct fmt_spec *wfmt = wv ? var_get_print_format (wv) : & F_8_0;
+
+ static const char *chisq_stats[N_CHISQ] =
calc_chisq (chisq_v, df, &fisher1, &fisher2);
tab_offset (chisq, nvar - 2, -1);
calc_chisq (chisq_v, df, &fisher1, &fisher2);
tab_offset (chisq, nvar - 2, -1);
for (i = 0; i < N_CHISQ; i++)
{
if ((i != 2 && chisq_v[i] == SYSMIS)
|| (i == 2 && fisher1 == SYSMIS))
continue;
s = 1;
for (i = 0; i < N_CHISQ; i++)
{
if ((i != 2 && chisq_v[i] == SYSMIS)
|| (i == 2 && fisher1 == SYSMIS))
continue;
s = 1;
tab_text (chisq, 0, 0, TAB_LEFT, gettext (chisq_stats[i]));
if (i != 2)
{
tab_text (chisq, 0, 0, TAB_LEFT, gettext (chisq_stats[i]));
if (i != 2)
{
- tab_float (chisq, 1, 0, TAB_RIGHT, chisq_v[i], 8, 3);
- tab_float (chisq, 2, 0, TAB_RIGHT, df[i], 8, 0);
- tab_float (chisq, 3, 0, TAB_RIGHT,
- gsl_cdf_chisq_Q (chisq_v[i], df[i]), 8, 3);
+ tab_double (chisq, 1, 0, TAB_RIGHT, chisq_v[i], NULL);
+ tab_double (chisq, 2, 0, TAB_RIGHT, df[i], wfmt);
+ tab_double (chisq, 3, 0, TAB_RIGHT,
+ gsl_cdf_chisq_Q (chisq_v[i], df[i]), NULL);
- tab_float (chisq, 4, 0, TAB_RIGHT, fisher2, 8, 3);
- tab_float (chisq, 5, 0, TAB_RIGHT, fisher1, 8, 3);
+ tab_double (chisq, 4, 0, TAB_RIGHT, fisher2, NULL);
+ tab_double (chisq, 5, 0, TAB_RIGHT, fisher1, NULL);
}
tab_next_row (chisq);
}
tab_text (chisq, 0, 0, TAB_LEFT, _("N of Valid Cases"));
}
tab_next_row (chisq);
}
tab_text (chisq, 0, 0, TAB_LEFT, _("N of Valid Cases"));
- tab_float (chisq, 1, 0, TAB_RIGHT, W, 8, 0);
+ tab_double (chisq, 1, 0, TAB_RIGHT, W, wfmt);
{
N_("Nominal by Nominal"),
N_("Ordinal by Ordinal"),
{
N_("Nominal by Nominal"),
N_("Ordinal by Ordinal"),
last_cat = stats_categories[i];
tab_text (sym, 0, 0, TAB_LEFT, gettext (categories[last_cat]));
}
last_cat = stats_categories[i];
tab_text (sym, 0, 0, TAB_LEFT, gettext (categories[last_cat]));
}
tab_text (sym, 1, 0, TAB_LEFT, gettext (stats[i]));
tab_text (sym, 1, 0, TAB_LEFT, gettext (stats[i]));
- tab_float (sym, 2, 0, TAB_RIGHT, sym_v[i], 8, 3);
+ tab_double (sym, 2, 0, TAB_RIGHT, sym_v[i], NULL);
- tab_float (sym, 3, 0, TAB_RIGHT, sym_ase[i], 8, 3);
+ tab_double (sym, 3, 0, TAB_RIGHT, sym_ase[i], NULL);
- tab_float (sym, 4, 0, TAB_RIGHT, sym_t[i], 8, 3);
- /*tab_float (sym, 5, 0, TAB_RIGHT, normal_sig (sym_v[i]), 8, 3);*/
+ 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_next_row (sym);
}
tab_text (sym, 0, 0, TAB_LEFT, _("N of Valid Cases"));
tab_next_row (sym);
}
tab_text (sym, 0, 0, TAB_LEFT, _("N of Valid Cases"));
- tab_float (sym, 2, 0, TAB_RIGHT, W, 8, 0);
+ tab_double (sym, 2, 0, TAB_RIGHT, W, wfmt);
if (!calc_risk (risk_v, upper, lower, c))
return;
if (!calc_risk (risk_v, upper, lower, c))
return;
- x->vars[COL_VAR]->name,
- x->vars[COL_VAR]->width, c[0].s,
- x->vars[COL_VAR]->width, c[1].s);
+ var_get_name (x->vars[COL_VAR]),
+ var_get_width (x->vars[COL_VAR]), c[0].s,
+ var_get_width (x->vars[COL_VAR]), c[1].s);
- x->vars[ROW_VAR]->name,
- x->vars[ROW_VAR]->width, rows[i - 1].s);
+ var_get_name (x->vars[ROW_VAR]),
+ var_get_width (x->vars[ROW_VAR]), rows[i - 1].s);
tab_text (risk, 0, 0, TAB_LEFT, buf);
tab_text (risk, 0, 0, TAB_LEFT, buf);
- tab_float (risk, 1, 0, TAB_RIGHT, risk_v[i], 8, 3);
- tab_float (risk, 2, 0, TAB_RIGHT, lower[i], 8, 3);
- tab_float (risk, 3, 0, TAB_RIGHT, upper[i], 8, 3);
+ 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_next_row (risk);
}
tab_text (risk, 0, 0, TAB_LEFT, _("N of Valid Cases"));
tab_next_row (risk);
}
tab_text (risk, 0, 0, TAB_LEFT, _("N of Valid Cases"));
- tab_float (risk, 1, 0, TAB_RIGHT, W, 8, 0);
+ tab_double (risk, 1, 0, TAB_RIGHT, W, wfmt);
{
N_("Nominal by Nominal"),
N_("Ordinal by Ordinal"),
{
N_("Nominal by Nominal"),
N_("Ordinal by Ordinal"),
{
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2,
};
{
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2,
};
{
0, 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4,
};
{
0, 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4,
};
{
0, 1, 2, 1, 2, 0, 1, 2, 0, 1, 2, 1, 2,
};
{
0, 1, 2, 1, 2, 0, 1, 2, 0, 1, 2, 1, 2,
};
double direct_v[N_DIRECTIONAL];
double direct_ase[N_DIRECTIONAL];
double direct_t[N_DIRECTIONAL];
double direct_v[N_DIRECTIONAL];
double direct_ase[N_DIRECTIONAL];
double direct_t[N_DIRECTIONAL];
int i;
if (!calc_directional (direct_v, direct_ase, direct_t))
return;
tab_offset (direct, nvar - 2, -1);
int i;
if (!calc_directional (direct_v, direct_ase, direct_t))
return;
tab_offset (direct, nvar - 2, -1);
{
if (j < 2)
tab_hline (direct, TAL_1, j, 6, 0);
{
if (j < 2)
tab_hline (direct, TAL_1, j, 6, 0);
tab_text (direct, j, 0, TAB_LEFT | TAT_PRINTF,
gettext (stats_names[j][k]), string);
}
}
}
tab_text (direct, j, 0, TAB_LEFT | TAT_PRINTF,
gettext (stats_names[j][k]), string);
}
}
}
-
- tab_float (direct, 3, 0, TAB_RIGHT, direct_v[i], 8, 3);
+
+ tab_double (direct, 3, 0, TAB_RIGHT, direct_v[i], NULL);
- tab_float (direct, 4, 0, TAB_RIGHT, direct_ase[i], 8, 3);
+ tab_double (direct, 4, 0, TAB_RIGHT, direct_ase[i], NULL);
- tab_float (direct, 5, 0, TAB_RIGHT, direct_t[i], 8, 3);
- /*tab_float (direct, 6, 0, TAB_RIGHT, normal_sig (direct_v[i]), 8, 3);*/
+ tab_double (direct, 5, 0, TAB_RIGHT, direct_t[i], NULL);
+ /*tab_double (direct, 6, 0, TAB_RIGHT, normal_sig (direct_v[i]), NULL);*/
calc_fisher (int a, int b, int c, int d, double *fisher1, double *fisher2)
{
int x;
calc_fisher (int a, int b, int c, int d, double *fisher1, double *fisher2)
{
int x;
swap (&a, &c), swap (&b, &d);
swap (&a, &c), swap (&b, &d);
swap (&a, &b), swap (&c, &d);
if (b * c < a * d)
{
swap (&a, &b), swap (&c, &d);
if (b * c < a * d)
{
const double expected = row_tot[r] * col_tot[c] / W;
const double freq = mat[n_cols * r + c];
const double residual = freq - expected;
const double expected = row_tot[r] * col_tot[c] / W;
const double freq = mat[n_cols * r + c];
const double residual = freq - expected;
if (ns_cols == 2 && ns_rows == 2)
{
double f11, f12, f21, f22;
if (ns_cols == 2 && ns_rows == 2)
{
double f11, f12, f21, f22;
{
double r, ase_0, ase_1;
calc_r ((double *) rows, (double *) cols, &r, &ase_0, &ase_1);
{
double r, ase_0, ase_1;
calc_r ((double *) rows, (double *) cols, &r, &ase_0, &ase_1);
for (sum_Xr = sum_X2r = 0., i = 0; i < n_rows; i++)
{
sum_Xr += X[i] * row_tot[i];
for (sum_Xr = sum_X2r = 0., i = 0; i < n_rows; i++)
{
sum_Xr += X[i] * row_tot[i];
for (s = c = 0., i = 0; i < n_rows; i++)
for (j = 0; j < n_cols; j++)
{
for (s = c = 0., i = 0; i < n_rows; i++)
for (j = 0; j < n_cols; j++)
{
for (r = 0; r < n_rows; r++)
for (c = 0; c < n_cols; c++)
{
const double expected = row_tot[r] * col_tot[c] / W;
const double freq = mat[n_cols * r + c];
const double residual = freq - expected;
for (r = 0; r < n_rows; r++)
for (c = 0; c < n_cols; c++)
{
const double expected = row_tot[r] * col_tot[c] / W;
const double freq = mat[n_cols * r + c];
const double residual = freq - expected;
if (cmd.a_statistics[CRS_ST_BTAU] || cmd.a_statistics[CRS_ST_CTAU]
|| cmd.a_statistics[CRS_ST_GAMMA] || cmd.a_statistics[CRS_ST_D])
{
if (cmd.a_statistics[CRS_ST_BTAU] || cmd.a_statistics[CRS_ST_CTAU]
|| cmd.a_statistics[CRS_ST_GAMMA] || cmd.a_statistics[CRS_ST_D])
{
double P, Q;
double btau_cum, ctau_cum, gamma_cum, d_yx_cum, d_xy_cum;
double btau_var;
double P, Q;
double btau_cum, ctau_cum, gamma_cum, d_yx_cum, d_xy_cum;
double btau_var;
/* Spearman correlation, Pearson's r. */
if (cmd.a_statistics[CRS_ST_CORR])
{
/* Spearman correlation, Pearson's r. */
if (cmd.a_statistics[CRS_ST_CORR])
{
{
double y, t, c = 0., s = 0.;
int i = 0;
{
double y, t, c = 0., s = 0.;
int i = 0;
{
double y, t, c = 0., s = 0.;
int j = 0;
{
double y, t, c = 0., s = 0.;
int j = 0;
calc_r (R, C, &v[6], &t[6], &ase[6]);
t[6] = v[6] / t[6];
calc_r (R, C, &v[6], &t[6], &ase[6]);
t[6] = v[6] / t[6];
calc_r ((double *) rows, (double *) cols, &v[7], &t[7], &ase[7]);
t[7] = v[7] / t[7];
calc_r ((double *) rows, (double *) cols, &v[7], &t[7], &ase[7]);
t[7] = v[7] / t[7];
{
double sum_fii, sum_rici, sum_fiiri_ci, sum_fijri_ci2, sum_riciri_ci;
int i, j;
{
double sum_fii, sum_rici, sum_fiiri_ci, sum_fijri_ci2, sum_riciri_ci;
int i, j;
+ (f22 / (f21 * (f21 + f22))));
lower[1] = value[1] * exp (-1.960 * v);
upper[1] = value[1] * exp (1.960 * v);
+ (f22 / (f21 * (f21 + f22))));
lower[1] = value[1] * exp (-1.960 * v);
upper[1] = value[1] * exp (1.960 * v);
value[2] = (f12 * (f21 + f22)) / (f22 * (f11 + f12));
v = sqrt ((f11 / (f12 * (f11 + f12)))
+ (f21 / (f22 * (f21 + f22))));
value[2] = (f12 * (f21 + f22)) / (f22 * (f11 + f12));
v = sqrt ((f11 / (f12 * (f11 + f12)))
+ (f21 / (f22 * (f21 + f22))));
for (accum = 0., i = 0; i < n_rows; i++)
if (cm_index != fim_index[i])
accum += (mat[i * n_cols + fim_index[i]]
for (accum = 0., i = 0; i < n_rows; i++)
if (cm_index != fim_index[i])
accum += (mat[i * n_cols + fim_index[i]]
for (accum = 0., j = 0; j < n_cols; j++)
if (rm_index != fmj_index[j])
accum += (mat[j + n_cols * fmj_index[j]]
for (accum = 0., j = 0; j < n_cols; j++)
if (rm_index != fmj_index[j])
accum += (mat[j + n_cols * fmj_index[j]]
v[3] = (W * sum_fij2_ci - sum_ri2) / (W * W - sum_ri2);
v[4] = (W * sum_fij2_ri - sum_cj2) / (W * W - sum_cj2);
v[3] = (W * sum_fij2_ci - sum_ri2) / (W * W - sum_ri2);
v[4] = (W * sum_fij2_ri - sum_cj2) / (W * W - sum_cj2);
for (UX = 0., i = 0; i < n_rows; i++)
if (row_tot[i] > 0.)
UX -= row_tot[i] / W * log (row_tot[i] / W);
for (UX = 0., i = 0; i < n_rows; i++)
if (row_tot[i] > 0.)
UX -= row_tot[i] / W * log (row_tot[i] / W);
for (UY = 0., j = 0; j < n_cols; j++)
if (col_tot[j] > 0.)
UY -= col_tot[j] / W * log (col_tot[j] / W);
for (UY = 0., j = 0; j < n_cols; j++)
if (col_tot[j] > 0.)
UY -= col_tot[j] / W * log (col_tot[j] / W);
ase1_yx += entry * pow2 (UY * log (entry / row_tot[i])
+ (UX - UXY) * log (col_tot[j] / W));
ase1_xy += entry * pow2 (UX * log (entry / col_tot[j])
ase1_yx += entry * pow2 (UY * log (entry / row_tot[i])
+ (UX - UXY) * log (col_tot[j] / W));
ase1_xy += entry * pow2 (UX * log (entry / col_tot[j])
v[5] = 2. * ((UX + UY - UXY) / (UX + UY));
ase[5] = (2. / (W * pow2 (UX + UY))) * sqrt (ase1_sym);
t[5] = v[5] / ((2. / (W * (UX + UY)))
* sqrt (P - pow2 (UX + UY - UXY) / W));
v[5] = 2. * ((UX + UY - UXY) / (UX + UY));
ase[5] = (2. / (W * pow2 (UX + UY))) * sqrt (ase1_sym);
t[5] = v[5] / ((2. / (W * (UX + UY)))
* sqrt (P - pow2 (UX + UY - UXY) / W));
v[6] = (UX + UY - UXY) / UX;
ase[6] = sqrt (ase1_xy) / (W * UX * UX);
t[6] = v[6] / (sqrt (P - W * pow2 (UX + UY - UXY)) / (W * UX));
v[6] = (UX + UY - UXY) / UX;
ase[6] = sqrt (ase1_xy) / (W * UX * UX);
t[6] = v[6] / (sqrt (P - W * pow2 (UX + UY - UXY)) / (W * UX));
v[7] = (UX + UY - UXY) / UY;
ase[7] = sqrt (ase1_yx) / (W * UY * UY);
t[7] = v[7] / (sqrt (P - W * pow2 (UX + UY - UXY)) / (W * UY));
v[7] = (UX + UY - UXY) / UY;
ase[7] = sqrt (ase1_yx) / (W * UY * UY);
t[7] = v[7] / (sqrt (P - W * pow2 (UX + UY - UXY)) / (W * UY));
for (sum_Xr = sum_X2r = 0., i = 0; i < n_rows; i++)
{
sum_Xr += rows[i].f * row_tot[i];
for (sum_Xr = sum_X2r = 0., i = 0; i < n_rows; i++)
{
sum_Xr += rows[i].f * row_tot[i];
for (SXW = 0., j = 0; j < n_cols; j++)
{
double cum;
for (cum = 0., i = 0; i < n_rows; i++)
{
for (SXW = 0., j = 0; j < n_cols; j++)
{
double cum;
for (cum = 0., i = 0; i < n_rows; i++)
{
for (sum_Yc = sum_Y2c = 0., i = 0; i < n_cols; i++)
{
sum_Yc += cols[i].f * col_tot[i];
for (sum_Yc = sum_Y2c = 0., i = 0; i < n_cols; i++)
{
sum_Yc += cols[i].f * col_tot[i];