Paper commentary
Joint Modeling of Conditional Mean and Variability in Multilevel Functional Data: Application to Postprandial Glucose Trajectories in the AEGIS Study
Joint modeling of mean and variability reveals how meals shape glucose spread
- Problem Existing multilevel regression methods for repeated functional data model only the average curve. Variability in glucose after a meal goes unmodeled, so it can hide when and how spread changes over time.
- Method The authors propose a heteroskedastic functional mixed-effects model. Covariates and participant random functions shape both the mean curve and the log residual SD, and a participant-level bootstrap quantifies uncertainty.
- Results In 363 AEGIS participants, carbohydrate raised both mean glucose and residual SD at breakfast, lunch and dinner. HbA1c related mainly to the mean, not to variability.

Figure 3 :Residual-SD associations over postmeal time. Effects are displayed as 100 {exp(daγa(t))−1} percent change in residual SD, with increments da in the panel labels; effects and band limits are calculated on the log-SD scale before transformation. Dark and light shading show pointwise nominal 95% intervals and simultaneous bands from 500 participant-bootstrap refits. Meal contrasts use breakfast at 50 g carbohydrate, and female (sex coded 0) is the recorded-sex reference. The three carbohydrate panels share a vertical scale, as do the two meal contrasts; each simultaneous band covers one coefficient curve.
Original paper · CC BY 4.0 · Yang Xiao, Francisco Gude, Marcos Matabuena · Joint Modeling of Conditional Mean and Variability in Multilevel Functional Data: Application to Postprandial Glucose Trajectories in the AEGIS Study · Original paper figure · Extracted the figure area from page 13 of the original PDF.Why mean-only models miss variability
Most multilevel functional regression work asks how covariates such as age and BMI shift the average trajectory. Methods where covariates also control the spread of a response are common for scalar outcomes but scarce for whole curves. Mixed-effects location-scale models let covariates and subject-specific random effects act on the within-subject variance of a scalar response.
These scalar models don't directly handle repeated trajectories, where the mean and the variability can both change continuously over time.
This gap matters for CGM data, because two people can share an average postprandial response yet differ in their day-to-day variability. Scalar summaries such as daily standard deviations are easy to compute, but they hide when during the day the variability occurs. Figure 1 shows the same problem for two AEGIS participants, with glucose trajectories recorded every five minutes on five days.
Those trajectories vary within and between individuals across meals and days, so the authors argue for random effects that capture each person's variation after a meal.

