#include <language/command.h>
#include <language/dictionary/split-file.h>
#include <language/lexer/lexer.h>
+#include <language/lexer/value-parser.h>
#include <libpspp/array.h>
#include <libpspp/assertion.h>
#include <libpspp/compiler.h>
#include <libpspp/taint.h>
#include <math/group-proc.h>
#include <math/levene.h>
+#include <math/correlation.h>
#include <output/manager.h>
#include <output/table.h>
#include <data/format.h>
+#include "minmax.h"
#include "xalloc.h"
#include "xmemdup0.h"
union value g_value[2]; /* CMP_EQ only: Per-group indep var values. */
};
-static int parse_value (struct lexer *, union value *, int width);
-
/* Statistics Summary Box */
struct ssbox
{
free (vars2);
return 1;
}
-
-/* Parses the current token (numeric or string, depending on type)
- value v and returns success. */
-static int
-parse_value (struct lexer *lexer, union value *v, int width)
-{
- if (width == 0)
- {
- if (!lex_force_num (lexer))
- return 0;
- v->f = lex_tokval (lexer);
- }
- else
- {
- if (!lex_force_string (lexer))
- return 0;
- value_copy_str_rpad (v, width, ds_cstr (lex_tokstr (lexer)), ' ');
- }
-
- lex_get (lexer);
-
- return 1;
-}
\f
/* Implementation of the SSBOX object. */
tab_text (this->t, 1, 0, TAB_CENTER | TAT_TITLE, _("N"));
tab_text (this->t, 2, 0, TAB_CENTER | TAT_TITLE, _("Mean"));
tab_text (this->t, 3, 0, TAB_CENTER | TAT_TITLE, _("Std. Deviation"));
- tab_text (this->t, 4, 0, TAB_CENTER | TAT_TITLE, _("SE. Mean"));
+ tab_text (this->t, 4, 0, TAB_CENTER | TAT_TITLE, _("S.E. Mean"));
}
/* Initialize the independent samples ssbox */
tab_text (this->t, 2, 0, TAB_CENTER | TAT_TITLE, _("N"));
tab_text (this->t, 3, 0, TAB_CENTER | TAT_TITLE, _("Mean"));
tab_text (this->t, 4, 0, TAB_CENTER | TAT_TITLE, _("Std. Deviation"));
- tab_text (this->t, 5, 0, TAB_CENTER | TAT_TITLE, _("SE. Mean"));
+ tab_text (this->t, 5, 0, TAB_CENTER | TAT_TITLE, _("S.E. Mean"));
}
/* Populate the ssbox for independent samples */
tab_text (ssb->t, 0, i * 2 + 1, TAB_LEFT,
var_get_name (proc->vars[i]));
- tab_text (ssb->t, 1, i * 2 + 1, TAB_LEFT | TAT_PRINTF,
- "%s%s", prefix[0], val_lab[0]);
- tab_text (ssb->t, 1, i * 2 + 1+ 1, TAB_LEFT | TAT_PRINTF,
- "%s%s", prefix[1], val_lab[1]);
+ tab_text_format (ssb->t, 1, i * 2 + 1, TAB_LEFT,
+ "%s%s", prefix[0], val_lab[0]);
+ tab_text_format (ssb->t, 1, i * 2 + 1+ 1, TAB_LEFT,
+ "%s%s", prefix[1], val_lab[1]);
/* Fill in the group statistics */
for (count = 0; count < 2; count++)
tab_text (this->t, 2, 0, TAB_CENTER | TAT_TITLE, _("Mean"));
tab_text (this->t, 3, 0, TAB_CENTER | TAT_TITLE, _("N"));
tab_text (this->t, 4, 0, TAB_CENTER | TAT_TITLE, _("Std. Deviation"));
- tab_text (this->t, 5, 0, TAB_CENTER | TAT_TITLE, _("SE. Mean"));
+ tab_text (this->t, 5, 0, TAB_CENTER | TAT_TITLE, _("S.E. Mean"));
}
/* Populate the ssbox for paired values */
struct pair *p = &proc->pairs[i];
int j;
- tab_text (ssb->t, 0, i * 2 + 1, TAB_LEFT | TAT_PRINTF, _("Pair %d"), i);
+ tab_text_format (ssb->t, 0, i * 2 + 1, TAB_LEFT, _("Pair %d"), i);
for (j=0; j < 2; j++)
{
/* Titles */
tab_text (self->t, 9, 2, TAB_CENTER | TAT_TITLE, _("Lower"));
tab_text (self->t, 10, 2, TAB_CENTER | TAT_TITLE, _("Upper"));
- tab_joint_text (self->t, 9, 1, 10, 1, TAB_CENTER | TAT_PRINTF,
- _("%g%% Confidence Interval of the Difference"),
- proc->criteria * 100.0);
+ tab_joint_text_format (self->t, 9, 1, 10, 1, TAB_CENTER,
+ _("%g%% Confidence Interval of the Difference"),
+ proc->criteria * 100.0);
}
/* Populate the independent samples trbox */
tab_hline (self->t, TAL_1, 5, 6, 2);
tab_vline (self->t, TAL_GAP, 6, 0, 1);
- tab_joint_text (self->t, 5, 1, 6, 1, TAB_CENTER | TAT_PRINTF,
- _("%g%% Confidence Interval of the Difference"),
- proc->criteria*100.0);
+ tab_joint_text_format (self->t, 5, 1, 6, 1, TAB_CENTER,
+ _("%g%% Confidence Interval of the Difference"),
+ proc->criteria*100.0);
tab_text (self->t, 2, 2, TAB_CENTER | TAT_TITLE, _("Mean"));
tab_text (self->t, 3, 2, TAB_CENTER | TAT_TITLE, _("Std. Deviation"));
double t;
double df = n - 1;
- tab_text (trb->t, 0, i + 3, TAB_LEFT | TAT_PRINTF, _("Pair %d"), i);
- tab_text (trb->t, 1, i + 3, TAB_LEFT | TAT_PRINTF, "%s - %s",
- var_get_name (pair->v[0]),
- var_get_name (pair->v[1]));
+ tab_text_format (trb->t, 0, i + 3, TAB_LEFT, _("Pair %d"), i);
+ tab_text_format (trb->t, 1, i + 3, TAB_LEFT, "%s - %s",
+ var_get_name (pair->v[0]),
+ var_get_name (pair->v[1]));
tab_double (trb->t, 2, i + 3, TAB_RIGHT, pair->mean_diff, NULL);
tab_double (trb->t, 3, i + 3, TAB_RIGHT, pair->std_dev_diff, NULL);
/* Degrees of freedom */
tab_double (trb->t, 8, i + 3, TAB_RIGHT, df, &proc->weight_format);
- p = gsl_cdf_tdist_P (t, df);
- q = gsl_cdf_tdist_P (t, df);
+ p = gsl_cdf_tdist_P (t,df);
+ q = gsl_cdf_tdist_Q (t,df);
tab_double (trb->t, 9, i + 3, TAB_RIGHT, 2.0 * (t > 0 ? q : p), NULL);
}
tab_hline (self->t, TAL_1, 1, hsize - 1, 1);
tab_vline (self->t, TAL_2, 1, 0, vsize - 1);
- tab_joint_text (self->t, 1, 0, hsize - 1, 0, TAB_CENTER | TAT_PRINTF,
- _("Test Value = %f"), proc->testval);
+ tab_joint_text_format (self->t, 1, 0, hsize - 1, 0, TAB_CENTER,
+ _("Test Value = %f"), proc->testval);
tab_box (self->t, -1, -1, -1, TAL_1, 1, 1, hsize - 1, vsize - 1);
- tab_joint_text (self->t, 5, 1, 6, 1, TAB_CENTER | TAT_PRINTF,
- _("%g%% Confidence Interval of the Difference"),
- proc->criteria * 100.0);
+ tab_joint_text_format (self->t, 5, 1, 6, 1, TAB_CENTER,
+ _("%g%% Confidence Interval of the Difference"),
+ proc->criteria * 100.0);
tab_vline (self->t, TAL_GAP, 6, 1, 1);
tab_hline (self->t, TAL_1, 5, 6, 2);
for (i = 0; i < proc->n_pairs; i++)
{
struct pair *pair = &proc->pairs[i];
- double p, q;
- double df = pair->n -2;
- double correlation_t = (pair->correlation * sqrt (df) /
- sqrt (1 - pow2 (pair->correlation)));
/* row headings */
- tab_text (table, 0, i + 1, TAB_LEFT | TAT_TITLE | TAT_PRINTF,
- _("Pair %d"), i);
- tab_text (table, 1, i + 1, TAB_LEFT | TAT_TITLE | TAT_PRINTF,
- _("%s & %s"),
- var_get_name (pair->v[0]),
- var_get_name (pair->v[1]));
+ tab_text_format (table, 0, i + 1, TAB_LEFT | TAT_TITLE,
+ _("Pair %d"), i);
+ tab_text_format (table, 1, i + 1, TAB_LEFT | TAT_TITLE,
+ _("%s & %s"),
+ var_get_name (pair->v[0]),
+ var_get_name (pair->v[1]));
/* row data */
tab_double (table, 2, i + 1, TAB_RIGHT, pair->n, &proc->weight_format);
tab_double (table, 3, i + 1, TAB_RIGHT, pair->correlation, NULL);
- p = gsl_cdf_tdist_P (correlation_t, df);
- q = gsl_cdf_tdist_Q (correlation_t, df);
- tab_double (table, 4, i + 1, TAB_RIGHT,
- 2.0 * (correlation_t > 0 ? q : p), NULL);
+ tab_double (table, 4, i + 1, TAB_RIGHT,
+ 2.0 * significance_of_correlation (pair->correlation, pair->n), NULL);
}
tab_submit (table);