/*
PSPP - a program for statistical analysis.
Copyright (C) 2012, 2013, 2016 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 3 of the License, or
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.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _(msgid) gettext (msgid)
#define N_(msgid) msgid
-static void
+static void
append_value_name (const struct variable *var, const union value *val, struct string *str)
{
var_append_value_name (var, val, str);
enum pc_alg pc_alg;
double *ptiles;
size_t n_percentiles;
-
+
bool npplot;
bool histogramplot;
bool boxplot;
struct extremity *minima;
struct extremity *maxima;
- /*
+ /*
Minimum should alway equal mimima[0].val.
Likewise, maximum should alway equal maxima[0].val.
This redundancy exists as an optimisation effort.
const struct variable *ivar = iact->vars[ivar_idx];
const int width = var_get_width (ivar);
const union value *val = case_data (c, ivar);
-
+
if (prev_val[ivar_idx])
if (! value_equal (prev_val[ivar_idx], val, width))
{
{
const struct variable *ivar = iact->vars[ivar_idx];
const union value *val = case_data (c, ivar);
-
+
prev_val[ivar_idx] = val;
}
return diff_idx;
}
else
ds_put_format (&title, _("Boxplot of %s"), var_to_string (cmd->dep_vars[v]));
-
+
for (grp = 0; grp < n_cats; ++grp)
{
const struct exploratory_stats *es =
if ( y_max < es[v].maximum)
y_max = es[v].maximum;
}
-
+
boxplot = boxplot_create (y_min, y_max, ds_cstr (&title));
ds_destroy (&title);
ds_destroy (&label);
}
-
+
boxplot_submit (boxplot);
}
}
{
const struct variable *ivar = iact->vars[ivar_idx];
const union value *val = case_data (c, ivar);
-
+
ds_put_cstr (&label, var_to_string (ivar));
ds_put_cstr (&label, " = ");
append_value_name (ivar, val, &label);
struct exploratory_stats *es =
categoricals_get_user_data_by_category_real (cmd->cats, iact_idx, grp);
- boxplot_add_box (boxplot, es[v].box_whisker,
+ boxplot_add_box (boxplot, es[v].box_whisker,
var_to_string (cmd->dep_vars[v]));
es[v].box_whisker = NULL;
}
categoricals_get_user_data_by_category_real (cmd->cats, iact_idx, grp);
struct string label;
- ds_init_cstr (&label,
+ ds_init_cstr (&label,
var_to_string (cmd->dep_vars[v]));
if ( iact->n_vars > 0)
{
const struct variable *ivar = iact->vars[ivar_idx];
const union value *val = case_data (c, ivar);
-
+
ds_put_cstr (&label, var_to_string (ivar));
ds_put_cstr (&label, " = ");
append_value_name (ivar, val, &label);
ds_put_cstr (&label, "; ");
-
+
}
ds_put_cstr (&label, ")");
}
-
+
np = es[v].np;
reader = casewriter_make_reader (np->writer);
np->writer = NULL;
struct chart_item *sl;
struct string label;
- ds_init_cstr (&label,
+ ds_init_cstr (&label,
var_to_string (cmd->dep_vars[v]));
if (iact->n_vars > 0)
interaction_to_string (iact, &label);
ds_put_cstr (&label, ")");
}
-
+
sl = spreadlevel_plot_create (ds_cstr (&label), cmd->sl_power);
for (grp = 0; grp < n_cats; ++grp)
if (sl == NULL)
msg (MW, _("Not creating spreadlevel chart for %s"), ds_cstr (&label));
- else
+ else
chart_item_submit (sl);
ds_destroy (&label);
if (es[v].histogram == NULL)
continue;
- ds_init_cstr (&label,
+ ds_init_cstr (&label,
var_to_string (cmd->dep_vars[v]));
if ( iact->n_vars > 0)
{
const struct variable *ivar = iact->vars[ivar_idx];
const union value *val = case_data (c, ivar);
-
+
ds_put_cstr (&label, var_to_string (ivar));
ds_put_cstr (&label, " = ");
append_value_name (ivar, val, &label);
ds_put_cstr (&label, "; ");
-
+
}
ds_put_cstr (&label, ")");
}
ds_cstr (&label), n, mean,
sqrt (var), false));
-
+
ds_destroy (&label);
}
}
int ivar_idx;
if ( v > 0 )
tab_hline (t, TAL_1, 0, nc - 1, heading_rows + v * rows_per_var);
-
+
tab_text (t,
0, heading_rows + v * rows_per_var,
TAT_TITLE | TAB_LEFT,
if (( diff_idx != -1 && diff_idx <= ivar_idx)
|| i == 0)
- {
+ {
struct string str;
ds_init_empty (&str);
append_value_name (ivar, val, &str);
-
+
tab_text (t,
1 + ivar_idx,
heading_rows + v * rows_per_var + i * rows_per_cat,
TAT_TITLE | TAB_LEFT,
ds_cstr (&str)
);
-
+
ds_destroy (&str);
}
}
);
}
- tab_text (t, heading_columns - 1,
+ tab_text (t, heading_columns - 1,
heading_rows + v * rows_per_var + i * rows_per_cat,
TAT_TITLE | TAB_LEFT,
gettext (ptile_alg_desc [cmd->pc_alg]));
for (p = 0; p < cmd->n_percentiles; ++p)
{
- tab_double (t, heading_columns + p,
+ tab_double (t, heading_columns + p,
heading_rows + v * rows_per_var + i * rows_per_cat,
0,
percentile_calculate (es->percentiles[p], cmd->pc_alg),
NULL, RC_OTHER);
-
+
if (cmd->ptiles[p] == 25.0)
{
- tab_double (t, heading_columns + p,
+ tab_double (t, heading_columns + p,
heading_rows + v * rows_per_var + i * rows_per_cat + 1,
0,
hinges[0],
}
else if (cmd->ptiles[p] == 50.0)
{
- tab_double (t, heading_columns + p,
+ tab_double (t, heading_columns + p,
heading_rows + v * rows_per_var + i * rows_per_cat + 1,
0,
hinges[1],
}
else if (cmd->ptiles[p] == 75.0)
{
- tab_double (t, heading_columns + p,
+ tab_double (t, heading_columns + p,
heading_rows + v * rows_per_var + i * rows_per_cat + 1,
0,
hinges[2],
}
- tab_text (t, heading_columns - 1,
+ tab_text (t, heading_columns - 1,
heading_rows + v * rows_per_var + i * rows_per_cat + 1,
TAT_TITLE | TAB_LEFT,
_("Tukey's Hinges"));
-
+
}
free (prev_vals);
int ivar_idx;
if ( v > 0 )
tab_hline (t, TAL_1, 0, nc - 1, heading_rows + v * rows_per_var);
-
+
tab_text (t,
0, heading_rows + v * rows_per_var,
TAT_TITLE | TAB_LEFT,
if (( diff_idx != -1 && diff_idx <= ivar_idx)
|| i == 0)
- {
+ {
struct string str;
ds_init_empty (&str);
append_value_name (ivar, val, &str);
-
+
tab_text (t,
1 + ivar_idx,
heading_rows + v * rows_per_var + i * rows_per_cat,
TAT_TITLE | TAB_LEFT,
ds_cstr (&str)
);
-
+
ds_destroy (&str);
}
}
_("%g%% Confidence Interval for Mean"),
cmd->conf * 100.0
);
-
+
tab_text (t,
1 + iact->n_vars + 1,
heading_rows + v * rows_per_var + i * rows_per_cat + 1,
TAB_LEFT,
_("Median")
);
-
+
tab_double (t,
1 + iact->n_vars + 2,
heading_rows + v * rows_per_var + i * rows_per_cat + 4,
tab_double (t,
1 + iact->n_vars + 2,
heading_rows + v * rows_per_var + i * rows_per_cat + 7,
- 0,
+ 0,
es->minima[0].val,
NULL, RC_OTHER);
tab_double (t,
1 + iact->n_vars + 2,
heading_rows + v * rows_per_var + i * rows_per_cat + 8,
- 0,
+ 0,
es->maxima[0].val,
NULL, RC_OTHER);
tab_double (t,
1 + iact->n_vars + 2,
heading_rows + v * rows_per_var + i * rows_per_cat + 9,
- 0,
+ 0,
es->maxima[0].val - es->minima[0].val,
NULL, RC_OTHER);
1 + iact->n_vars + 2,
heading_rows + v * rows_per_var + i * rows_per_cat + 10,
0,
- percentile_calculate (es->quartiles[2], cmd->pc_alg) -
+ percentile_calculate (es->quartiles[2], cmd->pc_alg) -
percentile_calculate (es->quartiles[0], cmd->pc_alg),
NULL, RC_OTHER);
tab_vline (t, TAL_2, heading_columns, 0, nr - 1);
- if ( cmd->id_var )
+ if ( cmd->id_var )
tab_text (t, heading_columns, 0, TAB_CENTER | TAT_TITLE,
var_to_string (cmd->id_var));
else
int ivar_idx;
if ( v > 0 )
tab_hline (t, TAL_1, 0, nc - 1, heading_rows + v * rows_per_var);
-
+
tab_text (t,
0, heading_rows + v * rows_per_var,
TAT_TITLE,
if (( diff_idx != -1 && diff_idx <= ivar_idx)
|| i == 0)
- {
+ {
struct string str;
ds_init_empty (&str);
append_value_name (ivar, val, &str);
-
+
tab_text (t,
1 + ivar_idx,
heading_rows + v * rows_per_var + i * rows_per_cat,
TAT_TITLE | TAB_LEFT,
ds_cstr (&str)
);
-
+
ds_destroy (&str);
}
}
heading_rows + v * rows_per_var + i * rows_per_cat
);
}
-
+
tab_text (t,
heading_columns - 2,
heading_rows + v * rows_per_var + i * rows_per_cat,
&es->maxima[e].identity,
cmd->id_var,
NULL);
- else
+ else
tab_double (t,
heading_columns,
heading_rows + v * rows_per_var + i * rows_per_cat + e,
0,
es->maxima[e].val,
var_get_print_format (cmd->dep_vars[v]), RC_OTHER);
-
+
tab_double (t,
heading_columns - 1,
TAB_CENTER | TAT_TITLE, _("Valid"));
tab_joint_text (t,
- heading_columns + 2, 1,
+ heading_columns + 2, 1,
heading_columns + 3, 1,
TAB_CENTER | TAT_TITLE, _("Missing"));
if (( diff_idx != -1 && diff_idx <= ivar_idx)
|| i == 0)
- {
+ {
struct string str;
ds_init_empty (&str);
append_value_name (ivar, val, &str);
-
+
tab_text (t,
1 + ivar_idx, heading_rows + n_cats * v + i,
TAT_TITLE | TAB_LEFT,
ds_cstr (&str)
);
-
+
ds_destroy (&str);
}
}
es = categoricals_get_user_data_by_category_real (cmd->cats, iact_idx, i);
-
-
+
+
total = es[v].missing + es[v].non_missing;
- tab_double (t,
+ tab_double (t,
heading_columns + 0,
heading_rows + n_cats * v + i,
0,
NULL, RC_WEIGHT);
- tab_text_format (t,
+ tab_text_format (t,
heading_columns + 1,
heading_rows + n_cats * v + i,
0,
);
- tab_double (t,
+ tab_double (t,
heading_columns + 2,
heading_rows + n_cats * v + i,
0,
es[v].missing,
NULL, RC_WEIGHT);
- tab_text_format (t,
+ tab_text_format (t,
heading_columns + 3,
heading_rows + n_cats * v + i,
0,
"%g%%",
100.0 * es[v].missing / total
);
- tab_double (t,
+ tab_double (t,
heading_columns + 4,
heading_rows + n_cats * v + i,
0,
NULL, RC_WEIGHT);
/* This can only be 100% can't it? */
- tab_text_format (t,
+ tab_text_format (t,
heading_columns + 5,
heading_rows + n_cats * v + i,
0,
{
const struct variable *v = NULL;
struct interaction *iact = NULL;
-
+
if ( lex_match_variable (lexer, ex->dict, &v))
{
iact = interaction_create (v);
}
lex_match (lexer, T_COMMA);
}
-
+
return iact;
}
create_n (const void *aux1, void *aux2 UNUSED)
{
int v;
-
+
const struct examine *examine = aux1;
struct exploratory_stats *es = pool_calloc (examine->pool, examine->n_dep_vars, sizeof (*es));
struct subcase ordering;
int v;
const struct examine *examine = aux1;
struct exploratory_stats *es = user_data;
-
+
bool this_case_is_missing = false;
/* LISTWISE missing must be dealt with here */
if (!examine->missing_pw)
struct ccase *outcase ;
const struct variable *var = examine->dep_vars[v];
const double x = case_data (c, var)->f;
-
+
if (var_is_value_missing (var, case_data (c, var), examine->dep_excl))
{
es[v].missing += weight;
case_data_idx (c, examine->id_idx), examine->id_width);
case_data_rw_idx (outcase, EX_WT)->f = weight;
-
+
es[v].cc += weight;
if (es[v].cmin > weight)
value_init_pool (examine->pool, &es[v].maxima[i].identity, examine->id_width) ;
value_init_pool (examine->pool, &es[v].minima[i].identity, examine->id_width) ;
}
-
+
+ bool warn = true;
for (reader = casereader_clone (es[v].sorted_reader);
(c = casereader_read (reader)) != NULL; case_unref (c))
{
const double val = case_data_idx (c, EX_VAL)->f;
- const double wt = case_data_idx (c, EX_WT)->f;
+ double wt = case_data_idx (c, EX_WT)->f;
+ wt = var_force_valid_weight (examine->wv, wt, &warn);
moments_pass_two (es[v].mom, val, wt);
{
struct extremity *max;
- if (x >= examine->calc_extremes)
+ if (x >= examine->calc_extremes)
break;
max = &es[v].maxima[x];
{
struct order_stats *os;
- es[v].box_whisker = box_whisker_create (es[v].hinges,
+ es[v].box_whisker = box_whisker_create (es[v].hinges,
EX_ID, examine->id_var);
os = &es[v].box_whisker->parent;
struct order_stats *os;
moments_calculate (es[v].mom, &n, &mean, &var, NULL, NULL);
-
+
es[v].np = np_create (n, mean, var);
os = &es[v].np->parent;
static void
cleanup_exploratory_stats (struct examine *cmd)
-{
+{
int i;
for (i = 0; i < cmd->n_iacts; ++i)
{
payload.update = update_n;
payload.calculate = calculate_n;
payload.destroy = NULL;
-
+
cmd->wv = dict_get_weight (cmd->dict);
cmd->cats
- = categoricals_create (cmd->iacts, cmd->n_iacts,
+ = categoricals_create (cmd->iacts, cmd->n_iacts,
cmd->wv, cmd->dep_excl, cmd->fctr_excl);
categoricals_set_payload (cmd->cats, &payload, cmd, NULL);
examine.id_width = 0;
examine.id_var = NULL;
examine.boxplot_mode = BP_GROUPS;
-
+
examine.ex_proto = caseproto_create ();
examine.pool = pool_create ();
if (iact)
{
examine.n_iacts++;
- iacts_mem =
+ iacts_mem =
pool_nrealloc (examine.pool, iacts_mem,
examine.n_iacts,
sizeof (*iacts_mem));
-
+
iacts_mem[examine.n_iacts - 1] = iact;
}
}
while (lex_is_number (lexer))
{
double p = lex_number (lexer);
-
+
if ( p <= 0 || p >= 100.0)
{
lex_error (lexer,
examine.npplot = true;
examine.boxplot = true;
}
- else
+ else
{
lex_error (lexer, NULL);
goto error;
}
lex_match (lexer, T_COMMA);
- }
+ }
}
else if (lex_match_id (lexer, "CINTERVAL"))
{
if ( !lex_force_num (lexer))
goto error;
-
+
examine.conf = lex_number (lexer);
lex_get (lexer);
}
struct casegrouper *grouper;
struct casereader *group;
bool ok;
-
+
grouper = casegrouper_create_splits (proc_open (ds), examine.dict);
while (casegrouper_get_next_group (grouper, &group))
run_examine (&examine, group);