Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do you have a CCA method incorporated with Multivariate Granger causality? #178

Open
WantongLi123 opened this issue Jul 31, 2023 · 3 comments

Comments

@WantongLi123
Copy link

Hey James,

Do you have a MCCA method incorporated with Multivariate Granger causality, similar as applied in this paper? https://ieeexplore.ieee.org/document/5959956

Cheers,
Wantong

@jameschapman19
Copy link
Owner

I don't implement this paper and have no particular knowledge of causal methods but I am vaguely aware that there is a connection between CCA and Granger Causality. From a quick scan you can substitute in MCCA or CCA for matlab canoncorr. The residualization steps you'd need to do yourself.

By an odd coincidence I have just written a residualization function for someone else in an unrelated project:

def residualize(X, C):
    """
    A simple function that residualizes the input features X by
    subtracting the contributions from the confound variables C
    """

    # Check and convert the input arrays
    X = check_array(X)
    C = check_array(C, ensure_2d=False)
    if C.ndim == 1:
        C = C[:, np.newaxis]

    # Clone and fit the regression model
    regr_model = LinearRegression()
    regr_model.fit(C, X)

    # Predict and subtract the contributions of confounds
    X_predicted = regr_model.predict(C)
    X_residualized = X - X_predicted

    return X_residualized

Might be able to adapt this to your case!

@jameschapman19
Copy link
Owner

If you end up implementing the multivariate grainger causality using any of the cca-zoo code give me a shout and I'll put a link to it on the readme page :)

@WantongLi123
Copy link
Author

Thanks for your reply! Not yet working on coding the causality by myself. But you pointed good directions for a check later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants