Korean J Anesthesiol Search

CLOSE


Korean J Anesthesiol > Epub ahead of print
Running title Linear mixed modeling for clinicians
Authors Initials HJ Kim, K Song
Kim and Song: Linear mixed-effects models for analysis of longitudinal repeated measures: a conceptual framework for clinical researchers

Abstract

In this paper, we provide a conceptual introduction to the linear mixed-effects model (LMM), statistical approaches that are used for analysis of longitudinal repeated-measure data, for clinical researchers with a limited statistical background. We begin by contrasting LMM with repeated-measures analysis of variance, and highlight the limitations of the latter approach, including its restrictive assumption of sphericity and its sensitivity to dropout. We show that LMM overcomes these limitations by providing valid inferences under the missing-at-random assumption, accommodating unbalanced designs, and offering flexible options for modeling covariance structures. Beyond addressing the core assumptions of LMM, we evaluate the implications of modeling time as a numerical versus as a categorical factor. We discuss approaches for handling baseline values, including longitudinal data analysis, constrained longitudinal data analysis, and analysis of covariance, and describe their relative strengths and limitations in both randomized and observational studies. We explain the roles of random effects and residual covariance structures and provide practical guidance for selecting candidate models by using exploratory plots and information criteria, such as the Akaike and Bayesian information criteria. Overall, by providing a clear and accessible conceptual framework, we hope to enable clinical researchers to understand, evaluate, and apply LMM effectively.

Introduction

In a substantial proportion of longitudinal randomized controlled trials (RCTs), a small number of follow-up measurements are obtained in clinical settings, with baseline outcomes routinely recorded before randomization is applied [1]. The selection of an appropriate statistical method for analyzing changes after baseline measurement, particularly when more than two follow-up measurements are involved, remains a practical challenge for many clinical researchers.
Performing multiple independent t-tests at follow-up time points in longitudinal studies is statistically problematic. Repeated testing across time points increases the risk of Type I errors, because each test contributes to the overall probability of a false-positive result. Conservative adjustments, such as the Bonferroni correction, are often applied to address this issue; however, using multiple independent t-tests with adjustments can markedly reduce the statistical power of the study, hampering detection of true group differences. Additionally, this approach fails to model the overall response trajectory or group-by-time interactions and ignores the correlation between repeated measures within the same subject, which can bias standard errors [2], given that observations in longitudinal studies are rarely independent. Therefore, robust methods, such as repeated-measures analysis of variance (RM-ANOVA) or the more flexible linear mixed-effects model (LMM), are recommended for analysis of longitudinal data [3]. In this paper, we provide a conceptual introduction to LMM and compare it with RM-ANOVA to help clinical investigators who lack advanced statistical expertise to understand and apply this approach appropriately for the analysis of longitudinal repeated-measure data.

Methodological approaches to longitudinal data analysis

Comparison of RM-ANOVA and LMM

In this section, we compare the use of RM-ANOVA with that of LMM, using the following study design as an example:
In a study, serum C-reactive protein (CRP) level was used as the dependent variable. Group (between-subject factor; Group A [n = 50] and Group B [n = 50]) and time (within-subject factor, with four time points: T1 [baseline, immediately before surgery], T2 [postoperative day 1], T3 [postoperative day 2], and T4 [postoperative day 3]) were used as independent variables. Each participant was assessed at all four time points, representing a repeated-measures design.
We begin by applying a two-way RM-ANOVA, which partitions the total variability into between- and within-subject components. We set group (A vs. B) as the between-subjects factor and time (T1–T4) as the within-subjects factor. This approach allows the assessment of group differences, time effects, and their interactions, while accounting for repeated measurements within individuals. The group effect is tested against the variability among subjects within each group. In contrast, time- and group-by-time interaction effects are tested against the residual variability of the repeated measurements within subjects (Table 1). Statistical significance is evaluated using the F-statistic, which is calculated as the ratio of the mean squares (i.e., the sum of squares divided by their respective degrees of freedom) for the effect of interest and its corresponding error term [4].
RM-ANOVA requires a balanced design; in other words, the same number of repeated measurements must be obtained in all participants, and complete data are necessary to compute the sum of squares and F-statistics. Consequently, cases with missing values must be excluded from the analysis, a procedure commonly referred to as “complete-case analysis” [5]. Although complete-case analysis simplifies the analytical method, it reduces statistical power because it typically involves a diminished sample size. It is also associated with inefficiencies in estimation and an elevated risk of bias in the estimated effects [6,7].
The inherent characteristics of repeated-measurement data must be understood. As multiple observations are collected from the same subjects over time, the assumption of independence among residuals across time points is generally violated. RM-ANOVA addresses this by imposing an assumption of sphericity. Sphericity assumes that the variance of the differences between any two time points is constant, treating the correlation between adjacent time points (e.g., T1 vs. T2) as identical to that between distant time points (e.g., T1 vs. T4).
However, in longitudinal data, such correlations often decay with an increasing time lag, so that violations of sphericity are likely. While this time-lag-dependent correlation pattern is commonly found in temporal data (which limits the flexibility of RM-ANOVA in such contexts), this may not necessarily hold true for non-temporal repeated factors (e.g., experimental conditions or anatomical sites), which lack meaningful chronological ordering.
In contrast to RM-ANOVA, LMM offers greater flexibility in addressing the two abovementioned major limitations (Table 2). First, LMM is more robust to missing data and unbalanced designs, which are frequently encountered in longitudinal clinical trials [1]. When data are missing-at-random (MAR), likelihood-based estimation allows valid inference without the need for imputation or complete-case deletion, thereby retaining all available observations and minimizing information loss. The MAR assumption is discussed in detail in the following section. Second, LMM can explicitly model correlations among repeated measurements by specifying various covariance structures. These include compound symmetry (CS), which assumes a constant correlation between all time points, regardless of the interval between them; first-order autoregressive [AR(1)], which accounts for correlations that naturally decay with the increase in time separation; and unstructured (UN), which offers the most flexibility by estimating correlations between each pair of time points, independently. This flexibility makes LMM well-suited for analyzing the complex longitudinal data commonly encountered in clinical research, particularly when the sphericity assumption of RM-ANOVA does not hold.
However, LMM is not universally superior to RM-ANOVA. In well-controlled studies with balanced data and small sample sizes, RM-ANOVA remains a robust and intuitive option [8]. In such contexts, LMM may suffer from biased or unstable estimations of variance components because of insufficient data [9]. Therefore, researchers should prioritize the method that best fits the characteristics, such as sample size and completeness, of their data set.

