From: John Darrington Date: Sat, 30 Oct 2004 04:46:38 +0000 (+0000) Subject: Fixed behaviour of oneway when presented with missing values X-Git-Tag: v0.4.0~247 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2c9a5954d98d4dd508d8fbf2496f2bb819527a46;p=pspp-builds.git Fixed behaviour of oneway when presented with missing values --- diff --git a/src/ChangeLog b/src/ChangeLog index 3c7527c7..11de18a8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,7 @@ Sat Oct 30 09:16:29 WST 2004 John Darrington + * oneway.q Fixed up the behaviour when given missing values + * levene.c oneway.q Fixed a buglet with the levene statistic and incorporated the levene test into the oneway command. diff --git a/src/oneway.q b/src/oneway.q index 185a9630..075ce0a1 100644 --- a/src/oneway.q +++ b/src/oneway.q @@ -95,7 +95,7 @@ static void show_contrast_coeffs(void); static void show_contrast_tests(void); -enum stat_table_t {STAT_DESC, STAT_HOMO}; +enum stat_table_t {STAT_DESC = 1, STAT_HOMO = 2}; static enum stat_table_t stat_tables ; @@ -903,12 +903,8 @@ calculate(const struct casefile *cf, void *cmd_) (hsh_hash_func *) hash_value, 0, (void *) indep_var->width ); - - - precalc(cmd); - for(r = casefile_get_reader (cf); casereader_read (r, &c) ; case_destroy (&c)) @@ -919,10 +915,30 @@ calculate(const struct casefile *cf, void *cmd_) dict_get_case_weight(default_dict,&c,&bad_weight_warn); const union value *indep_val = case_data (&c, indep_var->fv); + + /* Deal with missing values */ + if ( value_is_missing(indep_val,indep_var) ) + continue; + + /* Skip the entire case if /MISSING=LISTWISE is set */ + if ( cmd->miss == ONEWAY_LISTWISE ) + { + for(i = 0; i < n_vars ; ++i) + { + const struct variable *v = vars[i]; + const union value *val = case_data (&c, v->fv); + + if (value_is_missing(val,v) ) + break; + } + if ( i != n_vars ) + continue; + + } + hsh_insert ( global_group_hash, (void *) indep_val ); - for ( i = 0 ; i < n_vars ; ++i ) { const struct variable *v = vars[i]; @@ -986,7 +1002,9 @@ calculate(const struct casefile *cf, void *cmd_) if ( stat_tables & STAT_HOMO ) - levene(cf, indep_var, n_vars, vars, LEV_LISTWISE, value_is_missing); + levene(cf, indep_var, n_vars, vars, + (cmd->miss == ONEWAY_LISTWISE) ? LEV_LISTWISE : LEV_ANALYSIS , + value_is_missing); ostensible_number_of_groups = hsh_count (global_group_hash); @@ -1037,8 +1055,5 @@ postcalc ( struct cmd_oneway *cmd UNUSED ) totals->se_mean = totals->std_dev / sqrt(totals->n); - - - } } diff --git a/tests/Makefile.am b/tests/Makefile.am index a9882067..11904772 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -16,6 +16,7 @@ TESTS = \ command/list.sh \ command/loop.sh \ command/oneway.sh \ + command/oneway-missing.sh \ command/print.sh \ command/sample.sh \ command/sort.sh \ diff --git a/tests/command/oneway-missing.sh b/tests/command/oneway-missing.sh new file mode 100755 index 00000000..76ab99ea --- /dev/null +++ b/tests/command/oneway-missing.sh @@ -0,0 +1,166 @@ +#!/bin/sh + +# This program tests that the ONEWAY anova command works OK when there is missing data + +TEMPDIR=/tmp/pspp-tst-$$ + +here=`pwd`; + +# ensure that top_srcdir is absolute +cd $top_srcdir; top_srcdir=`pwd` + +export STAT_CONFIG_PATH=$top_srcdir/config + + +cleanup() +{ + rm -rf $TEMPDIR +} + + +fail() +{ + echo $activity + echo FAILED + cleanup; + exit 1; +} + + +no_result() +{ + echo $activity + echo NO RESULT; + cleanup; + exit 2; +} + +pass() +{ + cleanup; + exit 0; +} + +mkdir -p $TEMPDIR + +cd $TEMPDIR + +activity="create program" +cat > $TEMPDIR/out.stat < $TEMPDIR/out.stat < $TEMPDIR/out.stat <