salesforce / causalai

Salesforce CausalAI Library: A Fast and Scalable framework for Causal Analysis of Time Series and Tabular Data
BSD 3-Clause "New" or "Revised" License
259 stars 28 forks source link

Trend NC not Supported #17

Open firmai opened 8 months ago

firmai commented 8 months ago
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[13], line 4
      1 import time
      3 tic = time.time()
----> 4 result = var_lingam.run(pvalue_thres=0.03, max_lag=max_lag)
      5 toc = time.time()
      6 print(f'Time taken: {toc-tic:.2f}s\n')
in VARLINGAM.run(self, pvalue_thres, max_lag)
     76 data_array_ret, = self.data.data_arrays
     77 model = lingam.VARLiNGAM(max_lag)
---> 78 model.fit(data_array_ret)
     82 all_parents = {}
     83 for var_idx in range(model.adjacency_matrices_.shape[1]):
 VARLiNGAM.fit(self, X)
     92 M_taus = self._ar_coefs
     94 if M_taus is None:
---> 95     M_taus, lags, residuals = self._estimate_var_coefs(X)
     96 else:
     97     lags = M_taus.shape[0]
 VARLiNGAM._estimate_var_coefs(self, X)
    277 for lag in range(1, self._lags + 1):
    278     var = VAR(X)
--> 279     fitted = var.fit(maxlags=lag, ic=None, trend="nc")
    281     value = getattr(fitted, self._criterion)
    282     if value < min_value:
 VAR.fit(self, maxlags, method, ic, trend, verbose)
    654 lags = maxlags
    655 if trend not in ["c", "ct", "ctt", "n"]:
--> 656     raise ValueError("trend '{}' not supported for VAR".format(trend))
    658 if ic is not None:
    659     selections = self.select_order(maxlags=maxlags)
firmai commented 8 months ago
import time

tic = time.time()
result = var_lingam.run(pvalue_thres=0.03, max_lag=max_lag)
toc = time.time()
print(f'Time taken: {toc-tic:.2f}s\n')

print(f' The output graph_dict has keys: {result.keys()}')