CDANs class¶
The top-level estimator. Most users should interact with the library
through this class; the individual step functions are exposed under
cdans.steps for finer-grained control.
CDANs ¶
CDANs(
tau_max: int = 2,
alpha: float = 0.05,
pc_alpha: float = 0.2,
ci_test: str | CITest = "fisherz",
surrogate: str | ndarray = "time",
max_extra_conds: int = 2,
use_independent_change: bool = True,
independent_change_width: WidthSpec = AUTO,
verbose: bool = False,
)
Temporal causal discovery from autocorrelated, nonstationary time series.
Implements the four-step algorithm from Ferdous, Hasan & Gani (2023):
- Identify lagged adjacencies via MCI tests.
- Build the partial undirected graph (lagged + contemporaneous + surrogate).
- Refine the contemporaneous skeleton and confirm changing modules using CI tests with lagged-parent conditioning sets.
- Orient contemporaneous edges via v-structures and Meek's rules.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tau_max
|
int
|
Maximum lag. |
2
|
alpha
|
float
|
Significance level for the final CI tests. |
0.05
|
pc_alpha
|
float
|
Significance level for the preliminary PC step inside Step 1
(typically larger than |
0.2
|
ci_test
|
str | CITest
|
CI test to use for Steps 1 and 3. Either a string
( |
'fisherz'
|
surrogate
|
str | ndarray
|
Either |
'time'
|
max_extra_conds
|
int
|
Cap on contemporaneous neighbors added to the lagged conditioning set in Step 3. |
2
|
use_independent_change
|
bool
|
Whether Step 4 should run the iterative independent-change-principle
sink-finding sub-pass to orient undirected edges between two changing
modules. Set to |
True
|
independent_change_width
|
WidthSpec
|
Bandwidth for the kernels inside the independent-change score.
|
AUTO
|
verbose
|
bool
|
Print per-step progress. |
False
|
Examples:
>>> from cdans import CDANs
>>> from cdans.utils import generate_synthetic_cdans
>>> ds = generate_synthetic_cdans(n_vars=4, n_samples=300, tau_max=2, seed=0)
>>> model = CDANs(tau_max=2, alpha=0.05, ci_test="fisherz")
>>> result = model.fit(ds.data)
>>> print(result.summary())
fit ¶
Run the full four-step pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
Time series, shape |
required |
var_names
|
list[str] | None
|
Optional names for the variables (used in the result's summary). |
None
|
Returns:
| Type | Description |
|---|---|
CDANsResult
|
The discovered graph plus diagnostics. |
CDANsResult
dataclass
¶
Container for the output of :meth:CDANs.fit.
Attributes:
| Name | Type | Description |
|---|---|---|
graph |
TimeSeriesGraph
|
The final :class: |
timings |
dict[str, float]
|
Per-step wall-clock time in seconds. |
config |
dict
|
The configuration used to produce this result. |