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

Rename TimeGrangerCausality to GrangerCausality #282

Merged
merged 1 commit into from
Jan 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/source/reconstruction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ the same general usage as above.
netrd.reconstruction.CorrelationMatrix
netrd.reconstruction.CorrelationSpanningTree
netrd.reconstruction.FreeEnergyMinimization
netrd.reconstruction.GrangerCausality
netrd.reconstruction.GraphicalLasso
netrd.reconstruction.MarchenkoPastur
netrd.reconstruction.MaximumLikelihoodEstimation
Expand All @@ -34,7 +35,6 @@ the same general usage as above.
netrd.reconstruction.PartialCorrelationMatrix
netrd.reconstruction.RandomReconstructor
netrd.reconstruction.ThoulessAndersonPalmer
netrd.reconstruction.TimeGrangerCausality


Reference
Expand Down
4 changes: 2 additions & 2 deletions netrd/reconstruction/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from .graphical_lasso import GraphicalLasso
from .marchenko_pastur import MarchenkoPastur
from .naive_transfer_entropy import NaiveTransferEntropy
from .time_granger_causality import TimeGrangerCausality
from .granger_causality import GrangerCausality
from .optimal_causation_entropy import OptimalCausationEntropy
from .correlation_spanning_tree import CorrelationSpanningTree

Expand All @@ -32,7 +32,7 @@
'GraphicalLasso',
'MarchenkoPastur',
'NaiveTransferEntropy',
'TimeGrangerCausality',
'GrangerCausality',
'OptimalCausationEntropy',
'CorrelationSpanningTree',
]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
time_granger_causality.py
granger_causality.py
--------------

Graph reconstruction algorithm based on [1].
Expand All @@ -21,7 +21,7 @@
from ..utilities import create_graph, threshold


class TimeGrangerCausality(BaseReconstructor):
class GrangerCausality(BaseReconstructor):
"""Uses the Granger causality between nodes."""

def fit(self, TS, lag=1, threshold_type="range", **kwargs):
Expand Down Expand Up @@ -65,10 +65,10 @@ def fit(self, TS, lag=1, threshold_type="range", **kwargs):
W = np.zeros([n, n])

for i in range(n):
xi, yi = TimeGrangerCausality.split_data(TS[i, :], lag)
xi, yi = GrangerCausality.split_data(TS[i, :], lag)

for j in range(n):
xj, yj = TimeGrangerCausality.split_data(TS[j, :], lag)
xj, yj = GrangerCausality.split_data(TS[j, :], lag)
xij = np.concatenate([xi, xj], axis=-1)
reg1 = LinearRegression().fit(xi, yi)
reg2 = LinearRegression().fit(xij, yi)
Expand Down