Nested LMM (Hierarchical Mixed Model)
v1.0.1
Engineering context — fixed effect (treatment) + nested random effects. urun_dayanim_MPa ~ tedavi + (1|fabrika/uretim_hatti/parti). Difference from VARCOMP: a fixed effect (e.g. treatment/group comparison) is added.
🎯 What is it for?
When interpreting fixed effects in hierarchical data, it also accounts for the variance of the random factors. In Engineering, if the same batches receive different treatments, a classic 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
- Continuous DV, categorical fixed effect.
- Nested structure: uretim_hatti within fabrika, parti within uretim_hatti.
- Random effects ~ Normal(0, σ²).
- ≥1 observation in each treatment-parti combination.
📊 How to Run It in MerQur?
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
📊 Sample Dataset — Engineering
ℹ 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 Engineering:
Muhendislik/108_nested_lmm_R_P_F.xlsx
🎬 Scenario
We model a value in a nested design (upper>lower>block). For nested hierarchies,
nested LMM is appropriate.
⚙️ Variable Selection
- Dependent variable: value
- Factor (categorical): lower_group_no
- Factor (categorical): upper_group
- Factor (categorical): block
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
─────────────────────────────────────────────
upper_group (P) effect: F = 27.44, p < .001 *** lower_group_no (R) effect: F = 6.11, p < .001 ***
nested variance components (block within P)
💬 Interpretation
We modeled a value in a nested design (upper group > lower group > block): both the upper level (F = 27.44, p <
.001) and the lower/replication level (F = 6.11, p < .001) make significant contributions. Nested LMM correctly
handles hierarchies where sub-units are nested within super-units (each block belongs to only one group); by
partitioning variance into levels it shows each layer’s share. In the field it is used to correctly separate
effects in plot/block/replicate hierarchies.
⚠ Common Mistakes
- Specifying “crossed” instead of “nested” — the uretim_hatti ids must not repeat across each fabrika.
- Optimizer stalling (lbfgs llf=inf) — MerQur resolves it with a bfgs/cg cascade.
- Treatment × fabrika 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
📝 Ü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.