X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fstats%2Flogistic.c;h=eb200fe37889c54c04596068614167735faa13d1;hb=d5f42de822479581dded51ade0d997c16404890f;hp=2c214516b711dc05d79e2bff025053871a1e1c0e;hpb=6982cc4aef29f7026e75702174efa8091d9badb2;p=pspp diff --git a/src/language/stats/logistic.c b/src/language/stats/logistic.c index 2c214516b7..eb200fe378 100644 --- a/src/language/stats/logistic.c +++ b/src/language/stats/logistic.c @@ -523,6 +523,7 @@ initial_pass (const struct lr_spec *cmd, struct lr_result *res, struct casereade ) { msg (ME, _("Dependent variable's values are not dichotomous.")); + case_unref (c); goto error; } } @@ -594,11 +595,12 @@ run_lr (const struct lr_spec *cmd, struct casereader *input, work.warn_bad_weight = true; work.cats = NULL; work.beta_hat = NULL; + work.hessian = NULL; /* Get the initial estimates of \beta and their standard errors. And perform other auxilliary initialisation. */ if (! initial_pass (cmd, &work, input)) - return false; + goto error; for (i = 0; i < cmd->n_cat_predictors; ++i) { @@ -612,7 +614,7 @@ run_lr (const struct lr_spec *cmd, struct casereader *input, msg (ME, _("Category %s does not have at least two distinct values. Logistic regression will not be run."), ds_cstr(&str)); ds_destroy (&str); - return false; + goto error; } } @@ -692,7 +694,7 @@ run_lr (const struct lr_spec *cmd, struct casereader *input, if (converged) break; } - casereader_destroy (input); + if ( ! converged) @@ -707,12 +709,20 @@ run_lr (const struct lr_spec *cmd, struct casereader *input, output_classification_table (cmd, &work); output_variables (cmd, &work); + casereader_destroy (input); gsl_matrix_free (work.hessian); gsl_vector_free (work.beta_hat); - categoricals_destroy (work.cats); return true; + + error: + casereader_destroy (input); + gsl_matrix_free (work.hessian); + gsl_vector_free (work.beta_hat); + categoricals_destroy (work.cats); + + return false; } struct variable_node @@ -741,6 +751,7 @@ lookup_variable (const struct hmap *map, const struct variable *var, unsigned in int cmd_logistic (struct lexer *lexer, struct dataset *ds) { + int i; /* Temporary location for the predictor variables. These may or may not include the categorical predictors */ const struct variable **pred_vars; @@ -1092,6 +1103,10 @@ cmd_logistic (struct lexer *lexer, struct dataset *ds) ok = proc_commit (ds) && ok; } + for (i = 0 ; i < lr.n_cat_predictors; ++i) + { + interaction_destroy (lr.cat_predictors[i]); + } free (lr.predictor_vars); free (lr.cat_predictors); free (lr.indep_vars); @@ -1100,6 +1115,10 @@ cmd_logistic (struct lexer *lexer, struct dataset *ds) error: + for (i = 0 ; i < lr.n_cat_predictors; ++i) + { + interaction_destroy (lr.cat_predictors[i]); + } free (lr.predictor_vars); free (lr.cat_predictors); free (lr.indep_vars);