Figure 1 :Postprandial glucose trajectories of two AEGIS participants after breakfast, lunch and dinner on five study days (D1–D5), on a five-minute grid from the start of each meal. Solid lines are the observed glucose and dashed lines the participant’s fitted mean for that meal. Shading is an approximate pointwise 95% prediction band with asymptotic approximation, the fitted mean±1.96 times the fitted residual standard deviation; crosses mark observations outside it.
Original paper · CC BY 4.0The motivating study is AEGIS, where the authors want to characterize time-dependent variability in glucose responses among adults without diabetes. Individuals respond differently to identical meals, and the same person's responses to duplicate meals can be only limitedly reproducible. In diabetes, glucose variability complements mean glucose as a marker of metabolic instability.
Such summaries don't show how variability evolves over the period after a meal, which is the gap this paper targets.
A location-scale model for trajectories
The model gives each trajectory its own mean curve and its own noise level, and both depend on covariates and on participant-specific random functions. In Equation (1), Y_ij(t) equals X_ij transposed times beta(t), plus u_i(t), plus exp of X_ij transposed gamma(t) plus v_i(t), times epsilon_ij(t). The error scale exp{X_ij transposed gamma(t) + v_i(t)} therefore moves with the covariates and with the participant's own scale effect.
The model reduces to a mixed-effects location-scale model for repeated measurements when the functional quantities are replaced by scalars. Without participant random effects, it reduces to a location-scale regression model.
The authors define the participant-specific conditional mean as mu_ij(t) and the residual SD as omega_ij(t), so Y_ij(t) equals mu_ij(t) plus omega_ij(t) times epsilon_ij(t). The reference mean is m(x, t) equal to x transposed beta(t), averaged over participant-specific effects. The participant-averaged residual variance qbar(x, t) equals exp{2x transposed gamma(t)} times E[exp{2v_i(t)}], so it measures within-participant residual variability.
Because the participant term is a single constant, it shifts only the intercept of the log scale and leaves the covariate slopes unchanged. A one-unit increase in the a-th covariate changes the conditional mean by beta_a(t) and multiplies the residual SD by exp{gamma_a(t)}, describing associations rather than causal effects.
Conditions C1 and C2 require the errors to have conditional mean zero and unit variance, and to be independent across trajectories given the covariates and random effects. Within-participant dependence across trajectories therefore comes only from the shared random effects. Condition C3 requires the participant effects u_i(t) and v_i(t) to be independent of the covariates and of the number of trajectories n_i.
The authors state that C3 follows the design of Seaman et al. (2014), and it lets the coefficient functions describe covariate associations. Because participants with more trajectories get more weight in estimation, an association between n_i and the random effects could introduce bias. The model places no restrictions on temporal dependence within individual trajectories.
How the fit runs, step by step
The fit starts with the mean, which uses the coefficient curves expanded in an orthonormal cubic B-spline basis. Each basis coefficient gets its own random-intercept model, and REML fits it as a working Gaussian mixed model. The shrinkage predictions of each participant's effect then give the fitted mean curve for every trajectory. Residuals from this same fit come out too small, because Yij(·) itself pulls the predicted participant mean toward it.
The scale fit therefore uses cross-fitted residuals, which predict each trajectory's mean from a fit that leaves its fold out. The trajectories are split into F = maxi ni folds, with at most one trajectory per participant in each fold. The squared cross-fitted residuals Qij(t) are then modelled with a log-link Gamma regression, whose log-mean is Xij⊤α(t) + bi(t).
The squared residual carries the extra term ψij(t), the variance of the error in the predicted participant mean. That error does not vanish as participants accumulate, and it is largest for participants with few trajectories. For a trajectory-level covariate, the local log-variance slope is multiplied by ωij(t)²/{ωij(t)²+ψij(t)}, which is below one.
Step 1 estimates ψij from a shrinkage part and an averaging-noise part, which are uncorrelated and add up. The averaging-noise part is rescaled by ρij(t), the only piece of the estimate that changes with the scale fit.
Step 2 multiplies each Qij(t) by exp{η̂}/(exp{η̂}+ψ̂), because subtracting ψ̂ could give negative responses. The scale model is then refitted to these rescaled responses, and the refit is repeated S = 3 times in this analysis. At each refit, the error in the fitted variance is multiplied by at most ψ/(ω²+ψ), which is below one. The corrected slopes are the non-intercept coefficients of the last refit, halved.
Step 3 holds these slopes fixed and fits a separate intercept, which gives the participant-averaged variance level through an estimating equation. The Gamma quasi-score allows individual negative values of Qij(tk) minus ψ̂ in this level fit.
Uncertainty from the participant bootstrap
The bootstrap resamples whole participants with replacement, so each participant's trajectories, their within-participant dependence and their number stay intact. Because of this, the bootstrap distribution includes the variability that these steps add. The paper cites Field and Welsh (2007) and Field et al. (2010) for cluster bootstraps applied to clustered and multilevel data.
The 95% simultaneous band is the estimate plus or minus c times that standard error, where c is the empirical 0.95 quantile of the statistics Z*b. Each Z*b is the largest standardized deviation of replicate b from the estimate over the grid, so 95% of replicate curves lie entirely inside the band. A pointwise interval at t instead uses the 0.95 quantile of the standardized deviations at that time alone.
The simultaneous band is defined over the grid of one curve only, so it doesn't cover several coefficient curves at once.
The authors report both intervals, because a pointwise interval concerns a single time while a band supports statements about the whole curve. For beta(t), the bands cover its spline projection, which is the target the score means identify under (C1) and (C3). For log q-bar, the method works on the log scale and exponentiates the limits. A whole-curve test of phi(t) = 0 compares the largest standardized distance from zero with the bootstrap statistics Z*1 to Z*B, giving p = (1 + count)/(B + 1).
When several non-intercept coefficient curves are tested together, the p-values are adjusted with the Benjamini–Hochberg procedure. The Appendix covers duplicated participants, failed fits, the quantile definition and the lower bound on se(t).
Carbohydrate, premeal glucose and HbA1c in AEGIS
The model in this section used 363 participants without diabetes and 5,237 meals, observed on a grid of 37 points spanning 0 to 180 minutes. Each participant contributed at least three meals of each type, a requirement the authors set for their summaries rather than for the method. The fit used 8 mean and 6 scale basis functions, 15 cross-fitting folds and 3 refits.
Each coefficient was assessed over 500 participant-bootstrap refits, with BH adjustment run within each model's 11 non-intercept curves.
Carbohydrate raised both the mean glucose and the residual SD at breakfast, lunch and dinner. The dinner-minus-lunch difference in the log-SD model was positive at 100–140 minutes, with pBH = 0.048.
Premeal glucose was linked to higher mean glucose over the whole 180 minutes and to greater residual SD at 0–95 minutes. The authors note that premeal glucose is likely related to the participant effects, which would contradict condition (C3). HbA1c was associated with the mean only at 170–180 minutes, with pBH = 0.033. Its association with residual SD didn't pass BH adjustment, with pBH = 0.329.
HbA1c varied little in these participants without diabetes, with an SD of 0.33 percentage points. So the covariates don't act alike: carbohydrate and premeal glucose reach both the mean and the variability, while HbA1c reaches mainly the mean.
Reference mean and variance after a meal
The reference profile is built at the sample covariate means, with female sex and 50 g of carbohydrate. Relative to breakfast, lunch and dinner sit below it at 5 to 25 and 5 to 35 minutes, then above it from 60 to 180 minutes. Dinner falls most slowly after its peak, which is the first sign that its curve behaves differently from the other two meals.
The participant-averaged residual variance, the reference variance curve, rises from about 6 to 257 to 271 (mg/dL)² by 45 minutes. After breakfast and lunch the variance falls, and by 180 minutes it is about 40% below its peak. After dinner the curve doesn't fall: it stays between 253 and 276 (mg/dL)² from 45 minutes on. The log-SD meal contrasts show lunch with greater residual SD than breakfast at 90 to 140 minutes, and dinner at 65 to 180 minutes.
Between-participant variation is summarized separately from the meal-level curve. Averaged over 5 to 180 minutes, the SD of the participant scale effect vi(t) is 0.35. Participants one SD apart therefore differ in residual SD by a factor of about 1.4 at the same covariates. The participant mean effect ui(t) has SD 6.9 mg/dL and accounts for 12 to 22% of the projection score variance.
Most of the conditional variance is therefore meal-to-meal variation within a participant, not between participants.
How much participant effects explain per person
Individual R2 measures how much model-based squared error remains for each participant, relative to a common population variance. The fixed version predicts each meal from the covariates alone, through the reference mean m(Xij, t). The participant version adds the participant mean effect ui(t) to that prediction, so the two differ only by that term.
Both versions average the expected squared errors over 0 to 180 minutes, with the expectation taken over the standardized error.
The common baseline D is estimated from all M = 5,237 curves as 361.5 (mg/dL)², with an SD of 19.0 mg/dL. Each participant's R2 averages over that participant's ni meals, and the paired contribution is the gap between the two versions. The median R2 is 0.477 (IQR 0.173 to 0.639) for the reference mean and 0.548 (IQR 0.294 to 0.702) for the participant-specific mean.
The median paired contribution is 0.054 (IQR 0.024 to 0.117), which equals 5.4% of D rather than the gap between the two medians. 109 of 363 participants have a paired contribution above 0.1, so the gain from participant effects varies widely across people.
Individual R2 varies widely between participants, so the participant mean effect doesn't explain a similar share of error for everyone. Some participants get negative R2 values: 57 for the fixed prediction and 38 for the participant prediction. A negative value means the model-based squared error exceeds the common baseline D. Both R2 values keep the fitted participant scale effect and treat participant effects as known, so they're structural summaries, not predictive accuracy.
The paper gives no individual uncertainty intervals for these R2 values, so Figure 5 shows point summaries only.
Computation cost of the scale fit
The custom R functions exploit the orthonormal basis, so each curve model splits into score-wise problems. Each participant effect in these fits uses only that participant's own trajectories. That count covers one initial fit and one fit in each of the three conditional refits, since S is 3.
The authors timed one such Gamma fit on the AEGIS data with both implementations. With the custom functions, a fit took 0.36 seconds on average, with an SD of 0.02. With mgcv::bam (version 1.9-4), the same fit took 178.62 seconds on average, with an SD of 1.30. The mgcv::bam run used its faster approximate option, discrete = TRUE, and still ran far slower.
The 500 bootstrap refits need 2,000 such fits, because each replicate repeats the four penalized Gamma fits. At these speeds, the custom functions finish those fits in about 12 minutes. At the same speeds, mgcv::bam would need about 99 hours. Using the exact fREML criterion rather than discrete = TRUE would make mgcv::bam slower still in the authors' own setup.
The timing covers one Gamma fit on the AEGIS data, not the full estimation pipeline. The comparison therefore doesn't measure the cost of the mean fits or the participant bootstrap as a whole.
Limitations of the corrected estimates
The corrected estimates rest on condition C3, which assumes the participant random functions are independent of the covariates and of the number of trajectories per participant. That assumption matters because participants with more trajectories get more weight in estimation, so a link between cluster size and the random effects could bias the results.
In that case, some of the premeal glucose associations may partly reflect differences between participants rather than within-participant behaviour.
The prediction-error correction doesn't explicitly account for that correlation, so the corrected scale slopes don't address it. Future work could extend the correction to handle the correlation between mean and scale effects.
Some of these sources may grow with meal size, which could contribute to the observed carbohydrate associations with residual variability.
The confidence bands don't correct for smoothing or projection bias, so they don't fully capture those errors.
Paper info
- Authors
- Yang Xiao, Francisco Gude, Marcos Matabuena
- Venue
- arXiv · Preprint
- First published
- 2026-11-5
- Added
- 2026-11-6
- Updated
- 2026-11-5
- Version
- v1
- arXiv
- 2611.07937
- Category
- stat.ML · cs.LG · stat.AP · stat.ME
- Original paper terms
- CC BY 4.0
- What we show
- Paper info, commentary and permitted figures from the original paper
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Abstract
Functional data analysis provides a framework for studying time-varying associations between covariates and high-frequency biological signals. In digital health, participants often contribute repeated functional trajectories, yet existing multilevel regression methods largely focus on the conditional mean, overlooking variability and its role in biological heterogeneity. We propose a heteroskedastic functional mixed-effects regression framework that jointly models the conditional mean and variance of repeated trajectories, with participant-specific random effects in both components. We also develop a participant-level bootstrap to quantify uncertainty in estimated functional parameters. We apply the method to postprandial glucose trajectories from the AEGIS study. Premeal glucose, carbohydrate intake, and meal type show distinct time-dependent associations with glucose variability, whereas HbA1c is more strongly associated with the conditional mean than with variability. Substantial between-participant differences in residual variability remain even after accounting for observed covariates. These findings show that modeling conditional variability alongside the mean provides insights into glucose regulation and individual heterogeneity that mean-focused analyses may miss. More broadly, the proposed framework enables joint characterization of average responses, variability, and participant-specific heterogeneity in repeated biological signals.
Quote from the paper
Yang Xiao, Francisco Gude, Marcos Matabuena (2026). Joint Modeling of Conditional Mean and Variability in Multilevel Functional Data: Application to Postprandial Glucose Trajectories in the AEGIS Study. arXiv:2611.07937v1. https://arxiv.org/abs/2611.07937v1
BibTeX
@misc{xiao2026joint,
title = {{Joint Modeling of Conditional Mean and Variability in Multilevel Functional Data: Application to Postprandial Glucose Trajectories in the AEGIS Study}},
author = {Yang Xiao and Francisco Gude and Marcos Matabuena},
year = {2026},
eprint = {2611.07937},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2611.07937v1}
}