projects
/
pspp-builds.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8266aff
)
renamed pspp_linreg_coeff to pspp_coeff
author
Jason Stover
<jhs@math.gcsu.edu>
Fri, 19 May 2006 21:08:20 +0000
(21:08 +0000)
committer
Jason Stover
<jhs@math.gcsu.edu>
Fri, 19 May 2006 21:08:20 +0000
(21:08 +0000)
src/language/stats/regression.q
patch
|
blob
|
history
src/math/ChangeLog
patch
|
blob
|
history
src/math/coefficient.c
patch
|
blob
|
history
src/math/coefficient.h
patch
|
blob
|
history
src/math/linreg/linreg.c
patch
|
blob
|
history
src/math/linreg/linreg.h
patch
|
blob
|
history
src/math/linreg/predict.c
patch
|
blob
|
history
diff --git
a/src/language/stats/regression.q
b/src/language/stats/regression.q
index 3f41e16aad3e5e9d489f850100b193ec649219e0..7bb324295beaec3d1e0a3032d50a8e03026c1d94 100644
(file)
--- 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++)
{
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);
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.
*/
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);
}
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++)
{
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);
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;
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;
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];
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))
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;
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];
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];
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
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++)
{
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;
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;
int n_quantiles = 100;
double increment;
double tmp;
- struct pspp_
linreg_
coeff *coeff;
+ struct pspp_coeff *coeff;
if (export)
{
if (export)
{
@@
-1212,7
+1212,7
@@
run_regression (const struct ccase *first,
and store pointers to the variables that correspond to the
coefficients.
*/
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.
/*
Find the least-squares estimates and other statistics.
diff --git
a/src/math/ChangeLog
b/src/math/ChangeLog
index c8e3b7465b1837e12ffe19bc43931ea00d7c72b7..86186777709d8bb86df84582cb6d6d49c565218b 100644
(file)
--- a/
src/math/ChangeLog
+++ b/
src/math/ChangeLog
@@
-1,5
+1,7
@@
2006-05-19 Jason Stover <jhs@math.gcsu.edu>
2006-05-19 Jason Stover <jhs@math.gcsu.edu>
+ * coefficient.h: Renamed pspp_linreg_coeff to pspp_coeff.
+
* coefficient.c: Moved to src/math.
* coefficient.h: Moved to src/math.
* 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 f5d0eb56a52697b52f9e735fc1287ddc5fc994da..ef3eadfa17a1d1776dcd30d55f96da290b8a8469 100644
(file)
--- 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.
Copyright (C) 2005 Free Software Foundation, Inc. Written by Jason H Stover.
@@
-42,7
+42,7
@@
struct varinfo
};
void
};
void
-pspp_
linreg_coeff_free (struct pspp_linreg
_coeff *c)
+pspp_
coeff_free (struct pspp
_coeff *c)
{
free (c->v_info);
free (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
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;
{
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]));
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
}
}
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
{
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;
}
{
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
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)
{
{
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
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)
{
{
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
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)
{
{
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 *
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)
{
{
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 *
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;
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)
{
}
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;
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.
*/
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;
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)
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];
}
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];
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)
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
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];
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)
{
}
if (i == c->n_coeffs)
{
diff --git
a/src/math/coefficient.h
b/src/math/coefficient.h
index 0dc1a0353943b67e81e1a7bf5d73f4b4a4692874..5c9b61d174653ccb7fd2beca620cf90c0759d198 100644
(file)
--- 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.
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.
*/
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. */
{
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.
*/
/*
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
void
-pspp_
linreg_coeff_set_estimate (struct pspp_linreg
_coeff *, double estimate);
+pspp_
coeff_set_estimate (struct pspp
_coeff *, double estimate);
void
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.
/*
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.
*/
/*
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.
*/
/*
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?
*/
/*
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.
*/
/*
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?
*/
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 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
*,
*,
const struct variable
*,
diff --git
a/src/math/linreg/linreg.c
b/src/math/linreg/linreg.c
index e496150e71ca27140bcaefc7538e5822aa4c7696..c717e4ada4bd690ea7b0938f6c1289525cb24542 100644
(file)
--- 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_;
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;
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.
*/
/*
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++)
{
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. */
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++)
{
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;
}
free (c);
return true;
diff --git
a/src/math/linreg/linreg.h
b/src/math/linreg/linreg.h
index f66f878f8ebfe44e169f07f9523a3e5006ff124c..c5f5ef10ba24e944e91f548b37bf01621a85358a 100644
(file)
--- a/
src/math/linreg/linreg.h
+++ b/
src/math/linreg/linreg.h
@@
-26,7
+26,7
@@
#include <gsl/gsl_matrix.h>
struct variable;
#include <gsl/gsl_matrix.h>
struct variable;
-struct pspp_
linreg_
coeff;
+struct pspp_coeff;
union value;
enum
union value;
enum
@@
-107,7
+107,7
@@
struct pspp_linreg_cache_struct
const struct variable *depvar;
gsl_vector *residuals;
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.
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 6562d321e6c18e465c4aab41b0e396b88ac69fc9..ca96ab097e198d248e6aacf5a2208fd1ac808c3c 100644
(file)
--- 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 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;
double result;
double tmp;
@@
-69,7
+69,7
@@
pspp_linreg_predict (const struct variable **predictors,
if (i < c->n_coeffs)
{
found[i] = coe;
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;
if (predictors[j]->type == NUMERIC)
{
tmp *= vals[j]->f;