MotifDisco: Motif Causal Discovery For Time Series Motifs

## Abstract

Abstract Many time series, particularly health data streams, can be best understood as a sequence of phenomenon or events, which we call motifs . A time series motif is a short trace segment which may implicitly capture an underlying phenomenon within the time series. Specifically, we focus on glucose traces collected from continuous glucose monitors (CGMs), which inherently contain motifs representing underlying human behaviors such as eating and exercise. The ability to identify and quantify causal relationships amongst motifs can provide a mechanism to better understand and represent these patterns, useful for improving deep learning and generative models and for advanced technology development (e.g., personalized coaching and artificial insulin delivery systems). However, no previous work has developed causal discovery methods for time series motifs. Therefore, in this paper we develop MotifDisco ( motif disco very of causality), a novel causal discovery framework to learn causal relations amongst motifs from time series traces. We formalize a notion of Motif Causality (MC) , inspired from Granger Causality and Transfer Entropy, and develop a Graph Neural Network-based framework that learns causality between motifs by solving an unsupervised link prediction problem. We also integrate MC with three model use cases of forecasting, anomaly detection and clustering, to showcase the use of MC as a building block for other downstream tasks. Finally, we evaluate our framework and find that Motif Causality provides a significant performance improvement in all use cases.

## 1 Introduction

Many time series can be best understood as sequences of phenomenon or events. This is extremely common in many health data streams where traces are guided by underlying human physiology or behaviors.
We call these events in the traces motifs. A time series motif is a short trace segment
which may implicitly capture an underlying behavior or phenomenon within the time series.
To contextualize our discussion, and as our main running example, we focus on glucose traces collected from continuous glucose monitors (CGMs) for diabetes. Glucose traces inherently contain motifs which represent underlying human behaviors. For instance, a motif capturing a peak in glucose may correspond to an individual eating; a motif capturing a drop in glucose may correspond to an individual exercising. Figure 1 shows some real sample glucose traces and motifs.

Causal discovery is the process by which causal relations are found amongst observational data (Niu et al., ).
The ability to discover and quantify
causality amongst motifs
can provide a mechanism to better understand and represent these patterns, useful in a variety of applications.
For instance, learning causal relations in glucose motifs may enable better understanding of physiological
patterns contributing to advanced technology development (e.g., artificial insulin delivery systems).
Moreover, motif causal relationships may be helpful building blocks when used as sub-components in generative and deep learning models to improve their performance for other downstream tasks.

Granger Causality (Granger, ) and its nonlinear extension Transfer Entropy (TE) (Schreiber, ) are commonly used in time series causal discovery methods, as causal relations are quantified based on one trace’s predictability of another. This notion of causality provides an intuitive, understandable measure to quantify
causal relations
and is advantageous for time series because it innately incorporates temporality without requiring strong model assumptions.
Despite exciting recent developments for time series causal discovery (Gong et al., ; Assaad et al., ), no previous work has focused on causal discovery for time series motifs.
Motif causal discovery is challenging because
in many cases (particularly in health)
there is no ground truth about what underlying behavior a motif captures.
For example,
from data alone one cannot conclusively determine what caused a change in glucose
(e.g., a glucose rise may be from eating or stress).
As a result, unlike in many other causal models, there is no ground truth causal structure amongst motifs that could be used to guide the casual discovery model
(i.e., through supervised methods using labeled causal events.)

Therefore, in this paper we develop MotifDisco, (motif discovery of causality), a framework to discover causal relations from time series motifs.
First, we formalize the concept of motifs and define a notion of Motif Causality (MC) inspired from Granger Causality and Transfer Entropy, which is able to characterize causal relationships amongst sequences of motifs.
Next, we develop a causal discovery framework to learn MC amongst a set of ordered motifs pulled from time series traces. The framework uses a Graph Neural Network (GNN) based architecture that learns causality amongst motifs by solving an unsupervised link prediction problem, thereby not requiring knowledge of any ground truth causal structure for training.
The framework outputs a directed causal graph where nodes represent motifs and edges represent the degree of the MC relationship.
To demonstrate the suitability of Motif Causality as a building block in other models for downstream tasks,
we instantiate three model use cases that incorporate
MC
for forecasting, anomaly detection, and clustering tasks.
Finally, we evaluate MotifDisco in terms of scalability and use case performance by comparing the models with and without integration of MC, to see how helpful MC is for each use case.

The contributions of this paper are: (1) We formalize a new notion of causality between time series motifs, denoted as Motif Causality.
(2) We develop MotifDisco, the first causal discovery framework to learn Motif Causality amongst time series motifs.
(3) We illustrate the use of MC as a building block in other downstream tasks by integrating MC with three model use cases of forecasting, anomaly detection and clustering.
(4) We provide detailed framework evaluation
and find that MC provides a significant performance improvement compared to the base models in all use cases.

## 2 Related Work

