Skip to content

Cannot predict from VAR model with lags > 1 #332

@tsbinns

Description

@tsbinns

Describe the bug

Found while working on #330.

The predict() method of connectivity objects cannot be used when VAR coeffs have multiple lags.
I haven't been able to investigate exactly why this is occurring or if this behaviour was ever supported, but I wanted to open this as a reminder to myself.

Steps to reproduce

import numpy as np

from mne_connectivity import vector_auto_regression

rng = np.random.RandomState(0)
n_epochs, n_signals, n_times = 2, 3, 64
data = rng.randn(n_epochs, n_signals, n_times)
times = np.arange(n_times)

conn = vector_auto_regression(data, model="dynamic", lags=2)
conn.predict(data)

Expected results

The predicted data is returned.

Actual results

File "\GitHub\mne-connectivity\mne_connectivity\base.py", line 282, in predict      
    predicted_data[jdx, :, lags:] += np.dot(
                                     ^^^^^^^
ValueError: shapes (3,2,2) and (3,62) not aligned: 2 (dim 2) != 3 (dim 0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions