SlowGuess/NeurIPS_2023_OCR huggingface dataset:
Considering Eq. (53) as the Doob-Meyer decomposition of the mediator process, we can interpret the function  $f_{M}(\cdot ,\cdot)$  as the compensator function  $\Lambda^{*}(\cdot)$ , and the noise  $U_{M}$  as a zero-mean martingale. Hence, we parameterize the function  $f_{M}(\cdot ,\cdot)$  by a conditional intensity function  $\lambda^{*}(\tau)$ , where  $f_{M}(\cdot ,\cdot)$  is equivalent to the integral of  $\lambda^{*}(\tau)$ :  $f_{M}(\tau ,\mathcal{H}_{< \tau}) = \Lambda^{*}(\tau) = \int_{[0,T]\times \mathbb{R}}\lambda (\tau ,m\mid \mathcal{H}_{< \tau})\mathrm{d}\tau \mathrm{d}m$ .
The conditional intensity function  $\lambda(t_i, m_i \mid \mathcal{H}_{<t_i})$  consists of two main components: the mediator time intensity  $\lambda(t_i \mid \mathcal{H}_{<t_i})$  and the mediator dosage intensity  $\lambda(m_i \mid t_i, \mathcal{H}_{<t_i})$ :  $\lambda(t_i, m_i \mid \mathcal{H}_{<t_i}) = \lambda(t_i \mid \mathcal{H}_{<t_i})\lambda(m_i \mid t_i, \mathcal{H}_{<t_i})$ . The dosage intensity is modeled as a simple GP prior with Matern-1/2 kernel that does not depend on the history  $\mathcal{H}_{<t_i}$  and takes the absolute time as input:  $\lambda(m_i \mid t_i, \mathcal{H}_{<t_i}) = \lambda(m_i \mid t_i) \sim \mathcal{GP}$ .
We model the mediator time intensity  $\lambda(t_i \mid \mathcal{H}_{<t_i})$  using three independent components  $\{\beta_0, g_m, g_o\}$  similar to Hizli et al. [2023], where the constant  $\beta_0$  serves as a simple Poisson process baseline, the time-dependent function  $g_m$  captures the dependence on the past mediators, and the time-dependent function  $g_o$  captures the dependence on the past outcomes. We assume the effects of these components as additive, and their sum is squared to ensure non-negativity:
$$
\lambda (\tau \mid \mathcal {H} _ {<   \tau}) = \left(\underbrace {\beta_ {0}} _ {\text {P P b a s i l e n c e}} + \underbrace {g _ {m} (\tau ; \mathbf {m})} _ {\text {m e d i a t o r e f f e c t}} + \underbrace {g _ {o} (\tau ; \mathbf {o})} _ {\text {o u t c o m e e f f e c t}}\right) ^ {2}. \tag {55}
$$
The mediator effect function  $g_{m}(\tau; \mathbf{m})$  captures the dependence on the past mediators, e.g., the intensity should decrease just after a meal as the patient is unlikely to eat at this moment. For this, it regresses on the relative times of the last  $Q_{m}$  mediators that occurred before time  $\tau$ :  $(\tau - t_{1}, \dots, \tau - t_{Q_{m}})$ , where  $t_{q} < \tau$  for  $q \in 1, \dots, Q_{m}$ , with  $g_{m} : \mathbb{R}_{\geq 0}^{Q_{m}} \to \mathbb{R}$  [Liu and Hauskrecht, 2019, Hizli et al., 2023]. It is modeled as a GP prior  $g_{m} \sim \mathcal{GP}$ . Its input has  $Q_{m}$  dimensions, where each dimension  $q$  is modeled independently by a squared exponential (SE) kernel:  $k_{g_{m}}(\cdot, \cdot) = \sum_{q=1}^{Q_{m}} k_{\mathrm{SE}}^{(q)}(\cdot, \cdot)$ .
The outcome effect function  $g_{m}(\tau; \mathbf{m})$  captures the dependence on the past outcomes, e.g., the intensity should decrease when the blood glucose is high due to a previous meal. For this, it regresses on the relative times of the last  $Q_{o}$  outcomes that occurred before time  $\tau$ :  $(\tau - t_{1}, y_{1}, \dots, \tau - t_{Q_{o}}, y_{Q_{o}})$ , where  $t_{q} < \tau$  for  $q \in 1, \dots, Q_{o}$ , with  $g_{o} : \{\mathbb{R}_{\geq 0} \times \mathbb{R}\}^{Q_{o}} \to \mathbb{R}$  [Hizli et al., 2023]. It is modeled as a GP prior  $g_{o} \sim \mathcal{GP}$ . Its input has  $Q_{o} \times 2$  dimensions, where  $Q_{o}$  dimensions are modeled independently. Each dimension  $q \in 1, \dots, Q_{o}$  has a 2-dimensional SE kernel:  $k_{g_{o}}(\cdot, \cdot) = \sum_{q=1}^{Q} k_{\mathrm{SE}}^{(q)}(\cdot, \cdot)$ : the first axis represents the relative-time input and the second axis represents the measurement value, e.g., glucose levels. For more details on the non-parametric point process model, see Hizli et al. [2023].
B.3.2 Outcome Model
For Eq. (54), we model the function  $f_{Y}(\cdot ,\cdot)$  using two components: (i) a baseline function  $f_{b}(\tau)$  that is independent of the history (past mediators) and (ii) a mediator response function  $f_{m}(\cdot ,\cdot)$  that captures the outcome response due to a mediator occurrence [Schulam and Saria, 2017, Cheng et al., 2020, Hizli et al., 2023]. Together with the independent, zero-mean Gaussian noise  $u_{Y}\sim \mathcal{N}(0,\sigma_{Y}^{2})$ , we can write Eq. (54) as follows:
$$
Y (\tau) = \underbrace {f _ {b} (\tau)} _ {\text {b a s i l e n e}} + \underbrace {f _ {m} (\tau ; \mathbf {m})} _ {\text {m e d i a t o r r e s p o n s e}} + \underbrace {u _ {Y} (\tau)} _ {\text {n o i s e}}. \tag {56}
$$
The baseline function has a GP prior  $f_{b} \sim \mathcal{GP}$ . Its kernel is a sum of a constant and a periodic (PER) kernel  $k_{b}(\cdot, \cdot) = k_{\mathrm{CONST}}(\cdot, \cdot) + k_{\mathrm{PER}}(\cdot, \cdot)$ . The mediator response function  $f_{m}$  models the dependence of the future outcomes on the past mediators. We assume that the effect of the past mediators is additive, and the magnitude and the shape of the response are factorized as follows:
$$
f _ {m} (\tau ; \mathbf {m}) = \sum_ {i: t _ {i} \leq \tau} l \left(m _ {i}\right) f _ {m} ^ {0} \left(\tau - t _ {i}\right), \tag {57}
$$
where (i) the magnitude of the response depends on the mark  $m_{i}$  through the linear function  $l(m_{i})$  and (ii) the shape of the response depends on the relative time  $\tau - t_{i}$  through a GP prior  $f_{m}^{0} \sim \mathcal{GP}$  that has a SE kernel:  $k_{m}(\cdot, \cdot) = k_{\mathrm{SE}}(\cdot, \cdot)$ . We ensure that a future mediator does not affect a past outcome by using a 'time-marked' kernel [Cunningham et al., 2012] where the output of the kernel is set to zero if the relative time input is negative, i.e., the mediator has occurred after the outcome, similar to Cheng et al. [2020], Hizli et al. [2023]. Besides, we assume that the mediator has a causal effect on the outcome for an effective period  $\mathcal{T}_{\mathrm{eff}}$ , e.g., the glucose response of a meal takes place in the next  $3\mathrm{h}$  [Wyatt et al., 2021]. For more details on the non-parametric outcome model, see Hizli et al. [2023].
B.3.3 Joint Distribution of Mediator-Outcome Model
In our problem setup, each patient undergoes the surgery and is observed in two regimes (pre- and post-surgery):  $\mathcal{D} = \{\mathcal{D}^{(a)}\}_{a\in \{0,1\}}$ . Within each regime  $a\in \{0,1\}$ , the data set  $\mathcal{D}^{(a)}$  contains the measurements of mediator  $M$  and outcome  $Y$  at irregular times:  $\{(t_i^{(a)},m_i^{(a)})\}_{i = 1}^I^{(a)}$  and
$\{(t_j^{(a)},y_j^{(a)})\}_{j = 1}^{J^{(a)}}$  . For completeness, we repeat the joint distribution of  $\mathcal{D}$  ..
$$
p (\mathcal {D}) = \prod_ {a \in \{0, 1 \}} \left[ \exp \left(- \Lambda^ {(a)}\right) \prod_ {i = 1} ^ {I ^ {(a)}} \underbrace {\lambda^ {(a)} \left(t _ {i} , m _ {i} \mid \mathcal {H} _ {<   t _ {i}}\right)} _ {\text {m e d i a t o r i n t e n s i t y}} \prod_ {j = 1} ^ {J ^ {(a)}} \underbrace {p ^ {(a)} \left(y _ {j} \mid t _ {j} , \mathcal {H} _ {<   t _ {j}}\right)} _ {\text {o u t c o m e m o l e d}} \right], \tag {58}
$$
B.4 Learning and Inference
We use the likelihood in Eq. (58) to learn the joint mediator-outcome model. The mediator intensity has a sparse GP prior using inducing point approximations [Hensman et al., 2015]. Hence, we use variational inference and optimize the evidence lower bound (ELBO). The outcome model is a standard GP prior. Hence, we use the marginal likelihood to learn the hyperparameters. For more details on the derivations of the learning algorithms, see Hizlui et al. [2023].
Following Eq. (58), we learn a single joint model for each of pre-surgery  $(a = 0, [\emptyset, \emptyset])$  and postsurgery regimes  $(a = 1, [\tilde{t}_a, \tilde{t}_a])$ . With these two models, we can estimate the two interventional trajectories  $Y_{> \tilde{t}_a}[\emptyset, \emptyset]$  and  $Y_{> \tilde{t}_a}[\tilde{t}_a, \tilde{t}_a]$  under 'factual' interventions. For the interventional trajectory  $Y_{> \tilde{t}_a}[\emptyset, \tilde{t}_a]$  under the hypothetical intervention  $[\emptyset, \tilde{t}_a]$ , Eq. (27) states that the outcomes follow the pre-surgery outcome distribution while the mediators follow the post-surgery distribution. Therefore, we combine the pre-surgery outcome model  $p(\mathbf{Y}[A = \emptyset])$  and the post-surgery mediator intensity  $\lambda^*[A = \tilde{t}_a]$  to estimate the interventional trajectory  $Y_{> \tilde{t}_a}[\emptyset, \tilde{t}_a]$ .
B.5 Scalability
Outcome Model. The computational complexity for the learning and inference in standard GPs is  $\mathcal{O}(N^3)$  where  $N$  is the number of training data points. In the RCT data set used in experiments, we have ca. 5100 data points for each period, resulting from 17 patients with 3-day long glucose measurements in approximately 15-minute intervals. This is a relatively large data set that renders the standard GP inference slow. However, a straightforward inducing point approximation would not work on the outcome model, due to the 'time-marked' mediator-response function where a past mediator only affects the future outcomes. To make this approach more scalable, an efficient inducing point implementation will be required and it will be considered as future work. We believe that this will be a meaningful contribution for scalable Bayesian estimation of treatment-response curves [Schulam and Saria, 2017, Xu et al., 2016, Soleimani et al., 2017, Cheng et al., 2020].
Mediator Intensity. The computational complexity for the learning and inference in GPs with inducing point approximations is  $\mathcal{O}(NM^2)$  where  $M$  is the number of inducing points. In our experiments, we see that  $M$  can be chosen in the order of 10 and we use  $M = 20$  in all experiments. Hence, the learning and the inference for the mediator intensity is more scalable compared to the outcome model.
(a) Example patient 1.
(b) Example patient 2.
(c) Example patient 3.
Figure 7: Example 1-day long meal-glucose data and joint model fits for three patients: meals (carbohydrate intake, cyan bars), glucose (black crosses), predicted meal intensity  $\lambda^{*}$  (orange dashed line), predicted glucose baseline  $\mathbf{f_b}$  (red dashed line) and predicted glucose progression  $\mathbf{f}$  (blue dashed line). For blood glucose, we see, after the surgery, (i) the baseline declines, and (ii) a meal produces a faster rise and decline. For meals, we see, after the surgery, the patient eats (i) more frequently and (ii) less carbohydrate per meal.
C.1 Real-world Study
For the real-world study, we consider data from a real-world randomized controlled trial (RCT) about the effects of bariatric surgery on blood glucose [Saarinen et al., 2019, Ashrafi et al., 2021]. We investigate whether our model can learn clinically-meaningful direct and indirect effects of bariatric surgery on blood glucose, by analyzing how surgery affects glucose through the changed diet (indirectly) or other metabolic processes (directly).
Dataset. The RCT dataset consists of surgery-meal-blood glucose (treatment-mediator-outcome) measurements of 15 obesity patients (body mass index,  $\mathrm{BMI} \geq 35\mathrm{kg} / \mathrm{m}^2$ ) undergoing a gastric bypass surgery. In the original study, patients are randomized into two types of surgeries: Roux-en-Y gastric bypass (RYGB) [Wittgrove et al., 1994] and one-anastomosis gastric bypass (OAGB) [Rutledge, 2001]. Nevertheless, we consider both as a single surgery type since it has been previously reported that two surgeries do not have a statistically-significant difference between their effects on the blood glucose progression [Ashrafi et al., 2021]. A continuous-monitoring device measures the blood glucose of each patient at 15-minute intervals. Patients record their meals in a food diary. Data is collected over two 3-day long periods: (i) the pre-surgery period, which is 2-months prior to the surgery at weight stability, and (ii) the post-surgery period, which takes place right after the surgery. From the surgery-meal-glucose data set, we show 1-day long meal-glucose measurements in pre- and post-surgery periods for three example patients in Fig. 7.
Data Preprocessing. Since patients record their meals with error, self-recorded food diaries contain very noisy observations, especially in terms of the meal times. For example, a patient can record a meal with a 30-min delay when the blood glucose already peaked to its local maxima (top of the meal bump). Or, they can record a single meal as multiple meal records. This may cause a naive supervised learning algorithm to come to a counterintuitive conclusion that a meal causes a temporary decrease in the blood glucose. Therefore, we perform a data preprocessing step on the meals to correct their occurrence times. To avoid multiple records, we combine multiple meals that occur within  $30\mathrm{min}$ . To align the meal response bumps and the meal times, i.e., to find the true meal time values, we use a Bayesian error-in-variables model that accounts for the errors in meal timings [Ashrafi et al., 2021, Zhang et al., 2021]. We train the error-in-variables model using the provided code in Stan [Carpenter et al., 2017] and use the posterior means of the true meal times.
Model. We model the pre- and post-surgery sequences of meals and blood glucose measurements using our interacting mediator-outcome model, given in Eqs. (55) and (56). We represent each of pre- and post-surgery periods as a single regime  $a \in \{0,1\}$  using the binary-valued treatment process  $A(\tau) \in \{0,1\}$ . In the following, we explain the model parameters for a single regime  $a \in \{0,1\}$ , since we use the same model definition and initialisation for both regimes.
The mediator dosage intensity  $\lambda(m \mid \tau) \sim \mathcal{GP}$  has a Matern-1/2 kernel with the variance and the lengthscale parameters are initialized as follows:  $\sigma_d^2 = 1.0$ ,  $\ell_d = 1.0$ . Its hyperparameters are learned. The mediator time intensity has three components:  $\{\beta_0, g_m, g_o\}$ . The hyperparameters of these components are set using the domain knowledge. The Poisson process baseline  $\beta_0$  is initialized to 0.1. The meal-effect function  $g_m$  depends on the relative time to the last meal:  $Q_m = 1$ . The variance and the lengthscale parameters of its SE kernel are initialized as:  $\sigma_m^2 = 0.1$ ,  $\ell_m = 1.5$ . The lengthscale value 1.5 captures the likely decline and rise in the meal intensity right after a previous meal in the next 5 h. Similarly, the glucose-effect function  $g_o$  depends on the relative time and value of the last glucose measurement:  $Q_o = 1$ . The hyperparameters of its 2-dimensional SE kernel are initialized as:  $\sigma_o^2 = 0.1$ ,  $\ell_o = [100.0, 5.0]$ . The large lengthscale value 100.0 in the time dimension encourages a piecewise linear function that changes with a new glucose measurement in every  $\sim 15$  min, since the glucose measurements are more frequent compared to the meal measurements ( $\sim 3$  h). The large lengthscale value 5.0 of the glucose dimension encourages a smooth, slow-changing function as blood glucose levels fluctuate in the range [4.0, 9.0] to capture a monotonically decreasing intensity as the blood glucose levels increase. The number of inducing points are chosen as  $M = 20$  and they are placed on a regular grid in the input space. The hyperparameters are not learned, while the inducing variables  $\mathbf{Z}$  are learned. The mediator intensity is shared among all patients.
The outcome model has three components:  $\{f_b, f_m, u_Y\}$ . The most important hyperparameters are the GP lengthscale parameters, which are selected by a combination of domain knowledge and validation of the model fit. For meal-response, we considered lengthscales  $\{0.15\mathrm{h}, 0.3\mathrm{h}, 0.5\mathrm{h}, 1.0\mathrm{h}\}$ , and for the baseline, lengthscales  $\{5\mathrm{h}, 10\mathrm{h}, 20\mathrm{h}\}$ .
The kernel of the baseline function  $f_{b}$  is equal to the sum of a constant and a periodic kernel. The intercept parameter of the constant kernel is initialized to 1.0. The period parameter  $p$  is set to  $24\mathrm{h}$  so that  $f_{b}$  models the daily glucose profile. The variance and the lengthscale parameters of the  $k_{b}$  are initialized as:  $\sigma_b^2 = 1.0, \ell_b = 10.0$ . The large lengthscale value 10.0 encourages a slow-changing, smooth baseline function. We assume that each patient has an independent baseline function  $f_{b}$ . The meal response function  $f_{m} = \sum_{i:t_{i}\leq \tau}l(m_{i})f_{m}^{0}(\tau -t_{i})$  consists of two functions: (i) a linear function  $l(\cdot)$  whose intercept and slope parameters are initialized to 0.1, and (ii) the response shape function  $f_{m}^{0}\sim \mathcal{GP}$  with a SE kernel whose variance and lengthscale parameters are initialized as:  $\sigma_0^2 = 1.0,\ell_0 = 0.5$ . The magnitude function  $l(m_{i})$  is modeled in a hierarchical manner, where each patient has their own intercept and slope parameters and they all share hierarchical Gaussian priors  $N(0,0.1^{2})$ . The shape function  $f_{m}^{0}$  is shared among the patients as the meal responses for different individuals are very similar. Furthermore, the effective period for a meal  $T_{\mathrm{eff}}$  is set to  $3\mathrm{h}$  following the empirical findings on the duration of the meal response in Wyatt et al. [2021]. The hyperparameters of the outcome model are learned except the period of the baseline  $p$  (24 h) and the effective period  $T_{\mathrm{eff}}$  of the shape function (3 h), which are chosen w.r.t. the domain knowledge.
Training. As described above, the interacting mediator-outcome model is trained on the surgery-meal-glucose dataset. For each regime, one set of joint model is learned. We train the hyperparameters of the meal dosage intensity using the marginal likelihood and the inducing variables of the meal time intensity using the ELBO. For the outcome model, we learn the hyperparameters using the marginal likelihood. We show three example training fits of the joint model on 1-day long meal-glucose measurements in pre- and post-surgery periods in Fig. 7.
Next Meal Predictions in Section 5.1.3. Once the models are learned, we can sample from the GP posteriors. We take 5000 samples from the posterior of the time intensity for the next meal time under a typical glucose level. Similarly, we take 5000 samples from the posterior of the dosage intensity for the carbohydrate intake per meal. In Fig. 5 of the main text, we show the kernel density estimations (KDE) using dashed lines. For the computation of the KDE, we use the built-in function of the 'seaborn' library.
Direct and Indirect Effects on Glycemia in Section 5.1.4. In Section 5.1.4, we investigate the direct and indirect effects of the surgery on the glycemia to answer the following causal query: how much of the surgery effect can be contributed to the changed diet? To measure the contribution of the direct and indirect effects, we use two metrics: (i) the percentage time spent in hypoglycemia (HG)  $\% T_{\mathrm{HG}} = \{t : Y(t) \leq 3.9 \mathrm{mmol} / \mathrm{l}\} / T$ , and (ii) the percentage time spent in above-normal-glycemia (ANG)  $\% T_{\mathrm{ANG}} = \{t : Y(t) \geq 5.6 \mathrm{mmol} / \mathrm{l}\} / T$ . In the following, we describe the computation for one metric for brevity, e.g.,  $\% T_{\mathrm{HG}}$ , as the computations of the two metrics are the same.
The metrics can be calculated on the surgery-meal-glucose data set in a straightforward manner. After we calculate them for the pre-surgery period  $[t_A = \emptyset] \equiv [\emptyset, \emptyset]$  and the post-surgery period  $[t_A = \tilde{t}_a] \equiv [\tilde{t}_a, \tilde{t}_a]$ , we compute the total causal effect (TE) as follows
$$
\mathrm {T E} _ {\mathrm {H G}} \left(\tilde {t} _ {a}\right) = \% T _ {\mathrm {H G}} \left[ \tilde {t} _ {a}, \tilde {t} _ {a} \right] - \% T _ {\mathrm {H G}} [ \varnothing , \varnothing ].
$$
For direct and indirect effects, we further need to estimate  $\% T_{\mathrm{HG}}[\emptyset, \tilde{t}_a]$ , i.e., the percentage time spent in hypoglycemia under a hypothetical intervention  $[\emptyset, \tilde{t}_a]$ . As the counterfactual  $\% T_{\mathrm{HG}}[\emptyset, \tilde{t}_a]$  is not available in closed form, we take samples from the posterior of the learned joint model and perform a Monte Carlo approximation. As the posterior samples, we sample 3-day long meal-glucose trajectories for 17 patients for each of the three interventional regimes:  $\{[\emptyset, \emptyset], [\emptyset, \tilde{t}_a], [\tilde{t}_a, \tilde{t}_a]\}$ . Each 1-day long trajectory has 40 glucose measurements, which makes 2040 samples for each regime. For the interventional trajectories to be comparable, we fix the noise variables of the point process sampling, similar to Hizli et al. [2023]. Then, the Monte Carlo approximations of the NDE and the
Table 3: Benchmark models considered in the semi-synthetic study.
JOINT
MODEL	MODEL COMPONENTS
A→Y	MEDIATOR	RESPONSE
M1	✓	Non-interacting (L15)	Parametric (S17)
M2	✓	Non-interacting (L15)	Non-parametric (H22)
M3	✓	Interacting (H22)	Parametric (S17)
Z21-1	✓	Interacting (H22)	Parametric (Z21)
Z21-2	✓	ORACLE	Parametric (Z21)
H22	✗	Interacting (H22)	Non-parametric (H22)
OUR	✓	Interacting (H22)	Non-parametric (H22)
$\mathrm{NIE}$  in  $\% T_{\mathrm{Hg}}$  are computed as follows
$$
\mathrm{NDE}_{\mathrm{HG}}(\tilde{t}_{a}) = \sum_{i = 1}^{17\times 3}\% T_{\mathrm{HG}}^{(i)}[\tilde{t}_{a},\tilde{t}_{a}] - \% T_{\mathrm{HG}}^{(i)}[\emptyset ,\tilde{t}_{a}],
$$
$$
\mathrm{NIE}_{\mathrm{HG}}(\tilde{t}_{a}) = \sum_{i = 1}^{17\times 3}\% T_{\mathrm{HG}}^{(i)}[\varnothing ,\tilde{t}_{a}] - \% T_{\mathrm{HG}}^{(i)}[\varnothing ,\varnothing ],
$$
where each index  $i\in 1,\ldots ,17\times 3$  refers to a 1-day long trajectory sample.
C.2 Semi-synthetic Study
The performance on the causal tasks are validated on synthetic studies, since the true causal effects are unknown in real-world observational data sets. Hence, we set up a realistic, semi-synthetic simulation study to evaluate the performance of our model on two causal tasks: estimating the NDE and NIE trajectories.
C.2.1 Simulator
To set up a realistic semi-synthetic study, we design realistic ground-truth simulators, that are based on the real-world data set of the RCT study. To achieve this, we train our joint mediator-outcome model on the surgery-meal-blood glucose data to obtain a single joint simulator for each regime  $a \in \{0,1\}$ . We use the same model definition, initialisation and learning procedure in Appendix C.1. For a visual example on how the data and the simulator fits look, see Figs. 7 and 8.
The ground-truth joint simulator has two components: the meal (mediator) simulator and the glucose (outcome) simulator. To train the meal simulator, we use the meal-glucose data from all patients. We show the training fits on 1-day long meal trajectories of three example patients in the bottom panels of the sub-figures in Fig. 7. In addition, we show how the function components  $g_{m}$  and  $g_{o}$  differs in Figs. 9a and 9b. We see that in both pre- and post-surgery periods, the meal-time intensity decreases after a meal event. Besides, the post-surgery meal-time intensity increases faster compared to the pre-surgery meal-time intensity as expected, as the surgery leads to a diet with more frequent, smaller meals. For the decrease in the size of the meals, we show how the carbohydrate intake (meal dosage) intensity changes after the surgery in Fig. 9c.