Figure: Figure 1: Real Glucose Traces and Sample Motifs for $\tau=48$.
Refer to caption: extracted/5873931/Figures/SampleTracesMotifs.png

Motifs.
Recently, there has been interest in temporal network motifs, which are sets of recurring graph substructures.
Previous work has investigated causality within network motifs (Liu et al., ; Kovanen et al., );
developed network motif causal discovery and graph representation learning frameworks (Chen & Ying, ; Chen et al., ; Jin et al., );
and developed new use case architectures that utilize network motif causal structures, such as for pharmacovigilance and anomaly detection tasks (Xiao et al., ; Kalla et al., ; Yu & Gao, ; Zhu et al., ; Mu et al., ).
Importantly, the definition of motif used here is different than ours, referring to patterns in graph structures as opposed to patterns in the traces themselves.
In other motif application areas, Chinpattanakarn & Amornbunchornvej () solve a different problem and develop a method that, given two time series, infers a set of patterns, also called motifs, that follow each other in the traces.
Finally, Lamp et al. () develop a method to generate realistic synthetic time series glucose traces
and use a notion of causality amongst motifs to help the model perform well.
The focus of this work is not on causality,
and the causal learning method is
complicated and suffers from scalability issues.

Causal Discovery in Time Series.
There are a variety of works on causal discovery for time series (Niu et al., ; Gong et al., ; Hasan et al., ; Assaad et al., ; Shojaie & Fox, ).
In particular, previous methods have developed causal discovery frameworks for multivariate time series that incorporate temporal dynamics and use Granger Causality (Pan et al., ; Löwe et al., )
or Transfer Entropy (Bonetti et al., ; Najafi et al., ).
Recent work has also incorporated time series causality measures to improve model learning in downstream tasks such as forecasting and anomaly detection (Ansari et al., ; Chen et al., ; Febrinanto et al., ; Duan et al., ; Wu et al., ).
MotifDisco is the first framework focused on causal discovery for time series motifs,
which may broaden current model capabilities
for event-based time series.

## 3 Formalizing Motif Causality

Figure: (a) Chopping
Refer to caption: extracted/5873931/Figures/motif_chop.png

Motifs & Motif Construction.
We first formalize our notion of motifs. A motif is a short segment of the trace which may implicitly capture an underlying behavior within a time series. Real sample glucose traces and motifs are shown in Figure 1.
We define a *motif*, $\mu$, as a short, ordered sequence of values ($v$)
of length $\tau$:

$$ $\mu=[v_{i},v_{i+1},\ldots,v_{i+\tau}]$ (1) $$

We denote a set of $n$ time series traces as $X=[x^{1},\ldots,x^{n}]$.
Each time series may be represented as a sequence of motifs:
$x^{j}=[\mu_{1}^{i},\mu_{2}^{i},\ldots]$ where each $\mu^{i}_{t}$ gives the motif identifier $i$ at the ordered time step $t$. We also define a motif set $\mathcal{M}$, of $|m|$, which is the
complete set of motifs generated from the traces $\mathcal{M}=\{\mu^{1},\ldots,\mu^{m}\}$.
The user may choose how they wish to pull out motifs from the time series based on the end application goal.
We assume there is a consistent, conclusive way to pull motifs from the traces, and motif discovery is outside the scope of this work. We refer the interested reader to other works focused on this problem (Chinpattanakarn & Amornbunchornvej, ; Schäfer & Leser, ; Ye & Keogh, ). That being said, three straightforward methods to extract motifs from traces, shown in Figure 2, include chopping the traces into size $\tau$ chunks 2(a), using a sliding window of size $\tau$ to extract motifs 2(b), and using signal processing techniques such as Discrete Fourier Transforms (DFT) to automatically extract motifs 2(c).

Granger Causality & Transfer Entropy.
Granger Causality is a common method to characterize causal relations amongst time series (Granger, ). Different from other causal methods, Granger defines causal relations in terms of predictability. Under Granger Causality, given two time series $x$ and $y$, $x$ causes $y$ if past information about $x$ is more predictive than past information about $y$ only.
Transfer Entropy (TE), sometimes also called Causation Entropy, is a nonlinear extension of Granger Causality (Schreiber, ; Barnett et al., ). Using information theoretic measures, TE measures the amount of uncertainty that is reduced in future states of time series $y$ as a result of knowing the past states of time series $x$.
Given two time series, $x^{i}$ and $y^{i}$, the TE from $x^{i}$ to $y^{i}$ is:

$$ $TE_{x^{i}\rightarrow y^{i}}=H(y^{i}_{t}|y^{i}_{t-1,\ldots,t-f})-H(y^{i}_{t}|y^ {i}_{t-1,\ldots,t-f},x^{i}_{t-1,\ldots,t-g})$ (2) $$

where $H(\cdot|\cdot)$ is a conditional entropy function and $f$ and $g$ are lag constants.

