- get_mean_variance (*n_vars, cf, est);
- get_covariance (*n_vars, cf, est, lag);
- get_coef (*n_vars, cf, est, lag);
+ for (i = 0; i < max_lag; i++)
+ {
+ free (theta[i]);
+ }
+ free (theta);
+}
+
+static void
+innovations_struct_init (struct innovations_estimate *est,
+ const struct design_matrix *dm,
+ size_t lag)
+{
+ size_t j;
+
+ est->mean = 0.0;
+ /* COV[0] stores the lag 0 covariance (i.e., the variance), COV[1]
+ holds the lag-1 covariance, etc.
+ */
+ est->cov = xnmalloc (lag + 1, sizeof (*est->cov));
+ est->scale = xnmalloc (lag + 1, sizeof (*est->scale));
+ est->coeff = xnmalloc (lag, sizeof (*est->coeff)); /* No intercept. */
+
+ /*
+ The loop below is an unusual use of PSPP_COEFF_INIT(). In a
+ typical model, one column of a DESIGN_MATRIX has one
+ coefficient. But in a time-series model, one column has many
+ coefficients.
+ */
+ for (j = 0; j < lag; j++)
+ {
+ pspp_coeff_init (est->coeff + j, dm);
+ }
+ est->max_lag = (double) lag;
+}
+
+struct innovations_estimate **
+pspp_innovations (const struct design_matrix *dm, size_t lag)
+{
+ struct innovations_estimate **est;
+ size_t 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], dm, lag);
+ }
+
+ get_mean (dm->m, est);
+ get_covariance (dm->m, est, lag);
+ get_coef (dm->m, est, lag);