Concept and structure of an LMM

In the term LMM, “mixed” refers to the inclusion of both fixed and random effects. Fixed effects represent average effects at the population level, such as treatment groups, time points, and their interactions, whereas random effects capture subject-specific variability (i.e., the between-subject heterogeneity) [10].
The general equation for an LMM is expressed in matrix form, as follows:
(1)
Y=Xβ+Zb+ε
where X is the design matrix that incorporates all fixed factors and the study design structure, rather than representing a single variable. Specifically, design matrix X is constructed such that the rows correspond to individual observations, whereas the columns represent the model components, including the intercept, treatment group (A vs. B), time points (T1–T4), their interactions, and other covariates. This format allows estimation of the coefficient vector β, which contains the population-level average trends. Similarly, Z is the design matrix for random effects and b is the vector of random-effect coefficients. While Xβ represents the average effect, Zb accounts for the deviation of each individual patient’s data from that average, thereby capturing between-subject heterogeneity. Finally, ε denotes the residual error, which represents the noise remaining after accounting for fixed as well as random effects.
Using the structure in Equation (1), the LMM partitions overlapping sources of variability, such as the systematic influence of treatment over time (population effect) and the random deviation unique to each participant (between-subject heterogeneity). In other words, this modeling approach enables simultaneous population-level inferences and individual-specific predictions by integrating fixed and random effects. This ability distinguishes LMM from RM-ANOVA and generalized estimating equations, which are primarily designed for population-averaged inferences [11]. However, this detailed modeling requires adherence to several modeling assumptions, such as distributional forms and covariance structure specifications, which renders the method sensitive to violations of these assumptions. The critical assumptions are discussed in detail in the following sections.

Assumptions of LMM

Assumptions 1–4 below define the structural and distributional requirements of the LMM, while assumption 5 ensures the validity of LMM-based statistical inferences in the presence of missing data.

Assumption 1: linearity

The dependent variable Y is assumed to be a linear combination of fixed effects, random effects, and residual errors, implying a linear relationship between the predictors and the outcomes. Violations of this assumption can be detected by plotting residuals against the fitted values produced by the model [11]. Ideally, the residuals should be randomly scattered around zero, with no discernible pattern (Fig. 1) [12]. However, distinct patterns, such as a U-shaped curve in the residual plot (Fig. 2), indicate that the linear model has failed to capture the underlying nonlinear trend. When the assumption of linearity is violated, strategies such as variable transformation (e.g., log-transformation), polynomial terms, and regression splines, can be explored to address nonlinear relationships within the linear framework.

Assumption 2: distributional assumptions for random effects

The random-effects vector b is typically assumed to follow a multivariate normal distribution with a mean of zero and a covariance matrix G [13].
The random-effects vector b comprises subject-specific parameters, such as the random intercept (b0) and random slope (b1). Specifically, b0 represents a subject’s deviation from the population baseline, whereas b1 reflects their individual deviation from the average rate of change. Given that these components may be correlated (for instance, a subject with a starting value higher than the population average might show a steeper or slower decline over time), they are collectively assumed to follow a multivariate normal distribution with a mean of zero and a covariance matrix G (b~N (0, G)).
For a model with one random intercept and one random slope, the covariance matrix G takes the following form:
G=σ02σ01σ01σ12,
where the diagonal elements represent the between-subject variances of the intercept (σ20) and the slope (σ12), while the off-diagonal element (σ01) represents the covariance between them. Following model estimation, the validity of this normality assumption is typically assessed using diagnostic tools, such as quantile–quantile (Q-Q) plots of the predicted random effects. Fig. 3 presents a Q-Q plot used to assess the normality of the predicted random intercepts, based on the assumption that a random-intercept-only model is the most appropriate for the data structure. The x-axis represents the theoretical quantiles (expected values under conditions of normality) and the y-axis represents the predicted random effects. If the points align closely with the diagonal line, the normality assumption can be considered reasonable. For models with random intercepts and slopes, a separate plot should be examined for each random effect.
Moreover, because the intercept and slope are often correlated (as defined in the G matrix), examining their joint normality is also recommended. This can be done via a scatter plot of intercepts versus slopes, to observe an elliptical distribution, or by using a Q-Q plot of Mahalanobis distances.

Assumption 3: distributional assumptions for residuals

In our hypothetical study, serum CRP levels were measured at four specific time points (T1, T2, T3, and T4) for each participant. Let εi,T1 represent the residual error for subject i at baseline, and εi,T4 at postoperative day 3. The residual vector for subject i is defined as
εi=εi,T1,εi,T2,εi,T3,εi,T4T
Because these four residuals belong to the same subject and are likely interrelated, the vector εi is assumed to follow a multivariate normal distribution:
εi∼N (0,Ri),
where Ri is the residual covariance matrix (or intra-subject covariance matrix) of subject i.
Similar to random effects (b), the normality of residuals (ε) can also be assessed using Q-Q plots.

Assumption 4: independence of random effects and residuals

For stable estimation and clear interpretation, random effects (b) and residuals (ε) are assumed to be independent within the LMM framework [13]. To verify this, a scatter plot of the residuals against the predicted random effects is typically prepared. The absence of trends or correlations in this plot supports the assumption of independence.

Assumption 5: handling of missing data—the MAR assumption

While a key advantage of LMM is its ability to handle missing data without imputation, the validity thereof relies strictly on the MAR assumption. Thus, we discuss critical considerations regarding missing values below.
Because LMM relies on a likelihood-based method, it yields valid estimates when the data are MAR [14]. Under this framework, the probability of missingness depends on the observed variables but not on the unobserved values themselves.
For example, in our four-measurement CRP design, missingness is consistent with MAR if it is related to observed factors, such as weekend laboratory schedules or baseline severity. While administrative reasons (e.g., weekend effects) typically pose a minimal risk of bias, clinical predictors linked to the outcome, such as baseline severity, must be included as fixed effects. For instance, if patients who have milder disease are more likely to miss follow-up visits, failure to adjust for baseline severity would skew the results. By incorporating these associated covariates, the MAR assumption is satisfied and the LMM provides valid, unbiased estimates of the group (or treatment) effect. In contrast, if follow-up measurements were omitted because clinicians presumed that CRP levels were low (an unobserved value), the data would be missing not at random (MNAR). Under the MNAR assumption, sensitivity analyses or alternative modeling strategies are warranted, ideally in consultation with a statistician [15,16].

Modeling time in repeated measures: numerical vs. categorical specification

When specifying the fixed-effects structure of an LMM, a fundamental decision relates to the treatment of the time variable, specifically whether to model it as a continuous numerical predictor (e.g., T1 = 0, T2 = 1, T3 = 2, T4 = 3) or as a categorical factor (e.g., T1, T2, T3, and T4, as discrete levels). This choice depends on the nature of the temporal trends and the objectives of the research.

Time as a numerical (continuous) variable

When the data reveal an approximately linear trend over time (Fig. 4A), modeling time as a continuous variable is appropriate for estimating the overall rate of change. This specification captures global temporal patterns parsimoniously. This model can be expressed as
(2)
Yij=β0+β1Groupi+β2Timeij+β3Groupi×Timeij+boi+b1iTimeij+εij
where i denotes an individual subject, and j denotes the specific measurement occasion for that subject.
For fixed effects, β0 is the population intercept, β1 is the group difference at baseline (where Time = 0), β2 is the average rate of change in CRP over time within the reference group, β3 (interaction) is the difference in the rate of change (slope) between Groups A and B. This is the primary parameter of interest for testing whether treatment alters the CRP trajectory.
For random effects, b0i, b1i are the subject-specific deviations in baseline and slope, respectively, allowing each patient to have individual trajectories, and εij represents the residual error (unexplained variation) for subject i at occasion j.
Specifically, the group-by-time interaction term in this model directly tests whether the rates of change (i.e., slopes) differ between groups. Moreover, as discussed in the section on linearity assumptions, this approach can be extended beyond strict linearity by incorporating higher-order terms (e.g., quadratic or cubic effects) or flexible functions, such as splines or piecewise regressions [17,18].
However, modeling time as a continuous variable implies that estimates at specific time points are constrained by the assumed functional trajectory. Consequently, group comparisons at specific time points are based on model-predicted values rather than on the means that are estimated independently on each occasion. Although the estimated marginal means can be derived from the fitted trajectory, they may differ from the discrete means if the assumed trajectory does not fit the data perfectly.

Time as a categorical variable

When changes over time are nonlinear or irregular (Fig. 4B) or when the primary focus is comparing groups at specific follow-up occasions, time is preferably treated as a categorical variable. This specification allows the model to estimate distinct mean responses at each time point and to test between-group differences at specific time points, without imposing a functional form. In contrast, when the true trajectory is nonlinear, imposing a continuous trend, such as a linear function, may cause underfitting and misrepresentation of the mean structure, which can bias covariance parameter estimation and result in model misinterpretation. The mixed model for repeated measures (MMRM) is a representative example of a categorical time approach. The MMRM is particularly well-suited for randomized clinical trials in which outcomes are measured at a fixed set of follow-up time points [19]. Notably, in the MMRM framework, despite use of the term “mixed,” subject-specific variability is not explicitly modeled by using random effects (e.g., random intercepts or slopes). Instead, the residual covariance matrix accounts for the correlation between repeated measurements within the same individual, most commonly with an unstructured structure [20]. This model can be expressed as follows:
(3)
Yij=β0+β1Groupi+β2T2ij+β3T3ij+β4T4ij+β5(Groupi× T2ij)+β6(Groupi× T3ij)+β7(Groupi× T4ij)+εij
where β0 is the population intercept and β1 is the group difference at baseline (at T1). β2, β3, β4 are the average differences from the baseline time point at each follow-up. In our example, these parameters represent the mean deviation in CRP levels at each subsequent time point (T2, T3, and T4) relative to baseline (T1) within the reference group. β5, β6, β7(interaction) are the group differences in changes from baseline at each specific follow-up time point. These are the primary parameters of interest, as they evaluate whether the magnitude of change between T1 and each follow-up visit differs significantly between Groups A and B. εij represents the residual error (unexplained variation) for subject i at occasion j. Unlike in Equation (2), where residual errors are assumed to be independent after accounting for random effects, the errors in the MMRM are modeled to capture the correlation between repeated measures within each subject by using a residual covariance structure, commonly specified as “Unstructured”.
To illustrate interpretation of the model, the predicted mean response for a subject in Group B at T3 can be calculated as follows: Given that Groupi = 1 for Group B and the dummy variable T3ij = 1 (with T2ij = T4ij = 0), the equation simplifies to:
EY | Group B, T3 =β0+β1+β3+β6,
where β1 indicates the baseline difference, β3 represents the time-related change in the reference group, and β6 captures the difference between Groups B and A in terms of their change in CRP levels from baseline to T3.
This inherent flexibility, which stems from multiple fixed effects and an unstructured covariance matrix, requires the estimation of a larger number of parameters. Consequently, the potential for model instability or reduced statistical power due to the loss of residual degrees of freedom should be kept in mind, particularly when the sample size is modest relative to the number of time points.
To illustrate these contrasting specifications (numerical vs. categorical), we analyzed a sample dataset (provided in Supplementary Material 1, along with the fully annotated R code in Supplementary Material 2). When we modeled time as a continuous variable, we focused on the rate of change; however, no significant difference in slopes was observed between the groups (group × time interaction, P = 0.136). In contrast, when we treated time as a categorical factor, focusing on point-wise comparisons, Holm-adjusted comparisons across all four time points revealed a significant between-group difference at T3 (Holm-adjusted P = 0.036). The corresponding fitted linear trajectories when time was modeled as a numerical variable and the estimated marginal means at each visit when time was treated as a categorical variable are shown in Figs. 5A and B, respectively.

Three approaches to handling baseline (T1) measurement

While the specification of time (numerical versus categorical) is a critical modeling decision, an equally fundamental aspect of analyzing longitudinal data involves handling the initial measurement. As visually demonstrated in the individual spaghetti plots overlaid in Fig. 4, every subject's trajectory originates from the value initially observed at T1. The baseline measurement represents the participants’ initial status and acts as a fundamental reference point for the longitudinal profile. Variations in these starting values (at T1) may substantially influence the assessment of outcomes at later time points (T2–T4). Consequently, the mechanism of incorporating this baseline information into the model represents a critical methodological decision that affects the precision and interpretation of the results. In the following section, we discuss three common statistical approaches for handling baseline data within the LMM framework.

Method 1: longitudinal data analysis

In longitudinal data analysis (LDA), the baseline (T1) data are included in the outcome vector in the same manner as the data at the follow-up time points (T2–T4), without imposing any constraints. This is the simplest approach and directly reflects any imbalance in baseline values between the groups. Similar to the constrained LDA (cLDA) approach discussed below, the parameter estimates and statistical inferences remain asymptotically unbiased under the MAR assumption [21], even in the presence of missing baseline data, because this method incorporates the baseline as an outcome and utilizes a full likelihood function. The R code provided in the Supplementary Material 2 utilizes Method 1 (LDA), which serves as a basic example of an LMM framework.

Method 2: Constrained longitudinal data analysis

In cLDA, the baseline (T1) is also included in the outcome vector, with the constraint that the baseline means are equal across the treatment arms. This assumption is reasonable in RCTs, where randomization ensures comparability at baseline, and imposing this constraint improves estimation efficiency [22]. However, in smaller trials, chance imbalances may still be present at the baseline. Consequently, imposing this constraint despite observed differences can lead to model misspecifications. Thus, a sensitivity analysis is recommended to ensure the robustness of the results.

Method 3: analysis of covariance

In analysis of covariance (ANCOVA), baseline (T1) is included in the model as a covariate rather than as a part of the outcome vector. In other words, the outcome is limited to the post-baseline measurements (T2, T3, and T4), and T1 is no longer treated as a longitudinal outcome variable. This approach compares follow-up outcomes across groups adjusted for baseline values and provides efficient estimates under randomization. Specifically, adjusting for the baseline removes the conditional bias arising from chance imbalances present at baseline between groups and improves estimation efficiency [21]. Nevertheless, participants with missing values have to be excluded, which leads to data loss.
The choice between the abovementioned methods depends on the study design. In RCTs in which the baseline values are independent of the treatment assignment, Methods 2 (cLDA) and 3 (ANCOVA) are generally preferred over Method 1 (LDA) because they offer greater precision and power. In practice, when baseline data are missing, Method 2 (cLDA) is often favored over Method 3 (ANCOVA) because the latter excludes participants with missing covariates, whereas cLDA can retain participants with partial information [23]. However, missing baseline data in ANCOVA can be addressed by statistical techniques, such as multiple imputations, under the MAR assumption. Although the results are comparable to those of cLDA, this multistep process imposes an analytical burden and may reduce the clinical intuitiveness of the analysis as compared to more direct methods [24].
By contrast, observational studies may involve baseline values that are associated with both exposure and outcome, raising concerns regarding confounding factors. Therefore, methods that adjust for the baseline as a covariate (Method 3, ANCOVA) or constrain the equality of baseline means (Method 2, cLDA) should be applied with caution. Although ANCOVA does not constrain baseline means, conditioning on baseline means can distort the true treatment effect in scenarios in which selection biases or undetermined factors influence baseline values. However, when the scientific question specifically concerns conditional differences at a given baseline level, and appropriate confounding controls and causal assumptions are satisfied, Method 3 (ANCOVA) may be a valid approach. In situations in which satisfaction of these assumptions is uncertain, Method 1 (LDA), which includes the baseline values as part of the outcome vector, without constraints, is the most appropriate and conservative option for avoiding potential biases arising from incorrect causal assumptions [13,23].