Traditional TE is under the important assumption that the effect is influenced by the cause under a fixed, constant time delay. However, this assumption does not hold for many real world time series applications, particularly in health streams, where data may be affected by past events at varying lengths of time. As such, an extension of TE that allows for different time delays has been developed, denoted here as Variable-lag Transfer Entropy (VTE) (Amornbunchornvej et al., ).
The VTE from $x^{i}$ to $y^{i}$ is defined as:

$$ $VTE_{x^{i}\rightarrow y^{i}}=H(y^{i}_{t}|y^{i}_{t-1,\ldots,t-f})-H(y^{i}_{t}|y ^{i}_{t-1,\ldots,t-f},x^{i}_{t-1-\Delta_{t-1},\ldots,t-g-\Delta_{t-g}})$ (3) $$

where
$\Delta_{t}$ is a variable length lag amount.
We will adapt this equation and other notions of TE next for our definition of Motif Causality.

Defining Motif Causality.
Our definition of motif causality is inspired from various Transfer Entropy and Causation Entropy threads (Equation 3, Irribarra et al. (); Gong et al. (); Amornbunchornvej et al. (); Assaad et al. (); Sun et al. ()).
The Motif Causality (MC) from motif $\mu^{i}$ to motif $\mu^{j}$ conditioned on the set of motifs $\mathcal{K}$ is defined as:

$$ $MC_{\mu^{i}\rightarrow\mu^{j}|\mathcal{K}}=H(\mu^{j}_{t}|\mathcal{K}_{t-1, \ldots,t-f})-H(\mu^{j}_{t}|\mathcal{K}_{t-1,\ldots,t-f},\mu^{i}_{t-1-\Delta_{t -1},\ldots,t-g-\Delta_{t-g}})$ (4) $$

where $\mathcal{K}\subset\mathcal{M}$,
$H(\cdot|\cdot)$ is a conditional entropy function, $f$ and $g$ are lag constants and
$\Delta_{t}$ is a variable length lag amount.
Essentially, this provides a measure of information gain by determining how much uncertainty is reduced for $\mu^{j}$ by
observing past occurrences of $\mu^{i}$
compared to the “status quo”, the set of the rest of the motifs $\mathcal{K}$.
The $MC$ value will be between 0.0 and 1.0. Higher values indicate stronger causality (i.e., more uncertainty about the future is reduced for $\mu^{j}$ given $\mu^{i}$).

Conditional Entropy Function.
To implement the conditional entropy function, $H(\cdot|\cdot)$, there are many different types of entropy which the user can choose based on their end goal or application. For our purposes, we elucidate two common ones: Shannon entropy (Shannon, ) and Rényi entropy (Jizba et al., ; ).
Shannon entropy is defined as:

$$ $H(x^{i})=-\sum_{t}{p(x^{i}_{t})\log_{2}(p(x^{i}_{t}))}$ (5) $$

where $p$ is a probability distribution.
Rényi is more flexible at estimating uncertainty and defined as:

$$ $H_{\alpha}(x^{i})=\frac{1}{1-\alpha}\log\left(\sum^{n}_{v=1}{p_{v}^{\alpha}}(x ^{i})\right)$ (6) $$

where $\alpha$ is a weight parameter, $\alpha>0$. When $\alpha\rightarrow 1$ Rényi entropy converges to Shannon entropy. We note that there are many other types of entropy functions that could be used and might be relevant, such as Wavelet (Rosso et al., ) or Permutation Entropy (Bandt & Pompe, ).

Figure: Figure 3: Preprocessing Steps. $X$ are transformed to motif traces and $\mathcal{M}$ and then into a graph $G$.
Refer to caption: extracted/5873931/Figures/Preprocessing.png

## 4 Motif Causal Discovery Framework

Now that we have formulated our definition of Motif Causality, we next describe our casual discovery framework MotifDisco to learn motif causal relationships amongst a set of time series motifs. We first detail preliminaries related to the problem definition and preprocessing in subsection 4.1, describe the model architecture in subsection 4.2 and finish with the model training algorithm in subsection 4.3.

### 4.1 Preliminaries

Problem Definition.
Since we do not know nor have any way to determine the underlying motif-causal structure (i.e., we have no ground truth), we formulate this problem as an unsupervised graph link prediction problem:
Given a set of input time series motifs extracted from our set of traces $X$, and the complete set of nodes which is equivalent to the motif set $\mathcal{M}$ (i.e., each motif is a node), predict the edges between all the nodes. In other words, learn the edge weights, the motif causal relationships, between all the nodes, the motifs.
To solve this problem, we build a Graph Neural Network-based causal discovery framework that learns the MC edge weights in an unsupervised manner. We walk through each part of the framework next, starting with the preprocessing steps.

Preprocessing.
An overview is shown in Figure 3. Motifs of length $\tau$ are pulled from the input time series to create a set or ordered motif traces and the motif set $\mathcal{M}$
(see section 3).
In our implementation, we use the chopping method to generate motifs;
$\mathcal{M}$ is the union of all size-$\tau$ chunks in the traces.
From there, an initial motif graph is generated from the motif traces.
In the graph structure, each node contains the motif identifier and the actual motif values (e.g., motif $\mu^{1}=[129,130,128,...]$). Edges represent directed motif-causal relationships between two motifs. The edge weight indicates the strength of the causal relationship.
At this stage,
generating the best graph is not our primary concern since the framework will add and remove optimal edges during the learning process,
and we just need a starting graph structure to build from.
As such, we believe it an acceptable first pass to assume
there is some degree of causality between motifs that appear immediately one after the other, and build the preliminary graph
by adding edges between each subsequent motif in the traces. For example, for the first motif trace in Fig. 3 (2a), edges would be added from $\mu^{1}\rightarrow\mu^{2}$, $\mu^{2}\rightarrow\mu^{5}$,
etc.
We compute the MC edge weight
according to Equation 4.

Figure: Figure 4: Model Architecture: a GNN consisting of stacks of GraphSAGE, ReLU, Dropout (“X” boxes) and Linear layers learns a node embedding. The LinkPredictor consists of Linear, ReLU and Dropout layers followed by the “MC” motif causality layer and a Sigmoid layer ($\sigma$ box). The LinkPredictor takes in the node embedding and outputs the predicted edges and their weights.
Refer to caption: extracted/5873931/Figures/Model_Arch.png

### 4.2 Model Architecture

An overview of the model architecture is shown in Figure 4. The model consists of two main components: a Graph Neural Network (GNN)
that uses GraphSAGE layers to learn node embeddings, and a LinkPredictor network that uses the learned node embeddings to predict motif causal links amongst nodes. We detail each component next and then describe model training in subsection 4.2.

GNN. The Graph Neural Network takes in a starting motif graph $G$, and outputs a learned node embedding. The GNN is structured using GraphSage convolutional layers.
GraphSAGE (standing for Sample and Aggregate) (Hamilton et al., ) learns low dimensional vector representations of nodes. The core intuition of GraphSAGE is that a node is known by the company it keeps (i.e., its neighbors). The algorithm works by iterating over a sample of the node’s neighboring nodes and “aggregating” their embeddings in order to determine the current node’s embedding.
Importantly, GraphSAGE is inductive, meaning it can generalize to unseen nodes. GraphSage use both node features and topological structure (i.e., the graph structure) of each node’s neighbourhood simultaneously to efficiently generate representations for new nodes without requiring model retraining. To do this, the algorithm relies on its aggregation function, also known as the message-passing process, which learns how to aggregate node features based on encoding information about a node’s local neighborhood. Therefore, when given new node data, the function uses the local neighborhood of the node to aggregate the features appropriately, and learn the embedded feature representation (as opposed to needing to learn a unique embedding for every individual node).
As shown in Figure 4, in our framework the GNN consists of sequential stacks of GraphSAGE convolutional, ReLU and dropout layers (represented by the “X” boxes in the figure) followed by the message-passing layers– stacks of linear and dropout layers.
The motif time series values are the node data used to learn the embeddings.
We instantiate the aggregation function using mean aggregation for simplicity.

Figure: (a) Large Uncertainty Reduction
Refer to caption: extracted/5873931/Figures/TE_comp_big_reduction.png

Link Predictor.
The LinkPredictor network takes in learned node embeddings outputted from the GNN and a list of edges to predict, and returns the probability of each edge and the motif causality values for each edge.
At its core, the LinkPredictor learns a function to predict the probability of an edge between two nodes.
To do this, it computes the MC between the nodes using Equation 4,
and a probability score, represented by the element-wise dot product of the two embedded node vectors.
In terms of architecture, the LinkPredictor is implemented via stacks of linear, ReLU and dropout layers followed by Motif Causality ($MC$) and sigmoid layers to learn the edge probability function.
The network balances evaluating the product of the embedded node vectors and the motif causal values between the motifs themselves,
allowing the network to learn how to optimize edge addition/deletion in the graph guided by the underlying causality. (More details about this in subsection 4.3).
In this way, the
LinkPredictor learns to predict edges that have high motif causality
with high probability.

To implement the MC computation, we adapt existing Transfer Entropy libraries (Behrendt et al., ) and compute the conditional entropy function (i.e., $H(\mu)$, Shannon’s or Rényi entropy) using the histogram method. A simplified depiction is shown in Figure 5. Essentially, motif time series values are binned into a histogram.
Distributions between motifs can be compared to determine how much uncertainty about future predictions of the motif is reduced in the distribution. For example, in 5(a) when computing MC for $\mu^{i}$, $\mu^{j}$ covers a larger distribution, resulting in a large reduction in uncertainty and higher motif causality, whereas 5(b) $\mu^{z}$ covers hardly any new distribution compared to the status quo ($H(\mu^{i}|\mathcal{K})$), resulting in a small reduction in uncertainty and low causality for $\mu^{z}$.

### 4.3 Model Training

We next describe how the entire framework is trained together, shown in algorithm 1.
First, the graph is fed through the GNN network to learn an embedded representation of the nodes (Line 2).
Next, the LinkPredictor makes predictions on a sample of the edges that exist in the graph $G$, denoted as the positive edges $E$ using the learned node embedding (Line 3-4).
Then, a batch of edges that do not exist in $G$,
$\hat{E}$, are randomly sampled by selecting random pairs of nodes with no connections between them
(Line 5). The LinkPredictor makes predictions on the negative edges (Line 6).

From there, the positive predictions $y$ are computed by combining the positive edge predictions $p$ and the motif causality values for the positive links $c$ (Line 7).
Similarly, the negative predictions $\hat{y}$ are computed by combining the negative link predictions $\hat{p}$ with the MC values for the negative links $\hat{c}$ (Line 8). $\gamma$ and $\lambda$ are important hyper-parameters which balance the influence of the dot product predictions vs. the motif causality. The model is trained to minimize the log likelihood loss function, computed following the equation on Line 9.
Essentially, this loss function optimizes the model to maximize its predictions of positive edges (true links, edges that have high motif causality values) and minimize predictions of negative edges (links that should not exist in $G$, edges with low MC).
Finally, the edges in $G$ are updated based on the model edge predictions
and an edge threshold $\theta$ (Line 10). $\theta$ is a user-specified parameter with a range between 0 and 1. If any of the edges in $\hat{y}\geq\theta$, they are added to the graph $G$; if any of the edges in $y<\theta$, they are removed from $G$.

Due to the dual training between the GNN and the LinkPredictor, as the model iterates the node embeddings are continuously updated based on new linkages that may be added or removed. As such, the GNN learns good node embeddings representative of the types of nodes that are close to each other and have connections to each other (nodes that are very motif causal of one another).
The LinkPredictor is guided by the motif causality values between motifs to help it predict where linkages should be, and as it
learns characteristics of highly causal edges, and gets better and better node embeddings from the GNN, it learns a good prediction function for predicting node linkages.

Making New Edge Predictions. To make a link prediction between two new nodes using the trained framework, the nodes are first fed through the GNN to get their node embeddings, and then the embeddings are sent through the trained LinkPredictor network, which returns the predicted probability they have an edge between them, along with the motif causality value.

Figure: Algorithm 1 Training Procedure to Learn Motif Causality

Figure: Figure 6: Forecasting Model integrated with Motif Causality.
Refer to caption: extracted/5873931/Figures/Forecasting_MC.png

Figure: Figure 7: Anomaly Detection Model integrated with Motif Causality.
Refer to caption: extracted/5873931/Figures/Anomaly_MC.png

## 5 Uses of Learned Motif Causality

To illustrate the use of Motif Causality as a building block for other downstream tasks, in this section we integrate Motif Causality with three model use cases of Forecasting, Anomaly Detection and Clustering.
We evaluate the performance of these use cases later in section 6.

Forecasting.
Our integration is shown in Figure 6.
Briefly, some basic forecasting models work by sliding a window across input traces to learn sequential time series patterns.
Their loss function computes the difference between the model’s predicted future timesteps (y_pred) and the ground truth future time steps (y_true) in the traces.
To integrate motif causality, we add an additional loss function that seeks to minimize the difference in the MC between the previous time step ($x$) and
the predicted future time steps (y_pred) vs.
$x$ and
the ground truth future time steps (y_true).
The intuition is that there should be similar causality between the previous time step and the predicted future time step as the ground truth data.
MC is computed using the trained motif causal graph outputted from the MC framework.
We assume the motif size $\tau$ is the same as the forecasted prediction window size to ensure MC is computed on comparable time chunks (i.e., motifs).

Anomaly Detection.
Integration of a basic anomaly detection model with MC is shown in Figure 7. We add an MC-based anomaly prediction block after the model that uses the predicted MC between previous timesteps and future timesteps to determine if the next trace chunk may be anomalous or not.
Specifically, it checks if the MC between the previous time steps (previous motif) and the next one are less than a threshold, and if so classifies it as an anomaly.
The size of the predicted time chunk must be the same size as the motif size $\tau$ and we suggest the anomaly threshold be set to the edge prediction threshold $\theta$, since this was what was used to train the motif causal graph originally.

Clustering.
For clustering, there is typically a method to group clusters based on minimizing distances between each data point and the cluster centroid. These distances are computed using various distance measures such as
Discrete Time Warping (DTW) (Sakoe & Chiba, ) for traces. To integrate MC with a basic clustering algorithm,
we use the motif causality values as an additional distance metric.
The intuition here is to add an element of causality to the clustering, such that as the algorithm learns, MC values within each cluster will be minimized and similar data points within the cluster should be motif causal of each other. An example is shown in Figure 11 in A.1: the MC value between the blue centroid and the blue data point to the right is high with 0.9, whereas the MC between the blue centroid and the green data point belonging to a different cluster is low at 0.11.

