Nested LMM (Hierarchical Mixed Model)

Nested LMM (Hierarchical Mixed Model)

⚡ Advanced · Mixed Models · Nested

v1.0.1

Education Sciences context — fixed effect (treatment) + nested random effects. akademik_basari_puan ~ tedavi + (1|okul/sinif/ogrenci). The difference from VARCOMP: a fixed effect (e.g., treatment/group comparison) is added.

okul/sinif/ogrenci nestedTedavi sabit etkenREMLFixed effect estimate + p

🎯 What is it for?

When interpreting fixed effects in hierarchical data, it also accounts for the variance of the random factors. In Education Sciences, if the same students receive different treatments, a classical t-test/ANOVA ignores the clustering → Type-I error. A nested LMM computes this correctly.

📌 When is it used?

  • Comparison of a fixed effect (treatment, intervention, condition) + hierarchical sampling
  • Multi-site clinical research, multi-center field trial
  • Adjusting site/group-level variance in RCTs

⚙ Assumptions

  1. Continuous DV, categorical fixed effect.
  2. Nested structure: sinif within okul, ogrenci within sinif.
  3. Random effects ~ Normal(0, σ²).
  4. ≥1 observation in each treatment-ogrenci combination.

📊 How to Run It in MerQur?

1
Load data.
2
Analysis → ⚡ Advanced → Nested LMM.
3

Panel assignments (form fields in the program):

  • Dependent Variable: deger
  • Repeat Variable: blok
  • Upper Group: ust_grup
  • Nested Group: alt_grup_no
  • SS Type: 1
4
Estimator: REML.
5
▶ Run. Fixed effect β̂ + p + σ² for each random level.

📊 Sample Dataset — Education Sciences

ℹ Note: The scenario, MerQur output and interpretation below were produced by actually running the real example dataset in MerQur. Numeric results on your own data will differ; the goal is to show how the analysis is set up and interpreted end-to-end.

🎬 Example File

This analysis is demonstrated on the following example dataset for Education Sciences:

Egitim_Bilimleri/108_nested_lmm_R_P_F.xlsx

🎬 Scenario

Consider an educational experiment with a strictly hierarchical design: 288
measurement units are organized so that lower groups labeled F01 through F06
sit inside upper groups P1 through P4, which in turn sit inside blocks R1
through R4, and the outcome is value. Because each lower group belongs to
exactly one upper group and each upper group to one block, the factors are
nested rather than crossed. A Nested Mixed Model is the correct approach
because it assigns random effects to each level of nesting, correctly
partitioning the variance across blocks, upper groups and lower groups while
estimating the outcome. This avoids treating nested levels as independent
factors.

⚙️ Variable Selection

  • Dependent variable: value
  • Random effect (outermost level): block (R1…R4)
  • Nested random effect (middle level): upper_group (P1…P4)
  • Nested random effect (innermost level): lower_group_no (F01…F06)

Data Preview (First 5 Rows)

unit_id block upper_group lower_group_no value
B001 R1 P1 F01 43.23
B002 R1 P1 F01 48.59
B003 R1 P1 F01 43.18
B004 R2 P1 F01 41.92
B005 R2 P1 F01 43.46

n = 288 · Columns: unit_id, block, upper_group, lower_group_no, value

📈 MerQur Output

NESTED LMM (HIERARCHICAL MIXED MODEL) RESULT
─────────────────────────────────────────────

upper group (P): F = 27.44, p < .001 *** | lower x upper (RxP): F = 14.34, p < .001 ***
block [within upper group] (F): F = 2.20, p = 0.023 *

💬 Interpretation

In this design the measurements are nested: upper group > block > lower unit. The nested mixed model tests each
level’s contribution to the variance separately. The results are significant at all levels: between-upper-group
differences are largest (F = 27.44), but there are real differences at the block and lower-unit levels too.
Mixing up the levels in nested data (e.g. ignoring the upper group) produces spurious significance or wrong
standard errors. Nested LMM is the correct framework for hierarchical sampling designs (school/class/student,
region/school/class), separating the genuine contribution of each scale.

⚠ Common Mistakes

  • Specifying “crossed” instead of “nested” — the class-ids should not recur within each school.
  • Optimizer stalling (lbfgs llf=inf) — MerQur resolves this with a bfgs/cg cascade.
  • Treatment × school imbalance — the fixed-effect coefficient may be biased.

📚 MerQur’a Atıf

Örücü, Ö. K. (2026). MerQur: Integrated Academic Data Analysis & Reporting Platform [Computer software] (Version 1.0.0). https://doi.org/10.53463/merqur.2026001

Tüm atıf formatları →

📝 Üretim Notu — Bu sayfadaki örnek veri sentetik olarak üretilmiştir (sabit SEED=42, generator: samples/Ileri_Duzey_v102/_generate_v102_datasets.py). Sayfa içeriği Anthropic Claude desteği ile hazırlanmış, akademik doğruluk yazar tarafından kontrol edilmiştir.