From: Jason Stover Date: Fri, 19 May 2006 21:08:20 +0000 (+0000) Subject: renamed pspp_linreg_coeff to pspp_coeff X-Git-Tag: v0.6.0~841 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=945fd370f9fb880b310fb88f868ad47c2ae84533;p=pspp-builds.git renamed pspp_linreg_coeff to pspp_coeff --- diff --git a/src/language/stats/regression.q b/src/language/stats/regression.q index 3f41e16a..7bb32429 100644 --- a/src/language/stats/regression.q +++ b/src/language/stats/regression.q @@ -225,7 +225,7 @@ reg_stats_coeff (pspp_linreg_cache * c) tab_float (t, 6, 1, 0, pval, 10, 2); for (j = 1; j <= c->n_indeps; j++) { - v = pspp_linreg_coeff_get_var (c->coeff[j], 0); + v = pspp_coeff_get_var (c->coeff[j], 0); label = var_to_string (v); /* Do not overwrite the variable's name. */ strncpy (tmp, label, MAX_STRING); @@ -237,7 +237,7 @@ reg_stats_coeff (pspp_linreg_cache * c) for that value. */ - val = pspp_linreg_coeff_get_value (c->coeff[j], v); + val = pspp_coeff_get_value (c->coeff[j], v); val_s = value_to_string (val, v); strncat (tmp, val_s, MAX_STRING); } @@ -392,7 +392,7 @@ reg_stats_bcov (pspp_linreg_cache * c) tab_text (t, 1, 1, TAB_CENTER | TAT_TITLE, _("Covariances")); for (i = 1; i < c->n_coeffs; i++) { - const struct variable *v = pspp_linreg_coeff_get_var (c->coeff[i], 0); + const struct variable *v = pspp_coeff_get_var (c->coeff[i], 0); label = var_to_string (v); tab_text (t, 2, i, TAB_CENTER, label); tab_text (t, i + 2, 0, TAB_CENTER, label); @@ -728,7 +728,7 @@ reg_print_categorical_encoding (FILE * fp, pspp_linreg_cache * c) size_t j; int n_vars = 0; struct variable **varlist; - struct pspp_linreg_coeff *coeff; + struct pspp_coeff *coeff; const struct variable *v; union value *val; @@ -738,7 +738,7 @@ reg_print_categorical_encoding (FILE * fp, pspp_linreg_cache * c) for (i = 1; i < c->n_indeps; i++) /* c->coeff[0] is the intercept. */ { coeff = c->coeff[i]; - v = pspp_linreg_coeff_get_var (coeff, 0); + v = pspp_coeff_get_var (coeff, 0); if (v->type == ALPHA) { if (!reg_inserted (v, varlist, n_vars)) @@ -781,18 +781,18 @@ static void reg_print_depvars (FILE * fp, pspp_linreg_cache * c) { int i; - struct pspp_linreg_coeff *coeff; + struct pspp_coeff *coeff; const struct variable *v; fprintf (fp, "char *model_depvars[%d] = {", c->n_indeps); for (i = 1; i < c->n_indeps; i++) { coeff = c->coeff[i]; - v = pspp_linreg_coeff_get_var (coeff, 0); + v = pspp_coeff_get_var (coeff, 0); fprintf (fp, "\"%s\",\n\t\t", v->name); } coeff = c->coeff[i]; - v = pspp_linreg_coeff_get_var (coeff, 0); + v = pspp_coeff_get_var (coeff, 0); fprintf (fp, "\"%s\"};\n\t", v->name); } static void @@ -814,7 +814,7 @@ reg_has_categorical (pspp_linreg_cache * c) for (i = 1; i < c->n_coeffs; i++) { - v = pspp_linreg_coeff_get_var (c->coeff[i], 0); + v = pspp_coeff_get_var (c->coeff[i], 0); if (v->type == ALPHA) { return 1; @@ -832,7 +832,7 @@ subcommand_export (int export, pspp_linreg_cache * c) int n_quantiles = 100; double increment; double tmp; - struct pspp_linreg_coeff *coeff; + struct pspp_coeff *coeff; if (export) { @@ -1212,7 +1212,7 @@ run_regression (const struct ccase *first, and store pointers to the variables that correspond to the coefficients. */ - pspp_linreg_coeff_init (models[k], X); + pspp_coeff_init (models[k], X); /* Find the least-squares estimates and other statistics. diff --git a/src/math/ChangeLog b/src/math/ChangeLog index c8e3b746..86186777 100644 --- a/src/math/ChangeLog +++ b/src/math/ChangeLog @@ -1,5 +1,7 @@ 2006-05-19 Jason Stover + * coefficient.h: Renamed pspp_linreg_coeff to pspp_coeff. + * coefficient.c: Moved to src/math. * coefficient.h: Moved to src/math. diff --git a/src/math/coefficient.c b/src/math/coefficient.c index f5d0eb56..ef3eadfa 100644 --- a/src/math/coefficient.c +++ b/src/math/coefficient.c @@ -1,5 +1,5 @@ /* - lib/linreg/coefficient.c + src/math/coefficient.c Copyright (C) 2005 Free Software Foundation, Inc. Written by Jason H Stover. @@ -42,7 +42,7 @@ struct varinfo }; void -pspp_linreg_coeff_free (struct pspp_linreg_coeff *c) +pspp_coeff_free (struct pspp_coeff *c) { free (c->v_info); free (c); @@ -53,12 +53,12 @@ pspp_linreg_coeff_free (struct pspp_linreg_coeff *c) coefficient structures for the linear model. */ void -pspp_linreg_coeff_init (pspp_linreg_cache * c, struct design_matrix *X) +pspp_coeff_init (pspp_linreg_cache * c, struct design_matrix *X) { size_t i; size_t j; int n_vals = 1; - struct pspp_linreg_coeff *coeff; + struct pspp_coeff *coeff; c->coeff = xnmalloc (X->m->size2 + 1, sizeof (*c->coeff)); c->coeff[0] = xmalloc (sizeof (*c->coeff[0])); @@ -90,13 +90,13 @@ pspp_linreg_coeff_init (pspp_linreg_cache * c, struct design_matrix *X) } } void -pspp_linreg_coeff_set_estimate (struct pspp_linreg_coeff *c, double estimate) +pspp_coeff_set_estimate (struct pspp_coeff *c, double estimate) { c->estimate = estimate; } void -pspp_linreg_coeff_set_std_err (struct pspp_linreg_coeff *c, double std_err) +pspp_coeff_set_std_err (struct pspp_coeff *c, double std_err) { c->std_err = std_err; } @@ -105,7 +105,7 @@ pspp_linreg_coeff_set_std_err (struct pspp_linreg_coeff *c, double std_err) Return the estimated value of the coefficient. */ double -pspp_linreg_coeff_get_est (const struct pspp_linreg_coeff *c) +pspp_coeff_get_est (const struct pspp_coeff *c) { if (c == NULL) { @@ -118,7 +118,7 @@ pspp_linreg_coeff_get_est (const struct pspp_linreg_coeff *c) Return the standard error of the estimated coefficient. */ double -pspp_linreg_coeff_get_std_err (const struct pspp_linreg_coeff *c) +pspp_coeff_get_std_err (const struct pspp_coeff *c) { if (c == NULL) { @@ -131,7 +131,7 @@ pspp_linreg_coeff_get_std_err (const struct pspp_linreg_coeff *c) How many variables are associated with this coefficient? */ int -pspp_linreg_coeff_get_n_vars (struct pspp_linreg_coeff *c) +pspp_coeff_get_n_vars (struct pspp_coeff *c) { if (c == NULL) { @@ -145,7 +145,7 @@ pspp_linreg_coeff_get_n_vars (struct pspp_linreg_coeff *c) 0 unless the coefficient refers to an interaction term. */ const struct variable * -pspp_linreg_coeff_get_var (struct pspp_linreg_coeff *c, int i) +pspp_coeff_get_var (struct pspp_coeff *c, int i) { if (c == NULL) { @@ -159,7 +159,7 @@ pspp_linreg_coeff_get_var (struct pspp_linreg_coeff *c, int i) Which value is associated with this coefficient/variable combination? */ const union value * -pspp_linreg_coeff_get_value (struct pspp_linreg_coeff *c, +pspp_coeff_get_value (struct pspp_coeff *c, const struct variable *v) { int i = 0; @@ -175,7 +175,7 @@ pspp_linreg_coeff_get_value (struct pspp_linreg_coeff *c, } while (i < c->n_vars) { - candidate = pspp_linreg_coeff_get_var (c, i); + candidate = pspp_coeff_get_var (c, i); if (v->index == candidate->index) { return (c->v_info + i)->val; @@ -189,12 +189,12 @@ pspp_linreg_coeff_get_value (struct pspp_linreg_coeff *c, Which coefficient is associated with V? The VAL argument is relevant only to categorical variables. */ -const struct pspp_linreg_coeff * +const struct pspp_coeff * pspp_linreg_get_coeff (const pspp_linreg_cache * c, const struct variable *v, const union value *val) { int i = 1; - struct pspp_linreg_coeff *result = NULL; + struct pspp_coeff *result = NULL; const struct variable *tmp = NULL; if (c == NULL) @@ -207,11 +207,11 @@ pspp_linreg_get_coeff (const pspp_linreg_cache * c, } result = c->coeff[i]; - tmp = pspp_linreg_coeff_get_var (result, 0); + tmp = pspp_coeff_get_var (result, 0); while (tmp->index != v->index && i < c->n_coeffs) { result = c->coeff[i]; - tmp = pspp_linreg_coeff_get_var (result, 0); + tmp = pspp_coeff_get_var (result, 0); i++; } if (i > c->n_coeffs) @@ -229,12 +229,12 @@ pspp_linreg_get_coeff (const pspp_linreg_cache * c, matches the VAL. */ while (tmp->index != v->index && i < c->n_coeffs - && compare_values (pspp_linreg_coeff_get_value (result, tmp), + && compare_values (pspp_coeff_get_value (result, tmp), val, v->width)) { /* FIX THIS */ i++; result = c->coeff[i]; - tmp = pspp_linreg_coeff_get_var (result, 0); + tmp = pspp_coeff_get_var (result, 0); } if (i == c->n_coeffs) { diff --git a/src/math/coefficient.h b/src/math/coefficient.h index 0dc1a035..5c9b61d1 100644 --- a/src/math/coefficient.h +++ b/src/math/coefficient.h @@ -1,5 +1,5 @@ /* - lib/linreg/coefficient.c + src/math/coefficient.c Copyright (C) 2005 Free Software Foundation, Inc. Written by Jason H Stover. @@ -35,7 +35,7 @@ struct design_matrix; storage. Therefore non-essential members of the struct will be allocated only when requested. */ -struct pspp_linreg_coeff +struct pspp_coeff { double estimate; /* Estimated coefficient. */ double std_err; /* Standard error of the estimate. */ @@ -56,20 +56,20 @@ struct pspp_linreg_coeff }; -void pspp_linreg_coeff_free (struct pspp_linreg_coeff *); +void pspp_coeff_free (struct pspp_coeff *); /* Initialize the variable and value pointers inside the coefficient structures for the linear model. */ -void pspp_linreg_coeff_init (pspp_linreg_cache *, struct design_matrix *); +void pspp_coeff_init (pspp_linreg_cache *, struct design_matrix *); void -pspp_linreg_coeff_set_estimate (struct pspp_linreg_coeff *, double estimate); +pspp_coeff_set_estimate (struct pspp_coeff *, double estimate); void -pspp_linreg_coeff_set_std_err (struct pspp_linreg_coeff *, double std_err); +pspp_coeff_set_std_err (struct pspp_coeff *, double std_err); /* Accessor functions for matching coefficients and variables. @@ -78,31 +78,31 @@ pspp_linreg_coeff_set_std_err (struct pspp_linreg_coeff *, double std_err); /* Return the estimated value of the coefficient. */ -double pspp_linreg_coeff_get_est (const struct pspp_linreg_coeff *); +double pspp_coeff_get_est (const struct pspp_coeff *); /* Return the standard error of the estimated coefficient. */ -double pspp_linreg_coeff_get_std_err (const struct pspp_linreg_coeff *); +double pspp_coeff_get_std_err (const struct pspp_coeff *); /* How many variables are associated with this coefficient? */ -int pspp_linreg_coeff_get_n_vars (struct pspp_linreg_coeff *); +int pspp_coeff_get_n_vars (struct pspp_coeff *); /* Which variable does this coefficient match? The int argument is usually 0, unless the coefficient refers to an interaction. */ -const struct variable *pspp_linreg_coeff_get_var (struct pspp_linreg_coeff *, +const struct variable *pspp_coeff_get_var (struct pspp_coeff *, int); /* Which value is associated with this coefficient/variable comination? */ -const union value *pspp_linreg_coeff_get_value (struct pspp_linreg_coeff *, +const union value *pspp_coeff_get_value (struct pspp_coeff *, const struct variable *); -const struct pspp_linreg_coeff *pspp_linreg_get_coeff (const pspp_linreg_cache +const struct pspp_coeff *pspp_linreg_get_coeff (const pspp_linreg_cache *, const struct variable *, diff --git a/src/math/linreg/linreg.c b/src/math/linreg/linreg.c index e496150e..c717e4ad 100644 --- a/src/math/linreg/linreg.c +++ b/src/math/linreg/linreg.c @@ -97,7 +97,7 @@ int pspp_linreg_get_vars (const void *c_, struct variable **v) { const pspp_linreg_cache *c = c_; - struct pspp_linreg_coeff *coef = NULL; + struct pspp_coeff *coef = NULL; const struct variable *tmp; int i; int result = 0; @@ -113,12 +113,12 @@ pspp_linreg_get_vars (const void *c_, struct variable **v) /* Start at c->coeff[1] to avoid the intercept. */ - v[result] = (struct variable *) pspp_linreg_coeff_get_var (c->coeff[1], 0); + v[result] = (struct variable *) pspp_coeff_get_var (c->coeff[1], 0); result = (v[result] == NULL) ? 0 : 1; for (coef = c->coeff[2]; coef < c->coeff[c->n_coeffs]; coef++) { - tmp = pspp_linreg_coeff_get_var (coef, 0); + tmp = pspp_coeff_get_var (coef, 0); assert (tmp != NULL); /* Repeated variables are likely to bunch together, at the end of the array. */ @@ -187,7 +187,7 @@ pspp_linreg_cache_free (void *m) gsl_matrix_free (c->cov); for (i = 0; i < c->n_coeffs; i++) { - pspp_linreg_coeff_free (c->coeff[i]); + pspp_coeff_free (c->coeff[i]); } free (c); return true; diff --git a/src/math/linreg/linreg.h b/src/math/linreg/linreg.h index f66f878f..c5f5ef10 100644 --- a/src/math/linreg/linreg.h +++ b/src/math/linreg/linreg.h @@ -26,7 +26,7 @@ #include struct variable; -struct pspp_linreg_coeff; +struct pspp_coeff; union value; enum @@ -107,7 +107,7 @@ struct pspp_linreg_cache_struct const struct variable *depvar; gsl_vector *residuals; - struct pspp_linreg_coeff **coeff; + struct pspp_coeff **coeff; int method; /* Method to use to estimate parameters. */ /* Means and standard deviations of the variables. diff --git a/src/math/linreg/predict.c b/src/math/linreg/predict.c index 6562d321..ca96ab09 100644 --- a/src/math/linreg/predict.c +++ b/src/math/linreg/predict.c @@ -35,8 +35,8 @@ pspp_linreg_predict (const struct variable **predictors, const pspp_linreg_cache *c = c_; int i; int j; - const struct pspp_linreg_coeff **found; - const struct pspp_linreg_coeff *coe; + const struct pspp_coeff **found; + const struct pspp_coeff *coe; double result; double tmp; @@ -69,7 +69,7 @@ pspp_linreg_predict (const struct variable **predictors, if (i < c->n_coeffs) { found[i] = coe; - tmp = pspp_linreg_coeff_get_est (coe); + tmp = pspp_coeff_get_est (coe); if (predictors[j]->type == NUMERIC) { tmp *= vals[j]->f;