Understanding variance and covariance in longitudinal data

Prior to specifying the model, understanding the variance–covariance structure in the longitudinal data is crucial. Fundamentally, the covariance quantifies the joint variability between two observations. In a repeated-measures framework, variability is decomposed into two distinct sources:
1) Between-subject variability (heterogeneity): this is the extent to which subjects differ from one another (e.g., Patient A’s CRP level is consistently higher than that of Patient B).
2) Within-subject variability: this refers to how a single subject’s measurements vary over time (e.g., changes in Patient A’s CRP levels between T1 and T4).
In LMMs, these two sources of variation are modeled separately using two matrices: the G matrix (for random effects, between-subject variation) and the R matrix (for residuals, within-subject variation). The marginal variance of the data is thus partitioned into these two components.

Random-effects covariance matrix

The random effects covariance matrix (G matrix) captures between-subject heterogeneity that cannot be explained by fixed effects (population averages).
As mentioned previously, random effects typically include random intercepts and/or random slopes. The simplest model is one with only a random intercept. This structure assumes that, while each subject demonstrates unique deviation from the population mean, these deviations are drawn from a distribution with a shared between-subject variance (often denoted as σ02 or σb2). It also assumes independence between subjects.
This model can be extended to include random slopes, allowing for variations in individual trajectories. Although this may provide greater flexibility in some situations, it increases the complexity of the G matrix by expanding the number of parameters that must be estimated (i.e., the slope variance and the covariance between the intercept and the slope). This can lead to model overspecification, convergence issues, or overfitting. Moreover, when time is treated as a categorical variable, the notion of a slope is less meaningful; hence, this extension will not be discussed further.

Residual variance–covariance structure

The residual covariance matrix (R matrix) shows how errors at one time point are correlated with errors at other time points for the same subject. Specifically, the diagonal elements represent the error variances at each time point, while the off-diagonal elements represent the covariances between time points.
Several common structures are available for modeling R (Table 3) [13,25]. The simplest is the independence structure, which assumes that errors at different time points are uncorrelated and have constant variance across time. A slightly more complex option is CS, which assumes equal variances at all time points and equal covariances between any pair of time points within the same subject. Under balanced designs, this structure is akin to the sphericity assumption in RM-ANOVA. The AR(1) structure relaxes this assumption by allowing correlations to decay exponentially as the time lag increases. The UN structure is the most flexible, as it freely estimates every variance and covariance without imposing restrictions. However, it requires estimation of a large number of parameters and can become unstable when the number of time points is large. An intermediate alternative is the Toeplitz structure, which assumes covariances that depend only on the distance (lag) between time points. While this structure commonly assumes homogeneous variances, a heterogeneous version can also be employed, which provides more flexibility by allowing variances to vary across time points.

Criteria for model selection in LMM

The reliability of fixed-effect estimation in LMM depends on the selection of an appropriate covariance structure [26,27]. If the covariance structure is misspecified, the fixed-effects estimates may remain approximately unbiased, but their standard errors may be severely distorted, leading to incorrect inferences.
Because the overall covariance structure arises from the combination of the G and R matrices, a balance in modeling both components must be struck to avoid model misspecification. In practice, allowing both components to be highly flexible often complicates both estimation and interpretation, potentially leading to overfitting. Therefore, a common starting point is to use a parsimonious residual covariance structure (R matrix; e.g., independent errors) and to rely on random effects (G matrix) to capture the primary within-subject correlations. It may be somewhat confusing that the G matrix, representing between-subject heterogeneity, is used to address within-subject correlations. This is because the unique random effect assigned to each individual acts as a common factor across all repeated measures, causing a within-subject correlation. Alternatively, when the primary goal is a group-level means comparison, rather than subject-specific trajectories, a covariance pattern approach (such as an MMRM-type model) that models only within-subject covariance may be a parsimonious and interpretable option [28,29]. Nonetheless, the choice of R structure should be supported by empirical exploration and model comparison, because its adequacy depends on the observed within-subject correlation pattern.

Graphical exploration and candidate models

Before formal model selection, data should be explored graphically to assess whether the variances appear constant over time or vary across the measurement occasions. Spaghetti plots of individual trajectories and scatter plots of pairs of time points are particularly useful in this respect [25,26]. Based on these visual patterns, candidate structures, such as CS and AR(1), UN, and heterogeneous forms, can be identified (Fig. 6). For instance, if the spaghetti plot shows trajectories that remain roughly parallel, with consistent dispersion across time, and the scatter plot matrices between any pair of time points (e.g., T1 vs. T2 and T1 vs. T4) display similar correlation patterns, a CS structure is recommended. Conversely, if the scatter plots show tight clustering of points for adjacent times but more diffuse distribution of points at distant times, the AR(1) structure is more appropriate. Furthermore, visual evidence of unequal variances across time points (e.g., irregular dispersion changes) suggests the need for heterogeneous structures or UN structures.

