From: John Darrington Date: Sat, 9 Oct 2010 10:56:45 +0000 (+0200) Subject: NPAR TESTS: Implement parser for kruskal wallis test X-Git-Tag: v0.7.6~42 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4fb23f132f76b405137cc5a73f5913d949a437ae;p=pspp-builds.git NPAR TESTS: Implement parser for kruskal wallis test --- diff --git a/src/language/stats/npar.c b/src/language/stats/npar.c index ad1724da..6e2fae71 100644 --- a/src/language/stats/npar.c +++ b/src/language/stats/npar.c @@ -75,6 +75,7 @@ struct cmd_npar_tests int binomial; int wilcoxon; int sign; + int kruskal_wallis; int missing; int method; int statistics; @@ -112,6 +113,7 @@ static int npar_chisquare (struct lexer *, struct dataset *, struct npar_specs * static int npar_binomial (struct lexer *, struct dataset *, struct npar_specs *); static int npar_wilcoxon (struct lexer *, struct dataset *, struct npar_specs *); static int npar_sign (struct lexer *, struct dataset *, struct npar_specs *); +static int npar_kruskal_wallis (struct lexer *, struct dataset *, struct npar_specs *); static int npar_method (struct lexer *, struct npar_specs *); /* Command parsing functions. */ @@ -167,6 +169,24 @@ parse_npar_tests (struct lexer *lexer, struct dataset *ds, struct cmd_npar_tests NOT_REACHED (); } } + else if (lex_match_hyphenated_word (lexer, "K-S") || + lex_match_hyphenated_word (lexer, "KRUSKAL-WALLIS")) + { + lex_match (lexer, '='); + npt->kruskal_wallis++; + switch (npar_kruskal_wallis (lexer, ds, nps)) + { + case 0: + goto lossage; + case 1: + break; + case 2: + lex_error (lexer, NULL); + goto lossage; + default: + NOT_REACHED (); + } + } else if (lex_match_hyphenated_word (lexer, "WILCOXON")) { lex_match (lexer, '='); @@ -818,6 +838,30 @@ npar_sign (struct lexer *lexer, struct dataset *ds, return 1; } +static int +npar_kruskal_wallis (struct lexer *lexer, struct dataset *ds, + struct npar_specs *specs) +{ + struct n_sample_test *tp = pool_alloc (specs->pool, sizeof (*tp)); + struct npar_test *nt = &tp->parent; + + nt->insert_variables = n_sample_insert_variables; + + // nt->execute = kruskall_wallis_execute; + + if (!parse_n_sample_related_test (lexer, dataset_dict (ds), + tp, specs->pool) ) + return 0; + + specs->n_tests++; + specs->test = pool_realloc (specs->pool, + specs->test, + sizeof (*specs->test) * specs->n_tests); + specs->test[specs->n_tests - 1] = nt; + + return 1; +} + /* Insert the variables for TEST into VAR_HASH */ static void one_sample_insert_variables (const struct npar_test *test,