From bd9396a24e862f444e1d3199f3a9dfd0d65daceb Mon Sep 17 00:00:00 2001 From: Jason Stover Date: Thu, 13 Jul 2006 20:44:44 +0000 Subject: [PATCH] use struct design_matrix --- src/math/ts/ChangeLog | 5 +++++ src/math/ts/innovations.c | 20 +++++++++----------- src/math/ts/innovations.h | 4 +++- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/math/ts/ChangeLog b/src/math/ts/ChangeLog index fdc8e88b..7312d048 100644 --- a/src/math/ts/ChangeLog +++ b/src/math/ts/ChangeLog @@ -1,3 +1,8 @@ +2006-07-13 Jason Stover + + * innovations.c (pspp_innovations): Altered function to use struct + design_matrix. + 2006-07-06 Jason Stover * innovations.c (get_covariance): Fixed subscripts. diff --git a/src/math/ts/innovations.c b/src/math/ts/innovations.c index 4e3dfbf8..75b88d6c 100644 --- a/src/math/ts/innovations.c +++ b/src/math/ts/innovations.c @@ -110,13 +110,11 @@ get_covariance (const gsl_matrix *data, } } } - for (lag = 1; lag <= max_lag; lag++) + for (j = 0; j < data->size2; j++) { - for (j = 0; j < data->size2; j++) - { - *(est[j]->cov + lag - 1) /= (est[j]->n_obs - lag); - } + *(est[j]->cov + lag - 1) /= est[j]->n_obs; } + return rc; } static double @@ -257,22 +255,22 @@ innovations_struct_init (struct innovations_estimate *est, size_t lag) } struct innovations_estimate ** -pspp_innovations (const gsl_matrix *data, size_t lag) +pspp_innovations (const struct design_matrix *dm, size_t lag) { struct innovations_estimate **est; size_t i; - est = xnmalloc (data->size2, sizeof *est); - for (i = 0; i < data->size2; i++) + est = xnmalloc (dm->m->size2, sizeof *est); + for (i = 0; i < dm->m->size2; i++) { est[i] = xmalloc (sizeof *est[i]); /* est[i]->variable = vars[i]; */ innovations_struct_init (est[i], lag); } - get_mean_variance (data, est); - get_covariance (data, est, lag); - get_coef (data, est, lag); + get_mean_variance (dm->m, est); + get_covariance (dm->m, est, lag); + get_coef (dm->m, est, lag); return est; } diff --git a/src/math/ts/innovations.h b/src/math/ts/innovations.h index 1061e26a..d6ec1ce4 100644 --- a/src/math/ts/innovations.h +++ b/src/math/ts/innovations.h @@ -30,6 +30,8 @@ #ifndef INNOVATIONS_H #define INNOVATIONS_H #include +#include + struct innovations_estimate { const struct variable *variable; @@ -41,6 +43,6 @@ struct innovations_estimate double max_lag; coefficient **coeff; }; -struct innovations_estimate ** pspp_innovations (const gsl_matrix *, size_t); +struct innovations_estimate ** pspp_innovations (const struct design_matrix *, size_t); void pspp_innovations_free (struct innovations_estimate **, size_t); #endif -- 2.30.2