Tutorials › Biostatistics › Random Slopes vs. Random Intercepts Explained

Longitudinal & Mixed Models

Random Slopes vs. Random Intercepts Explained

A practical guide to understanding random intercepts, random slopes, and random-intercept-and-slope models in linear mixed-effects analysis, with longitudinal clinical trial examples, model equations, interpretation, covariance structures, R, and SAS implementations.

Intermediate 18 min read

What You'll Learn

  • What a random intercept means and why subjects can have different baselines
  • What a random slope means and how subjects can have different trajectories
  • How random-intercept and random-slope models differ mathematically
  • How covariance between random intercepts and slopes is interpreted
  • How to compare models using likelihood, AIC, BIC, and variance components
  • How random slopes are implemented in R and SAS for longitudinal clinical data

Introduction

Longitudinal clinical data have a feature that ordinary linear regression does not handle naturally: the same patient is measured repeatedly over time.

A patient may have a high outcome value at baseline, while another patient may have a low baseline value. Even more importantly, patients may change at different rates during follow-up.

One patient might improve rapidly, another might improve slowly, and another might remain nearly unchanged.

Linear mixed-effects models provide a natural framework for representing these two sources of subject-to-subject heterogeneity.

The two most important random-effects concepts are:

  • Random intercepts: patients can start at different levels.
  • Random slopes: patients can change at different rates.
Key idea: A random intercept answers "Do subjects have different starting points?" A random slope answers "Do subjects have different rates of change?"

The Simplest Longitudinal Model

Suppose \(Y_{ij}\) is the outcome for patient \(i\) at visit \(j\), and \(t_{ij}\) represents time. A simple population-average regression model is:

$$ Y_{ij} = \beta_0+\beta_1t_{ij}+\varepsilon_{ij} $$

Here:

  • \(\beta_0\) is the population-average intercept.
  • \(\beta_1\) is the population-average slope.
  • \(\varepsilon_{ij}\) is the residual error.

This model assumes that every patient follows the same regression line, apart from residual measurement noise.

That assumption is often unrealistic.

Why Patients Need Their Own Random Effects

Consider two patients whose outcomes are measured at baseline, Week 4, Week 8, and Week 12.

Patient Baseline Week 4 Week 8 Week 12
A 80 75 70 65
B 60 58 56 54

Both patients decline over time at approximately the same rate, but Patient A starts substantially higher.

A model with a random intercept can represent this pattern naturally.

Now consider a different pair:

Patient Baseline Week 4 Week 8 Week 12
C 70 66 62 58
D 70 76 82 88

These patients start at the same level but have dramatically different trajectories.

A random slope is needed to represent this type of heterogeneity.

The distinction: Different baselines suggest a random intercept. Different trajectories suggest a random slope. Longitudinal clinical data often require both.

Random Intercept Model

The random-intercept model allows each subject to have an individual baseline deviation from the population-average intercept.

$$ Y_{ij} = \beta_0+\beta_1t_{ij}+b_{0i}+\varepsilon_{ij} $$

The subject-specific random intercept is:

$$ b_{0i}\sim N(0,\sigma_b^2) $$

Therefore, patient \(i\)'s intercept is:

$$ \beta_0+b_{0i} $$

Some patients have positive \(b_{0i}\), meaning they start above the population mean. Others have negative \(b_{0i}\), meaning they start below it.

Visual Interpretation of a Random Intercept

Imagine plotting every patient's outcome against time.

With a random intercept but a fixed slope, the fitted subject-specific lines are approximately parallel.

1
Patient A: starts above the population line.
2
Patient B: starts close to the population line.
3
Patient C: starts below the population line.
4
All patients share the same fixed time slope \(\beta_1\).

Thus, the random intercept changes the vertical position of each subject's trajectory without changing its slope.

Random Slope Model

A random-slope model allows patients to have different rates of change.

$$ Y_{ij} = \beta_0+\beta_1t_{ij}+b_{1i}t_{ij}+\varepsilon_{ij} $$

The patient-specific slope is:

$$ \beta_1+b_{1i} $$

where:

$$ b_{1i}\sim N(0,\sigma_{b1}^2) $$

A positive random slope means the patient changes faster in the positive direction than the population-average trajectory. A negative random slope means the patient changes more slowly or declines more strongly, depending on the outcome and coding of time.

Random Intercept and Random Slope Together

In many longitudinal applications, the most useful model includes both random effects:

