- 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, size_t lag)
+{
+ size_t j;
+
+ est->mean = 0.0;
+ est->variance = 0.0;
+ est->cov = xnmalloc (lag, sizeof (*est->cov));
+ est->scale = xnmalloc (lag + 1, sizeof (*est->scale));
+ est->coeff = xnmalloc (lag, sizeof (*est->coeff));
+ est->max_lag = (double) lag;
+ /* COV does not the variance (i.e., the lag 0 covariance). So COV[0]
+ holds the lag 1 covariance, COV[i] holds the lag i+1 covariance. */
+ for (j = 0; j < lag; j++)
+ {
+ est->coeff[j] = xmalloc (sizeof (*(est->coeff[j])));
+ }
+}
+
+struct innovations_estimate **
+pspp_innovations (const gsl_matrix *data, size_t lag)
+{
+ struct innovations_estimate **est;
+ size_t i;
+
+ est = xnmalloc (data->size2, sizeof *est);
+ for (i = 0; i < data->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);