projects
/
pspp-builds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add CONST_CAST macro, for casting away "const" more safely.
[pspp-builds.git]
/
src
/
math
/
linreg.c
diff --git
a/src/math/linreg.c
b/src/math/linreg.c
index f2897e8e8d2461cd3c4a4484335bcca2bb0ba1c3..8028697c6b7f3410b12927a0fe7ae1d82c5a6b4b 100644
(file)
--- a/
src/math/linreg.c
+++ b/
src/math/linreg.c
@@
-24,7
+24,6
@@
#include <math/coefficient.h>
#include <math/linreg.h>
#include <math/coefficient.h>
#include <math/coefficient.h>
#include <math/linreg.h>
#include <math/coefficient.h>
-#include <math/covariance-matrix.h>
#include <math/design-matrix.h>
#include <src/data/category.h>
#include <src/data/variable.h>
#include <math/design-matrix.h>
#include <src/data/category.h>
#include <src/data/variable.h>
@@
-661,24
+660,28
@@
void pspp_linreg_set_indep_variable_mean (pspp_linreg_cache *c, const struct var
only variables in the model are in the covariance matrix.
*/
static struct design_matrix *
only variables in the model are in the covariance matrix.
*/
static struct design_matrix *
-rearrange_covariance_matrix (const struct
design_matrix *cov
, pspp_linreg_cache *c)
+rearrange_covariance_matrix (const struct
covariance_matrix *cm
, pspp_linreg_cache *c)
{
const struct variable **model_vars;
{
const struct variable **model_vars;
+ struct design_matrix *cov;
struct design_matrix *result;
size_t *permutation;
size_t i;
size_t j;
size_t k;
struct design_matrix *result;
size_t *permutation;
size_t i;
size_t j;
size_t k;
+ size_t n_coeffs = 0;
+ assert (cm != NULL);
+ cov = covariance_to_design (cm);
assert (cov != NULL);
assert (c != NULL);
assert (cov->m->size1 > 0);
assert (cov->m->size2 == cov->m->size1);
assert (cov != NULL);
assert (c != NULL);
assert (cov->m->size1 > 0);
assert (cov->m->size2 == cov->m->size1);
- permutation = xnmalloc (1 + c->n_indeps, sizeof (*permutation));
model_vars = xnmalloc (1 + c->n_indeps, sizeof (*model_vars));
/*
Put the model variables in the right order in MODEL_VARS.
model_vars = xnmalloc (1 + c->n_indeps, sizeof (*model_vars));
/*
Put the model variables in the right order in MODEL_VARS.
+ Count the number of coefficients.
*/
for (i = 0; i < c->n_indeps; i++)
{
*/
for (i = 0; i < c->n_indeps; i++)
{
@@
-686,6
+689,8
@@
rearrange_covariance_matrix (const struct design_matrix *cov, pspp_linreg_cache
}
model_vars[i] = c->depvar;
result = covariance_matrix_create (1 + c->n_indeps, model_vars);
}
model_vars[i] = c->depvar;
result = covariance_matrix_create (1 + c->n_indeps, model_vars);
+ permutation = xnmalloc (design_matrix_get_n_cols (result), sizeof (*permutation));
+
for (j = 0; j < cov->m->size2; j++)
{
k = 0;
for (j = 0; j < cov->m->size2; j++)
{
k = 0;
@@
-719,8
+724,8
@@
rearrange_covariance_matrix (const struct design_matrix *cov, pspp_linreg_cache
having to alter it. The problem is that this means the caller must
set CACHE->N_COEFFS.
*/
having to alter it. The problem is that this means the caller must
set CACHE->N_COEFFS.
*/
-int
-pspp_linreg_with_cov (const struct
design
_matrix *full_cov,
+void
+pspp_linreg_with_cov (const struct
covariance
_matrix *full_cov,
pspp_linreg_cache * cache)
{
struct design_matrix *cov;
pspp_linreg_cache * cache)
{
struct design_matrix *cov;
@@
-732,6
+737,11
@@
pspp_linreg_with_cov (const struct design_matrix *full_cov,
cache_init (cache);
reg_sweep (cov->m);
post_sweep_computations (cache, cov, cov->m);
cache_init (cache);
reg_sweep (cov->m);
post_sweep_computations (cache, cov, cov->m);
-
covariance
_matrix_destroy (cov);
+
design
_matrix_destroy (cov);
}
}
+double pspp_linreg_mse (const pspp_linreg_cache *c)
+{
+ assert (c != NULL);
+ return (c->sse / c->dfe);
+}