Atlas
statminds
Multilevel GLM (Non-Normal Link Model)The underlying model family class (e.g. GLM, linear model, categorical matrix, log-linear).Parametric ReferenceStatistical methods that assume a specific probability distribution family (typically normal).12-stage workflow

Generalized Linear Mixed Model

The engine for Non-Normal Hierarchical Discovery. GLMM audits nested data with categorical or count outcomes (e.g., binary success/failure), providing a robust multi-level path for complex biological and social data.

Model familyMultilevel GLM (Non-Normal Link Model)
Hypothesistwo-tailed (can be one-tailed for directional hypotheses)
AliasesHierarchical GLM · Multilevel Logistic/Poisson Model · Random Effects Categorical Regression
G1
Hierarchical Probability Audit
Determine the likelihood of success while accounting for clustering in non-normal data.
G2
Categorical Clustering Neutralization
Correct for the correlation of counts or categories within subjects or sites.
G3
Non-Linear Trajectory Mapping
Audit the recovery paths of binary or discrete outcomes over time in a multi-level field.
Visual Overview Dashboard
1

What is it?

Generalized Linear Mixed Model is designed to analyze clustered, longitudinal, or repeated measures data by modeling both population trends and correlation structures.

The engine for Non-Normal Hierarchical Discovery. GLMM audits nested data with categorical or count outcomes (e.g., binary success/failure), providing a robust multi-level path for complex biological and social data.

2

Goals & Indications

  • Hierarchical Probability Audit: Determine the likelihood of success while accounting for clustering in non-normal data.
  • Categorical Clustering Neutralization: Correct for the correlation of counts or categories within subjects or sites.
  • Non-Linear Trajectory Mapping: Audit the recovery paths of binary or discrete outcomes over time in a multi-level field.
3

Core Idea Diagram

Grouped Logistic Probability Sigmoids
4

Hypotheses

H₀: H₀: β₁ = 0 (no fixed effect of predictor on outcome, controlling for random effects)
Hₐ: Hₐ: β₁ ≠ 0 (predictor has a fixed effect on outcome)
5

How it works

  1. Choose a link function matching the outcome type (e.g. logit for binary).
  2. Specify fixed covariates and cluster-level random effects.
  3. Estimate parameters using numerical integration (e.g. Adaptive Gauss-Hermite Quadrature).
  4. Construct odds ratios or rate ratios adjusted for subject nesting.
6

Assumptions

Outcome variable follows a distribution from the exponential family: Non-normal outcome with appropriate distribution
Correct specification of link function relating linear predictor to outcome: Appropriate link function for outcome type
Correct specification of random effects structure: Random effects capture correlation structure
7

Important Note

GLMMs partition variance into fixed effects (population-average effects) and random effects (subject/cluster-specific deviations). Unlike GEE, GLMMs model the data-generating process and allow subject-specific inference. The null hypothesis tests fixed effect parameters while accounting for random effect correlation structure.

8

Worked Example

ParameterOdds Ratio95% CI
Treatment (Fixed)2.45[1.54, 3.89]
Random Intercept SD0.84Clinic Cluster
Interactive Sandbox

Generalized Linear Mixed Model (Logistic)

Adjust log-odds slope and random intercept variances. Observe how groups (represented by clinics) separate horizontally along their sigmoids.

Fixed Effect Slope (odds)0.80
Random Intercept SD (σu0)0.80
Sigmoid Probability curves by Clinic (Random Intercepts)
50% Threshold-3.0-1.50.01.53.0
The 12-Stage Precision Workflow
01Likelihood Synergy
Hypotheses
We test predictor influence on the non-linear probability link while simultaneously auditing random-intercept shifts.
02Link-Level Normality
Assumptions
Ensuring the random effects follow a normal distribution on the logit or log scale—the foundational mandate of GLMM math.
03Laplace Approximation
Diagnostics
Checking the numerical integration method; the Laplace audit ensures the complex marginal likelihood is estimated with high-fidelity.
04focus
Predicting FlowMotion 'Certification Success' (Binary) across 15 regions, accounting for regional baseline variability.
05GEE / LMM Pivot
Alternatives
Knowing when to switch to GEE if the random distribution is unknown, or LMM if the outcome can be safely transformed to normal.
06Z-Strikes
Significance
Utilizing the Z-distribution for large-sample approximations of predictor importance in the non-linear multi-level world.
07Odds Ratios / IRRs
Effect Size
Interpreting the multiplicative effect of predictors within the hierarchy—isolating the subject-specific discovery.
08Quadrature Power
Sample Size
Accounting for the significant computational and data requirements to stabilize non-linear random effect estimations.
09Subject-Specific Odds
Reporting
Reporting Odds Ratios clearly as 'Within-Cluster' or 'Between-Cluster' effects—a critical distinction in multilevel reporting.
10glmer / glmmTMB Logic
Software
Executing 'glmer(family = binomial)'—the command that bridges the gap between logistic choice and hierarchical complexity.
11focus
Identifying the 'Complexity Trap'—adding random slopes to a binary model with small clusters, which leads to model collapse.
12focus
Tracing the model back to the integration of Generalized Linear Models and Random Effects in the 1990s.
01Hypothesis test logic