## 6 Evaluation

In this section we evaluate our causal discovery framework in terms of scalability and performance for three downstream task use cases: forecasting, anomaly detection and clustering.

Experimental Details.
For all experiments, we use sets of single-day glucose traces randomly sampled across each month from January to December 2022, collected from Dexcom’s G6 Continuous Glucose Monitors (CGMs)
Akturk et al. (). Data was recorded every 5 minutes (total of 288 timepoints per trace)
and each trace was aligned temporally from 00:00 to 23:59.
All experiments were run 5 times
with an 80/20% train/test split
on an Intel Sky Lake 48 CPU VM with 192GB of RAM. Motifs were pulled from traces using the chopping method and we set $\gamma=0.7$ and $\lambda=0.5$.

Motif Causal Graphs.
An example motif causal graph from the MotifDisco framework is shown in Figure 8. The edge color indicates the strength of the MC relationship; darker is stronger (closer to 1) while lighter is less strong (closer to 0).
A.1 shows example MC between motifs of different $\tau$.

Figure: Figure 8: Learned Motif Causal Graph for $n=10$, $|\mathcal{M}|=20$. Edge color indicates the MC value.
Refer to caption: extracted/5873931/Figures/LinkPredGraph_nseq10_tau120_epochs10_theta0.png

Figure: (a) $n$ vs. Training Time
Refer to caption: extracted/5873931/Figures/VaryTraceLengths.png

Scalability.
The scalability evaluation is shown in Figure 9, computing total time to train the MotifDisco causal discovery framework in seconds for 9(a) different numbers of traces ($n$), 9(b) motif lengths ($\tau$) and 9(c) motif set sizes ($|\mathcal{M}|$). In all experiments
training was for 10 epochs.
As to be expected, training time increases for larger $n$ and $|\mathcal{M}|$.
Interestingly, time reduces as the $\tau$ increases, which may in part be because larger $\tau$s mean there are less total motifs (i.e., $|\mathcal{M}|$ is smaller).

**Table 1: Use Case Performance Summary. The arrow indicates desired result direction and bold values indicate the best performing model.**
| Model | Forecasting | Anomaly Detection | Clustering |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| RMSE ($\downarrow$) | Accuracy ($\uparrow$) | F1 ($\uparrow$) | Sensitivity ($\uparrow$) | Specificity ($\uparrow$) | C-Index ($\downarrow$) | SSE ($\downarrow$) | Silhouette ($\uparrow$) | Caliński Harabasz ($\uparrow$) |  |
| Base | $0.22\pm 0.05$ | $0.83\pm 0.02$ | $0.80\pm 0.03$ | $0.67\pm 0.02$ | $\mathbf{1.0\pm 0.0}$ | $0.086\pm 1e{-6}$ | $477.0\pm 1e{-3}$ | $0.318\pm 1e{-2}$ | $490.95\pm 6e{-2}$ |
| MC | $\mathbf{0.18\pm 0.07}$ | $\mathbf{0.92\pm 0.02}$ | $\mathbf{0.92\pm 0.02}$ | $\mathbf{1.0\pm 0.0}$ | $0.85\pm 0.03$ | $\mathbf{0.085\pm 3e{-5}}$ | $\mathbf{473.79\pm 5e{-3}}$ | $\mathbf{0.332\pm 2e{-3}}$ | $\mathbf{496.24\pm 5e{-4}}$ |

Use Cases.
We next evaluate the suitability of Motif Causality to help in three downstream tasks: Forecasting, Anomaly Detection and Clustering. For each use case, we build a simple base model and integrate MC following the architecture descriptions in section 5.
We then compute a set of evaluation metrics to compare the performance between the base model and the MC integrated one.

Forecasting.
For the forecasting task, we use a simple bidirectional LSTM as our base model.
We set the sliding window size, $\tau$ and forecasting window to 6 (corresponding to 30 minutes of time).
We train the causal discovery and forecasting models for 20 and 2000 epochs, respectively.
The Root Mean Square Error (RMSE) is reported in Table 1; the MC model outperforms the base one.

Anomaly Detection.
For this task, we build a simple autoencoder consisting of stacks of sequential dense layers.
In the base model, an anomaly is detected if the Mean Absolute Error (MAE) of the reconstructed data (i.e., the trace fed through the encoder and then returned via the decoder) is less than a reconstruction threshold
which we set as the standard deviation of the mean of the normal (non-anomalous) training data.
In the MC-integrated version, we detect an anomaly if the predicted MC value between the previous time chunk (motif) and the current one is less than the edge prediction threshold $\theta$.
We set the sliding window size and $\tau$ to 48, $\theta$ to 0.1 and train the causal discovery and anomaly models for 10 and 50 epochs, respectively.
We compare the models by computing a set of classification metrics including accuracy, F1, Sensitivity and Specificity using the ground truth labeled anomalies.
Results are reported in Table 1. For all metrics except Specificity, the MC-integrated model does better. Interestingly, the base model has better Specificity while the MC model has better Sensitivity - this indicates the MC model is better at identifying the anomalies (the true negatives) and the base is better at identifying the normal traces (the true positives). Example anomaly predictions
are shown in Figure 10. Each graph plots the original input trace (in blue) and the reconstructed trace (in red, trace fed through the encoder + decoder) with the error between the two shaded in red. The window segments (dashed black lines) correspond to the motif and prediction window size and the model predictions are annotated in each window, colored by the correctness of the prediction. Green indicates a correct prediction, red indicates an incorrect one.