$$ Y_{ij} = \beta_0+\beta_1t_{ij} + b_{0i} + b_{1i}t_{ij} + \varepsilon_{ij} $$

The subject-specific intercept is:

$$ \beta_0+b_{0i} $$

and the subject-specific slope is:

$$ \beta_1+b_{1i} $$

This model allows both the starting level and the trajectory to vary between patients.

This is the key mixed-model structure: Random intercepts capture between-subject differences in level. Random slopes capture between-subject differences in change over the covariate.

Comparing the Three Basic Models

Model Patient-Specific Intercept Patient-Specific Slope Trajectory Shape
Fixed effects only No No Same line for everyone
Random intercept Yes No Parallel lines
Random slope Usually fixed intercept unless otherwise specified Yes Different slopes
Random intercept + slope Yes Yes Different starting points and trajectories

What Does "Random" Actually Mean?

The word random can be confusing.

It does not mean that the patient's baseline or slope was randomly selected from an arbitrary distribution for the purposes of the study.

Instead, the model treats the subject-specific deviations as realizations from a probability distribution.

For a random intercept:

$$ b_{0i}\sim N(0,\sigma_0^2) $$

For a random slope:

$$ b_{1i}\sim N(0,\sigma_1^2) $$

The variances \(\sigma_0^2\) and \(\sigma_1^2\) describe how much subjects differ from one another.

Random Effects Are Not the Same as Fixed Effects

A fixed effect describes a systematic population-level association. For example:

$$ \beta_1 = \text{population-average change per unit increase in time} $$

A random slope describes how individual subjects deviate around that average:

$$ b_{1i} = \text{subject-specific deviation from the population slope} $$
Effect Question Answered
Fixed intercept What is the average outcome at the reference value of time?
Fixed slope What is the average rate of change?
Random intercept How much do subjects differ in their baseline levels?
Random slope How much do subjects differ in their rates of change?

The Random-Effects Covariance Matrix

When both a random intercept and a random slope are included, they may be correlated.

The random-effects vector is:

$$ \mathbf b_i = \begin{pmatrix} b_{0i}\\ b_{1i} \end{pmatrix} $$

Its covariance matrix is:

$$ \mathbf G = \begin{pmatrix} \sigma_0^2 & \sigma_{01}\\ \sigma_{01} & \sigma_1^2 \end{pmatrix} $$

Here:

  • \(\sigma_0^2\) is the random-intercept variance.
  • \(\sigma_1^2\) is the random-slope variance.
  • \(\sigma_{01}\) is the intercept-slope covariance.

The corresponding correlation is:

$$ \rho_{01} = \frac{\sigma_{01}} {\sigma_0\sigma_1} $$

How to Interpret the Intercept-Slope Correlation

Suppose the estimated intercept-slope correlation is positive.

This means patients with higher-than-average random intercepts tend, under the model, to have higher-than-average random slopes.

A negative correlation means that patients with higher intercepts tend to have lower slopes.

However, interpretation depends critically on where time is centered.

Centering matters: The random intercept represents the expected subject-specific outcome at \(t=0\). If \(t=0\) is baseline, the intercept has a natural clinical interpretation. If time is centered at Week 8, the random intercept instead represents the subject-specific level at Week 8.

Why Time Centering Can Change the Random-Effects Correlation

Suppose time is originally coded as:

$$ 0,\;4,\;8,\;12 $$

Now center time at Week 8:

$$ -8,\;-4,\;0,\;4 $$

The fixed-effects predictions do not fundamentally change merely because of this reparameterization, but the interpretation of the intercept changes.

More importantly, the estimated covariance between the random intercept and random slope can change substantially.

This is not necessarily a problem.

The correlation is partly determined by the location at which the intercept is defined.

A Simple Clinical Example

Suppose a clinical trial measures a continuous biomarker at baseline, Week 4, Week 8, and Week 12. The population-average model is:

$$ Y_{ij} = \beta_0+\beta_1t_{ij} + b_{0i} + b_{1i}t_{ij} + \varepsilon_{ij} $$

Suppose the fixed effects are estimated as:

$$ \hat\beta_0=100 $$
$$ \hat\beta_1=-2.0 $$

The average patient therefore has an expected biomarker value of 100 at baseline and declines by approximately 2 units per week.

Now suppose Patient A has:

$$ \hat b_{0A}=8 \qquad \hat b_{1A}=-0.5 $$

Patient A's estimated trajectory is:

$$ \hat Y_A(t) = (100+8)+(-2.0-0.5)t $$

or:

$$ \hat Y_A(t) = 108-2.5t $$

Patient A starts above the population-average trajectory and declines faster than average.

Another Patient

Suppose Patient B has:

$$ \hat b_{0B}=-6 \qquad \hat b_{1B}=0.8 $$

Then:

$$ \hat Y_B(t) = (100-6)+(-2.0+0.8)t $$

so:

$$ \hat Y_B(t) = 94-1.2t $$

Patient B starts below average but declines more slowly than average.

Interpretation: The fixed effects describe the average trajectory. The random effects describe how individual patients depart from that average trajectory.

Random Intercept Only: When Is It Appropriate?

A random-intercept model is appropriate when there is meaningful between-subject heterogeneity in baseline level but insufficient evidence that the slopes vary substantially.

For example, suppose every patient tends to improve by approximately the same amount over time, but patients begin at different baseline values.

The model:

$$ Y_{ij} = \beta_0+\beta_1t_{ij}+b_{0i}+\varepsilon_{ij} $$

can represent that structure efficiently.

Random Slope: When Is It Appropriate?

A random slope becomes useful when the trajectory itself varies substantially between subjects.

Examples include:

  • Patients responding to treatment at different rates
  • Different rates of disease progression
  • Different rates of biomarker recovery
  • Different growth or decline trajectories
  • Repeated measurements where subject-specific trends are evident

The model then becomes:

$$ Y_{ij} = \beta_0+\beta_1t_{ij}+b_{1i}t_{ij}+\varepsilon_{ij} $$

In practice, however, random slopes are often included together with random intercepts.

Why Random Slopes Matter for Longitudinal Data

Consider a trial in which every patient is measured repeatedly. If the true patient trajectories have different slopes but the model includes only a random intercept, the model is forcing all subjects to have the same underlying rate of change.

That can be too restrictive.

The residual structure may then be asked to absorb systematic subject-specific trajectory differences that should instead be represented by random effects.

Practical principle: If patients visibly follow different trajectories over time, a random-intercept-only model may be inadequate even when it captures baseline heterogeneity well.

Random Slopes Do Not Automatically Solve Correlation

Another common misconception is that adding a random slope automatically provides the correct covariance structure for all repeated observations.

It does not.

In a linear mixed model:

$$ \mathbf Y_i = \mathbf X_i\boldsymbol\beta + \mathbf Z_i\mathbf b_i + \boldsymbol\varepsilon_i $$

The marginal covariance is:

$$ \operatorname{Var}(\mathbf Y_i) = \mathbf Z_i\mathbf G\mathbf Z_i^\top + \mathbf R_i $$

The random-effects structure contributes covariance through \(\mathbf Z_i\mathbf G\mathbf Z_i^\top\), while the residual covariance matrix \(\mathbf R_i\) can provide additional within-subject correlation.

Important distinction: Random effects and residual covariance structures are related but are not the same modeling component. A random slope describes heterogeneity in subject trajectories; the residual covariance structure describes remaining within-subject dependence after accounting for those random effects.

Random Effects vs. Residual Covariance

Component Primary Role
Random intercept Subject-specific baseline heterogeneity
Random slope Subject-specific trajectory heterogeneity
Intercept-slope covariance Association between baseline level and trajectory
Residual variance Unexplained observation-level variability
Residual covariance Remaining within-subject correlation

Geometric Interpretation

The distinction becomes especially intuitive when visualizing fitted lines.

A random-intercept model produces lines that differ primarily by vertical position:

I
Same slope, different starting values.
II
The lines are approximately parallel.

A random-slope model produces lines that can rotate around a reference point:

I
Subjects can have different rates of change.
II
The lines are no longer required to be parallel.

A random-intercept-and-slope model allows both behaviors simultaneously.

Why a Random Slope Can Improve the Model

Suppose the true data-generating process contains subject-specific slopes. The random-intercept-only model assumes:

$$ \text{Slope}_i=\beta_1 \qquad\text{for every subject }i $$

The random-slope model instead assumes:

$$ \text{Slope}_i=\beta_1+b_{1i} $$

The second model allows the data to estimate a population distribution of subject-specific slopes.

Variance Components Tell You Whether Slopes Vary

In a random-slope model, the random-slope variance is:

$$ \sigma_1^2 = \operatorname{Var}(b_{1i}) $$

A larger value indicates greater heterogeneity in subject-specific slopes.

If the estimated variance is very small, the data may provide little evidence for meaningful slope heterogeneity.

Caution: A variance estimate close to zero does not automatically prove that a random slope is inappropriate. Boundary estimates can occur because of limited information, sparse measurements, or too few subjects.

Why Random Slopes Need Enough Repeated Measurements

A random slope requires information about how an individual changes over the covariate.

With only one observation per subject, there is no subject-specific trajectory from which to estimate a slope.

With two observations per subject, a slope is mathematically identifiable in a simple setting, but estimation can still be unstable.

More repeated measurements generally provide more information about the individual trajectory.

Repeated Measurements per Subject Random Slope Information
1 Cannot estimate an individual trajectory
2 Limited slope information
3–4 More useful for trajectory estimation
Many Typically more information, assuming adequate spread in time

The number of subjects also matters because the random-effects distribution is estimated from the population of subjects.

The Role of the Number of Subjects

A random-effects variance is a population-level parameter.

Therefore, estimating it reliably requires information across many subjects, not merely many observations from one subject.

Two dimensions of information matter: Repeated observations help characterize individual trajectories, while the number of independent subjects helps estimate the population distribution of those trajectories.

Random Intercept vs. Random Slope: A Clinical Interpretation

Question Random Intercept Random Slope
Do patients differ at baseline? Yes Not necessarily
Do patients differ in rate of change? No Yes
Can trajectories be nonparallel? No Yes
Requires repeated measurements? Yes for longitudinal interpretation Especially important
Typical use Baseline heterogeneity Trajectory heterogeneity

A Complete Longitudinal Example

Suppose a clinical trial measures a disease severity score at baseline, Week 4, Week 8, and Week 12. The outcome is modeled as a function of time and treatment group.

A fixed-effects model might be:

$$ Y_{ij} = \beta_0 + \beta_1 t_{ij} + \beta_2 T_i + \beta_3(t_{ij}T_i) + \varepsilon_{ij} $$

Here:

  • \(T_i\) indicates treatment group.
  • \(\beta_1\) represents the average time trend in the reference group.
  • \(\beta_3\) represents the treatment-by-time interaction.

Now suppose patients differ in their baseline severity and in their rates of change. A random-intercept-and-slope model becomes:

$$ Y_{ij} = \beta_0 + \beta_1t_{ij} + \beta_2T_i + \beta_3(t_{ij}T_i) + b_{0i} + b_{1i}t_{ij} + \varepsilon_{ij} $$

This is often a much more realistic representation of longitudinal patient data.

What the Treatment-by-Time Interaction Means

The random slope does not replace the treatment-by-time interaction.

These terms answer different questions.

Term Question
Fixed time effect What is the average time trend?
Treatment effect How do groups differ at the reference time?
Treatment × time Do groups have different average trajectories?
Random intercept How do individual baseline levels vary?
Random slope How do individual trajectories vary around the average trajectory?
Critical distinction: A fixed treatment-by-time interaction describes a systematic difference in average trajectories between treatment groups. A random slope describes subject-to-subject variation around the population-average trajectory.

R: Random Intercept with lme4

The R package lme4 uses a compact formula notation for mixed models. A random intercept for subject is specified as:

library(lme4)

fit_ri <- lmer(
  outcome ~ time + (1 | subject),
  data = dat
)

The expression:

(1 | subject)

means that each subject receives a subject-specific random intercept.

R: Random Slope with lme4

A random slope for time is specified as:

fit_rs <- lmer(
  outcome ~ time + (0 + time | subject),
  data = dat
)

The expression:

(0 + time | subject)

specifies a random slope without a random intercept in that random-effects term.

This is not usually the first model considered for longitudinal clinical data, because baseline heterogeneity is often important.

R: Random Intercept and Random Slope

The most common specification is:

fit_ri_rs <- lmer(
  outcome ~ time + (1 + time | subject),
  data = dat
)

The expression:

(1 + time | subject)

means that each subject has both:

  • a random intercept, and
  • a random slope for time,

with their covariance estimated by default.

R: Random Intercept and Slope Without Their Covariance

Sometimes a model may specify independent random intercepts and slopes:

fit_independent <- lmer(
  outcome ~ time +
    (1 | subject) +
    (0 + time | subject),
  data = dat
)

This corresponds to setting the intercept-slope covariance to zero.

The distinction is important:

R Formula Random-Effects Structure
(1 | subject) Random intercept only
(0 + time | subject) Random slope only
(1 + time | subject) Random intercept + random slope + covariance
(1 | subject) + (0 + time | subject) Random intercept + random slope, covariance fixed to zero

Inspecting Random Effects in R

summary(fit_ri_rs)

VarCorr(fit_ri_rs)

The VarCorr() output provides estimates of the random-intercept variance, random-slope variance, and their covariance or correlation.

Subject-specific empirical Bayes estimates can be obtained with:

ranef(fit_ri_rs)

These are often useful for understanding individual trajectories, but they should not be interpreted as if each subject's random effect were estimated with no uncertainty.

Fixed-Effect Interpretation in a Random-Slope Model

Suppose the model is:

outcome ~ time + (1 + time | subject)

The coefficient for time is still the population-average fixed time effect, subject to the model's parameterization and the interpretation of the fixed-effects model.

The random slope does not mean that the fixed time effect is no longer useful. Instead:

$$ \text{subject-specific slope}_i = \beta_1+b_{1i} $$

The population fixed slope \(\beta_1\) describes the center of the subject-specific slope distribution under the model.

SAS: PROC MIXED Random Intercept

In SAS, a random intercept can be specified using the RANDOM statement:

proc mixed data=dat method=reml;
    class subject;
    model outcome = time / solution;
    random intercept / subject=subject;
run;

This estimates a subject-specific random intercept.

SAS: PROC MIXED Random Intercept and Slope

A random intercept and random time slope can be specified as:

proc mixed data=dat method=reml;
    class subject;
    model outcome = time / solution;
    random intercept time / subject=subject type=un;
run;

The TYPE=UN option specifies an unstructured covariance matrix for the random intercept and random slope.

For two random effects, the matrix is:

$$ \mathbf G = \begin{pmatrix} \sigma_0^2 & \sigma_{01}\\ \sigma_{01} & \sigma_1^2 \end{pmatrix} $$

SAS: Independent Random Intercept and Slope

If the intercept and slope are assumed independent, the random-effects covariance can be constrained:

proc mixed data=dat method=reml;
    class subject;
    model outcome = time / solution;
    random intercept time / subject=subject type=vc;
run;

The appropriate covariance specification should be selected based on the scientific structure and supported by the available data.

Random Effects and Time Coding

Suppose time is coded in weeks:

$$ 0,\;4,\;8,\;12 $$

The intercept represents the expected outcome at baseline.

If instead time is coded as:

$$ -6,\;-2,\;2,\;6 $$

then the intercept represents the expected outcome at the midpoint of the study's time scale, not baseline.

This can improve numerical interpretation and sometimes reduce correlation between random intercepts and slopes.

Best practice: Choose the zero point of time deliberately. In clinical longitudinal analyses, baseline-centered time is often easiest to interpret, while midpoint-centered time can sometimes improve numerical conditioning and make intercept-slope correlation easier to estimate.

Model Comparison: Random Intercept vs. Random Slope

Suppose you fit:

fit_ri <- lmer(
  outcome ~ time + (1 | subject),
  data = dat,
  REML = FALSE
)

fit_ri_rs <- lmer(
  outcome ~ time + (1 + time | subject),
  data = dat,
  REML = FALSE
)

You may compare the models using a likelihood ratio test:

anova(fit_ri, fit_ri_rs)

A substantially improved likelihood for the more complex model can provide evidence that the random slope adds useful information.

Important: Likelihood-ratio comparisons involving different fixed-effects specifications should generally be performed using maximum likelihood rather than REML. When the fixed-effects structure is identical, REML-based comparisons of different random-effects structures are commonly used, although boundary issues require care.

AIC and BIC

Information criteria provide another way to compare models.

$$ AIC=-2\ell+2k $$

where \(\ell\) is the maximized log-likelihood and \(k\) is the number of estimated parameters.

Lower AIC indicates a preferred tradeoff between model fit and complexity according to the AIC criterion.

BIC imposes a stronger penalty for model complexity:

$$ BIC=-2\ell+k\log(n) $$

Neither AIC nor BIC should be treated as an automatic scientific decision rule.

Do Not Choose a Random Slope Solely by P-Value

A common mistake is to fit a random slope and ask only whether its estimated variance has a conventional p-value below 0.05.

Variance parameters are constrained to be nonnegative, meaning that testing whether a variance equals zero is a boundary problem.

Consequently, standard regularity conditions for ordinary likelihood-ratio tests do not apply without qualification.

