From d835f1bc9ff85cb44f874b764e8f7ac27fd50b50 Mon Sep 17 00:00:00 2001 From: Dylan D'Souza Date: Thu, 3 Apr 2025 01:03:07 +1100 Subject: [PATCH] Changes to get PDC method in connectivity to work - changed sp to np - changed indexes/ matrices for _constructu_var_eqns --- scot/var.py | 2 +- scot/varbase.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scot/var.py b/scot/var.py index 1cc3463..cff8601 100644 --- a/scot/var.py +++ b/scot/var.py @@ -72,7 +72,7 @@ def fit(self, data): # regularized least squares (ridge regression) x, y = self._construct_eqns_rls(data) - b, res, rank, s = sp.linalg.lstsq(x, y) + b, res, rank, s = np.linalg.lstsq(x, y) self.coef = b.transpose() diff --git a/scot/varbase.py b/scot/varbase.py index 61ff78c..fa83e54 100644 --- a/scot/varbase.py +++ b/scot/varbase.py @@ -340,7 +340,7 @@ def _construct_eqns(self, data): def _construct_var_eqns(data, p, delta=None): """Construct VAR equation system (optionally with RLS constraint). """ - t, m, l = np.shape(data) + t, l, m = np.shape(data) n = (l - p) * t # number of linear relations rows = n if delta is None else n + m * p @@ -348,14 +348,14 @@ def _construct_var_eqns(data, p, delta=None): x = np.zeros((rows, m * p)) for i in range(m): for k in range(1, p + 1): - x[:n, i * p + k - 1] = np.reshape(data[:, i, p - k:-k].T, n) + x[:n, i * p + k - 1] = np.reshape(data[:, p - k:-k, i], n) if delta is not None: np.fill_diagonal(x[n:, :], delta) # Construct vectors yi (response variables for each channel i) y = np.zeros((rows, m)) for i in range(m): - y[:n, i] = np.reshape(data[:, i, p:].T, n) + y[:n, i] = np.reshape(data[:, p:, i], n) return x, y