Figure: (a) Base Model
Refer to caption: extracted/5873931/Figures/AD-Error_Base1.png

Clustering.
We implement a simple K-Means clustering algorithm.
In the base model we compute distances between the cluster centroids and other trace data points using Discrete Time Warping (DTW) (Sakoe & Chiba, ).
In the MC-integrated version we compute the distances as DTW + MC. We set the number of clusters $k=3$, and $\tau=48$. Causal discovery and clustering models were trained for 20 epochs.
We compute a set of clustering evaluation metrics including C-Index (Hubert & Levin, ), Sum of Squared Error (SSE) (Macqueen, ),
Silhouette score (Rousseeuw, ), and Caliński Harabasz score (Caliński & Harabasz, ), reported in Table 1. Across all metrics the MC version does better, indicating adding an element of causality may help clustering.

## 7 Conclusion & Limitations

In this paper we presented MotifDisco, the first causal discovery framework to infer Motif Causality amongst time series motifs.
By providing a new method to learn and quantify relationships amongst motifs, MotifDisco may facilitate the development of advanced, high performing
technologies for event-based time series.
As shown by the scalability experiments, for very large $\mathcal{M}$ and $n$ (e.g., $n\geq 10000$) the runtime can take several hours. There are many opportunities in the training framework to further optimize the runtime.
For example, MC is currently computed between each edge in a batch sequentially;
using sampling or parallelization would significantly speed up the training time.
Additionally, a challenge of this work is that there is no known causal structure available, so it was not possible to evaluate the learned motif causal graphs against some ground truth.
However, as evidenced by the use case evaluation, using a relatively simple integration of MC with naive base models resulted in significant performance improvements for all three use cases, providing some evidence
about the potential generalizability and applicability of MC for many real world tasks.

## Appendix A Appendix

### A.1 Additional Figures

Figure: Figure 11: Depiction of Clustering Model integrated with MC.
Refer to caption: extracted/5873931/Figures/Clustering_MC.png

Figure: (a) $\tau=6$
Refer to caption: extracted/5873931/Figures/Motif_Preds_nseq5_tau6_epochs20_medTE.png

Figure: (a) $\tau=6$
Refer to caption: extracted/5873931/Figures/Motif_Preds_nseq5_tau6_epochs20_lowTE.png

## Peer Reviews

confidence: 4
contribution: 2
initial_rating: 5
presentation: 3
questions: Comparison with competing Granger causal baselines at various granularity should be presented to improve the soundness of the result.
soundness: 2
strengths: * Empirically , using the motif causal graphs, improvements in the 3 downstream tasks are identified demonstrate the use of motifs
* Comparison against chunked time series prediction should be presented
* Chunking provides a simple way of making all motifs of the same length
summary: The paper proposes to learn granger causal graphs over time series segments. The segments are defined as motifs as they have specific characteristics. The segments are then embedded into graph node embeddings using GraphSage, a message passing graph neural network. These embeddings are then passed through a link prediction model that maximizes the probability of links with high transfer entropy (conditional entropy gain achieved through adding node i to the conditional to predict node j). This process is then repeated over multiple epochs of the training time series data to learn the graph where links are added iteratively. Subsequently, in each iteration, links are removed by computing the reverse edge graph and their corresponding link prediction probabilities. Finally, this motif causal network is used for time series prediction, anomaly detection and clustering.
weaknesses: * Comparing against existing granger causal techniques applied directly on time lagged variables needs to be done to validate the necessity of motifs
* Identifiability of motifs is left as out of scope, but should be discussed as that defines the nodes used in the causal graph construction.
* Metadata such as time of occurrence and frequency of occurrence of motifs is not well presented in an interpretable manner in the link prediction task, how this might be captured in the motif representation is lacking
* A discussion of complex variable length motifs should be presented.

---

