size_t n_vars;
const struct variable **vars;
- const struct dictionary *dict;
-
const struct variable *indep_var;
enum statistics stats;
/* List of contrasts */
struct ll_list contrast_list;
+
+ /* The weight variable */
+ const struct variable *wv;
};
/* Routines to show the output tables */
static void show_anova_table (const struct oneway_spec *, const struct oneway_workspace *);
-static void show_descriptives (const struct oneway_spec *, const struct dictionary *dict);
+static void show_descriptives (const struct oneway_spec *);
static void show_homogeneity (const struct oneway_spec *);
static void output_oneway (const struct oneway_spec *, struct oneway_workspace *ws);
int
cmd_oneway (struct lexer *lexer, struct dataset *ds)
{
+ const struct dictionary *dict = dataset_dict (ds);
struct oneway_spec oneway ;
oneway.n_vars = 0;
oneway.vars = NULL;
oneway.stats = 0;
oneway.missing_type = MISS_ANALYSIS;
oneway.exclude = MV_ANY;
- oneway.dict = dataset_dict (ds);
+ oneway.wv = dict_get_weight (dict);
ll_init (&oneway.contrast_list);
lex_match (lexer, '=');
}
- if (!parse_variables_const (lexer, oneway.dict,
+ if (!parse_variables_const (lexer, dict,
&oneway.vars, &oneway.n_vars,
PV_NO_DUPLICATE | PV_NUMERIC))
goto error;
lex_force_match (lexer, T_BY);
- oneway.indep_var = parse_variable_const (lexer, oneway.dict);
+ oneway.indep_var = parse_variable_const (lexer, dict);
while (lex_token (lexer) != '.')
{
struct casereader *group;
bool ok;
- grouper = casegrouper_create_splits (proc_open (ds), oneway.dict);
+
+
+ grouper = casegrouper_create_splits (proc_open (ds), dict);
while (casegrouper_get_next_group (grouper, &group))
run_oneway (&oneway, group, ds);
ok = casegrouper_destroy (grouper);
struct dictionary *dict = dataset_dict (ds);
struct casereader *reader;
struct ccase *c;
- const struct variable *wv = dict_get_weight (dict);
+
struct oneway_workspace ws;
ws.vws = xmalloc (cmd->n_vars * sizeof (*ws.vws));
+
for (v = 0; v < cmd->n_vars; ++v)
{
+ struct categoricals *cats = categoricals_create (&cmd->indep_var, 1,
+ cmd->wv, cmd->exclude);
+
ws.vws[v].cov = covariance_2pass_create (1, &cmd->vars[v],
- 1, &cmd->indep_var,
- wv, cmd->exclude);
+ cats,
+ cmd->wv, cmd->exclude);
ws.vws[v].cc = 0;
}
}
if (cmd->stats & STATS_DESCRIPTIVES)
- show_descriptives (cmd, cmd->dict);
+ show_descriptives (cmd);
if (cmd->stats & STATS_HOMOGENEITY)
show_homogeneity (cmd);
/* Show the descriptives table */
static void
-show_descriptives (const struct oneway_spec *cmd, const struct dictionary *dict)
+show_descriptives (const struct oneway_spec *cmd)
{
size_t v;
int n_cols = 10;
const double confidence = 0.95;
const double q = (1.0 - confidence) / 2.0;
- const struct variable *wv = dict_get_weight (dict);
- const struct fmt_spec *wfmt = wv ? var_get_print_format (wv) : & F_8_0;
+ const struct fmt_spec *wfmt = cmd->wv ? var_get_print_format (cmd->wv) : & F_8_0;
int n_rows = 2;
int n_cols = 2 + ws->actual_number_of_groups;
int n_rows = 2 + n_contrasts;
- void *const *group_values;
-
struct tab_table *t;
+ const struct covariance *cov = ws->vws[0].cov ;
+
t = tab_create (n_cols, n_rows);
tab_headers (t, 2, 0, 2, 0);
tab_joint_text (t, 2, 0, n_cols - 1, 0, TAB_CENTER | TAT_TITLE,
var_to_string (cmd->indep_var));
- group_values = hsh_sort (ws->group_hash);
-
for ( cli = ll_head (&cmd->contrast_list);
cli != ll_null (&cmd->contrast_list);
cli = ll_next (cli))
{
int count = 0;
struct contrasts_node *cn = ll_data (cli, struct contrasts_node, ll);
- struct ll *coeffi = ll_head (&cn->coefficient_list);
+ struct ll *coeffi ;
tab_text_format (t, 1, c_num + 2, TAB_CENTER, "%d", c_num + 1);
- for (count = 0;
- count < hsh_count (ws->group_hash) && coeffi != ll_null (&cn->coefficient_list);
- ++count)
+ for (coeffi = ll_head (&cn->coefficient_list);
+ coeffi != ll_null (&cn->coefficient_list);
+ ++count, coeffi = ll_next (coeffi))
{
- double *group_value_p;
- union value group_value;
+ const struct categoricals *cats = covariance_get_categoricals (cov);
+ const union value *val = categoricals_get_value_by_subscript (cats, count);
struct string vstr;
ds_init_empty (&vstr);
- group_value_p = group_values[count];
- group_value.f = *group_value_p;
- var_append_value_name (cmd->indep_var, &group_value, &vstr);
+ var_append_value_name (cmd->indep_var, val, &vstr);
tab_text (t, count + 2, 1, TAB_CENTER | TAT_TITLE, ds_cstr (&vstr));
tab_text_format (t, count + 2, c_num + 2, TAB_RIGHT, "%g", coeffn->coeff);
}
-
- coeffi = ll_next (coeffi);
}
++c_num;
}