Introduction
Clinical-trial data frequently violate the assumptions of ordinary regression models.
Patients may contribute multiple observations over time. Patients may be clustered within centers. Subjects may contribute correlated binary outcomes. Counts may be overdispersed. Ordinal outcomes may have a natural ordering but cannot reasonably be analyzed with ordinary linear regression.
These situations require models that can account for both the distribution of the response and the dependence among observations.
PROC GLIMMIX is SAS's general-purpose procedure for fitting generalized linear mixed models and performing inference for them.
What Is a Generalized Linear Mixed Model?
A generalized linear mixed model, or GLMM, has three important components:
- A probability distribution for the response.
- A link function connecting the expected response to the predictors.
- Fixed and random effects describing systematic and subject-specific variation.
Conceptually, the model can be written as:
where:
- \(g(\cdot)\) is the link function
- \(\mu_{ij}=E(Y_{ij}\mid b_i)\)
- \(\boldsymbol{\beta}\) contains fixed-effect parameters
- \(\mathbf{b}_i\) contains random effects for subject or cluster \(i\)
- \(\mathbf{x}_{ij}\) and \(\mathbf{z}_{ij}\) are design vectors
The random effects introduce dependence among observations from the same subject or cluster.
Why Not Just Use PROC LOGISTIC?
PROC LOGISTIC is an excellent procedure for ordinary logistic regression.
However, ordinary logistic regression assumes that the observations are independent, conditional on the fixed effects in the model.
Suppose every patient has four visits:
These observations are generally not independent because they come from the same patient.
A patient's treatment response at Week 8 is likely related to that same patient's response at Week 12.
PROC GLIMMIX allows the analysis to model this within-subject dependence.
| Procedure | Typical Use |
|---|---|
| PROC LOGISTIC | Independent binary or ordinal observations |
| PROC GENMOD | Generalized linear models; some correlated-data approaches |
| PROC MIXED | Continuous approximately normal mixed models |
| PROC GLIMMIX | Generalized mixed models with random effects and flexible covariance structures |
PROC GLIMMIX Can Also Fit Ordinary Linear Mixed Models
An important conceptual point is that GLMMs include ordinary linear mixed models as a special case.
If the response is normally distributed and the identity link is used, the model becomes a conventional linear mixed model.
Thus, PROC GLIMMIX overlaps with PROC MIXED.
This does not mean that the two procedures should be treated as completely interchangeable. Their syntax and default approaches can differ, especially when modeling residual covariance structures.
The Basic PROC GLIMMIX Structure
A minimal PROC GLIMMIX program often looks like this:
proc glimmix data=analysis;
class treatment sex;
model response =
treatment
sex
age
/ dist=binary
link=logit;
run;
The major statements are:
| Statement | Purpose |
|---|---|
| PROC GLIMMIX | Starts the procedure and identifies the input dataset |
| CLASS | Identifies categorical variables |
| MODEL | Defines the response and fixed effects |
| RANDOM | Defines random effects or residual covariance structures |
| LSMEANS | Requests estimated marginal means and comparisons |
| CONTRAST | Tests specified linear combinations of fixed effects |
| ESTIMATE | Estimates specified linear combinations |
| OUTPUT | Creates an output dataset containing requested statistics |
The CLASS Statement
Categorical predictors generally belong in the CLASS statement.
proc glimmix data=analysis;
class usubjid treatment visit sex;
...
run;
For a clinical-trial dataset, variables such as:
- Treatment arm
- Visit
- Sex
- Region
- Study center
- Subject identifier
may need to be treated as classification variables depending on their role in the model.
The MODEL Statement
The MODEL statement defines the response and fixed effects.
model response =
treatment
visit
treatment*visit
baseline
/ dist=binary
link=logit;
Here:
responseis the dependent variable.treatmentis a fixed treatment effect.visitis a fixed visit effect.treatment*visittests whether treatment effects differ by visit.baselineis a continuous adjustment covariate.dist=binaryspecifies a binary response.link=logitspecifies the logit link.
Distributions
One of the defining features of PROC GLIMMIX is the ability to select an appropriate response distribution.
| Distribution | Typical Outcome |
|---|---|
| Normal | Continuous approximately normal response |
| Binary | Yes/no, responder/non-responder |
| Binomial | Number of successes out of a number of trials |
| Poisson | Event counts or rates |
| Negative binomial | Overdispersed count data |
| Gamma | Positive continuous skewed outcomes |
| Multinomial | Nominal multi-category outcomes |
| Ordinal models | Ordered categorical outcomes |
The correct distribution should be determined from the scientific nature of the response and the statistical analysis plan rather than selected solely because a particular model converges.
Link Functions
The link function connects the expected response to the linear predictor.
Common examples include:
| Outcome | Common Link | Interpretation |
|---|---|---|
| Binary | Logit | Log odds |
| Count | Log | Log expected count or rate |
| Normal | Identity | Mean response |
| Gamma | Log | Log mean response |
Binary Outcomes
Binary outcomes are one of the most common applications of PROC GLIMMIX in clinical research.
Examples include:
- Responder versus non-responder
- Occurrence versus non-occurrence of an adverse event
- Remission versus no remission
- Successful versus unsuccessful treatment outcome
A basic logistic GLMM is:
proc glimmix data=analysis;
class treatment usubjid;
model response(event='1') =
treatment
/ dist=binary
link=logit;
random intercept / subject=usubjid;
run;
The random intercept allows each subject to have their own underlying propensity for the outcome.
Interpreting the Logistic Model
Suppose the treatment coefficient is:
Because the model uses a logit link, exponentiating the coefficient gives an odds ratio:
The interpretation is that the modeled odds of the outcome are approximately twice as high for the treatment comparison represented by that coefficient, holding other model terms constant.
Odds Ratio Estimates
PROC GLIMMIX can directly request odds-ratio estimates.
proc glimmix data=analysis;
class treatment;
model response(event='1') =
treatment
/ dist=binary
link=logit
oddsratio;
run;
Odds ratios can also be obtained through LS-means and differences.
proc glimmix data=analysis;
class treatment;
model response(event='1') =
treatment
/ dist=binary
link=logit;
lsmeans treatment /
diff
oddsratio
cl;
run;
The current SAS documentation supports odds-ratio estimation through the MODEL statement and through LS-means-based comparisons.
Random Intercepts
The simplest random-effects model gives each subject their own random intercept.
random intercept / subject=usubjid;
Conceptually:
where:
Subjects with positive random intercepts have a higher underlying propensity for the outcome, while subjects with negative random intercepts have a lower propensity.
Why the Random Intercept Matters
Consider repeated binary response data:
| Patient | Week | Response |
|---|---|---|
| 001 | 4 | 1 |
| 001 | 8 | 1 |
| 001 | 12 | 1 |
| 002 | 4 | 0 |
| 002 | 8 | 0 |
| 002 | 12 | 0 |
The three observations from Patient 001 are not equivalent to three independent patients.
The random intercept accounts for patient-level heterogeneity and induces correlation among repeated observations.
Random Slopes
A random slope allows patients to have different trajectories over time.
random intercept visit / subject=usubjid;
Conceptually:
Now both the starting level and the time trend can vary across subjects.
Random-Effects Covariance
For a random intercept and random slope, PROC GLIMMIX estimates the variance of each random effect and their covariance unless the covariance structure is constrained.
The random-effects covariance matrix can be written as:
The covariance determines whether subjects with higher intercepts tend to have higher or lower slopes.
Repeated Measures and Residual Correlation
Repeated measurements can also be correlated through the residual covariance structure.
For example, measurements closer together in time may be more strongly correlated than measurements far apart.
An autoregressive structure might therefore be considered:
random _residual_ /
subject=usubjid
type=ar(1);
The `_RESIDUAL_` specification is important because PROC GLIMMIX handles residual covariance through the RANDOM statement rather than using the traditional PROC MIXED REPEATED syntax. SAS documents this distinction explicitly.
Common Covariance Structures
| Structure | Concept |
|---|---|
| VC | Variance components |
| CS | Compound symmetry |
| AR(1) | Correlation decreases with increasing time separation |
| UN | Unstructured covariance |
| TOEP | Toeplitz-type covariance structure |
Compound Symmetry
Compound symmetry assumes approximately equal variances and a common correlation among repeated measurements.
This can be reasonable when the correlation does not depend strongly on the time separation.
AR(1)
An AR(1) structure assumes that observations become less correlated as the time gap increases.
For example:
- Adjacent visits: relatively high correlation
- Two visits apart: lower correlation
- Three visits apart: still lower correlation
A typical specification is:
random _residual_ /
subject=usubjid
type=ar(1);
Unstructured Covariance
An unstructured covariance matrix makes minimal structural assumptions.
For four visits:
This flexibility comes at a cost: many parameters must be estimated.
Binary Longitudinal Example
Suppose a clinical trial measures whether each patient has achieved a clinically meaningful response at Weeks 4, 8, 12, and 16.
The data may look like:
USUBJID TRT01P AVISIT RESPONSE 001 Drug A Week 4 0 001 Drug A Week 8 1 001 Drug A Week 12 1 001 Drug A Week 16 1 002 Placebo Week 4 0 002 Placebo Week 8 0 002 Placebo Week 12 0 002 Placebo Week 16 1
A basic model might be:
proc glimmix data=analysis;
class usubjid trt01p avisit;
model response(event='1') =
trt01p
avisit
trt01p*avisit
/ dist=binary
link=logit;
random intercept /
subject=usubjid;
lsmeans trt01p*avisit /
ilink
diff
cl;
run;
What Does ILINK Do?
Model estimates are naturally expressed on the linear-predictor scale.
For a logistic model, that scale is the logit scale.
The inverse-logit transformation converts the estimate to a probability:
Thus, the ILINK option can make LS-means easier to
interpret because the results are presented on the response scale rather than
the logit scale.
LS-Means
Least-squares means are among the most useful features of PROC GLIMMIX for clinical-trial reporting.
For example:
lsmeans trt01p /
ilink
cl;
This requests model-adjusted estimates on the response scale.
For treatment-by-visit interactions:
lsmeans trt01p*avisit /
ilink
diff
cl;
This can produce estimated probabilities for each treatment and visit combination and comparisons between them.
Estimated Probabilities
Suppose the model produces:
| Treatment | Visit | Estimated Probability |
|---|---|---|
| Drug A | Week 12 | 0.62 |
| Placebo | Week 12 | 0.38 |
The model-estimated response probabilities are therefore approximately 62% and 38%.
The difference is:
or 24 percentage points.
Depending on the requested comparison and model, PROC GLIMMIX can also provide an odds ratio for the same treatment contrast.
Odds Ratio Versus Risk Difference
These are different estimands.
| Measure | Example | Interpretation |
|---|---|---|
| Probability | 0.62 | Estimated probability of response |
| Risk difference | 0.24 | 24 percentage-point difference |
| Odds ratio | 2.67 | Odds are 2.67 times as high |
A strong statistical report should state clearly which quantity is being reported.
Count Data
PROC GLIMMIX is also useful for repeated or clustered count outcomes.
Examples include:
- Number of exacerbations
- Number of hospitalizations
- Number of adverse events
- Number of rescue-medication uses
- Number of disease episodes
A Poisson model may begin with:
proc glimmix data=analysis;
class usubjid treatment;
model count =
treatment
age
/ dist=poisson
link=log;
random intercept /
subject=usubjid;
run;
Interpreting a Poisson Coefficient
Suppose:
Exponentiating:
The corresponding rate or mean ratio is approximately 0.80, depending on the model and exposure specification.
This can be described as an estimated 20% lower expected event rate relative to the reference group, holding other model terms constant.
Poisson Versus Negative Binomial
A major issue with count data is overdispersion.
The Poisson distribution imposes:
Real clinical data often violate this assumption.
If the variance substantially exceeds the mean, a negative binomial model may be more appropriate.
proc glimmix data=analysis;
class treatment usubjid;
model count =
treatment
/ dist=negbin
link=log;
random intercept /
subject=usubjid;
run;
Offset Variables
Count-rate analyses may require an exposure or observation-time offset.
For example, if patients have different amounts of follow-up, modeling raw event counts can be misleading.
A log exposure offset can be incorporated into the linear predictor:
The offset adjusts the expected count for differing exposure times.
Ordinal Outcomes
Clinical trials frequently use ordered outcomes.
Examples include:
- Mild / moderate / severe
- Grade categories
- Clinical severity scales
- Ordered patient-reported outcome categories
An ordinal model respects the ordering of the categories rather than treating them as unrelated nominal categories.
A cumulative-logit formulation can be expressed as:
where each category boundary has its own intercept or threshold.
Nominal Versus Ordinal Outcomes
| Outcome | Relationship Between Categories |
|---|---|
| Nominal | No natural ordering |
| Ordinal | Natural ordering exists |
For example, tumor subtype categories may be nominal, while toxicity grades have a natural severity ordering.
Random Center Effects
Clinical trials may involve many investigative sites.
If the scientific objective is to account for site-to-site heterogeneity, center can potentially be represented as a random effect.
proc glimmix data=analysis;
class treatment site;
model response(event='1') =
treatment
/ dist=binary
link=logit;
random intercept /
subject=site;
run;
This model treats sites as sampled from a broader population of possible sites.
Nested Random Effects
Hierarchical data may have several levels.
For example:
Random effects can represent multiple levels of this hierarchy when supported by the design and analysis plan.
Crossed Versus Nested Effects
An effect is nested when its levels occur within another effect.
For example, patients are nested within study centers:
Crossed effects occur when every level of one factor can potentially occur with multiple levels of another factor.
Understanding whether effects are nested or crossed is essential when specifying random effects.
Treatment-by-Visit Interactions
Longitudinal clinical-trial analyses often require a treatment-by-visit interaction.
model response(event='1') =
treatment
visit
treatment*visit
/ dist=binary
link=logit;
The interaction asks whether the treatment difference changes across visits.
Without the interaction, the model imposes a common treatment effect across all visits on the model scale.
Contrasts
The CONTRAST statement lets you test specific linear combinations of fixed effects.
contrast "Drug A vs Placebo at Week 12"
treatment 1 -1
treatment*visit 1 -1
/ chisq;
The exact coefficients depend on the model parameterization and reference levels.
In production clinical programming, contrasts should be explicitly derived from the model design rather than copied blindly from another analysis.
ESTIMATE Statements
The ESTIMATE statement can obtain a specific linear combination of parameters.
estimate "Treatment effect"
treatment 1 -1
/ exp cl;
For logistic models, EXP transforms a log-odds
contrast into an odds ratio.
Model-Based Versus Empirical Covariance
PROC GLIMMIX supports different approaches to estimating the covariance of fixed-effect estimates.
The model-based approach assumes the specified covariance model is correct.
Empirical or sandwich-style approaches can provide robustness against some forms of covariance misspecification.
However, robust methods do not automatically solve every problem involving small samples, sparse data, or a misspecified mean model.
Estimation Methods
GLMMs involve integration over random effects.
For nonlinear mixed models, these integrals generally do not have simple closed-form solutions.
PROC GLIMMIX therefore provides several computational approaches, including linearization methods and numerical integration approaches such as quadrature or Laplace-type methods.
Linearization
A common approach approximates the nonlinear model locally so that mixed-model methods can be applied.
This is computationally attractive and often useful for large longitudinal datasets.
However, approximations can be less accurate when the response distribution is highly nonnormal or the random-effect variance is large.
Quadrature
Numerical quadrature approximates the integration over random effects directly.
Adaptive quadrature can provide more accurate likelihood-based calculations in some low-dimensional random-effects problems.
The computational burden increases as the dimensionality of the random-effects distribution increases.
When Models Become Difficult to Estimate
GLMMs can be substantially harder to estimate than ordinary regression models.
Common causes include:
- Very sparse binary outcomes
- Complete or quasi-complete separation
- Too many random-effect parameters
- Very few clusters
- Unstructured covariance with many visits
- Near-zero random-effect variance
- Highly correlated random effects
- Extremely unbalanced treatment groups
- Rare outcome categories
- Overly complex interactions
Convergence Warnings
A model that produces output is not automatically a valid model.
Always examine the SAS log and convergence information.
Warning signs include:
- Failure to converge
- Nonpositive definite covariance matrices
- Parameters at boundaries
- Very large standard errors
- Extreme estimates
- Near-zero variance components
- Optimization warnings
Complete Separation
Suppose every responder is in the treatment group and every non-responder is in placebo.
A logistic model may attempt to send the treatment coefficient toward infinity.
Conceptually:
This can cause estimation problems.
Possible solutions depend on the analysis objective and may involve:
- Reconsidering the model specification
- Reducing unnecessary parameters
- Using an appropriate alternative model
- Considering exact or penalized methods when justified
- Following the prespecified statistical methodology
Boundary Estimates
Suppose the random-intercept variance is estimated as essentially zero.
This suggests that the data provide little evidence for subject-level random intercept heterogeneity under the specified model.
It does not automatically mean the random effect should be deleted without considering the scientific model, inferential target, and prespecified analysis.
Model Selection
PROC GLIMMIX can support model comparisons, but statistical model selection should be driven by the analysis objective rather than by automated searching through every possible covariance structure.
Candidate models may differ in:
- Fixed effects
- Random effects
- Covariance structure
- Distribution
- Link function
Information criteria such as AIC can be useful descriptive tools for comparing candidate models under appropriate circumstances.
AIC and BIC
AIC balances model fit and complexity:
where \(L\) is the likelihood and \(k\) is the number of estimated parameters.
BIC imposes a stronger complexity penalty:
Lower values indicate a better fit-complexity tradeoff under the criterion.
Missing Data
Longitudinal GLMMs can use incomplete repeated-measures data under the assumptions associated with the likelihood-based analysis.
For example, one patient might have:
Week 4 0 Week 8 1 Week 12 . Week 16 1
The missing Week 12 measurement does not necessarily require deleting the entire patient from the analysis.
However, the missing-data assumptions remain critical.
Missing at Random
Many likelihood-based longitudinal analyses rely on a Missing At Random, or MAR, framework.
Informally, after conditioning on observed information in the model, the probability of missingness does not depend on the unobserved value itself.
MAR is an assumption about the missing-data mechanism, not a guarantee provided by PROC GLIMMIX.
Clinical-Trial Example: Binary Endpoint
Suppose the primary endpoint is clinical response at multiple visits.
A possible model specification is:
proc glimmix data=adae;
class usubjid trt01p avisit;
model response(event='1') =
trt01p
avisit
trt01p*avisit
baseline
/ dist=binary
link=logit;
random intercept /
subject=usubjid;
lsmeans trt01p*avisit /
ilink
diff
oddsratio
cl;
run;
This model includes:
- Treatment
- Visit
- Treatment-by-visit interaction
- Baseline adjustment
- Patient-level random intercept
Clinical-Trial Example: Repeated Count Endpoint
Suppose patients contribute repeated counts of disease-related events.
proc glimmix data=analysis;
class usubjid trt01p avisit;
model events =
trt01p
avisit
trt01p*avisit
/ dist=negbin
link=log;
random intercept /
subject=usubjid;
lsmeans trt01p*avisit /
ilink
cl;
run;
If follow-up differs substantially between patients, the model may also need an appropriate exposure-time offset.
Clinical-Trial Example: Ordinal Outcome
Suppose a patient-reported outcome is categorized as:
- None
- Mild
- Moderate
- Severe
The ordering contains information.
An ordinal model can account for that ordering rather than treating the four categories as unrelated nominal outcomes.
Baseline Covariates
Baseline covariates can be included when specified by the statistical analysis plan.
model response(event='1') =
treatment
baseline
age
sex
/ dist=binary
link=logit;
Continuous baseline variables should generally remain continuous unless there is a prespecified scientific reason to categorize them.
Continuous Covariates
Suppose age is included as a continuous covariate.
The coefficient for age describes the change in the linear predictor for a one-unit increase in age, holding the other model terms constant.
Interactions With Continuous Covariates
A treatment-by-age interaction can test whether the treatment association changes with age:
model response(event='1') =
treatment
age
treatment*age
/ dist=binary
link=logit;
Because this is a nonlinear model, interpretation should generally use estimated probabilities or contrasts at clinically meaningful ages rather than relying exclusively on individual regression coefficients.
Centering Covariates
Continuous covariates can sometimes be centered to improve interpretability.
For example:
data analysis2;
set analysis;
age_c = age - 60;
run;
Now the model intercept corresponds to an age of 60 rather than age zero.
Modeling Time
Time can be modeled categorically or continuously.
| Approach | Advantage | Limitation |
|---|---|---|
| Categorical visit | Flexible visit-specific effects | More parameters |
| Continuous time | Parsimonious | Assumes a functional form |
| Spline-based time | Flexible smooth trajectory | More complex interpretation |
For clinical-trial visits such as baseline, Week 4, Week 8, Week 12, and Week 24, categorical visit is often attractive when no simple functional form is scientifically justified.
Random Effects Versus Repeated Covariance
These concepts are related but not identical.
Random effects model latent subject-level variation.
Residual covariance models dependence remaining after accounting for the fixed and random effects.
A model may contain both.
proc glimmix data=analysis;
class usubjid treatment visit;
model response(event='1') =
treatment
visit
treatment*visit
/ dist=binary
link=logit;
random intercept /
subject=usubjid;
random _residual_ /
subject=usubjid
type=ar(1);
run;
Whether both structures are appropriate depends on the response distribution, design, estimation method, and analysis plan.
PROC MIXED Versus PROC GLIMMIX
This is one of the most common sources of confusion for SAS programmers.
| Feature | PROC MIXED | PROC GLIMMIX |
|---|---|---|
| Normal continuous response | Yes | Yes |
| Binary response | No | Yes |
| Poisson response | No | Yes |
| Random effects | Yes | Yes |
| Residual covariance | REPEATED statement | RANDOM _RESIDUAL_ approach |
| Generalized response distributions | Limited | Core capability |
SAS describes PROC MIXED as a special case within the broader GLIMMIX framework when the response is normal and the identity link is used.
Converting a PROC MIXED Model
Consider a PROC MIXED model:
proc mixed data=analysis;
class usubjid visit;
model y = treatment visit treatment*visit;
repeated visit /
subject=usubjid
type=ar(1);
run;
A related GLIMMIX formulation for a normal response can use:
proc glimmix data=analysis;
class usubjid visit;
model y =
treatment
visit
treatment*visit
/ dist=normal
link=identity;
random _residual_ /
subject=usubjid
type=ar(1);
run;
The two procedures can therefore express closely related models, but the programmer should validate the parameterization, estimation method, covariance specification, and resulting inference rather than assuming that a textual conversion is automatically equivalent.
Estimated Marginal Means
For a treatment comparison, LS-means can be requested with:
lsmeans treatment /
diff
cl;
For a binary outcome:
lsmeans treatment /
ilink
diff
oddsratio
cl;
The ILINK option is particularly useful because it
returns estimates on the response scale.
Multiple Comparisons
When there are more than two treatment groups, multiple comparisons can be requested.
lsmeans treatment /
diff=all
adjust=tukey
cl;
Other multiplicity adjustments may be appropriate depending on the analysis objective.
OUTPUT Statements
PROC GLIMMIX can create an output dataset for model-based quantities.
For example:
output out=pred
pred(ilink)=pred_prob
lower(ilink)=lower_prob
upper(ilink)=upper_prob;
This can be useful for creating:
- Predicted probability plots
- Model-based longitudinal figures
- Diagnostic displays
- Custom clinical-trial tables
Predicted Probabilities
Suppose the output dataset contains predicted response probabilities across visits.
These can be plotted to show model-estimated treatment trajectories.
proc sgplot data=pred;
series x=avisit y=pred_prob / group=trt01p;
band x=avisit
lower=lower_prob
upper=upper_prob
/ group=trt01p
transparency=0.65;
yaxis label="Estimated Probability of Response";
xaxis label="Visit";
run;
This provides a model-based longitudinal visualization rather than a plot of raw patient observations.
Raw Proportions Versus Model-Based Estimates
These should not be confused.
| Quantity | Meaning |
|---|---|
| Observed proportion | Directly calculated from observed responses |
| Model-estimated probability | Estimated after accounting for the model structure |
| Adjusted probability | Model-based estimate under specified covariate settings or marginalization |
A clinical report should clearly distinguish observed summaries from model-derived estimates.
Model Diagnostics
Model diagnostics should address both statistical fit and computational stability.
Important checks include:
- Convergence
- Covariance parameter estimates
- Residual or Pearson-type diagnostics where appropriate
- Influential observations or clusters
- Outlying counts
- Rare categories
- Overdispersion
- Model-predicted versus observed patterns
Overdispersion
For Poisson models, overdispersion is particularly important.
If:
the Poisson assumption may be inadequate.
Possible explanations include:
- Unmodeled heterogeneity
- Clustering
- Excess zeros
- Incorrect mean structure
- Genuine negative-binomial variation
The appropriate response depends on the source of the extra variability.
Zero-Inflated Data
Some count datasets contain substantially more zeros than expected under a standard Poisson or negative-binomial distribution.
For example, an adverse-event count may contain many patients with zero events.
Before choosing a zero-inflated model, investigate why the zeros occur.
A large number of zeros does not automatically prove that a zero-inflated model is appropriate.
Modeling Adverse Events
PROC GLIMMIX can be useful when the adverse-event endpoint is structured as a repeated binary or count outcome.
For example, whether an adverse event is present at each assessment:
proc glimmix data=adae;
class usubjid trt01p avisit;
model ae_present(event='1') =
trt01p
avisit
trt01p*avisit
/ dist=binary
link=logit;
random intercept /
subject=usubjid;
run;
However, standard clinical-trial adverse-event summaries often use subject-level incidence rather than repeated-visit binary modeling. The analysis method should therefore follow the endpoint definition.
Subject-Level Versus Visit-Level Endpoints
This distinction is critical.
A subject-level endpoint might ask:
A visit-level endpoint instead contains multiple observations per patient.
The appropriate GLIMMIX model depends on which estimand is being analyzed.
Clinical Trial Programming Workflow
A Complete Binary GLMM Example
The following example combines many of the concepts discussed above.
proc glimmix data=analysis
method=laplace;
class usubjid
trt01p
avisit;
model response(event='1') =
trt01p
avisit
trt01p*avisit
baseline
/ dist=binary
link=logit
solution
oddsratio;
random intercept /
subject=usubjid;
lsmeans trt01p*avisit /
ilink
diff
oddsratio
cl;
ods output
ParameterEstimates = parm
LSMeans = lsmeans
Differences = diffs;
run;
The exact estimation method, model structure, and requested output tables should be consistent with the statistical analysis plan.
Reading the Fixed-Effects Table
A typical parameter table might contain:
| Effect | Estimate | SE | DF | t/Estimate | p-value |
|---|---|---|---|---|---|
| Treatment A | 0.52 | 0.21 | ... | ... | 0.014 |
| Week 12 | −0.31 | 0.18 | ... | ... | 0.085 |
| Treatment × Week 12 | 0.42 | 0.20 | ... | ... | 0.036 |
For a logistic model, these coefficients are on the log-odds scale.
They should generally not be interpreted as direct percentage-point changes.
Reading the Odds Ratio Table
If a treatment contrast has:
then:
An odds ratio of approximately 1.68 indicates higher modeled odds in the numerator treatment relative to the reference comparison.
Reading the LS-Means Table
Suppose the ILINK-transformed results are:
| Treatment | Visit | Estimate | 95% CI |
|---|---|---|---|
| Drug A | Week 12 | 0.62 | 0.54–0.69 |
| Placebo | Week 12 | 0.38 | 0.30–0.46 |
These values are much easier to communicate clinically than the corresponding logit-scale estimates.
Reference Coding Matters
SAS parameter estimates depend on the coding and ordering of CLASS variables.
Therefore, the meaning of:
treatment 1 -1
depends on which treatment level is represented by each coefficient.
Always inspect the CLASS-level information and verify the reference category.
ORDER= Options and Reference Levels
For reproducible clinical programming, explicitly controlling category ordering can be useful.
class treatment(ref='Placebo') / param=ref;
This makes the intended reference treatment explicit.
Parameterization
PROC GLIMMIX supports different CLASS-variable parameterizations.
Reference-cell coding is common in clinical-trial work:
class treatment(ref='Placebo') / param=ref;
The choice affects the interpretation of individual parameter estimates but does not change the fitted model when equivalent parameterizations are used correctly.
Why LS-Means Are Often Better Than Raw Coefficients
In a model containing interactions, interpreting a single coefficient can be misleading.
Suppose the model contains:
treatment visit treatment*visit
The treatment coefficient may represent the treatment difference at the reference visit rather than at every visit.
LS-means and explicit contrasts allow the programmer to estimate the treatment difference at each clinically relevant visit.
Interaction Example
Suppose treatment A and placebo have:
| Visit | Drug A | Placebo | Difference |
|---|---|---|---|
| Week 4 | 0.40 | 0.35 | 0.05 |
| Week 8 | 0.55 | 0.38 | 0.17 |
| Week 12 | 0.62 | 0.38 | 0.24 |
The treatment effect is clearly not constant on the probability scale.
A treatment-by-visit interaction can represent this changing pattern.
Model-Based Probability Plot
The inverse-link function transforms the linear predictor to the response scale. For logistic models, this is the predicted probability.
A useful figure can show these model-based probabilities over time with confidence intervals for each treatment group.
When to Use G-Side Random Effects
In mixed-model terminology, random effects are sometimes described as G-side effects.
Examples include:
- Random subject intercept
- Random subject slope
- Random site intercept
- Random cluster effect
These effects represent variation among subjects or clusters.
When to Use R-Side Covariance
R-side covariance describes dependence among residual observations after accounting for the modeled fixed and random effects.
In PROC GLIMMIX this can be represented through a residual random effect.
random _residual_ /
subject=usubjid
type=cs;
The distinction between G-side and R-side modeling is important when designing a repeated-measures model.
Random Intercept Versus AR(1)
These structures answer different questions.
| Model Component | What It Represents |
|---|---|
| Random intercept | Patient-to-patient heterogeneity in underlying level |
| AR(1) residual covariance | Correlation among residual measurements that depends on time separation |
Both may be scientifically reasonable in some models, but they should not be added indiscriminately.
Small Number of Clusters
Random-effects inference can become unreliable when the number of independent clusters is very small.
For example, a model with only six study centers may not support the same inference about center-level variability as a model with hundreds of centers.
The number of subjects is not necessarily the same as the number of independent clusters.
Degrees of Freedom
Mixed-model procedures may use approximations for denominator degrees of freedom.
The choice can affect standard errors, confidence intervals, and p-values.
For clinical-trial analyses, the selected inferential method should follow the SAP and the methodology appropriate for the model.
Confidence Intervals
Confidence intervals should generally accompany key effect estimates.
For an odds ratio:
where \(L\) and \(U\) are the confidence limits on the log-odds-ratio scale.
Interpreting an Odds Ratio Confidence Interval
Suppose:
The estimated odds are 1.75 times the reference odds, and the confidence interval excludes 1.
Whether this constitutes statistical significance depends on the prespecified inferential framework.
Interpreting a Rate Ratio
For a log-linked count model:
If:
the modeled event rate is approximately 28% lower for the comparison represented by the ratio.
Interpreting an Identity-Link Estimate
For a normal response with an identity link:
a treatment coefficient can be interpreted directly in the response units.
For example, an estimate of −4.2 could mean a 4.2-unit lower adjusted mean, depending on the treatment contrast.
Choosing the Distribution
A useful decision framework is:
Common Mistakes
- Treating repeated observations as independent. Ignoring within-subject dependence can produce inappropriate inference.
- Using the wrong distribution. A convenient model is not necessarily an appropriate model.
- Confusing odds ratios with probability differences. These are different effect measures.
- Ignoring the link function. Regression coefficients live on the model's linear-predictor scale.
- Overfitting random effects. Complex random structures require sufficient information.
- Adding unstructured covariance automatically. UN covariance can require many parameters.
- Ignoring convergence warnings. A numerical result is not automatically a valid statistical result.
- Interpreting interaction coefficients in isolation. Use appropriate LS-means and contrasts.
- Forgetting the reference category. Treatment contrasts depend on coding.
- Confusing observed proportions with model-estimated probabilities. They answer different questions.
- Choosing a model solely by AIC. Scientific interpretation and the SAP remain central.
- Reporting only p-values. Effect estimates and confidence intervals are generally more informative.
Production Clinical Programming Checklist
Validation Strategy
For regulatory clinical-trial programming, a GLIMMIX analysis should be validated at multiple levels.
Dataset Validation
- Confirm the analysis population.
- Verify treatment assignments.
- Verify visit derivations.
- Verify baseline values.
- Check duplicates.
- Check missingness.
Model Validation
- Verify the distribution.
- Verify the link.
- Verify CLASS variables.
- Verify reference levels.
- Verify fixed effects.
- Verify random effects.
- Verify covariance structure.
- Verify estimation method.
Output Validation
- Verify parameter estimates.
- Verify LS-means.
- Verify contrasts.
- Verify confidence intervals.
- Verify odds ratios or rate ratios.
- Verify p-values.
Independent Recalculation
One useful validation strategy is to independently reproduce selected results.
For example, if the primary result is a treatment odds ratio, the independent program should verify:
and independently confirm the confidence interval and treatment coding.
Traceability
Every reported model-based result should be traceable through:
When PROC GLIMMIX Is a Good Choice
PROC GLIMMIX is particularly useful when all three of the following are true:
- The response is not adequately represented by an ordinary normal linear model.
- The observations have a hierarchical or repeated-measures structure.
- A mixed-effects framework is scientifically appropriate.
Examples include repeated binary outcomes, clustered count outcomes, ordinal longitudinal endpoints, and other generalized responses with subject-level heterogeneity.
When PROC GLIMMIX May Not Be the Best Choice
PROC GLIMMIX is powerful, but it is not automatically the correct procedure for every nonnormal or repeated-measures problem.
Other methods may be preferable depending on the estimand and study design.
Examples include:
- GEE methods when the marginal population-average effect is the primary target.
- PROC MIXED for straightforward Gaussian mixed models.
- PROC GENMOD for generalized linear models without random effects.
- Survival-analysis procedures for time-to-event endpoints.
- Specialized ordinal or multinomial approaches when the outcome structure requires them.
GLMM Versus GEE
This distinction is especially important for longitudinal clinical-trial analysis.
| Feature | GLMM | GEE |
|---|---|---|
| Primary perspective | Subject-specific / conditional | Population-average / marginal |
| Random effects | Yes | No |
| Subject heterogeneity | Explicitly modeled | Not modeled through random effects |
| Correlation | Can be modeled through random effects and covariance structures | Working correlation structure |
| Interpretation | Conditional on random effects | Marginal population-level effect |
Neither framework is universally superior.
The correct choice depends on the scientific question and estimand.
Subject-Specific Versus Population-Average Effects
Suppose a logistic model estimates a treatment effect.
A GLMM treatment coefficient is naturally interpreted conditionally on the random effects.
A marginal model instead targets the population-average effect.
Because logistic models are nonlinear, these two quantities generally differ.
Practical Example: Why This Matters
Suppose the conditional odds ratio from a GLMM is:
A marginal population-average odds ratio need not also equal 2.4.
Therefore, analysts should not casually substitute one modeling framework for another simply because both can analyze binary repeated measurements.
A Minimal GLIMMIX Template
For day-to-day programming, the following template is a useful starting point:
proc glimmix data=analysis;
class
usubjid
treatment
visit;
model response =
treatment
visit
treatment*visit
baseline
/ dist=binary
link=logit
solution;
random intercept /
subject=usubjid;
lsmeans treatment*visit /
ilink
diff
cl;
run;
The analyst should then customize the distribution, link, covariance structure, random effects, estimation method, contrasts, and multiplicity handling according to the prespecified analysis.
Practical Interpretation Framework
When reviewing PROC GLIMMIX output, use the following sequence.
Example Reporting Table
| Endpoint | Drug A | Placebo | Effect | 95% CI | P-value |
|---|---|---|---|---|---|
| Response at Week 12 | 62% | 38% | OR 2.67 | 1.48–4.81 | 0.001 |
| Response at Week 24 | 58% | 35% | OR 2.56 | 1.40–4.69 | 0.002 |
The exact estimand and model-based interpretation should be stated in the table footnote.
Example Footnote
Debugging PROC GLIMMIX
When a model does not behave as expected, work systematically.
Step 1: Fit the Simplest Model
proc glimmix data=analysis;
class treatment;
model response(event='1') =
treatment
/ dist=binary
link=logit;
run;
Step 2: Add the Subject Structure
random intercept / subject=usubjid;
Step 3: Add Visit
visit
Step 4: Add the Interaction
treatment*visit
Step 5: Evaluate Covariance Complexity
Only after the basic model is stable should additional covariance complexity be considered.
Why Incremental Modeling Helps
If a complex model fails to converge immediately, it can be difficult to know whether the problem is caused by:
- The distribution
- The fixed-effects structure
- The random-effects structure
- The covariance structure
- Data sparsity
- Category separation
Building the model incrementally makes the source of the problem much easier to identify.
What to Check in the SAS Log
Do not rely exclusively on the printed output tables.
Inspect the SAS log for:
- Warnings
- Notes about convergence
- Iteration information
- Invalid likelihood calculations
- Boundary estimates
- Singular covariance warnings
- Missing or invalid observations
Clinical-Trial Programming Best Practices
- Use analysis datasets rather than raw source domains whenever appropriate.
- Make the reference treatment explicit.
- Use meaningful variable names.
- Document the model specification.
- Capture ODS output datasets.
- Validate critical contrasts independently.
- Review the SAS log as part of QC.
- Keep the production model aligned with the SAP.
- Document deviations from the prespecified analysis.
- Do not rely on numerical convergence alone.
The Most Important Concept
PROC GLIMMIX is best understood as a framework for answering a specific question:
The distribution describes the response, the link connects the response to the linear predictor, fixed effects describe systematic associations, and random effects or covariance structures describe dependence and heterogeneity.
Summary
PROC GLIMMIX is one of the most versatile mixed-model procedures in SAS.
Its primary strength is the ability to combine:
- Generalized response distributions
- Nonlinear link functions
- Fixed effects
- Random effects
- Repeated-measures structures
- Flexible covariance structures
- Model-based treatment comparisons
For clinical programmers, the most important skills are not memorizing syntax. They are understanding what each component of the model means.
A robust PROC GLIMMIX analysis should therefore proceed in this order:
References
SAS Institute Inc. The GLIMMIX Procedure. SAS/STAT User's Guide.
SAS Help Center.
SAS Institute Inc. Comparing the GLIMMIX and MIXED Procedures. SAS/STAT User's Guide.
SAS Help Center.
McCulloch, C.E., Searle, S.R., and Neuhaus, J.M. (2008). Generalized, Linear, and Mixed Models.
Wiley.
Stroup, W.W. (2012). Generalized Linear Mixed Models: Modern Concepts, Methods and
Applications.
CRC Press.
Diggle, P., Heagerty, P., Liang, K.-Y., and Zeger, S. (2002). Analysis of Longitudinal Data.
Oxford University Press.