Formal selection criteria

Finally, the UN model, which freely estimates all variances and covariances, often serves as an upper-bound reference for model fitting. In practice, alternative structures are compared against the UN model, and more parsimonious models (i.e., models with fewer parameters that have adequate fit) are preferred if they provide a comparable fit according to information criteria, such as the Akaike information criterion (AIC) and Bayesian information criterion (BIC) [25].
These indices are defined as follows:
(4)
AIC = −2lnL + 2k
(5)
BIC = −2lnL +klnn
where L is the maximized value of the likelihood function, k is the number of parameters, and n is the effective sample size.
The log-likelihood measures how well the model explains the observed data, with larger values indicating a better fit. Because the AIC and BIC are based on “−2 × ln(L),” smaller values indicate a better relative fit. The BIC applies a stronger penalty for model complexity (ln (n) >2 when the effective sample size > 7), thus favoring simpler models, whereas the AIC, which imposes a weaker penalty, may select more complex models. Both indices assess relative adequacy and are valid only when comparing candidate models fitted to the same dataset. The likelihood can be estimated either by the maximum likelihood (ML) or restricted maximum likelihood (REML). Under the REML, the AIC and BIC are appropriate only when comparing models with identical fixed-effects structures, because the fixed effects are integrated. In contrast, the ML estimation allows comparisons across models that differ in both fixed and random effects. For small samples, use of a corrected version of the AIC is recommended.

Conclusion

Dropouts and unbalanced designs are inevitable in clinical research, and particularly in longitudinal studies; consequently, LMM is a practical and powerful tool for analyzing longitudinal data. LMM provides valid inferences under the MAR assumption, flexibly accommodates unequal numbers of repeated measurements, and often achieves higher power than do complete-case methods, even when the focus is on a single follow-up comparison [1]. Choosing an appropriate covariance structure is critical for reliably estimating fixed effects in LMM. Covariance pattern models may serve as parsimonious and practical alternatives, depending on the research objective.
This paper was primarily written for clinical researchers with a limited statistical background. Accordingly, discussion of detailed technical aspects, such as likelihood-based estimation procedures (ML, REML), optimality properties of estimators (generalized least squares, best linear unbiased estimator, best linear unbiased predictor), and formal hypothesis testing were intentionally omitted. Instead, we sought to provide a clear conceptual foundation for understanding the structure and assumptions of LMM, offering a practical roadmap for clinicians who intend to apply this method to repeated-measures data, while highlighting its advantages and limitations in clinical research.

Acknowledgments

The authors used ChatGPT (OpenAI) to improve the language of the manuscript and to assist in generating R code. All AI-assisted output was reviewed and verified by the authors, who take full responsibility for the final content.

Funding

None.

Conflicts of Interest

Hye Jin Kim has been a member of the Statistical Round of the Korean Journal of Anesthesiology since 2022. However, she was not involved in any process of review for this article, including peer reviewer selection, evaluation, or decision-making. There were no other potential conflicts of interest relevant to this article.

Data Availability

All datasets generated and analyzed in the current study are available in the supplementary materials accompanying the article.

Author Contributions

Hye Jin Kim (Conceptualization; Formal analysis; Investigation; Methodology; Writing – original draft; Writing – review & editing)

Kijun Song (Conceptualization; Methodology; Validation; Writing – review & editing)

Supplementary Materials

Supplementary Material 1.
Sample dataset.
kja-25877-Supplementary-Material-1.csv
Supplementary Material 2.
Annotated R code for the linear mixed-effects model and mixed model for repeated measures analyses.
kja-25877-Supplementary-Material-2.R

