causalcompass.algorithms.VAR
- class causalcompass.algorithms.VAR(tau_max=3, threshold=0.01, seed=None, **kwargs)[source]
Granger causality-based causal discovery method that fits a Vector Autoregressive model and infers causal relationships from the estimated coefficient matrix.
References
https://github.com/cloud36/graphical_granger_methods
- Parameters:
tau_max (int, default 3) – Maximum time lag
threshold (float, default 0.01) – Coefficient threshold for edge filtering
Examples
>>> from causalcompass.algorithms import VAR >>> model = VAR(tau_max=3, threshold=0.01) >>> predicted_adj = model.run(X) >>> all_metrics, no_diag_metrics = model.eval(true_adj, predicted_adj)
Methods
__init__([tau_max, threshold, seed])Initialize VAR
eval(true_adj, predicted_adj[, shd_thresholds])Evaluate the predicted adjacency matrix against the ground truth.
run(X)Run VAR algorithm.
run_raw(X)Run the algorithm and return an unthresholded intermediate result that can be reused across multiple threshold values.
run_threshold_sweep(X, thresholds)Run the algorithm once and post-process the raw result for each threshold.