VARCOMP (Variance-Components Analysis)
v1.0.1
Health Sciences context — in a hierarchical design, decomposes how much of the total variance originates from which level (site, group, subgroup, error). Equivalent to SAS PROC VARCOMP, implemented in MerQur with an REML/ML cascade.
REML + ML fallbackICC + heritabilityσ²hastane ≈ 0.7
🎯 What is it for?
VARCOMP answers the question of which level contributes how much variance. Is the variability in the distribution of a single HbA1c_pct measurement entirely random, or does it stem from systematic differences among hospital and doctor? With VARCOMP, σ²hospital, σ²doctor, σ²patient and σ²residual are estimated separately; the percentage share of each is reported.
📌 When is it used?
- When there is a multilevel (nested) sampling design in the Health Sciences field
- For sample-size calculation when designing a data collection plan in which you will have the same measurement taken by different doctors under different hospitals
- To compute heritability / generalizability (σ² ratios)
- Before building a fixed-effects model — where is the variance primarily?
⚙ Assumptions
- Continuous DV (HbA1c_pct).
- Nested structure: doctor within hospital, patient within doctor (no cross-level confounding).
- Random effects ~ Normal (homoscedastic, mean 0).
- Sufficient units at each level: ≥4-6 hospitals, each with ≥2 doctors, is recommended.
📊 How to Run It in MerQur
Panel assignments (form fields in the program):
- Columns:
{'dv': 'tedavi_yanit', 'factors': [('klinik', False), ('doktor_id', True), ('hasta_id', True)]} - Parameters:
{'estimator': 'REML'}
📊 Sample Dataset — Health 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 Health Sciences:
Tip/100_varcomp_clinical_doctor_patient_h2.xlsx
🎬 Scenario
We decompose treatment-response variability into nested levels (clinic/doctor).
For hierarchical variability, variance components is appropriate.
⚙️ Variable Selection
- Dependent variable: treatment_response
- Factor (categorical): clinical
- Factor (categorical): doctor_id (nested)
Data Preview (First 5 Rows)
| clinical | doctor_id | patient_id | treatment_response |
|---|---|---|---|
| clinical_A | Kli_Dr01 | Kli_Dr01_H01 | 74.6 |
| clinical_A | Kli_Dr01 | Kli_Dr01_H02 | 55.3 |
| clinical_A | Kli_Dr01 | Kli_Dr01_H03 | 66.5 |
| clinical_A | Kli_Dr01 | Kli_Dr01_H04 | 63.4 |
| clinical_A | Kli_Dr01 | Kli_Dr01_H05 | 74.2 |
n = 120 · Columns: clinical, doctor_id, patient_id, treatment_response
📈 MerQur Output
─────────────────────────────────────────────
Random factors: clinical + doctor_id (nested within clinical) % contribution of each component + residual
💬 Interpretation
We decomposed treatment-response variability into nested levels — clinic and doctor within clinic: the percent
contribution of each level and the residual were reported. Variance components analysis answers “how much of the
variability is between clinics, how much between doctors, how much within patient?”. In medicine it is used in
multi-center hierarchical structures (clinic>doctor>patient) to see where uncertainty concentrates and in sampling
design.
⚠ Common Mistakes
- Forgetting the nested checkbox — the doctor column is clustered within hospital (e.g. DOKTOR_05_03 exists only in HASTANE_05). If the checkbox is not ticked, crossed is assumed → the variance is shared incorrectly.
- A single level at the second tier — if there is only one doctor under a hospital, VARCOMP cannot estimate that level (σ²=doctor≈0 ‘singular fit’ warning).
- Continuous-DV assumption — for Bernoulli/count data, a GLMM or a categorical-VARCOMP alternative is needed instead of VARCOMP (outside the scope of MerQur).
📚 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.