# A Synthetic Demonstration of Longitudinal Analysis with Random Intercepts and Slopes

## Introduction

This manuscript presents a synthetic demonstration of a research software workflow for analyzing longitudinal data using a linear mixed model. The demonstration is entirely synthetic and uses no real observations, patients, or clinical data. The purpose is to illustrate how a fixed analysis recipe can be executed and reported reproducibly. The simulated design includes 180 independent individuals, each with six monthly visits (time 0 to 5), a stable binary group variable, and a baseline covariate z. The outcome y was generated from a known linear model with subject-specific random intercepts and slopes, plus measurement error. The analysis uses a linear mixed model fitted by REML with Satterthwaite contrasts at months 0 and 5. The selected output is the mixed model, not a GEE. All numerical results are properties of the synthetic data and must not be interpreted as clinical or real-world effects. The workflow is documented here to show model assumptions, data generation, exclusions, and scope. No novelty, superiority, or publication readiness is claimed. The only citations are to supplied method documentation [1][2].

## Methods

Synthetic data generation. We simulated 180 independent individuals with six monthly visits at times 0, 1, 2, 3, 4, and 5. Each individual had a stable binary group indicator (0 or 1) and a baseline covariate z drawn from a standard normal distribution. The outcome y was generated as y = 2 + 0.3*time + 0.4*group + 0.2*time*group + 0.25*z + b0 + b1*time + e, where b0 ~ Normal(0, 1.3^2) was a subject-specific random intercept, b1 ~ Normal(0, 0.35^2) was a subject-specific random slope for time, and e ~ Normal(0, 1^2) was measurement error. The seed was 230925. This yielded 1080 observations from 180 individuals with no missing outcome values. The outcomes are educational in arbitrary units and represent no clinical or real-world measurements. Model fitting. We fitted a linear mixed model with the fixed effects formula y ~ factor(group)*time + z and random effects (1 + time | id). The model was estimated by restricted maximum likelihood (REML). The model was fitted using lmer [1]. One-dimensional contrasts and their confidence intervals used the lmerTest Satterthwaite approximation [2]. No other analyses were performed. Contrasts. We computed Satterthwaite contrasts at months 0 and 5 to compare group 1 versus group 0. The contrast at time 0 corresponds to the group main effect. The contrast at time 5 corresponds to the group effect plus five times the interaction. The joint interaction test was also reported. All contrasts used the fixed-effect mean trajectory with numeric covariates at their sample mean and categorical covariates at the first reference level. Exclusions and missingness. The analysis input contained 1080 records from 180 individuals. No records were excluded, and no outcome values were missing. The main model inference used all 1080 observations from 180 independent individuals. The analysis did not apply additional screening or exclusion rules beyond the fixed recipe. The mixed model uses available outcome observations and relies on the MAR assumption given modeled information; the software cannot prove the missingness mechanism. This demonstration includes no ethics approval, no patients, no hospital data, and no real interventions.

## Results

The fitted linear mixed model used 1080 observations from 180 independent individuals. No observations were excluded or missing. Table 1 contains fixed-effect coefficients; Table 2 contains the prespecified group contrasts. Fixed-effect coefficients are reported with 95% confidence intervals and p-values. The intercept was 2.106 (95% CI 1.798 to 2.414; p < 0.001). The group 1 main effect at time 0 was 0.372 (95% CI -0.055 to 0.798; p = 0.087). Time had a coefficient of 0.292 (95% CI 0.194 to 0.390; p < 0.001). The covariate z had a coefficient of 0.313 (95% CI 0.120 to 0.505; p = 0.002). The group by time interaction was 0.236 (95% CI 0.101 to 0.372; p < 0.001). The joint interaction test statistic was 11.850 (p < 0.001). The group contrast at time 0 was 0.372 (95% CI -0.055 to 0.798; p = 0.087). The group contrast at time 5 was 1.553 (95% CI 0.844 to 2.263; p < 0.001). The model-based mean trajectory for group 0 at time 0 was 2.102 (95% CI 1.795 to 2.410), and at time 5 it was 3.563 (95% CI 3.050 to 4.075). For group 1, the mean trajectory at time 0 was 2.474 (95% CI 2.180 to 2.768), and at time 5 it was 5.116 (95% CI 4.626 to 5.606). Table 3 reports the joint group-by-time interaction test, and Table 4 summarizes analysis units and diagnostics. The missingness assumption diagnostic noted that the mixed model uses available outcome observations and relies on the MAR assumption given modeled information; the software cannot prove the missingness mechanism. Table 5 shows the analysis inclusion and exclusion flow: 1080 records received, 0 missing, 0 excluded, and 180 individuals analyzed. Table 6 provides baseline and group descriptions. All results in this section are from the synthetic demonstration and do not imply clinical validity, real effects, or generalizable findings.

## Discussion

This synthetic demonstration illustrates a complete linear mixed model workflow for longitudinal data. The model assumes a linear relationship between the outcome and time, group, and covariate z, with normally distributed subject-specific random intercepts and slopes. The synthetic data generation followed this known structure, so the fitted model is correctly specified for the demonstration. The results are properties of the synthetic data and must not be interpreted as clinical, real-world, or generalizable effects. The group contrast at time 0 was 0.372 (95% CI -0.055 to 0.798; p = 0.087). This is a difference in model-estimated mean outcomes, expressed in the arbitrary units of the simulated outcome. The group contrast at time 5 was 1.553 (95% CI 0.844 to 2.263; p < 0.001). The interaction was 0.236 (95% CI 0.101 to 0.372; p < 0.001). The joint interaction test was 11.850 (p < 0.001). The covariate z coefficient was 0.313 (95% CI 0.120 to 0.505; p = 0.002). These numerical results exactly match the supplied metrics, including uncertainty. No clinical validity, patient population, hospital data, ethics approval, or real intervention is implied. The analysis excluded no records, and missingness was zero in the synthetic input. The mixed model relies on the MAR assumption given modeled information; the software cannot prove the missingness mechanism. The demonstration is limited to the specified model and contrasts. No power calculations, references beyond the supplied method documentation, novelty claims, or model fit statistics are included. The workflow is educational and synthetic. The selected output is the linear mixed model, not a GEE.  Future users of this workflow should verify assumptions and fit for their own data, but this demonstration makes no claims beyond the synthetic results presented.

## References

[1] lme4 authors. lmer: Fit Linear Mixed-Effects Models.
[2] Kuznetsova A, Brockhoff PB, Christensen RHB. lmerTest Package: Tests in Linear Mixed Effects Models. J Stat Softw. 2017;82(13). doi:10.18637/jss.v082.i13.


## Figure legends

Figure 1. Model-predicted trajectories. Lines show model estimates; shading indicates pointwise 95% confidence intervals. The analysis included 180 individuals and 1080 observations.

> AI 生成内容，请人工核对。请按期刊要求披露 AI 使用。

<!-- AIGC {"AIGC":{"Label":"1","ContentProducer":"Clin2Sci","ProduceID":"clin2sci:ed69155d-976f-4b7f-a7d1-029cc1948ac5","ReservedCode1":"","ContentPropagator":"Clin2Sci","PropagateID":"clin2sci:ed69155d-976f-4b7f-a7d1-029cc1948ac5","ReservedCode2":""}} -->
