-/* PSPP - One way ANOVA. -*-c-*-
+/* PSPP - a program for statistical analysis.
+ Copyright (C) 1997-9, 2000, 2007 Free Software Foundation, Inc.
-Copyright (C) 1997-9, 2000, 2007 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
+ (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 2 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.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301, USA. */
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
#include <language/command.h>
#include <language/dictionary/split-file.h>
#include <language/lexer/lexer.h>
-#include <libpspp/alloc.h>
#include <libpspp/compiler.h>
#include <libpspp/hash.h>
-#include <libpspp/magic.h>
#include <libpspp/message.h>
#include <libpspp/misc.h>
#include <libpspp/str.h>
#include <output/table.h>
#include "sort-criteria.h"
+#include "xalloc.h"
+
#include "gettext.h"
#define _(msgid) gettext (msgid)
sum += subc_list_double_at(&cmd.dl_contrast[i],j);
if ( sum != 0.0 )
- msg(SW,_("Coefficients for contrast %d do not total zero"),
- (int) i + 1);
+ msg(SW,_("Coefficients for contrast %zu do not total zero"), i + 1);
}
if ( stat_tables & STAT_DESC )
struct hsh_table *group_hash = group_proc_get (vars[i])->group_hash;
struct hsh_iterator g;
struct group_statistics *gs;
- double ssa=0;
+ double ssa = 0;
const char *s = var_to_string(vars[i]);
for (gs = hsh_first (group_hash,&g);
gs != 0;
gs = hsh_next(group_hash,&g))
{
- ssa += (gs->sum * gs->sum)/gs->n;
+ ssa += pow2 (gs->sum) / gs->n;
}
- ssa -= ( totals->sum * totals->sum ) / totals->n ;
+ ssa -= pow2 (totals->sum) / totals->n;
tab_text (t, 0, i * 3 + 1, TAB_LEFT | TAT_TITLE, s);
tab_text (t, 1, i * 3 + 1, TAB_LEFT | TAT_TITLE, _("Between Groups"));
{
struct group_proc *gp = group_proc_get (vars[i]);
- const double sst = totals->ssq - ( totals->sum * totals->sum) / totals->n ;
+ const double sst = totals->ssq - pow2 (totals->sum) / totals->n ;
const double df1 = gp->n_groups - 1;
const double df2 = totals->n - gp->n_groups ;
const double msa = ssa / df1;
tab_float (t, 4, i * 3 + 1, TAB_RIGHT, msa, 8, 3);
tab_float (t, 4, i * 3 + 2, TAB_RIGHT, gp->mse, 8, 3);
-
{
const double F = msa/gp->mse ;
/* The significance */
tab_float (t, 6, i * 3 + 1, 0, gsl_cdf_fdist_Q(F,df1,df2), 8, 3);
}
-
}
-
}
for (count = 0 ; count < hsh_count(gp->group_hash) ; ++count)
{
+ struct string vstr;
+ ds_init_empty (&vstr);
gs = gs_array[count];
+ var_append_value_name (indep_var, &gs->id, &vstr);
+
tab_text (t, 1, row + count,
- TAB_LEFT | TAT_TITLE, var_get_value_name(indep_var,
- &gs->id));
+ TAB_LEFT | TAT_TITLE,
+ ds_cstr (&vstr));
+
+ ds_destroy (&vstr);
/* Now fill in the numbers ... */
tab_float (t, 2, row + count, 0, gs->n, 8,0);
- tab_float (t, 3, row + count, 0, gs->mean,8,2);
+ tab_float (t, 3, row + count, 0, gs->mean, 8, 2);
- tab_float (t, 4, row + count, 0, gs->std_dev,8,2);
+ tab_float (t, 4, row + count, 0, gs->std_dev, 8, 2);
std_error = gs->std_dev/sqrt(gs->n) ;
tab_float (t, 5, row + count, 0,
- std_error, 8,2);
+ std_error, 8, 2);
/* Now the confidence interval */
- T = gsl_cdf_tdist_Qinv(q,gs->n - 1);
+ T = gsl_cdf_tdist_Qinv(q, gs->n - 1);
tab_float(t, 6, row + count, 0,
gs->mean - T * std_error, 8, 2);
++count)
{
int i;
+ struct string vstr;
group_value = group_values[count];
+ ds_init_empty (&vstr);
+
+ var_append_value_name (indep_var, group_value, &vstr);
+
tab_text (t, count + 2, 1, TAB_CENTER | TAT_TITLE,
- var_get_value_name (indep_var, group_value));
+ ds_cstr (&vstr));
+
+ ds_destroy (&vstr);
+
for (i = 0 ; i < cmd.sbc_contrast ; ++i )
{
const double coef = subc_list_double_at(&cmd.dl_contrast[i], ci);
struct group_statistics *gs = group_stat_array[ci];
- const double winv = (gs->std_dev * gs->std_dev) / gs->n;
+ const double winv = pow2 (gs->std_dev) / gs->n;
contrast_value += coef * gs->mean;
coef_msq += (coef * coef) / gs->n ;
- sec_vneq += (coef * coef) * (gs->std_dev * gs->std_dev ) /gs->n ;
+ sec_vneq += (coef * coef) * pow2 (gs->std_dev) /gs->n ;
df_numerator += (coef * coef) * winv;
df_denominator += pow2((coef * coef) * winv) / (gs->n - 1);
cmd.sbc_contrast,
TAB_RIGHT, contrast_value, 8,2);
- std_error_contrast = sqrt(grp_data->mse * coef_msq);
+ std_error_contrast = sqrt (grp_data->mse * coef_msq);
/* Std. Error */
tab_float (t, 4, (v * lines_per_variable) + i + 1,
struct ccase c;
if (!casereader_peek (input, 0, &c))
- return;
+ {
+ casereader_destroy (input);
+ return;
+ }
output_split_file_values (ds, &c);
case_destroy (&c);
exclude = cmd->incl != ONEWAY_INCLUDE ? MV_ANY : MV_SYSTEM;
input = casereader_create_filter_missing (input, &indep_var, 1,
- exclude, NULL);
+ exclude, NULL, NULL);
if (cmd->miss == ONEWAY_LISTWISE)
input = casereader_create_filter_missing (input, vars, n_vars,
- exclude, NULL);
+ exclude, NULL, NULL);
input = casereader_create_filter_weight (input, dict, NULL, NULL);
reader = casereader_clone (input);
{
struct group_statistics *totals = &gp->ugs;
- totals->n+=weight;
- totals->sum+=weight * val->f;
- totals->ssq+=weight * val->f * val->f;
+ totals->n += weight;
+ totals->sum += weight * val->f;
+ totals->ssq += weight * pow2 (val->f);
if ( val->f * weight < totals->minimum )
totals->minimum = val->f * weight;
if ( val->f * weight > totals->maximum )
totals->maximum = val->f * weight;
- gs->n+=weight;
- gs->sum+=weight * val->f;
- gs->ssq+=weight * val->f * val->f;
+ gs->n += weight;
+ gs->sum += weight * val->f;
+ gs->ssq += weight * pow2 (val->f);
if ( val->f * weight < gs->minimum )
gs->minimum = val->f * weight;
gs != 0;
gs = hsh_next(group_hash,&g))
{
- gs->mean=gs->sum / gs->n;
+ gs->mean = gs->sum / gs->n;
gs->s_std_dev= sqrt(
- ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
+ gs->ssq / gs->n - pow2 (gs->mean)
) ;
gs->std_dev= sqrt(
- gs->n/(gs->n-1) *
- ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
+ gs->n / (gs->n - 1) *
+ ( gs->ssq / gs->n - pow2 (gs->mean))
) ;
- gs->se_mean = gs->std_dev / sqrt(gs->n);
- gs->mean_diff= gs->sum_diff / gs->n;
-
+ gs->se_mean = gs->std_dev / sqrt (gs->n);
+ gs->mean_diff = gs->sum_diff / gs->n;
}
-
-
totals->mean = totals->sum / totals->n;
totals->std_dev= sqrt(
- totals->n/(totals->n-1) *
- ( (totals->ssq / totals->n ) - totals->mean * totals->mean )
+ totals->n / (totals->n - 1) *
+ (totals->ssq / totals->n - pow2 (totals->mean))
) ;
- totals->se_mean = totals->std_dev / sqrt(totals->n);
-
+ totals->se_mean = totals->std_dev / sqrt (totals->n);
}
}
+
+/*
+ Local Variables:
+ mode: c
+ End:
+*/