Fig. 1.
Residuals vs. fitted values plot for linearity assessment. Scatter plot showing the distribution of residuals relative to the model’s fitted values. The horizontal blue line at zero serves as a reference for the expected mean of the residuals. The absence of any systematic trend or non-random pattern in the scatter of the points confirms the assumption of linearity.
kja-25877f1.jpg
Fig. 2.
Residuals vs. fitted values plot demonstrating non-linearity. Scatter plot illustrating a violation of the assumption of linearity. Unlike the random distribution shown in Fig. 1, the residuals here exhibit a distinct U-shaped curvilinear pattern as compared to the fitted values. This non-random trend indicates model misspecification, suggesting the need for higher-order terms (e.g., quadratic terms) or alternative modeling strategies.
kja-25877f2.jpg
Fig. 3.
Normal quantile–quantile plot of predicted random effects. Quantile–quantile plot for evaluating the assumption of normality of the random effects. The y-axis represents the quantiles of the predicted random effects (e.g., random intercepts), and the x-axis represents the theoretical quantiles expected under a normal distribution. The close alignment of the points along the reference line (blue line) indicates approximate normality of the random effects, supporting the distributional assumption of the linear mixed-effects model.
kja-25877f3.jpg
Fig. 4.
Mean response trajectories over time: linear vs. nonlinear patterns. Group mean trajectories following (A) linear and (B) nonlinear trends. Individual subject trajectories (“spaghetti plots”) are overlaid to illustrate within-group variability around the group means.
kja-25877f4.jpg
Fig. 5.
Effect of time specification on longitudinal modeling (continuous vs. categorical). (A) Fitted linear trajectories when time is modeled as a continuous numerical variable, indicating the absence of significant differences in slopes between groups (group × time interaction, P = 0.136). (B) Estimated marginal means at each occasion when time is treated as a categorical factor, revealing a significant between-group difference at T3 (Holm-adjusted P = 0.036). The raw data and R code for the analyses are provided in Supplementary Materials 1 and 2.
kja-25877f5.jpg
Fig. 6.
Graphical exploration for selecting candidate covariance structures in longitudinal data. The figure compares three common covariance structures (Rows) using two visualization methods (Columns). The left column displays spaghetti plots of individual trajectories over four time points (T1–T4). The right column shows scatterplot matrices, where the diagonal panels represent the density plots of data at each time point. The lower triangle displays bivariate scatterplots between time-pairs, and the upper triangle provides the corresponding Pearson correlation coefficients (Corr). Top row (CS): Constant dispersion in trajectories and similar correlation magnitudes between all time-pairs suggest a compound symmetry structure. Middle row (AR(1)): A pattern of correlations decaying with increasing time lag (e.g., the correlation between T1 and T2 is higher than that between T1 and T4) indicates a first-order autoregressive structure. Bottom row (UN): Irregular dispersion across time points and inconsistent correlation patterns suggest unstructured covariance with potentially heterogeneous variances.
kja-25877f6.jpg
Table 1.
Sources of Variation and Error Terms in Two-way Repeated-measures Analysis of Variance
Source of variation Sum of squares (SS) Error term Tests/Comparisons
Between-subjects
 Group SS_Group SS_Subjects (within groups) Main effect of Group
 Subjects (within group) SS_Subjects (within groups) — Error term for Group
Within-subjects
 Time SS_Time SS_Residual (Time × Subject) Main effect of Time
 Group × Time SS_Group × Time SS_Residual (Time × Subject) Group-by-Time interaction
 Residual (Error) SS_Residual — Error term for Time and Interaction
Total (Between + Within) SS_Total — —
Table 2.
Advantages of Linear Mixed-effects Models Over Repeated-measures Analysis of Variance
Aspect Repeated measures ANOVA (RM-ANOVA) Linear mixed-effects model (LMM)
Handling of missing data Utilizes complete data only; cases with missing values are excluded Allows missing data under the missing-at-random assumption; estimation via likelihood-based methods
Unbalanced data Requires an equal number of observations at each time point (balanced design required) Allows a varying number of observations across subjects (supports unbalanced design)
Covariance structure Assumes sphericity Flexible specification of covariance structures (e.g., CS, UN, AR(1))
Practical suitability Less suitable for clinical data with missingness or dropout Well-suited for the complexities of real-world clinical longitudinal data

ANOVA: analysis of variance, LMM: linear mixed-effects model, CS: compound symmetry, UN: unstructured, AR(1): first-order autoregressive.

Table 3.
Common Structures for Residual Variance–covariance
Structure name Description Example matrix R (T = 4) No. of parameters
Independent (homogeneous variance) Errors are independent and have constant variance across time points σ21001000000001001 1 (σ2)
Compound symmetry (CS) Constant variance and equal covariance across all time points σ21ρρ1ρρρρρρρρ1ρρ1 2 (σ2, ρ)
Autoregressive (AR(1)) Correlation decays with increasing lag between time points σ2  1  ρρ  1ρ2ρ3ρρ2ρ2ρρ3ρ21  ρρ  1 2 (σ2, ρ)
Unstructured (UN) All variances and covariances are freely estimated σ12σ12σ12σ22σ13σ14σ23σ24σ13σ23σ14σ24σ32σ34σ34σ42 t (t + 1) / 2 = 10
Toeplitz Covariances depend only on the lag between time points (stationary pattern) σ2ρ1ρ1σ2ρ2ρ3ρ1ρ2ρ2ρ1ρ3ρ2σ2ρ1ρ1σ2 t = 4

References

1. Ashbeck EL, Bell ML. Single time point comparisons in longitudinal randomized controlled trials: power and bias in the presence of missing data. BMC Med Res Methodol 2016; 16: 43.
crossref pmid pmc pdf
2. Schober P, Vetter TR. Repeated measures designs and analysis of longitudinal data: if at first you do not succeed-try, try again. Anesth Analg 2018; 127: 569-75.
crossref pmid pmc
3. Gueorguieva R, Krystal JH. Move over ANOVA: progress in analyzing repeated-measures data and its reflection in papers published in the archives of general psychiatry. Arch Gen Psychiatry 2004; 61: 310-7.
crossref pmid
4. Sullivan LM. Repeated measures. Circulation 2008; 117: 1238-43.
crossref pmid
5. Muhammad LN. Guidelines for repeated measures statistical analysis approaches with basic science research considerations. J Clin Invest 2023; 133: e171058.
crossref pmid pmc
6. Carpenter JR, Smuk M. Missing data: a statistical framework for practice. Biom J 2021; 63: 915-47.
crossref pmid pmc pdf
7. Sterne JA, White IR, Carlin JB, Spratt M, Royston P, Kenward MG, et al. Multiple imputation for missing data in epidemiological and clinical research: potential and pitfalls. BMJ 2009; 338: b2393.
crossref pmid pmc
8. Haverkamp N, Beauducel A. Differences of type I error rates for ANOVA and multilevel-linear-models using SAS and SPSS for repeated measures designs. Meta-Psychology 2019; 3: MP.2018.898.
crossref pdf
9. Maas CJ, Hox JJ. Sufficient sample sizes for multilevel modeling. Methodology 2005; 1: 86-92.
crossref
10. Drikvandi R, Noorian S. Testing random effects in linear mixed-effects models with serially correlated errors. Biom J 2019; 61: 802-12.
crossref pmid pdf
11. Wang X, Andrinopoulou ER, Veen KM, Bogers AJ, Takkenberg JJ. Statistical primer: an introduction to the application of linear mixed-effects models in cardiothoracic surgery outcomes research-a case study using homograft pulmonary valve replacement data. Eur J Cardiothorac Surg 2022; 62: ezac429.
crossref pmid pmc pdf
12. Schielzeth H, Dingemanse NJ, Nakagawa S, Westneat DF, Allegue H, Teplitsky C, et al. Robustness of linear mixed-effects models to violations of distributional assumptions. Methods Ecol Evol 2020; 11: 1141-52.
crossref pdf
13. Fitzmaurice GM, Laird NM, Ware JH. Applied Longitudinal Analysis. 2nd ed. New Jersey, John Wiley & Sons, Inc. 2011, pp 124-34, 166-71, 187-240.