Hypotheses

Pragmatic null and alternative hypotheses defined in mathematical notation.

A hypothesis is a question sharpened to a point. Ambiguity is the enemy of inference.
Logic Core
Null · H₀

H₀: β₁ = 0 (no fixed effect of predictor on outcome, controlling for random effects)

Alternative · Hₐ

Hₐ: β₁ ≠ 0 (predictor has a fixed effect on outcome)

Why it matters two-tailed (can be one-tailed for directional hypotheses)

GLMMs partition variance into fixed effects (population-average effects) and random effects (subject/cluster-specific deviations). Unlike GEE, GLMMs model the data-generating process and allow subject-specific inference. The null hypothesis tests fixed effect parameters while accounting for random effect correlation structure.

02Model diagnostics

Assumptions

The core mathematical criteria needed to ensure that statistical testing remains unbiased and valid.

Build your analysis on rock, not sand. Verify the mathematical foundation before building the model.
Integrity Shield
7
Assumptions
5
Critical / High Severity
How to check
Quick
For binary outcomes: verify 0/1 or success/failure coding. For count outcomes: check for non-negative integers, plot histogram to assess Poisson vs negative binomial (overdispersion). For continuous positive outcomes: check for right-skew suggesting gamma distribution
Rigorous
For count data: compare variance to mean (if var >> mean, overdispersion suggests negative binomial). Use dispersion parameter (φ): if φ > 1, overdispersed. For binomial: check for separation (all successes or failures in some predictor combinations). Use DHARMa package in R to simulate residuals and test distributional assumptions
If violated
If count data overdispersed (var >> mean): use negative binomial GLMM instead of Poisson GLMM. If binary data shows complete/quasi-complete separation: use penalized likelihood (Firth's method) or Bayesian GLMM with weakly informative priors. If continuous outcome non-normal: try different family (gamma for right-skewed positive data, inverse Gaussian). If zero-inflated counts: use zero-inflated Poisson/negative binomial GLMM
How to check
Quick
Verify standard link: logit for binomial (log-odds), log for Poisson/negative binomial (log-count), inverse for gamma. Plot predicted probabilities/counts to ensure they stay in valid range (e.g., [0,1] for probabilities)
Rigorous
Compare models with different link functions using AIC/BIC. For binomial: test logit vs probit vs cloglog. Use residual diagnostics: DHARMa quantile residuals should be uniform. Check linearity of continuous predictors on link scale using partial residual plots or GAM smooths
If violated
For binomial: if rare events, try complementary log-log (cloglog) link. For Poisson: if non-linear on log scale, add polynomial or spline terms. For gamma: try log link instead of inverse if more interpretable. Use GAM with smoothers to identify non-linearities, then add appropriate transformations or splines to GLMM
How to check
Quick
Review study design: repeated measures suggest random intercepts (and slopes if time-varying predictor). Nested data (students in schools) suggest random intercepts for clusters. Check if model converges; non-convergence often signals overparameterized random structure
Rigorous
Use likelihood ratio tests (LRT) to compare models with vs without random slopes. Check if random slope variance is near zero (suggests unnecessary). Use AIC/BIC for model comparison. Examine intraclass correlation (ICC) to quantify clustering. For crossed designs (e.g., subjects × items), ensure both random effects included
If violated
If omitted random effects: model will underestimate standard errors (Type I error inflation). Add random intercepts for each clustering unit (subject ID, school ID, etc.). If time-varying predictors: test random slopes with LRT; keep if significant or theoretically important. If non-convergence with random slopes: simplify to random intercepts only, or use uncorrelated random effects (remove correlation between slopes/intercepts)
gee
How to check
Quick
Review sampling design: were subjects independently recruited? Check for spatial/temporal clustering (e.g., subjects from same geographic region, cohort effects). Ensure each cluster ID is unique and subjects don't appear in multiple clusters
Rigorous
Check for autocorrelation in cluster-level residuals if clusters have natural ordering (e.g., time). Plot cluster-level random effects by spatial location or time to detect patterns. Use Moran's I for spatial autocorrelation if geographic data
If violated
If spatial autocorrelation between clusters: add spatial random effects or use geostatistical models. If temporal autocorrelation: add time-period random effects or autoregressive structure. If subjects nested in multiple crossed clusters (e.g., students in schools in districts): add all levels as nested or crossed random effects. If non-independence unavoidable: use cluster-robust sandwich SEs or GEE
gee
How to check
Quick
Extract random effects (BLUPs) using ranef() in R. Create Q-Q plots for random intercepts and slopes. Check for severe skewness or outlier clusters with extreme random effects
Rigorous
Shapiro-Wilk test on random effects (note: underpowered with few clusters). Plot histograms of BLUPs. Check for multivariate normality if multiple random effects using Mahalanobis distance. Use caterpillar plots to identify outlier clusters (BLUPs with CIs not overlapping zero)
If violated
GLMMs are moderately robust to random effects non-normality, especially with many clusters (k > 30). If severe outliers: investigate outlier clusters for data quality issues. If skewness: transform predictors, add cluster-level covariates to explain heterogeneity, or use robust GLMMs. If few clusters (k < 10): random effects normality more critical; consider fixed effects for small categorical predictors instead
gee
How to check
Quick
Caterpillar plots of random effects (BLUPs): look for clusters with CIs far from zero. Calculate Cook's distance for clusters. Check residual plots colored by cluster ID to identify outlier clusters
Rigorous
Calculate DFBETAS for each cluster (change in fixed effects when cluster removed). Use influence.ME package in R. Compare model with/without suspected outlier clusters to assess sensitivity. Check leverage (hat values) at cluster level
If violated
First: verify data quality for outlier clusters (entry errors, protocol violations). If legitimate outliers: (1) Report results with/without outlier clusters (sensitivity analysis); (2) Use robust GLMMs with Huber or bisquare weighting at cluster level; (3) Add cluster-level covariates to explain heterogeneity (e.g., cluster size, baseline characteristics); (4) Use bootstrap confidence intervals; (5) If single outlier cluster is theoretically distinct, consider excluding with justification
How to check
Quick
Count unique cluster IDs. Check minimum, median, and maximum cluster size. Plot distribution of cluster sizes. Rule of thumb: k ≥ 20 clusters for random intercepts, k ≥ 50 for random slopes, at least 5-10 observations per cluster on average
Rigorous
Use simulation-based power analysis for specific design (simr package in R). Check convergence warnings (often signal too few clusters or too many random effects). Examine SE of random effect variances (large SEs indicate estimation uncertainty with few clusters). For binary outcomes: ensure sufficient events per cluster (at least 10 events total per predictor)
If violated
If few clusters (k < 20): (1) Use restricted maximum likelihood (REML) for better small-sample properties; (2) Use Kenward-Roger or Satterthwaite df approximation for fixed effects tests; (3) Simplify random effects (intercepts only); (4) Consider cluster-level fixed effects instead of random effects; (5) Use GEE with sandwich SEs (more robust with few clusters); (6) Bootstrap confidence intervals. If small cluster sizes: check if adequate for intended inferences; may still be OK if many clusters. Never drop clustering just because small n per cluster
gee
03Residual Forensics

Diagnostics

Checking residual plots and indices to examine model deviations and ensure standard error integrity.

Trust, but verify. The outliers often hold more truth than the averages.
System Health
Essential checks
  1. Check random effects normality (Q-Q plot of BLUPs)
  2. Residual plots (Pearson or deviance residuals vs fitted values) to check for patterns
  3. DHARMa quantile residuals for distributional assumptions (R package)
  4. Variance inflation factors (VIF) for multicollinearity
  5. Convergence checks (warnings, Hessian positive definite)
  6. Overdispersion check for Poisson models (compare variance to mean)
Recommended checks
  1. Caterpillar plots of random effects to identify outlier clusters
  2. Influence diagnostics (Cook's D, DFBETAS at cluster level)
  3. Plot observed vs predicted values by cluster
  4. Check intraclass correlation (ICC) to quantify clustering
  5. Likelihood ratio tests for random effects significance
  6. Compare multiple link functions and families using AIC/BIC
  7. Sensitivity analysis: results with/without outlier clusters
04Live Instances

Applied Minds

Review concrete study examples, data layout guidelines, and copy executable syntax scripts.

Theory is the map. Practice is the terrain. Simulation bridges the gap.
Applied Wisdom
Example 01

Insomnia Treatment Response (Binary Outcome, Repeated Measures)

Research question: Does cognitive behavioral therapy for insomnia (CBT-I) improve sleep onset latency remission (SOL ≤ 30 min) compared to sleep education control over 8 weeks? Design: RCT with 80 patients (40 per group), assessed at baseline, weeks 2, 4, 6, 8 (5 timepoints). Outcome: Binary (1 = remission, 0 = insomnia). Random intercept for subjects accounts for within-subject correlation.

Designlongitudinal RCT
Outcome Scalebinary remission (0/1)
# GLMM: Binary outcome (insomnia remission) with repeated measures
# Random intercept model with binomial family (logit link)

library(lme4)        # For glmer()
library(DHARMa)      # For residual diagnostics
library(effects)     # For plotting effects
library(emmeans)     # For marginal means and contrasts
library(performance) # For ICC
library(ggplot2)

set.seed(2025)

# Simulate realistic data
n_subjects <- 80
n_timepoints <- 5
subject_id <- rep(1:n_subjects, each=n_timepoints)
treatment <- rep(rep(c("Control", "CBT-I"), each=40), each=n_timepoints)
week <- rep(c(0, 2, 4, 6, 8), times=n_subjects)

# Generate random intercepts (subject-specific baseline log-odds)
subject_intercepts <- rnorm(n_subjects, mean=0, sd=0.8)
subject_intercepts_expanded <- rep(subject_intercepts, each=n_timepoints)

# Fixed effects: baseline log-odds, time effect, treatment effect, interaction
logodds <- -1.5 +                           # Baseline (control at week 0): ~18% remission
           0.15 * week +                    # Time effect in control
           0.5 * (treatment == "CBT-I") +   # Treatment main effect
           0.10 * week * (treatment == "CBT-I") +  # Treatment × time interaction
           subject_intercepts_expanded      # Random intercept

prob <- plogis(logodds)  # Convert to probability
remission <- rbinom(length(prob), size=1, prob=prob)

data <- data.frame(
  subject_id = factor(subject_id),
  treatment = factor(treatment, levels=c("Control", "CBT-I")),
  week = week,
  remission = remission
)

# === STEP 1: Descriptive Statistics ===
table(data$remission, data$treatment)
prop.table(table(data$remission, data$treatment), margin=2)

# Remission rate by treatment over time
library(dplyr)
data %>%
  group_by(treatment, week) %>%
  summarise(n = n(),
            remission_rate = mean(remission),
            SE = sqrt(remission_rate * (1-remission_rate) / n))

# === STEP 2: Fit GLMM ===
# Random intercept for subject, binomial family with logit link
model <- glmer(remission ~ week * treatment + (1 | subject_id),
               data = data,
               family = binomial(link = "logit"),
               control = glmerControl(optimizer = "bobyqa"))

summary(model)

# Output:
# Fixed effects:
#                       Estimate Std. Error z value Pr(>|z|)    
# (Intercept)           -1.52      0.25     -6.08   <.001 ***
# week                   0.15      0.03      5.00   <.001 ***
# treatmentCBT-I         0.48      0.35      1.37    .171    
# week:treatmentCBT-I    0.10      0.04      2.50    .012 *  
#
# Random effects:
#  Groups     Name        Variance
#  subject_id (Intercept) 0.64

# === STEP 3: Diagnostics ===

# 3a. Convergence check
if(is.null(model@optinfo$conv$lme4$messages)) {
  cat("Model converged successfully\n")
} else {
  print(model@optinfo$conv$lme4$messages)
}

# 3b. Check random effects normality (BLUPs)
rand_effects <- ranef(model)$subject_id[[1]]
qqnorm(rand_effects, main="Q-Q Plot: Random Intercepts")
qqline(rand_effects)
shapiro.test(rand_effects)  # p > .05 indicates normality

# 3c. DHARMa residuals (simulated quantile residuals)
simulated_residuals <- simulateResiduals(fittedModel = model, n = 1000)
plot(simulated_residuals)  # Should show uniform distribution
testDispersion(simulated_residuals)  # Check for over/underdispersion

# 3d. Intraclass correlation (ICC)
icc(model)  # Proportion of variance due to subjects
# ICC = 0.64 / (0.64 + π²/3) = 0.16 (16% of variance due to subjects)

# 3e. Influential clusters (caterpillar plot)
library(lattice)
dotplot(ranef(model, condVar=TRUE))  # Look for outliers

# === STEP 4: Fixed Effects Tests ===
library(car)
Anova(model, type="III")  # Wald tests

# === STEP 5: Marginal Means and Contrasts ===
# Predicted remission rates at week 8
emm <- emmeans(model, ~ treatment | week, at=list(week=8), type="response")
summary(emm)
# Control at week 8: 44% remission (95% CI [35%, 53%])
# CBT-I at week 8: 72% remission (95% CI [63%, 80%])

# Odds ratio for treatment effect at week 8
contrast_emm <- contrast(emmeans(model, ~ treatment | week, at=list(week=8)),
                         method="pairwise")
summary(contrast_emm, type="response")  # OR = 3.2, 95% CI [1.5, 6.8]

# === STEP 6: Visualize Results ===

# Plot 1: Predicted probabilities over time
newdata <- expand.grid(
  week = seq(0, 8, by=0.5),
  treatment = c("Control", "CBT-I")
)
newdata$pred_prob <- predict(model, newdata=newdata, re.form=NA, type="response")

ggplot(newdata, aes(x=week, y=pred_prob, color=treatment)) +
  geom_line(size=1.2) +
  geom_point(data=data %>% group_by(treatment, week) %>% 
             summarise(obs_prob = mean(remission)),
             aes(y=obs_prob), size=3, alpha=0.6) +
  labs(title="Insomnia Remission Over Time by Treatment",
       x="Week", y="Predicted Probability of Remission",
       color="Treatment") +
  scale_y_continuous(limits=c(0,1), labels=scales::percent) +
  theme_minimal()

# Plot 2: Subject-specific trajectories (random effects)
subj_preds <- data.frame(
  subject_id = data$subject_id,
  week = data$week,
  treatment = data$treatment,
  pred_prob_subj = predict(model, type="response")  # Subject-specific
)

ggplot(subj_preds[subj_preds$subject_id %in% sample(1:80, 20), ],
       aes(x=week, y=pred_prob_subj, group=subject_id, color=treatment)) +
  geom_line(alpha=0.5) +
  facet_wrap(~treatment) +
  labs(title="Subject-Specific Remission Trajectories(20 random subjects)",
       x="Week", y="Predicted Probability") +
  theme_minimal()

# === STEP 7: APA-Style Reporting ===
cat("
=== APA-Style Report ===
A generalized linear mixed model(GLMM) with binomial family(logit link)
was used to analyze insomnia remission over 8 weeks, accounting for repeated
measures with random intercepts for subjects. The model included fixed effects
of time(week), treatment(CBT-I vs control), and their interaction.

Results showed a significant time × treatment interaction(z = 2.50, p = .012),
indicating that CBT-I produced greater improvement over time than control.
At week 8, CBT-I patients had 72% remission rate(95% CI [63%, 80%]) compared
to 44% in controls(95% CI [35%, 53%]). The odds ratio for CBT-I vs control at
week 8 was 3.2 (95% CI [1.5, 6.8]), indicating CBT-I patients had 3.2 times
higher odds of remission. The intraclass correlation was .16, indicating 16%
of variance in remission was due to between-subject differences.

These findings support CBT-I as an effective treatment for insomnia, with
clinically meaningful improvements emerging by week 8.
")
Interpretation Blueprint

The time × treatment interaction (z = 2.50, p = .012) indicates CBT-I produces significantly greater improvement in insomnia remission compared to control. At week 8, CBT-I showed 72% remission vs 44% in controls (OR = 3.2, 95% CI [1.5, 6.8]). ICC = .16 indicates moderate within-subject correlation, justifying mixed model approach. Results align with Edinger et al. (2001) showing CBT-I superiority for insomnia treatment.

05Tactical Pivots

Alternatives

Structured fallback pathways for choosing alternative tests when normality or slopes requirements fail.

When the path is blocked, pivot. Rigor is not rigidity; it is the intelligent adaptation to reality.
Adaptive Strategy
Measurement Precision Ladder Ideal · Non-Normal Nested Grid
Ratio
Consider Linear Mixed Models (LMM) if the distribution can be safely transformed to normal. GLMM links introduce extra bias.
Logic Over-Complexity
Binary / Count
Maintain GLMM logic. The definitive standard for hierarchical probability and frequency discovery.
Peak Signal
Ordinal Groups
Pivot to Multilevel Ordinal Logistic Regression to preserve the natural rank of your clustered outcomes.
Threshold Loss
Temporal Trajectory Audit Longitudinal Probability Flow
Repeated Binary
Trajectory flips.
Stay with GLMM. Isolate subject-specific drivers of status changes.
Marginal Average
Global rates.
Pivot to GEE with binomial/poisson links to model population-average frequencies.
Adaptive Technical Safeguards · adaptive safeguards
numerical integration failure
  • Laplace Approximation Audit — Increase the number of 'Adaptive Gauss-Hermite Quadrature' points to stabilize the link.
  • glmmTMB Switch — Pivot to the Template Model Builder framework for high-speed, stable non-normal convergence.
overdispersion in counts
  • Mixed-NB Model — Use Negative Binomial links within the hierarchy to neutralize extra-Poisson variance.
  • Observation-Level Random Effects — Add a unique intercept per data point to soak up dispersion noise.
06Adjusted Comparisons

Post-hoc

Group mean comparisons and correction controls (e.g. Tukey HSD, Bonferroni) to protect against Family-Wise Error Rates.

The omnibus test opens the door; post-hoc analysis explores the room.
Forensic Detail
Adjusted Comparisons

Post-hoc pairwise tests defined for this model.

Interpretation Guidelines

All comparisons on link scale (log-odds, log-rate), then exponentiate for OR/RR

07Standardized scale impact

Effect Size

Understanding effect sizes (e.g., Cohen's d, Partial Eta-Squared) and clinical impact benchmarks.

Significance is noise. Magnitude is the signal. Measure the impact, not just the probability.
Impact Magnitude

OR = 1.5 means 50% higher odds in treatment vs control. OR = 0.67 means 33% lower odds. OR = 1 means no effect. Cohen's d can be approximated: d ≈ log(OR) × √3/π ≈ 0.55 × log(OR)

RR = 1.3 means 30% higher rate in treatment. RR = 0.7 means 30% lower rate. RR = 1 means no effect. More interpretable than OR for common outcomes

ICC = .05 (small, 5% variance due to clusters), .10 (medium, 10%), .20+ (large, 20%+). Justifies need for mixed model. ICC = random_var / (random_var + residual_var)

Proportion of variance explained by fixed effects only (population-average). Small: .02, Medium: .13, Large: .26

Proportion of variance explained by fixed + random effects (total model). Always ≥ Marginal R²

Recommended Metric: For binomial: OR with 95% CI. For counts: RR with 95% CI. Always report ICC to quantify clustering. Report Marginal/Conditional R² for overall model fit (using r.squaredGLMM from MuMIn package in R)
Small
0.2
Medium
0.5
Large
0.8
0.50
For binomial: OR with 95% CI. For counts: RR with 95% CI. Always report ICC to quantify clustering. Report Marginal/Conditional R² for overall model fit (using r.squaredGLMM from MuMIn package in R)
Recommended Measure
5
Available Metrics
ReportUse For binomial: OR with 95% CI. For counts: RR with 95% CI. Always report ICC to quantify clustering. Report Marginal/Conditional R² for overall model fit (using r.squaredGLMM from MuMIn package in R) to represent clinical impact magnitude.
08Statistical Power

Sample Size

Guidelines for minimum sample requirements and power analysis parameters.

An underpowered study is an ethical failure. Respect the data by collecting enough of it.
Power Protocol
Floor Requirements

The 'Non-Normal 30/30' Mandate: A minimum of 30 Level-2 clusters is essential. GLMMs (Logistic/Poisson) are even more data-hungry than LMMs; the non-linear link requires massive data to stabilize random effect variance.

Effect SizeParametersRequired n
Small EffectOdds Ratio = 1.5 (Small)n ≈ 60 clusters
Medium EffectOdds Ratio = 2.5 (Medium)n ≈ 30 clusters
Large EffectOdds Ratio = 4.0 (Large)n ≈ 15 clusters
Key considerations

The 'Link-Expansion' Penalty: Every level of complexity (e.g., random slopes for multiple variables) increases the risk of 'Non-Convergence'. Only add random effects that survive the LRT strike to preserve your N-efficiency.

G*Power StrategyBenchmark: Z-tests → Multilevel GLM (Odds Ratio). Parameters: 2 groups, 3 timepoints, ICC = .20, α = .05, Power = .80. Note: Power is dictated by the density of 'Events' within clusters—rare outcomes require doubling the cluster count.
09APA narrative blueprint

Reporting

How to compile statistical results into publication prose matching APA and journal style guides.

Data does not speak for itself. It requires a translator. Be clear, be precise, be honest.
Narrative Arc
Worked APA paragraph example
A generalized linear mixed model with binomial family (logit link) and random intercepts for subjects was used to analyze insomnia remission (binary outcome) over 8 weeks. The model included fixed effects of time (week), treatment (CBT-I vs control), and their interaction. Results showed a significant time × treatment interaction (z = 2.50, p = .012), indicating that CBT-I produced greater improvement over time compared to control. At week 8, the odds ratio for CBT-I vs control was 3.2 (95% CI [1.5, 6.8]), indicating CBT-I patients had 3.2 times higher odds of remission. The intraclass correlation was .16, indicating 16% of variance in remission was attributable to between-subject differences. DHARMa residuals indicated adequate model fit with no evidence of overdispersion. These findings support CBT-I as an effective treatment for insomnia, with clinically meaningful improvements by week 8.
Reusable template

A generalized linear mixed model with family and link, e.g., 'binomial family (logit link)' or 'Poisson family (log link)' was used to analyze outcome variable. The model included list fixed effects as fixed effects and random intercepts/slopes for subject/cluster as random effects to account for repeated measures/clustering structure. If applicable: Model selection: 'Negative binomial GLMM was chosen over Poisson due to significant overdispersion (dispersion ratio = X.X, p < .001).' OR 'Random slopes were retained based on likelihood ratio test (χ² = X.X, df = X, p = .XX).' Results showed significant/non-significant effect, z = X.XX, p = .XXX. For binomial: The odds ratio was OR = X.XX (95% CI X.XX, X.XX), indicating interpretation in context. For counts: The rate ratio was RR = X.XX (95% CI X.XX, X.XX), indicating interpretation. The intraclass correlation was ICC = .XX, indicating X% of variance was due to subject/cluster. Model diagnostics: DHARMa residuals indicated adequate/inadequate model fit. Conclude with substantive interpretation in research context.

Essential statistics to report
  • Model specification (family, link, random effects structure)
  • Fixed effects estimates (β), standard errors, z-values, p-values
  • Exponentiated coefficients (OR or RR) with 95% CIs
  • Random effects variance components
  • ICC (intraclass correlation)
  • Model fit: AIC, BIC, or likelihood ratio tests
  • Diagnostics: convergence, overdispersion check, residual plots
  • Sample size: n observations, k clusters, observations per cluster
10Exhibit Builder

Manuscript Lab

Copy standard summary tables and forensic reporting grids to outline analysis details.

Table 1: GLMM for Longitudinal Treatment Success (Binary)
Fixed EffectB (Log-Odds)SEzpOR95% CI (OR)
(Intercept)-0.850.22-3.86< .0010.43[0.28, 0.66]
Time (Months)0.420.085.25< .0011.52[1.30, 1.78]
Treatment (Active)1.120.303.73< .0013.06[1.70, 5.52]
Time × Treatment0.350.122.92.0031.42[1.12, 1.80]
Note. Link function: Logit. Random Intercept for Subject included. N = 150 (450 obs).
Interaction (p=.003)Confirms Treatment Superiority. The odds of success improve 42% faster per month in the Active group compared to Control.
Treatment OR = 3.06Powerful Effect. At the average timepoint, the treatment group has over 3x the odds of success compared to control.
Header glossary

The Success Multiplier. OR = 1.52 for Time means the odds of success increase by 52% each month for the average subject.

Baseline Heterogeneity. Measures how much subjects differ in their starting success probability on the logit scale.

11Algorithmic Logic

Command Center

Syntax libraries and function parameters for executing calculations in stats packages.

Code is the modern laboratory. Clean execution ensures reproducible discovery.
Execution Engine
# 1. Fit GLMM (Binary Outcome)
model <- lme4::glmer(success ~ time * treatment + (1 | subject_id), 
                     data = df, family = binomial)
summary(model)

# 2. Extract Odds Ratios
exp(fixef(model))
Library stack
R
lme4emmeansperformance
Python
statsmodels
Elite Forensic Strike

GLMMs are prone to 'Convergence Failure'. If the model doesn't converge, try simplify the random effects or switch to the 'bobyqa' optimizer.

# Audit for Convergence and Overdispersion
performance::check_convergence(model)
performance::check_overdispersion(model)
12The Over-adjustment Trap

Common Mistakes

Analytical caveats and corrections to maintain modeling integrity.

Wisdom is learning from the failures of others. Anticipate the error before it occurs.
Defensive Logic
Why it's wrong
Poisson assumes variance = mean (equidispersion). When variance > mean (overdispersion), Poisson underestimates standard errors, leading to inflated Type I error (false positives). P-values are too small, confidence intervals too narrow. Overdispersion is common in count data due to unmeasured heterogeneity
The correction
Test for overdispersion using performance::check_overdispersion() or DHARMa::testDispersion(). If detected (p < .05 or dispersion ratio > 1.5), use negative binomial GLMM (glmer.nb in lme4) or quasi-Poisson. Compare AIC: negative binomial should have much lower AIC if overdispersion present
Why it's wrong
If treatment effect varies by subject (random slopes needed) but only random intercepts included, model underestimates SEs for fixed effects and inflates Type I error. Assumes all subjects respond identically to treatment, which is often unrealistic. Violates assumption that random effects capture all within-cluster correlation
The correction
For time-varying predictors (time, treatment × time), test random slopes with likelihood ratio test: compare models with/without random slopes using anova(model_intercept, model_slope). If LRT p < .05 or if theoretically justified, include random slopes: (time | subject_id). If non-convergence, try uncorrelated random effects: (time || subject_id), or simplify to random intercepts only if slopes variance near zero
Why it's wrong
With few clusters, random effect variance is poorly estimated (large SE), and fixed effect SEs are anticonservative (too small), inflating Type I error. Asymptotic theory for GLMMs requires many clusters. Random effects assumed normally distributed, but this cannot be verified with few clusters. Simulation studies show coverage of 95% CIs drops below 90% with k < 20
The correction
If k < 20: (1) Use GEE with sandwich SEs (more robust with few clusters); (2) Use cluster-level fixed effects instead of random effects; (3) Use Kenward-Roger or Satterthwaite df corrections (not available for GLMMs, only LMMs); (4) Use bootstrap CIs; (5) Use Bayesian GLMMs with weakly informative priors on variance components. Minimum k = 20-30 for random intercepts, k = 50+ for random slopes
Why it's wrong
For rare outcomes (< 10%), OR ≈ RR. But for common outcomes, OR overestimates RR (odds ratios are further from 1 than risk ratios). Example: If outcome increases from 40% to 60%, RR = 60/40 = 1.5 (50% increase), but OR = (0.6/0.4)/(0.4/0.6) = 2.25. OR = 2.25 sounds like 'more than double risk' but actual risk increase is 50%. This exaggerates effects and misleads non-technical audiences
The correction
For common outcomes (> 10-20%): (1) Report OR with clear interpretation: 'OR = 2.25 means 2.25 times higher odds, not risk'; (2) Calculate predicted probabilities at representative covariate values using emmeans with type='response', then report absolute risk difference; (3) Use log-binomial model or modified Poisson with robust SEs to directly estimate RR (but convergence issues common); (4) Always visualize predicted probabilities; (5) In papers, state: 'OR overestimates RR for common outcomes'
Why it's wrong
Convergence warnings indicate optimizer did not find reliable parameter estimates. Results may be incorrect, with inaccurate SEs and p-values. 'Singular fit' means random effect variance estimated at exactly zero (or correlation at ±1), suggesting overparameterized random structure. Proceeding with non-converged models leads to unreliable inference
The correction
If convergence warning: (1) Try different optimizer: control=glmerControl(optimizer='bobyqa') or 'Nelder_Mead'; (2) Increase iterations: optCtrl=list(maxfun=1e5); (3) Scale/center continuous predictors; (4) Simplify random structure: remove random slopes or correlation. If singular fit (random variance ≈ 0): (1) Remove that random effect (not contributing); (2) Use simpler model; (3) Check if few clusters or small within-cluster n. Never report results from non-converged models without addressing convergence
Why it's wrong
Uncentered predictors lead to: (1) Intercept interpreted at predictor = 0, which may be out of range or meaningless (e.g., age = 0); (2) High multicollinearity between main effects and interactions, inflating SEs; (3) Convergence issues in models with random slopes (optimizer struggles with different scales); (4) Random intercept variance difficult to interpret when predictors not centered. Random slopes may be correlated with intercepts due to scaling artifacts
The correction
Grand-mean center continuous predictors: age_c = age - mean(age). Benefits: (1) Intercept = outcome at mean age (interpretable); (2) Reduces collinearity; (3) Aids convergence; (4) Random intercept = deviation at mean predictor value. For interactions: center all components before multiplying. For random slopes: centering reduces intercept-slope correlation. Standardizing (z-scores) additionally aids interpretation: 1-unit increase = 1 SD increase
Why it's wrong
In GLMMs, fixed effect coefficients are conditional effects (subject-specific effects controlling for random effects), not population-average (marginal) effects. Due to nonlinearity of link function, averaging over random effects changes effect magnitude. Conditional effects are typically larger than marginal effects. Example: conditional OR = 2.0 might correspond to marginal OR = 1.5. Reporting conditional effects as population-average effects overstates impact
The correction
Clarify interpretation: 'OR = 2.0 is conditional effect (subject-specific), controlling for random effects'. For population-average effects, use GEE instead of GLMM. To report marginal effects from GLMM: predict outcome at fixed covariate values averaging over random effect distribution (emmeans with re.form=NA does this). Visualize both subject-specific (with random effects) and population-average (without random effects) predictions. GEE directly estimates marginal effects; GLMM estimates conditional effects
Why it's wrong
If ICC ≈ 0 (negligible clustering), mixed model is unnecessary and reduces power compared to simpler GLM. Conversely, if ICC is moderate-high but ignored (using GLM instead of GLMM), SEs are underestimated and Type I error inflated. Reporting ICC quantifies clustering magnitude and justifies model complexity. Reviewers expect ICC to be reported
The correction
Always calculate and report ICC using performance::icc() or manual formula: ICC = σ²_cluster / (σ²_cluster + σ²_residual). For Poisson: σ²_residual = 1; for binomial: σ²_residual = π²/3 ≈ 3.29. Interpret: ICC = .05 (small, 5% variance due to clustering), .10 (medium), .20+ (large). If ICC < .01 and non-significant random effect variance, consider simpler GLM. If ICC > .05, mixed model is justified. Report: 'ICC = .12, indicating 12% of variance due to clustering, justifying mixed model approach'
13Academic Lineage

References

Scholarly lineage and citation keys grounding the statistical framework.

We stand on the shoulders of giants. Honor the source of the method.
Academic Lineage
[1]
Bolker, B. M., Brooks, M. E., Clark, C. J., Geange, S. W., Poulsen, J. R., Stevens, M. H. H., & White, J. S. S. (2009). Generalized linear mixed models: a practical guide for ecology and evolution. Trends in Ecology & Evolution, 24(3), 127-135.
Essential practical guide to GLMMs: assumptions, diagnostics, common pitfalls, when to use random slopes, overdispersion. Highly cited tutorial
doi: 10.1016/j.tree.2008.10.008
[2]
Harrison, X. A., Donaldson, L., Correa-Cano, M. E., Evans, J., Fisher, D. N., Goodwin, C. E., ... & Inger, R. (2018). A brief introduction to mixed effects modelling and multi-model inference in ecology. PeerJ, 6, e4794.
Accessible introduction to mixed models including GLMMs. Covers model selection, random effects structure, diagnostics using DHARMa, reporting guidelines
doi: 10.7717/peerj.4794
[3]
Stroup, W. W. (2012). Generalized Linear Mixed Models: Modern Concepts, Methods and Applications. CRC Press.
Comprehensive textbook on GLMMs. Covers theory, software (SAS GLIMMIX, R lme4), binomial/Poisson/negative binomial models, overdispersion, model selection, diagnostics. Includes agricultural and clinical examples
[4]
Hartig, F. (2022). DHARMa: Residual Diagnostics for Hierarchical (Multi-Level / Mixed) Regression Models. R package version 0.4.6.
DHARMa package for GLMM diagnostics using simulated quantile residuals. Essential for checking distributional assumptions, overdispersion, zero-inflation in GLMMs
[5]
Gelman, A., & Hill, J. (2006). Data Analysis Using Regression and Multilevel/Hierarchical Models. Cambridge University Press.
Classic textbook on multilevel models (including GLMMs). Emphasizes practical data analysis, interpretation, and visualization. Chapters 13-16 cover GLMMs for binary and count outcomes
[6]
Edinger, J. D., Wohlgemuth, W. K., Radtke, R. A., Marsh, G. R., & Quillian, R. E. (2001). Cognitive behavioral therapy for treatment of chronic primary insomnia: A randomized controlled trial. JAMA, 285(14), 1856-1864.
RCT showing CBT-I efficacy for insomnia (OR ≈ 3.5 for remission). Basis for Example 1
doi: 10.1001/jama.285.14.1856
Probability is complex; hierarchical probability is elite. Respect the random intercept, for it represents the unique starting line of every cluster in your study.
The Interpretive Rigor Directive
statminds · GeneralizedMind reference · v2.2 · updated 2026-01-1715 of 15 sections