confidence: 4
contribution: 2
initial_rating: 3
presentation: 3
questions: 1. How does the chosen motif extraction method impact the causality results? Would alternative approaches, such as clustering-based motif identification, lead to different outcomes?
2. How does the interpretability of the causal graphs change across datasets with different numbers of motifs and motif lengths?
3. How generalizable is MotifDisco to other health data, such as heart rate variability or electroencephalogram (EEG) signals?
4. How does the framework account for inter-individual variability, especially given that causal relationships can be highly individualized?
soundness: 2
strengths: 1. Novelty of Causal Discovery Framework: The introduction of Motif Causality (MC) for time series motifs and the development of MotifDisco fills an important gap in time series analysis, especially for health-related data. No prior work has explicitly targeted causal discovery among motifs within time series, which makes this a novel contribution.
2. Flexible Application Scope: Integrating MC into multiple use cases, namely forecasting, anomaly detection, and clustering, demonstrates the proposed framework's versatility and broadens its potential real-world applicability.
3. The experiments span various scenarios, including different motif extraction methods, motif lengths, and scalability. The performance gains in forecasting and anomaly detection validate the utility of incorporating causality into motif-based models.
summary: The paper introduces MotifDisco, a novel framework for motif causal discovery in time series. The authors focus on causal relations among motifs, defined as short segments representing underlying phenomena within time series. MotifDisco leverages a combination of Granger Causality and Transfer Entropy to define Motif Causality (MC) and uses a GNN to learn causal relationships by solving an unsupervised link prediction problem. The framework is evaluated on glucose traces collected from continuous glucose monitors and further integrated into forecasting, anomaly detection, and clustering tasks. Overall, the authors claim significant improvements in performance for each of these downstream applications compared to non-causal baselines.
weaknesses: 1. Motif Construction Limitation: The method for constructing motifs is largely dependent on heuristic techniques (e.g., chopping or sliding windows). This may lead to arbitrary definitions of motifs that do not always correspond to well-defined physiological phenomena. The authors could consider more dynamic motif extraction methods.
2. Lack of Personalization: The majority strategy for causal inference used in the GNN might overlook personalized differences across individuals, which could limit the accuracy of BP estimation or understanding of other health parameters in highly diverse populations.
3. No Ground Truth for Causal Evaluation: A notable limitation is the lack of ground truth causal structures for motifs, which makes the evaluation of the learned causal graphs challenging. Although indirect measures such as downstream task performance are used to validate the usefulness of the model, a more direct assessment of the accuracy of causal inference is missing.\
4. No comparison with SOTA: this paper does not provide an extensive, systematic comparison against other state-of-the-art causal discovery frameworks and deep learning methods for forecasting, anomaly detection, and clustering.
5. Scalability Issues: The scalability analysis shows that training times grow significantly for large motif sets and numbers of traces. The current implementation may not be suitable for very large datasets, especially in real-time applications. Methods like parallelization for computing motif causality are suggested as improvements.
6. Limited Clinical Validation: The evaluation was limited to glucose data, and the clinical significance of the discovered causal motifs is not thoroughly validated. This limits the generalizability of the proposed method to other medical domains without further empirical evidence.

---

confidence: 3
contribution: 2
initial_rating: 3
presentation: 2
questions: As above
soundness: 3
strengths: The paper is well written. The literature survey is good. Work is mathematically sound and the author shows run time requirements. The idea of showing the model performance on three tasks was also good.
summary: In this paper author proposed MotifDisco (motif discovery of causality), a novel causal discovery framework to learn causal relations amongst motifs from time series traces based on Granger Causality and Transfer Entropy. Used motif causality in down stream tasks like forecasting, anomaly detection and clustering.
weaknesses: Marginal technical novelty. What is the contribution compared to  Lamp et el (2024) needs to be discussed. Pan et al., 2024; Lowe ¨ et al., 2022 Bonetti et al., 2024; Najafi et al., 2023) are already using  Granger Causality and Transfer Entropy then what is contribution compared to this work is not clear to me. 
Please explicitly state key technical contributions of this paper and how it differ from or improve upon the cited works, particularly in the context of motif-based causal discovery for time series.

I could not understand what you mean by discovery. I am requesting a clear definition of what the authors mean by "discovery" in this context would help clarify the paper's novelty.

The experiment section is incomplete. The author has compared with only one base model.  Also base model is built by the author. The author needs to provide the architecture of the base model. The author need to compare the work with other existing state of art motif causality models for all tasks like Pan et al., 2024; Lowe ¨ et al., 2022 Bonetti et al., 2024; Najafi et al., 2023. 
Also, it seems the author has compared the proposed model only for one data set for each task. Please compare on more real-world data sets. Also, provide details of the data set used.

Meta-review: MotifDisco is a framework that tries to find short segments representing underlying phenomena within time series. MotifDisco uses Granger Causality and Transfer Entropy to learn causal relationships by solving an unsupervised link prediction problem in a graph neural network. I think this is an important problem in healthcare where early identification of signals of future outcomes can be used to create interventions for patients. There were a few problems identified in the manuscript. Reviewers highlighted concerns around identifiability (which was not responded to), the need for evaluations with known ground truth and the limited datasets that the method was evaluated on. I think one method to improve the overall presentation of the work is a pedagogically relevant synthetic data experiment that allows the authors to compare this and other papers on an equal footing that changes the complexity of the underlying dynamics and the hardness of the motif relationship discovery problem. The use of such data would also enable study of the idea in cases where ground truth is known (by construction).

Decision: Reject