Model selection should consider:

  • Scientific plausibility
  • Study design
  • Number and timing of repeated measurements
  • Variance estimates
  • Model convergence
  • Likelihood and information criteria
  • Residual diagnostics
  • Impact on the scientific conclusions

Singular Fits

A random-intercept-and-slope model can sometimes be too complex for the data. In R, lme4 may report a singular fit.

For example:

isSingular(
  fit_ri_rs,
  tol = 1e-4
)

A singular fit can occur when one or more random-effects variance components are estimated at or extremely close to the boundary of the parameter space.

It may indicate that:

  • The random-effects structure is too complex.
  • There is insufficient information to estimate all components.
  • The random intercept and slope are estimated as nearly perfectly correlated.
  • The data do not support the assumed heterogeneity.
Do not ignore convergence warnings. A model that technically produces coefficient estimates may still be poorly identified or numerically unstable.

The Problem of Near-Perfect Correlation

Suppose the estimated random-intercept/random-slope correlation is:

$$ \hat\rho_{01}\approx-0.99 $$

This can be a warning sign.

It may occur because the time scale is poorly centered relative to the observed measurements.

For example, if all observations occur at positive time values and the intercept corresponds to a time point far outside the observed range, the estimated intercept and slope can become strongly correlated.

Centering time closer to the middle of the observation window can sometimes improve this situation.

Random Slopes and Sparse Visit Schedules

Clinical trials often have a small number of scheduled visits. For example:

Visit Time
Baseline 0
Week 4 4
Week 8 8
Week 12 12

A linear random slope assumes that subject-specific trajectories are adequately approximated by a straight line over this time interval.

That assumption should be considered separately from whether a random slope is statistically useful.

Two separate questions: 1. Do patients differ in their rates of change? 2. Is a straight-line trajectory an adequate representation of change over time? A random slope answers the first question. It does not automatically answer the second.

Random Slopes Are Not a Substitute for Nonlinear Time

Suppose the average trajectory is curved. A model such as:

$$ Y_{ij} = \beta_0+\beta_1t_{ij} +b_{0i}+b_{1i}t_{ij} +\varepsilon_{ij} $$

allows patients to have different linear slopes, but the population-average trajectory is still linear in time.

If the scientific trajectory is nonlinear, alternatives include:

  • Polynomial time terms
  • Splines
  • Categorical visit effects
  • Piecewise-linear models
  • Nonlinear mixed-effects models

Random Slope with a Quadratic Fixed Effect

For example, a model could include a quadratic population-average trajectory:

$$ Y_{ij} = \beta_0 + \beta_1t_{ij} + \beta_2t_{ij}^2 + b_{0i} + b_{1i}t_{ij} + \varepsilon_{ij} $$

Here, the average trajectory can curve while individual subjects still have different linear deviations in slope.

Random Slopes for Treatment Groups

Another important distinction concerns the level at which a random effect is defined.

Suppose patients are nested within treatment groups. A subject-level random slope might be:

(1 + time | subject)

This says that individual patients have different trajectories.

It does not mean that treatment groups have random slopes.

A group-level random effect would be specified at the group level, if the study design and inferential goals justify treating groups as a random sample from a larger population of groups.

Random Slopes in Multilevel Data

The same concept extends beyond patients. For example, observations might be clustered within:

  • Patients
  • Clinics
  • Hospitals
  • Physicians
  • Study sites

A random slope can represent heterogeneity in the relationship between a covariate and the outcome across the relevant clustering units.

For example, a multicenter study might allow the time trend to vary by site:

outcome ~ time + (1 + time | site)

This asks a different scientific question from a patient-level random slope.

Subject-Level vs. Site-Level Random Slopes

Random Effect Interpretation
(1 + time | subject) Patients have different trajectories
(1 + time | site) Sites have different time trends
(1 | subject) Patients have different baseline levels
(1 | site) Sites have different baseline levels

Common Misconception: "Random Intercept Means Baseline Is Random"

The phrase "random intercept" does not necessarily mean that the observed baseline measurement itself is modeled as a random effect.

Rather, the random intercept represents a subject-specific latent deviation from the population-average intercept.

Observed baseline measurements also contain residual or measurement error depending on the model.

Common Misconception: "Random Slope Means Time Is Random"

A random slope does not mean that time is random.

Time is typically treated as an observed covariate.

The term random refers to the subject-specific coefficient multiplying time:

$$ \beta_1+b_{1i} $$

Common Misconception: "Random Slopes Are Always Better"