14. Faria R, Gomes M, Epstein D, White IR. A guide to handling missing data in cost-effectiveness analysis conducted within randomised controlled trials. Pharmacoeconomics 2014; 32: 1157-70.
crossref pmid pmc pdf
15. Gabrio A, Plumpton C, Banerjee S, Leurent B. Linear mixed models to handle missing at random data in trial-based economic evaluations. Health Econ 2022; 31: 1276-87.
crossref pmid pmc pdf
16. Gomes M, Radice R, Camarena Brenes J, Marra G. Copula selection models for non-Gaussian outcomes that are missing not at random. Stat Med 2019; 38: 480-96.
crossref pmid pdf
17. Elhakeem A, Hughes RA, Tilling K, Cousminer DL, Jackowski SA, Cole TJ, et al. Using linear and natural cubic splines, SITAR, and latent trajectory models to characterise nonlinear longitudinal growth trajectories in cohort studies. BMC Med Res Methodol 2022; 22: 68.
crossref pmid pmc pdf
18. Jackson AS, Janssen I, Sui X, Church TS, Blair SN. Longitudinal changes in body composition associated with healthy ageing: men, aged 20-96 years. Br J Nutr 2012; 107: 1085-91.
crossref pmid
19. Donohue MC, Aisen PS. Mixed model of repeated measures versus slope models in Alzheimer's disease clinical trials. J Nutr Health Aging 2012; 16: 360-4.
crossref pmid pmc pdf
20. Ukyo Y, Noma H, Maruo K, Gosho M. Improved small sample inference methods for a mixed-effects model for repeated measures approach in incomplete longitudinal data analysis. Stats 2019; 2: 174-88.
crossref
21. Liu GF, Lu K, Mogg R, Mallick M, Mehrotra DV. Should baseline be a covariate or dependent variable in analyses of change from baseline in clinical trials? Stat Med 2009; 28: 2509-30.
crossref pmid pdf
22. Lu K. On efficiency of constrained longitudinal data analysis versus longitudinal analysis of covariance. Biometrics 2010; 66: 891-6.
crossref pmid
23. Coffman CJ, Edelman D, Woolson RF. To condition or not condition? Analysing 'change' in longitudinal randomised controlled trials. BMJ Open 2016; 6: e013096.
crossref pmid pmc
24. White IR, Thompson SG. Adjusting for partially missing baseline measurements in randomized trials. Stat Med 2005; 24: 993-1007.
crossref pmid
25. Pusponegoro NH, Rachmawati RfN, Notodiputro KA, Sartono B. Linear mixed model for analyzing longitudinal data: a simulation study of children growth differences. Procedia Comput Sci 2017; 116: 284-91.
crossref
26. Littell RC, Pendergast J, Natarajan R. Modelling covariance structure in the analysis of repeated measures data. Stat Med 2000; 19: 1793-819.
crossref pmid
27. Gurka MJ, Edwards LJ, Muller KE. Avoiding bias in mixed model inference for fixed effects. Stat Med 2011; 30: 2696-707.
crossref pmid pmc pdf
28. Liu S, Rovine MJ, Molenaar PC. Selecting a linear mixed model for longitudinal data: repeated measures analysis of variance, covariance pattern model, and growth curve approaches. Psychol Methods 2012; 17: 15-30.
crossref pmid
29. Bell ML, Rabe BA. The mixed model for repeated measures for cluster randomized trials: a simulation study investigating bias and type I error with missing continuous data. Trials 2020; 21: 148.
crossref pmid pmc pdf


ABOUT
ARTICLE CATEGORY

Browse all articles >

BROWSE ARTICLES
AUTHOR INFORMATION
Editorial Office
101-3503, Lotte Castle President, 109 Mapo-daero, Mapo-gu, Seoul 04146, Korea
Tel: +82-2-792-5128    Fax: +82-2-792-4089    E-mail: journal@anesthesia.or.kr                
Business Name: Korean Society of Anesthesiologists
Business Registration: 106-82-07194
Representative: Young-Tae Jeon

Copyright © 2026 by Korean Society of Anesthesiologists.

Developed in M2PI

Close layer
prev next