Atlas
statminds
Categorical GLM (Multi-Way Frequency 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

Log-Linear Analysis

The engine for Multi-Way Categorical Discovery. Log-Linear Analysis audits the complex network of associations between categorical variables in multi-dimensional tables, seeking the 'Best-Fit' hierarchy of synergy.

Model familyCategorical GLM (Multi-Way Frequency Model)
Hypothesisomnibus test
AliasesMulti-Way Contingency Analysis · Hierarchical Log-Linear Model · Categorical Interaction Test
G1
Categorical Synergy Audit
Identify higher-order interactions between three or more categorical variables.
G2
Non-DV Association Discovery
Map relationships in a field where all variables are treated as interdependent, rather than DV vs. IV.
G3
Model Parsimony Search
Determine the simplest set of interactions required to explain the observed frequency distribution.
1

What is it?

Log-Linear Analysis models contingency tables involving multiple categorical variables, evaluating multi-way interactions on logarithmic probability scales.

2

When to use it

  • Multiple Categories: Outcome variable is count frequencies in combinations of factors.
  • 3-Way Interactions: Evaluate if associations change across categories.
Interactive Sandbox

Categorical Log-Linear Interaction Laboratory

Adjust interaction coefficient size to see observed vs expected category deviations.

Interaction Coefficient0.80
Total Table Frequency60
Observed vs Expected Cell Counts (2x2 contingency grid)Amber numbers indicate expected counts
20E=15.010E=15.010E=15.020E=15.0
Goodness-of-Fit Table
MetricValue
Likelihood Chi-Square6.6667
p-value0.0098
The 12-Stage Precision Workflow
01Interaction Saturated
Hypotheses
We test the Saturated Model (all possible synergies) against the discovery of a more efficient, parsimonious hierarchy.
02Frequency Density
Assumptions
Ensuring the expected cell counts are large enough to support the Chi-Square basis of the model—the foundational categorical mandate.
03focus
Utilizing G-Square (Likelihood Ratio Chi-Square) to audit model fit—seeking the non-significant p-value that indicates your model matches reality.
04focus
Analyzing the three-way interaction between FlowMotion Group, Recovery Status, and Gender—seeking the categorical 'Hotspot'.
05Logistic Pivot
Alternatives
Knowing when to switch to Logistic Regression if one categorical variable is clearly the 'Outcome' rather than just a related factor.
06Stepwise Strike
Significance
Executing 'K-Way and Higher' strikes to determine the overall complexity level of the associations in the grid.
07focus
Interpreting parameter estimates as the multiplicative shift in cell frequencies—revealing the 'Weight' of each association.
08The N Density
Sample Size
Accounting for the exponential increase in required N as categories are added—preventing the 'Empty Cell' model collapse.
09The Parsimony Story
Reporting
Reporting the 'Simplest Saturated Model' that successfully captures the data pattern without unnecessary complexity.
10loglm / loglin Logic
Software
Executing the 'loglm' or 'MASS' commands, ensuring the model formula specifies the hierarchy correctly (e.g., A*B*C).
11focus
Avoiding the error of reporting higher-order interactions without including all underlying lower-order terms—the 'Functional Error'.
12focus
Tracing the logic back to Goodman (1970) and the foundational evolution of multi-way frequency forensics.
01Hypothesis test logic

Hypotheses

Pragmatic null and alternative hypotheses defined in mathematical notation.

We ask not just 'is there a link?', but 'how much does Y change for every unit of X?'
Logic Core
Null · H₀

H₀: Model of independence (or specified structure) fits the data (no k-way interaction)

Alternative · Hₐ

Hₐ: Model does not fit; specified interaction(s) exist

Why it matters omnibus test

For saturated model: H₀: all k-way interactions = 0. For independence model: H₀: all associations = 0 (variables independent). For partial associations: test specific λ parameters (interaction terms). Loglinear models are symmetric: no distinction between DV and IVs, unlike logistic regression. Log of expected cell frequencies modeled as linear combination of effects.

02Model diagnostics

Assumptions

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

Linearity is a strong claim. Nature often curves; ensure your model does not force a straight line on a bent world.
Integrity Shield
7
Assumptions
5
Critical / High Severity
How to check
Quick
Design review: verify each subject counted once in contingency table. Check for repeated measures (same subject in multiple cells), matched pairs, or clustering. Sum of cell counts should equal total sample size.
Rigorous
Examine data structure for duplicate IDs. Check if sum of frequencies equals n. If longitudinal data, verify cross-sectional slice or use appropriate repeated-measures approach.
If violated
If repeated measures: (1) Use marginal homogeneity models (e.g., McNemar for 2×2, Cochran's Q for larger). (2) Generalized estimating equations (GEE) for categorical data. (3) Log-linear models with repeated measures structures. If clustered: (4) Account for clustering via robust SEs or multilevel categorical models.
mcnemargee
How to check
Quick
Calculate expected frequencies under independence model: E_ij = (row_i total × col_j total) / grand total. Count cells with E < 5. If >20% have E<5 or any E=0, assumption violated.
Rigorous
Fit independence model and extract expected frequencies. Check proportion of cells with expected <5. For sparse tables, use exact methods or collapse categories if substantively justified.
If violated
If sparse cells: (1) BEST: Collapse adjacent categories if theoretically justified (e.g., combine rare responses). (2) Use exact tests (Fisher's exact for 2×2, Monte Carlo for larger tables). (3) Increase sample size. (4) Use Bayesian methods with informative priors. (5) Report results cautiously with wider confidence intervals. Never create categories solely to meet assumption.
fisher exact
How to check
Quick
Verify all variables are discrete categories with finite levels. Check if variables have been artificially categorized from continuous measures. Count number of levels per variable (loglinear works best with 2-5 levels per variable).
Rigorous
Assess measurement level: nominal (unordered categories), ordinal (ordered), or continuous. If continuous variables were categorized, consider using original continuous form with appropriate regression.
If violated
If continuous DV: (1) Use Poisson/negative binomial regression (count outcome) or linear regression (continuous outcome). If continuous predictors: (2) Use logistic regression (binary DV) or multinomial logistic (polytomous DV) or ordinal regression (ordinal DV). If mix of categorical and continuous: (3) Use generalized linear models (GLMs) appropriate for outcome type.
poisson regressionlogistic regressionmultinomial logistic
How to check
Quick
For Poisson assumption: total sample size is random (not fixed in advance). For multinomial: row totals, column totals, or both are fixed by design. Check study design: simple random sample → Poisson; stratified with fixed margins → multinomial.
Rigorous
Assess sampling scheme. If Poisson, variance should equal mean for each cell (overdispersion test). If overdispersion detected (variance > mean across cells), quasi-Poisson or negative binomial loglinear may be needed.
If violated
If overdispersion (variance >> mean): (1) Use quasi-Poisson loglinear (adjusts SEs for overdispersion). (2) Negative binomial loglinear models. (3) Check for unmeasured confounders or model misspecification causing overdispersion. If multinomial sampling but Poisson assumed: (4) Results usually robust to this violation; inference still valid.
How to check
Quick
If model includes AB interaction, must include A and B main effects. If ABC three-way interaction, must include AB, AC, BC two-way interactions and A, B, C main effects. Check model specification for hierarchy violations.
Rigorous
Review model formula. For each interaction term, verify all lower-order relatives present. Software (e.g., R's MASS::loglm, loglin) enforces hierarchy automatically in most cases.
If violated
If hierarchy violated: (1) Add missing lower-order terms to respect marginality. Non-hierarchical models are difficult to interpret and usually not recommended. (2) If intentional (rare), justify theoretically and interpret carefully. Standard practice: always maintain hierarchy.
How to check
Quick
Count number of cells in contingency table (product of variable levels: I×J for 2-way, I×J×K for 3-way). Calculate n / (number of cells). If ratio < 5, sample may be insufficient. For saturated model, need n ≥ number of cells.
Rigorous
Calculate degrees of freedom for model. Ensure sample size provides adequate power for tests of interest. Check if any cells are structural zeros (impossible combinations) vs sampling zeros.
If violated
If insufficient sample: (1) Reduce model complexity (fewer variables or collapsed categories). (2) Fit simpler models (e.g., mutual independence instead of saturated). (3) Increase sample size if feasible. (4) Use exact methods for sparse tables. (5) Apply Bayesian methods with regularizing priors.
How to check
Quick
Identify structural zeros based on design: e.g., 'Male' × 'Pregnant' is structural zero. Differentiate from sampling zeros (possible combinations with zero observed count by chance). Count structural zeros and check if they affect model fit.
Rigorous
For structural zeros: fit quasi-independence or quasi-loglinear models that exclude these cells from analysis. Use incomplete table methods. Check if structural zeros create separation issues.
If violated
If structural zeros present: (1) BEST: Use quasi-independence model (fits only non-structural cells). (2) Recode variables to eliminate impossible combinations (e.g., separate analysis by sex). (3) Use incomplete contingency table methods. (4) Report structural zeros explicitly and exclude from expected counts.
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. Likelihood ratio chi-square (G²) for overall model fit
  2. Pearson chi-square (X²) as alternative fit statistic
  3. Standardized residuals (|r| > 2 suggests poor fit in cell)
  4. AIC/BIC for model comparison (lower is better)
  5. Deviance residuals to identify poorly fitted cells
Recommended checks
  1. Compare multiple models (independence, main effects, two-way interactions, saturated)
  2. Examine adjusted residuals (> |2| indicates significant cell contribution to misfit)
  3. Plot mosaic plots or association plots for visualizing patterns
  4. Check for outlier cells (large residuals)
  5. Calculate λ parameters (log-linear effects) with confidence intervals
  6. Odds ratios for specific associations
  7. Test specific contrasts or simple effects if interactions present
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

Yoga Type × Injury Status × Experience Level (3-Way Contingency Table)

Research question: Are yoga-related injuries associated with yoga type and practitioner experience level? Design: Cross-sectional survey (n=600). Variables: Yoga type (Hatha, Vinyasa, Restorative), Injury past year (No, Yes), Experience (Beginner, Intermediate, Advanced). Test all two-way and three-way associations.

DesignThree-way contingency table analysis
# Loglinear Analysis: 3-Way Contingency Table
# Yoga Type × Injury × Experience Level

library(MASS)        # For loglm()
library(vcd)         # For mosaic plots and association plots
library(vcdExtra)    # For extended loglinear tools

set.seed(2025)

# Simulate realistic data
n <- 600
yoga_type <- sample(c("Hatha", "Vinyasa", "Restorative"), n, replace=TRUE, prob=c(0.4, 0.4, 0.2))
experience <- sample(c("Beginner", "Intermediate", "Advanced"), n, replace=TRUE, prob=c(0.35, 0.45, 0.2))

# Injury depends on yoga type and experience (interaction)
# Hatha + Beginner = higher injury risk
injury_prob <- 0.10 + 
               0.15*(yoga_type=="Hatha") + 
               0.10*(yoga_type=="Vinyasa") - 
               0.05*(experience=="Intermediate") - 
               0.10*(experience=="Advanced") +
               0.12*(yoga_type=="Hatha" & experience=="Beginner")

injury <- rbinom(n, 1, pmin(injury_prob, 0.6))
injury <- factor(injury, levels=c(0, 1), labels=c("No", "Yes"))

# Create contingency table
data <- data.frame(yoga_type, injury, experience)
contingency_table <- xtabs(~ yoga_type + injury + experience, data=data)

cat("=== Three-Way Contingency Table ===\n")
print(contingency_table)
cat("\nTotal n:", sum(contingency_table), "\n")
cat("Number of cells:", length(contingency_table), "\n\n")

# === STEP 1: Test Independence (Mutual Independence Model) ===

# Model 1: Mutual independence [Y][I][E]
model_indep <- loglm(~ yoga_type + injury + experience, data=contingency_table)
summary(model_indep)

cat("\n=== Model 1: Mutual Independence ===\n")
cat("G² =", model_indep$lrt, ", df =", model_indep$df, ", p =", model_indep$prob, "\n")
if(model_indep$prob < 0.05) {
  cat("Model does NOT fit(p < .05): variables are associated\n")
} else {
  cat("Model fits(p > .05): mutual independence supported\n")
}

# === STEP 2: All Two-Way Associations [YI][YE][IE] ===

model_2way <- loglm(~ yoga_type*injury + yoga_type*experience + injury*experience,
                    data=contingency_table)
summary(model_2way)

cat("\n=== Model 2: All Two-Way Associations ===\n")
cat("G² =", model_2way$lrt, ", df =", model_2way$df, ", p =", model_2way$prob, "\n")
cat("AIC:", model_2way$lrt - 2*model_2way$df, "\n")

# === STEP 3: Saturated Model (includes three-way interaction) [YIE] ===

model_sat <- loglm(~ yoga_type*injury*experience, data=contingency_table)
summary(model_sat)

cat("\n=== Model 3: Saturated(Three-Way Interaction) ===\n")
cat("G² =", model_sat$lrt, ", df =", model_sat$df, "\n")
cat("(Saturated model always fits perfectly)\n")

# === STEP 4: Model Comparison ===

cat("\n=== Model Comparison ===\n")
models <- data.frame(
  Model = c("Mutual Independence", "All 2-Way", "Saturated"),
  G2 = c(model_indep$lrt, model_2way$lrt, model_sat$lrt),
  df = c(model_indep$df, model_2way$df, model_sat$df),
  p_value = c(model_indep$prob, model_2way$prob, NA),
  AIC = c(model_indep$lrt - 2*model_indep$df,
          model_2way$lrt - 2*model_2way$df,
          model_sat$lrt - 2*model_sat$df)
)
print(models)

cat("\nBest model(lowest AIC):")
best_model <- models$Model[which.min(models$AIC)]
cat(best_model, "\n\n")

# === STEP 5: Test Specific Associations ===

# Test if three-way interaction is needed (compare 2-way vs saturated)
G2_diff <- model_2way$lrt - model_sat$lrt
df_diff <- model_2way$df - model_sat$df
p_diff <- 1 - pchisq(G2_diff, df_diff)

cat("=== Test Three-Way Interaction ===\n")
cat("ΔG² =", G2_diff, ", Δdf =", df_diff, ", p =", round(p_diff, 4), "\n")
if(p_diff < 0.05) {
  cat("Three-way interaction significant(p < .05)\n")
  cat("Injury × Yoga × Experience interaction exists\n\n")
} else {
  cat("Three-way interaction not significant(p > .05)\n")
  cat("Two-way associations model is adequate\n\n")
}

# === STEP 6: Examine Residuals ===

# Standardized residuals from best-fitting model
resid_model <- model_2way
std_resids <- residuals(resid_model, type="pearson")

cat("=== Standardized Residuals(|r| > 2 indicates poor fit) ===\n")
print(round(std_resids, 2))

large_resids <- which(abs(std_resids) > 2, arr.ind=TRUE)
if(nrow(large_resids) > 0) {
  cat("\nCells with |residual| > 2:\n")
  print(large_resids)
} else {
  cat("\nNo cells with large residuals(model fits well)\n")
}

# === STEP 7: Odds Ratios for Key Associations ===

# Yoga Type × Injury association (collapsed across experience)
yoga_injury_table <- margin.table(contingency_table, c(1,2))
cat("\n=== Yoga Type × Injury Table ===\n")
print(yoga_injury_table)

# Odds ratios (Hatha vs Restorative for injury)
OR_hatha_rest <- (yoga_injury_table["Hatha","Yes"] * yoga_injury_table["Restorative","No"]) /
                 (yoga_injury_table["Hatha","No"] * yoga_injury_table["Restorative","Yes"])

cat("\nOdds Ratio(Hatha vs Restorative for Injury):", round(OR_hatha_rest, 2), "\n")
cat("Interpretation: Hatha practitioners have", round(OR_hatha_rest, 2), 
    "times the odds of injury compared to Restorative practitioners\n")

# === STEP 8: Visualization ===

# Mosaic plot
library(vcd)
mosaic(~ yoga_type + experience + injury, data=data,
       shade=TRUE, legend=TRUE,
       main="Mosaic Plot: Yoga Type × Experience × Injury",
       labeling=labeling_border(rot_labels=c(45,0,0,0)))

# Association plot (shows residuals)
assoc(contingency_table, shade=TRUE,
      main="Association Plot: Standardized Residuals")

# Conditional plot: Injury by Yoga Type, stratified by Experience
library(ggplot2)
ggplot(data, aes(x=yoga_type, fill=injury)) +
  geom_bar(position="fill") +
  facet_wrap(~ experience) +
  scale_fill_manual(values=c("#1a9850", "#d73027"),
                    labels=c("No Injury", "Injury")) +
  labs(title="Injury Rates by Yoga Type and Experience Level",
       x="Yoga Type", y="Proportion", fill="Injury Status") +
  theme_classic() +
  theme(axis.text.x=element_text(angle=45, hjust=1))

# === APA-Style Reporting ===
cat("\n=== APA Report ===\n")
cat("A loglinear analysis examined associations among yoga type(Hatha, Vinyasa,\n")
cat("Restorative), injury status, and experience level in a 3×2×3 contingency\n")
cat("table(n=600). The mutual independence model did not fit(G²=XX.X, df=XX,\n")
cat("p<.001), indicating variables were associated. The model with all two-way\n")
cat("associations fit adequately(G²=X.X, df=X, p=.XX, AIC=XX) and was preferred\n")
cat("over the saturated model(ΔAIC=X.X). The three-way interaction was not\n")
cat("significant(ΔG²=X.X, Δdf=X, p=.XX), suggesting associations did not differ\n")
cat("across experience levels. Key findings: Hatha yoga was associated with higher\n")
cat("injury risk compared to Restorative(OR=2.3, 95% CI [1.5, 3.6]). Beginners\n")
cat("showed higher injury rates across all yoga types(OR=1.8 vs Advanced,\n")
cat("p<.01). Results suggest injury prevention efforts should target Hatha\n")
cat("practitioners, especially beginners.\n")
Interpretation Blueprint

Loglinear analysis revealed significant associations among yoga type, injury status, and experience level. Mutual independence model was rejected (G²=45.3, p<.001), indicating variables are not independent. Model with all two-way associations fit adequately (G²=3.2, df=4, p=.52, AIC=31.2) and was preferred (lowest AIC). Three-way interaction was not significant (ΔG²=3.2, p=.52), suggesting associations between yoga type and injury were similar across experience levels. Key findings: (1) Yoga Type × Injury: Hatha associated with higher injury odds (OR=2.3 vs Restorative). (2) Experience × Injury: Beginners had 1.8× higher injury odds than Advanced. (3) Yoga Type × Experience: Beginners disproportionately practice Hatha. Results suggest injury prevention should target Hatha beginners specifically.

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 · Multi-Way Nominal Grid
Ratio / Interval
Consider Poisson Regression or Logistic models if you have a clear DV. Log-linear is for interdependent frequencies.
Extreme Data Loss
Ordinal Grid
Pivot to Ordinal Log-Linear models (Linear-by-Linear association) to preserve the ranked nature of your grid.
Information Leak
Nominal Grid
Maintain Log-Linear logic. The definitive engine for auditing multi-dimensional categorical synergy.
Peak Signal
Temporal Trajectory Audit Static Frequency Snapshot
Static Grid
Single point audit.
Stay with Log-Linear. Find the 'Best-Fit' hierarchy of associations.
Repeated Grids
Longitudinal frequencies.
Pivot to Marginal Homogeneity tests or Categorical GEE to account for subject-level status flips.
Adaptive Technical Safeguards · adaptive safeguards
excessive zero cells
  • Category Collapsing — Merge adjacent thin levels to stabilize the G-Square fit.
  • Monte Carlo Chi-Square — resample the null distribution to protect significance in sparse grids.
  • Penalized Log-Linear (L1) — Apply Lasso shrinkage to select only the most robust interactions.
clear dv defined
  • Multinomial Logistic Regression — Pivot to asymmetric modeling if one variable is the 'Outcome' and others are 'Predictors'.
  • Poisson Regression — Treat the cell counts as the dependent variable if exposure varies across the grid.
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

No specific guidelines provided.

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 for 2×2 subtables. OR=1: no association. OR>1: positive association. OR<1: negative association. Report with 95% CI. Convert to log-odds for additive interpretation.

Log-linear effect parameters (λ). λ=0: no effect. λ>0: positive effect on log cell frequency. λ<0: negative effect. Exponentiate for multiplicative interpretation on cell counts.

Pseudo-R² based on G²: R²_LR = (G²_null - G²_model) / G²_null. Values 0.20-0.40 considered moderate to good fit for categorical models.

Recommended Metric: odds ratios for specific associations (interpretable), λ parameters for full model description
Small
0.2
Medium
0.5
Large
0.8
0.50
odds ratios for specific associations (interpretable), λ parameters for full model description
Recommended Measure
3
Available Metrics
ReportUse odds ratios for specific associations (interpretable), λ parameters for full model description 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 'Cell-Symmetry' Minimum: A minimum of 5 participants per individual cell in the multi-way grid is required. Categorical interactions collapse mathematically if grid sparsity is too high to stabilize the G-Square math.

Effect SizeParametersRequired n
Small Effectw=0.10 (Small)n ≈ 1200
Medium Effectw=0.30 (Medium)n ≈ 150
Large Effectw=0.50 (Large)n ≈ 50
Key considerations

The 'Parsimony Buffer': In large grids, 'Zero-Cells' are the silent killers of discovery. If your grid has more than 20% empty cells, your power is a phantom. Recruit for 'Grid Saturation' to maintain the integrity of the hierarchy audit.

G*Power StrategyBenchmark: χ² tests → Log-linear synergy. Parameters: Table dimensions (r x c x l), Effect size w, α = .05, Power = .80. Note: Power decreases exponentially as the number of variables in the 'Saturated Model' increases.
09APA narrative blueprint

Reporting

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

The Beta coefficient is the currency of change. Interpret it in real-world units, not just standardized abstractions.
Narrative Arc
Worked APA paragraph example
A loglinear analysis examined associations among yoga type (Hatha, Vinyasa, Restorative), injury status (No, Yes), and experience level (Beginner, Intermediate, Advanced) in a 3×2×3 contingency table (n=600). The mutual independence model was rejected (G²=45.3, df=12, p<.001), indicating the variables were associated. The model with all two-way associations fit adequately (G²=3.2, df=4, p=.52, AIC=31.2) and was preferred over the saturated model (ΔAIC=8.8). The three-way interaction was not significant (ΔG²=3.2, Δdf=4, p=.52), suggesting that associations between yoga type and injury did not differ across experience levels. Hatha yoga was associated with higher injury odds compared to Restorative (OR=2.3, 95% CI [1.5, 3.6]), and beginners showed higher injury rates than advanced practitioners (OR=1.8, 95% CI [1.2, 2.7]). Findings suggest injury prevention efforts should target Hatha practitioners, particularly beginners.
Reusable template

A loglinear analysis examined associations among list variables in a I×J×K contingency table (n=N). If tested The mutual independence model was rejected (G²=value, df=value, p<.XXX), indicating variables were associated. Model fitting The model specify: e.g., with all two-way associations fit the data adequately (G²=value, df=value, p=.XXX, AIC=value) and was preferred over comparison model (ΔAIC=value). If tested three-way interaction The three-way interaction was/was not significant (ΔG²=value, Δdf=value, p=.XXX). Key associations Specifically, Variable A and Variable B were significantly associated (OR=value, 95% CI X.XX, X.XX), indicating substantive interpretation. Conclude Findings suggest theoretical/practical implications.

Essential statistics to report
  • Sample size and table dimensions (I×J×K)
  • G² (likelihood ratio chi-square) and df for each model tested
  • p-values for model fit tests
  • AIC/BIC for model comparison
  • Specific test statistics for key associations or interactions (ΔG², Δdf, p)
  • Odds ratios with 95% CI for substantively important associations
  • Statement about which model was selected and why
  • Any violations of assumptions (sparse cells) and remedies
10Exhibit Builder

Manuscript Lab

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

Table 1: Log-Linear Analysis for Multi-way Categorical Interactions
Model TermdfL.R. χ² (G²)pResult
Main Effects (G+R+O)6145.2< .001Significant
First-Order Int. (G*R + G*O + R*O)1245.1< .001Significant
Saturated (G*R*O)42.1.718Parity (Good Fit)
Note. Factors: Group × Response × Outcome. N = 400. Reporting Likelihood Ratio χ².
Saturated p = .718Identifies the Winner. A non-significant p-value relative to the saturated model means the simpler interaction model is 'good enough' to explain the data.
Header glossary

The Deviance Meter. Measures how well the model predicts the frequency counts in each cell of the multi-way table.

The Perfect Model. Includes every possible interaction. We compare simpler models to the saturated model to find the most 'parsimonious' fit.

11Algorithmic Logic

Command Center

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

Code your model to handle residuals. The errors tell you what your model missed.
Execution Engine
# 1. Fit Log-Linear Model
model <- loglm(~ Group * Response * Outcome, data = table_data)

# 2. Extract Partial Associations
summary(model)
Library stack
R
MASSvcd
Python
statsmodels
Elite Forensic Strike

Log-linear analysis is the multidimensional version of the Chi-Square test. Use it when you have 3 or more categorical variables and want to find where the interactions live.

# Visualize Multi-way Interactions (Mosaic Plot)
vcd::mosaic(~ Group + Response + Outcome, data = table_data)
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
Loglinear models ALL variables symmetrically (no DV vs IV distinction); predicts cell frequencies. Logistic regression has designated DV (binary/categorical outcome) predicted by IVs; predicts individual probabilities. Using wrong approach misspecifies research question and yields incorrect interpretation.
The correction
Use loglinear when: (1) No clear DV (exploratory associations among categories), (2) Analyzing patterns in contingency table, (3) Testing independence or specific association structures. Use logistic when: (1) Clear DV to predict, (2) Individual-level data with covariates, (3) Want odds ratios for effects on outcome.
Why it's wrong
Sparse cells inflate Type I error (anti-conservative tests), lead to unstable parameter estimates, large standard errors, and poor model convergence. Chi-square approximation breaks down with expected <5 in >20% cells. Results unreliable.
The correction
Check expected frequencies under independence model. If >20% cells have E<5: (1) Collapse adjacent categories (pre-specify, justify theoretically), (2) Use exact tests (Fisher's exact, Monte Carlo simulation), (3) Increase sample size, or (4) Use Bayesian methods. Report sparse cells and remedies.
Why it's wrong
Non-hierarchical models violate principle of marginality: if A×B interaction included, A and B main effects must be included for interpretability. Without hierarchy, marginal effects depend on arbitrary coding, parameters not invariant to recoding, and interpretation is ambiguous.
The correction
Always maintain hierarchical structure. If testing A×B interaction, include A and B main effects. If testing A×B×C three-way interaction, include all two-way interactions (A×B, A×C, B×C) and main effects. Software usually enforces this automatically.
Why it's wrong
Pearson χ² is not additive across nested models; cannot compute ΔX² meaningfully. G² (likelihood ratio chi-square) is additive: G²_A - G²_B = ΔG² for testing nested models. Pearson χ² also less robust to sparse cells than G².
The correction
Use G² (likelihood ratio statistic) for model comparison and testing specific effects. Pearson χ² can supplement as goodness-of-fit check but primary inference should use G². Report both if they diverge substantially (suggests model issues).
Why it's wrong
With many cells (e.g., 18-cell table), expect ~1 cell to have |residual|>2 by chance (α=.05 per cell). Examining all cells without adjustment inflates family-wise error rate, leading to false positives (finding 'significant' cells that are chance deviations).
The correction
Use adjusted critical values for residuals (e.g., |r| > 3 for α=.001 per cell, or Bonferroni: |r| > z_(α/(2×cells))). Focus on substantively meaningful patterns, not isolated extreme cells. Report adjustment method. Consider residuals as exploratory, not confirmatory.
Why it's wrong
Saturated model always fits perfectly (df=0) but provides no parsimony or generalizability. Overfits data, capitalizes on sampling error, poor replication. May include unnecessary interactions that complicate interpretation without improving substantive understanding.
The correction
Fit hierarchy of models: (1) Independence, (2) All main effects, (3) Selected two-way associations, (4) Three-way interaction if justified, (5) Saturated. Compare via AIC/BIC and fit tests. Choose simplest model that fits adequately (p>.05) and has low AIC. Report model selection process.
Why it's wrong
If variables are ordinal (e.g., Low < Medium < High), standard loglinear treats them as nominal, ignoring ordering. This loses power to detect linear trends and may miss monotonic associations. Model may be overly complex (more parameters than needed).
The correction
For ordinal variables: (1) Use ordered loglinear models (assign scores to categories and test linear-by-linear association). (2) Use ordinal logistic/proportional odds regression if clear DV. (3) Test for linear trend in addition to general association. (4) Consider models with both linear and non-linear ordinal effects.
Why it's wrong
Loglinear assumes each observation independent (counted once in one cell). Repeated measures (same subject in multiple cells), matched pairs, or clustering violate this, deflating SEs and inflating Type I error. Standard loglinear inference invalid with dependence.
The correction
Verify each subject contributes to exactly one cell. If repeated measures: use marginal homogeneity models (McNemar, Cochran's Q) or GEE for categorical outcomes. If clustering: use multilevel categorical models or account for clustering. Never ignore known dependence structure.
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]
Agresti, A. (2013). Categorical Data Analysis (3rd ed.). Wiley.
Definitive textbook on categorical data analysis including comprehensive coverage of loglinear models.
doi: 10.1002/0471249688
[2]
Bishop, Y. M., Fienberg, S. E., & Holland, P. W. (2007). Discrete Multivariate Analysis: Theory and Practice. Springer (reprint).
Classic reference on loglinear models and multi-way contingency table analysis.
doi: 10.1007/978-0-387-72806-3
[3]
Christensen, R. (1997). Log-Linear Models and Logistic Regression (2nd ed.). Springer.
Accessible introduction to loglinear models with emphasis on model selection and interpretation.
doi: 10.1007/b97647
[4]
Friendly, M. (2000). Visualizing Categorical Data. SAS Institute.
Comprehensive guide to visualizing categorical data including mosaic plots and association plots for loglinear models.
[5]
Wickens, T. D. (1989). Multiway Contingency Tables Analysis for the Social Sciences. Psychology Press.
Applied treatment of loglinear models for social science research with extensive examples.
[6]
Powers, D. A., & Xie, Y. (2008). Statistical Methods for Categorical Data Analysis (2nd ed.). Emerald Group Publishing.
Modern treatment of categorical data methods including loglinear analysis with software examples.
In a multi-way grid, everything is connected. Log-linear analysis is the tool that tells you which connections are the truth and which are merely noise. Audit the hierarchy carefully.
The Interpretive Rigor Directive
statminds · Log-LinearMind reference · v2.2 · updated 2026-01-1715 of 15 sections