A more complex random-effects structure is not automatically better.

Adding a random slope introduces additional variance and covariance parameters.

If the data contain insufficient information to estimate those parameters, the model can become unstable or singular.

The goal is not to maximize complexity.

The goal is to specify a random-effects structure that is scientifically reasonable and supported by the data.

Common Mistakes

  1. Using a random intercept when trajectories clearly differ. This can force all subjects to share the same rate of change.
  2. Adding a random slope automatically. A random slope requires sufficient information and should have a scientific justification.
  3. Ignoring the intercept-slope covariance. When both effects are included, their covariance can be important.
  4. Ignoring time centering. The meaning and numerical behavior of the random effects depend on the time origin.
  5. Confusing random slopes with treatment-by-time interactions. One describes individual heterogeneity; the other describes average group differences.
  6. Ignoring convergence or singular-fit warnings. A model that fails numerically should not simply be reported without investigation.
  7. Assuming a random slope handles all within-subject correlation. The residual covariance structure may still be important.
  8. Interpreting empirical Bayes random effects as error-free patient parameters. Subject-specific random-effect estimates are predictions with uncertainty.
  9. Using a random slope to model curvature. Random slopes allow subject-specific linear deviations; they do not create a nonlinear population trajectory.

A Practical Model-Building Strategy

1
Understand the longitudinal outcome and measurement schedule.
2
Define the fixed-effects scientific question.
3
Decide what subject-level heterogeneity should be represented.
4
Fit a scientifically reasonable random-intercept model.
5
Evaluate whether subject-specific trajectories plausibly vary.
6
Consider adding a random slope for time.
7
Evaluate the intercept-slope covariance.
8
Check convergence, singularity, and variance estimates.
9
Evaluate the residual covariance structure separately.
10
Compare scientifically plausible candidate models.
11
Inspect fitted trajectories and residual diagnostics.
12
Prespecify the final model and interpretation in the analysis plan when appropriate.

How to Think About the Model in One Picture

Question Model Component
Where does the average trajectory start? Fixed intercept
How does the average trajectory change? Fixed slope
Do subjects start at different levels? Random intercept
Do subjects change at different rates? Random slope
Are high-baseline subjects systematically different in trajectory? Intercept-slope covariance
What dependence remains after random effects? Residual covariance structure

Random Intercept vs. Random Slope: The Core Equations

The fixed-effects-only model is:

$$ Y_{ij} = \beta_0+\beta_1t_{ij}+\varepsilon_{ij} $$

The random-intercept model is:

$$ Y_{ij} = \beta_0+\beta_1t_{ij}+b_{0i}+\varepsilon_{ij} $$

The random-slope model is:

$$ Y_{ij} = \beta_0+\beta_1t_{ij}+b_{1i}t_{ij}+\varepsilon_{ij} $$

The random-intercept-and-slope model is:

$$ Y_{ij} = \beta_0+\beta_1t_{ij} +b_{0i} +b_{1i}t_{ij} +\varepsilon_{ij} $$

The final model is often the most flexible of these basic specifications, but flexibility must be balanced against identifiability and model stability.

What Changes When You Add a Random Slope?

Feature Random Intercept Random Intercept + Slope
Random-effect parameters 1 variance 2 variances + covariance
Baseline heterogeneity Yes Yes
Trajectory heterogeneity No Yes
Parallel subject trajectories Approximately yes No
Model complexity Lower Higher
Data requirements Lower Higher

Why the Random Slope Can Change Standard Errors

Adding a random slope changes the assumed covariance structure of repeated observations.

Consequently, estimated standard errors of fixed effects can change even when the fixed-effect estimates themselves change only modestly.

This is one reason random-effects specification matters for clinical inference.

The model is not simply a descriptive device for drawing individual lines. It determines the assumed dependence structure used to estimate uncertainty.

Inference matters: An inappropriate covariance or random-effects structure can lead to inefficient or misleading standard errors even when the estimated mean trajectory appears reasonable.

Random Slope and Treatment Effect Interpretation

Suppose treatment is represented by \(T_i\), and the model contains a treatment-by-time interaction:

$$ Y_{ij} = \beta_0 + \beta_1t_{ij} + \beta_2T_i + \beta_3T_it_{ij} + b_{0i} + b_{1i}t_{ij} + \varepsilon_{ij} $$

For the reference treatment group, the population-average slope is:

$$ \beta_1 $$

For the treatment group, the population-average slope is:

$$ \beta_1+\beta_3 $$

The treatment-by-time interaction \(\beta_3\) therefore describes the difference in average slopes between treatment groups.

The random slope \(b_{1i}\) represents additional patient-level variation around those average trajectories.

Random Slopes and Missing Data

One important reason mixed models are frequently used in longitudinal clinical trials is their ability to use incomplete repeated-measures records under appropriate missing-data assumptions.

For example, a patient may have measurements at:

$$ 0,\;4,\;8 $$

but miss Week 12.

A mixed model can still use the available observations without requiring the patient to have a complete trajectory.

However, the missing-data assumptions remain important.

Important: Including a random slope does not make missing data ignorable under every possible missingness mechanism. The validity of the analysis still depends on the assumed missing-data process and the overall analysis strategy.

When a Random Intercept May Be Enough

A random-intercept model may be reasonable when:

  • Patients clearly differ in baseline levels.
  • Individual trajectories appear approximately parallel.
  • The random-slope variance is negligible or poorly supported.
  • The study has limited repeated-measures information.
  • The simpler covariance structure provides an adequate representation of the data.

When Random Intercepts and Slopes Are More Appropriate

A random-intercept-and-slope model is attractive when:

  • Patients have different baseline levels.
  • Patients have meaningfully different rates of change.
  • The measurement schedule provides sufficient information about trajectories.
  • The model converges reliably.
  • The estimated variance components are interpretable and stable.
  • The richer covariance structure materially improves the model.

A Compact Decision Framework

Observed Pattern Candidate Structure
Same baseline, same trajectory Fixed-effects model
Different baselines, similar trajectories Random intercept
Similar baselines, different trajectories Random slope may be useful
Different baselines and trajectories Random intercept + random slope
Strong curvature over time Consider nonlinear fixed-effects structure
Random-effects model unstable Reconsider complexity and time coding

The Most Important Concept

The distinction between random intercepts and random slopes can be reduced to one simple question:

Random intercept: Do individuals have different starting levels?

Random slope: Do individuals have different rates of change?

In a longitudinal clinical trial, both are often scientifically plausible.

The random intercept allows each patient to begin at a different level:

$$ \text{intercept}_i = \beta_0+b_{0i} $$

The random slope allows each patient to follow a different trajectory:

$$ \text{slope}_i = \beta_1+b_{1i} $$

Together:

$$ Y_{ij} = \beta_0+\beta_1t_{ij} +b_{0i}+b_{1i}t_{ij} +\varepsilon_{ij} $$

This model separates the population-average trajectory from individual patient-level deviations.

Final Practical Checklist

  • Identify the subject or cluster for which repeated observations are dependent.
  • Ask whether subjects differ in their baseline levels.
  • Ask whether subjects differ in their rates of change.
  • Choose the time origin deliberately.
  • Consider whether intercept and slope should be correlated.
  • Check whether enough repeated measurements exist to support a random slope.
  • Evaluate the estimated variance components.
  • Check convergence and singularity diagnostics.
  • Consider the residual covariance structure separately.
  • Do not confuse random slopes with treatment-by-time interactions.
  • Do not use random slopes simply because a more complex model seems preferable.
  • Interpret fixed effects and random effects as answering different scientific questions.
Bottom line: Random intercepts model differences in where subjects start. Random slopes model differences in how subjects change. A random-intercept-and-slope model allows both baseline heterogeneity and trajectory heterogeneity, and can be especially useful for longitudinal clinical trial data. The choice should be driven by the scientific structure of the data, the repeated-measure schedule, model stability, and the covariance patterns that the study can realistically support.

References

Laird, N.M. & Ware, J.H. (1982). Random-effects models for longitudinal data. Biometrics, 38(4), 963–974.
Verbeke, G. & Molenberghs, G. (2000). Linear Mixed Models for Longitudinal Data. Springer.
Fitzmaurice, G.M., Laird, N.M. & Ware, J.H. (2011). Applied Longitudinal Analysis, 2nd ed. Wiley.
Pinheiro, J.C. & Bates, D.M. (2000). Mixed-Effects Models in S and S-PLUS. Springer.
West, B.T., Welch, K.B. & Galecki, A.T. (2014). Linear Mixed Models: A Step-by-Step Approach, 2nd ed. CRC Press.
Bates, D., Mächler, M., Bolker, B. & Walker, S. (2015). Fitting linear mixed-effects models using lme4. Journal of Statistical Software, 67(1), 1–48.