Nested LMM (Hierarchical Mixed Model)
v1.0.1
Agriculture, Forestry & Aquatic context — fixed effect (treatment) + nested random effects. boy_artisi_m ~ tedavi + (1|saha/populasyon/aile). Difference from VARCOMP: a fixed effect (e.g. treatment/group comparison) is added.
🎯 What is it for?
It accounts for the variance of the random factors while interpreting fixed effects in hierarchical data. In Agriculture, Forestry & Aquatic, if different treatments are applied within the same families, 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
- Continuous DV, categorical fixed effect.
- Nested structure: population within site, family within population.
- Random effects ~ Normal(0, σ²).
- ≥1 observation in each treatment-family 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 — Agriculture, Forestry & Aquatic
ℹ 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 Agriculture, Forestry & Aquatic:
Ziraat_Orman_Su/108_nested_lmm_R_P_F.xlsx
🎬 Scenario
In a replicated hierarchical breeding trial — block (block), upper group (upper_group), lower group (lower_group_no) — we
estimate the variance components and effects of a trait (value) in a single model. The nested LMM, in this structure where the
lower group is nested within the upper group, gives each level’s contribution with correct F tests: is the difference among
populations/families significant, is there a genotype-environment interaction?
⚙️ Variable Selection
- Dependent (continuous): value
- Replication (block): block
- Upper group: upper_group
- Lower group (nested): lower_group_no
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): F(3) = 4.92, p = 0.010 * | model: value ~ R + P + R*P + F(P) + R*F(P)
block (R), upper_group (P), lower_group_no (F nested in P)
💬 Interpretation
In a replicated hierarchical breeding trial — block, upper group (population), lower group (family, nested within
population) — we estimated the variance components and effects of a trait in a single model. The nested LMM, in
this nested structure, gives each level’s contribution with correct F tests (each effect uses the appropriate error
term — something ordinary ANOVA cannot do). The result: the upper group (population) is significant, F(3) = 4.92, p
= 0.010. So there is a genetic/structural difference among populations. This is the fundamental question of forest
breeding: at which level should selection be done? If the population difference is significant, choosing the right
population is the priority; if the family difference dominates, choosing families within a population is. The nested
LMM provides the statistical basis for this decision.
⚠ Common Mistakes
- Defining “crossed” instead of “nested” — the population IDs should not recur across each site.
- Optimizer crashing (lbfgs llf=inf) — MerQur resolves this with a bfgs/cg cascade.
- Treatment × site 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.