From: Jason Stover Date: Fri, 16 Jun 2006 09:18:34 +0000 (+0000) Subject: added initial innovations functions X-Git-Tag: v0.6.0~818 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0188d216a999f6f45ccb98f6ee40bb82c13ac7fd;p=pspp-builds.git added initial innovations functions --- diff --git a/src/math/ts/ChangeLog b/src/math/ts/ChangeLog index d506aaf0..e4bb39fe 100644 --- a/src/math/ts/ChangeLog +++ b/src/math/ts/ChangeLog @@ -1,3 +1,8 @@ +2006-06-16 Jason Stover + + * innovations.c (innovations_convolve): New function. + * innovations.c (get_coef): New function. + 2006-06-04 Jason Stover * innovations.c (get_covariance): Initial version diff --git a/src/math/ts/innovations.c b/src/math/ts/innovations.c index 43d86ec1..6870c4e4 100644 --- a/src/math/ts/innovations.c +++ b/src/math/ts/innovations.c @@ -1,5 +1,5 @@ /* - src/math/time-series/arma/innovations.c + src/math/ts/innovations.c Copyright (C) 2006 Free Software Foundation, Inc. Written by Jason H. Stover. @@ -170,9 +170,50 @@ get_covariance (size_t n_vars, const struct casefile *cf, } free (c); } +static double +innovations_convolve (double **theta, struct innovations_estimate *est, + int i, int j) +{ + int k; + double result = 0.0; + + for (k = 0; k < i; k++) + { + result += theta[i][i-k] * theta[j][i-j] * est->cov[k]; + } + return result; +} +static void +get_coef (size_t n_vars, const struct casefile *cf, + struct innovations_estimate **est, size_t max_lag) +{ + int j; + int i; + int k; + size_t n; + double v; + double **theta; + + for (n = 0; n < n_vars; n++) + { + for (i = 0; i < max_lag; i++) + { + v = est[n]->cov[i]; + for (j = 0; j < i; j++) + { + k = i - j; + theta[i][k] = est[n]->cov[k] - + innovations_convolve (theta, est, i, j); + } + } + } +} -struct innovations_estimate ** pspp_innovations (const struct variable **vars, size_t *n_vars, - size_t lag, const struct casefile *cf) +struct innovations_estimate ** +pspp_innovations (const struct variable **vars, + size_t *n_vars, + size_t lag, + const struct casefile *cf) { struct innovations_estimate **est; size_t i; @@ -202,11 +243,9 @@ struct innovations_estimate ** pspp_innovations (const struct variable **vars, s } } - /* - First data pass to get the mean and variance. - */ get_mean_variance (*n_vars, cf, est); get_covariance (*n_vars, cf, est, lag); + get_coef (*n_vars, cf, est, lag); return est; }