const struct variable *v;
};
-/* Linear regression models. */
-static pspp_linreg_cache **models = NULL;
-
/*
Transformations for saving predicted values
and residuals, etc.
static struct file_handle *model_file;
static bool run_regression (struct casereader *, struct cmd_regression *,
- struct dataset *);
+ struct dataset *, pspp_linreg_cache **);
/*
STATISTICS subcommand output functions.
{
struct casegrouper *grouper;
struct casereader *group;
+ pspp_linreg_cache **models;
bool ok;
size_t i;
/* Data pass. */
grouper = casegrouper_create_splits (proc_open (ds), dataset_dict (ds));
while (casegrouper_get_next_group (grouper, &group))
- run_regression (group, &cmd, ds);
+ run_regression (group, &cmd, ds, models);
ok = casegrouper_destroy (grouper);
ok = proc_commit (ds) && ok;
subcommand_save (ds, cmd.sbc_save, models);
free (v_variables);
free (models);
+ free_regression (&cmd);
+
return ok ? CMD_SUCCESS : CMD_FAILURE;
}
as the dependent variable. Print a warning and continue.
*/
msg (SE,
- gettext ("The dependent variable is equal to the independent variable. The least sequares line is therefore Y=X. Standard errors and related statistics may be meaningless."));
+ gettext ("The dependent variable is equal to the independent variable."
+ "The least squares line is therefore Y=X."
+ "Standard errors and related statistics may be meaningless."));
n_indep_vars = 1;
indep_vars[0] = v_variables[0];
}
static bool
run_regression (struct casereader *input, struct cmd_regression *cmd,
- struct dataset *ds)
+ struct dataset *ds, pspp_linreg_cache **models)
{
size_t i;
int n_indep = 0;
assert (models != NULL);
if (!casereader_peek (input, 0, &c))
- return true;
+ {
+ casereader_destroy (input);
+ return true;
+ }
output_split_file_values (ds, &c);
case_destroy (&c);
lopts.get_indep_mean_std[i] = 1;
}
models[k] = pspp_linreg_cache_alloc (X->m->size1, X->m->size2);
- models[k]->indep_means = gsl_vector_alloc (X->m->size2);
- models[k]->indep_std = gsl_vector_alloc (X->m->size2);
models[k]->depvar = dep_var;
/*
For large data sets, use QR decomposition.
}
casereader_destroy (reader);
}
+ for (i = 0; i < n_variables; i++)
+ {
+ moments1_destroy ((mom + i)->m);
+ }
+ free (mom);
free (indep_vars);
free (lopts.get_indep_mean_std);
casereader_destroy (input);