pspp-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pspp-cvs] pspp/src/math/ts ChangeLog innovations.c innova...


From: Jason H Stover
Subject: [Pspp-cvs] pspp/src/math/ts ChangeLog innovations.c innova...
Date: Sun, 16 Jul 2006 12:49:13 +0000

CVSROOT:        /sources/pspp
Module name:    pspp
Changes by:     Jason H Stover <jstover>        06/07/16 12:49:13

Modified files:
        src/math/ts    : ChangeLog innovations.c innovations.h 

Log message:
        center the data before computing the coefficients; remove variance 
member of innovations estimate

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/src/math/ts/ChangeLog?cvsroot=pspp&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/pspp/src/math/ts/innovations.c?cvsroot=pspp&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/pspp/src/math/ts/innovations.h?cvsroot=pspp&r1=1.5&r2=1.6

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/pspp/pspp/src/math/ts/ChangeLog,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- ChangeLog   16 Jul 2006 12:19:23 -0000      1.15
+++ ChangeLog   16 Jul 2006 12:49:13 -0000      1.16
@@ -2,6 +2,8 @@
 
        * innovations.c (get_coef): Fixed diagonal elements and call to
        innovations_convolve().
+       (subtract_mean): New function. Subtract the mean before computing
+       the coefficients.
 
 2006-07-15  Jason Stover  <address@hidden>
 

Index: innovations.c
===================================================================
RCS file: /sources/pspp/pspp/src/math/ts/innovations.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- innovations.c       16 Jul 2006 12:19:23 -0000      1.15
+++ innovations.c       16 Jul 2006 12:49:13 -0000      1.16
@@ -239,9 +239,6 @@
                          + est->coeff[m-1] * (X[m-2] - X_hat[m-2])
                          ...
                          + est->coeff[m-max_lag] * (X[m - max_lag] - X_hat[m - 
max_lag])
-
-           (That is what X_hat[m] SHOULD be, anyway. These routines need
-           to be tested.)
           */
          pspp_coeff_set_estimate (est[n]->coeff[i], theta[max_lag - 1][i]);
        }
@@ -281,7 +278,28 @@
     }
   est->max_lag = (double) lag;
 }
+/*
+  The mean is subtracted from the original data before computing the
+  coefficients. The mean is NOT added back, so if you want to predict
+  a new value, you must add the mean to X_hat[m] to get the correct
+  value.
+ */
+static void
+subtract_mean (gsl_matrix *m, struct innovations_estimate **est)
+{      
+  size_t i;
+  size_t j;
+  double tmp;
       
+  for (i = 0; i < m->size1; i++)
+    {
+      for (j = 0; j < m->size2; j++)
+       {
+         tmp = gsl_matrix_get (m, i, j) - est[j]->mean;
+         gsl_matrix_set (m, i, j, tmp);
+       }
+    }
+}
 struct innovations_estimate ** 
 pspp_innovations (const struct design_matrix *dm, size_t lag)
 {
@@ -297,6 +315,7 @@
     }
 
   get_mean (dm->m, est);
+  subtract_mean (dm->m, est);
   get_covariance (dm->m, est, lag);
   get_coef (dm->m, est, lag);
   

Index: innovations.h
===================================================================
RCS file: /sources/pspp/pspp/src/math/ts/innovations.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- innovations.h       13 Jul 2006 20:44:44 -0000      1.5
+++ innovations.h       16 Jul 2006 12:49:13 -0000      1.6
@@ -36,7 +36,6 @@
 {
   const struct variable *variable;
   double mean;
-  double variance;
   double *cov;
   double *scale;
   double n_obs;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]