Home / Sleep and depression symptoms: how many records can be linked? / Study protocol and materials
NHANES
Study protocol and materials
Sleep and depression symptoms: how many records can be linked?
The study protocol, variable definitions and verification code for the published dataset.
Study protocol #
Sleep and depressive symptoms
Working plan for methodological review.
Research question
How is workday sleep duration associated with the severity of depressive symptoms in adults participating in NHANES 2015–2016?
Unit of observation
One row represents one adult survey participant. Modules from the same cycle were joined by SEQN.
Data
CDC · United States · 2015–2016. The dataset includes 5,992 adults and eight variables.
1. Specify the question and population
Include adults aged 18 or older from the 2015–2016 cycle. The exposure is SLD012, the duration of the main sleep period on workdays. The symptom measure is the total PHQ-9 score. Define the exclusion criteria before analysis.
2. Check the data and estimation plan
Check that SEQN is unique and examine missing values and zero weights. For the DPQ module, CDC specifies the WTMEC2YR examination weight. Account for SDMVPSU and SDMVSTRA in the survey design. Agree on a missing-data strategy before calculating estimates.
3. Specify the model and sensitivity analyses
Give reasons for the chosen functional form of the association, covariates and approach to multiple testing. Address the overlap with DPQ030, the sleep item in the PHQ-9. Additional covariates must be obtained from the relevant source modules because the starter CSV omits them.
Limitations
The association has yet to be estimated. Analysis requires appropriate weights and the survey design. The PHQ-9 measures symptoms and by itself cannot establish a clinical diagnosis.
The CSV includes eight fields for exploring the data. Obtain the original DPQ010–DPQ090 responses and additional covariates from the source modules. PHQ9_WITHOUT_SLEEP is a teaching score that omits the sleep item. It has not been validated as a PHQ-8 measure, and clinical PHQ-9 cutoffs do not apply. The detailed view provides the original XPT files, the join log and the full data dictionary.
Documentation
Variable dictionary #
SEQN
Participant. Public identifier within this release. It cannot be used to link participants in independent cohorts.
integer · ID
RIDAGEYR
Age. Age at screening. Ages 80 and above are recorded as 80, as specified in the codebook.
integer · years
SLD012
Weekday sleep. Duration of the main sleep period on workdays, derived from usual sleep and wake times and rounded to the nearest half hour. Total sleep over 24 hours may differ.
An empty value is retained as null.
number · hours
PHQ9_SCORE
PHQ-9 total. Sum of DPQ010–DPQ090, nine responses on symptoms over the previous two weeks, each scored 0–3. The score screens for symptoms. A clinical diagnosis requires a separate assessment.
The total is null if any of the nine responses is missing or outside 0–3.
integer · 0–27
PHQ9_WITHOUT_SLEEP
Sum excluding the sleep item. Teaching sum of eight items excluding DPQ030. It illustrates the overlap between measures and has not been validated as a substitute for the PHQ-9.
A missing value or a response outside 0–3 on any of the eight items gives a null total.
integer · 0–24
WTMEC2YR
MEC examination weight. Examination weight for the two-year cycle. Participants who did not attend the examination have zero weight. Select the weight according to the survey components used.
number · weight
SDMVPSU
Masked PSU. Masked primary sampling unit used for variance estimation under the complex survey design.
integer · code
SDMVSTRA
Masked stratum. Masked survey stratum used for variance estimation under the complex survey design.
integer · code
Data provenance #
{
"data_period": "2015–2016",
"coverage": {
"demographic_rows": 9971,
"adult_rows": 5992,
"sleep_module_rows": 6327,
"dpq_module_rows": 5735,
"joined_adult_rows": 5992,
"complete_sleep_and_phq9": 5110,
"unique_keys": true,
"join": "left; validate=one_to_one; DEMO adults as base",
"weighted_population_estimate": false
},
"retained_source_responses": [
{
"file": "DEMO_I.xpt",
"url": "https://wwwn.cdc.gov/Nchs/Data/Nhanes/Public/2015/DataFiles/DEMO_I.xpt",
"status": 200,
"content_type": "text/plain",
"bytes": 3756480,
"sha256": "c9297c6c37ae8f78f29be9568fa2a03cf3b112616a39afee04030fc775a66a0d",
"retrieved_at": "2026-10-20T18:11:03.983008+00:00",
"complete_response": true
},
{
"file": "SLQ_I.xpt",
"url": "https://wwwn.cdc.gov/Nchs/Data/Nhanes/Public/2015/DataFiles/SLQ_I.xpt",
"status": 200,
"content_type": "text/plain",
"bytes": 368880,
"sha256": "42dc4ce269704791223954e8513d91bd9b1da4cca89224b3ba87f043a9fa736a",
"retrieved_at": "2026-10-20T18:10:12.923588+00:00",
"complete_response": true
},
{
"file": "DPQ_I.xpt",
"url": "https://wwwn.cdc.gov/Nchs/Data/Nhanes/Public/2015/DataFiles/DPQ_I.xpt",
"status": 200,
"content_type": "text/plain",
"bytes": 507040,
"sha256": "6f4561aab077b9fd199a414fc516d6fedf40967266b81f1ab7b7d75afb72232d",
"retrieved_at": "2026-10-20T18:10:13.962448+00:00",
"complete_response": true
}
],
"derived_csv_sha256": "4b7510ae93fd7aaa7de2a6bdcd072b237bdcee7c7b9ce2acb01687b79a92d5dc",
"notes": [
"Показаны первые 12 взрослых по SEQN, без случайного отбора. Это демонстрация структуры, не репрезентативная мини-выборка.",
"Распределения и числа строк здесь невзвешенные. Популяционные оценки требуют WTMEC2YR и учёта SDMVPSU/SDMVSTRA.",
"При анализе связи нужно учитывать содержательное пересечение: PHQ-9 включает DPQ030 о нарушениях сна. Анализ требует заранее заданной стратегии и проверки чувствительности.",
"Добавленная сумма без DPQ030 служит учебным обсуждением чувствительности. Это не валидированная шкала PHQ-8. Не применяйте к ней клинические пороги PHQ-9. Сравнение с полной суммой требует одной общей complete-case выборки, иначе меняется состав участников.",
"Этот предпросмотр не рассчитывает причинный эффект и не устанавливает диагноз."
],
"references": [
{
"label": "DEMO_I",
"url": "https://wwwn.cdc.gov/Nchs/Data/Nhanes/Public/2015/DataFiles/DEMO_I.htm"
},
{
"label": "SLQ_I",
"url": "https://wwwn.cdc.gov/Nchs/Data/Nhanes/Public/2015/DataFiles/SLQ_I.htm"
},
{
"label": "DPQ_I",
"url": "https://wwwn.cdc.gov/Nchs/Data/Nhanes/Public/2015/DataFiles/DPQ_I.htm"
},
{
"label": "CDC: веса и дизайн NHANES",
"url": "https://wwwn.cdc.gov/nchs/nhanes/tutorials/weighting.aspx"
}
]
}
Data verification script #
"""Check the supplied data and package integrity. Python 3; no extra libraries."""
from pathlib import Path
import csv, json, hashlib, collections
root=Path(__file__).resolve().parent
manifest=json.loads((root/'manifest.json').read_text())
for item in manifest['files']:
actual=hashlib.sha256((root/item['path']).read_bytes()).hexdigest()
assert actual==item['sha256'], 'Changed file: '+item['path']
with (root/'data.csv').open(encoding='utf-8-sig',newline='') as f:
reader=csv.DictReader(f); rows=list(reader)
dictionary=json.loads((root/'dictionary.json').read_text())
assert reader.fieldnames==[c['name'] for c in dictionary], 'Column mismatch'
assert len(rows)==manifest['rows'], 'Row count mismatch'
keys=manifest['key_columns']
assert all(all(r[k] for k in keys) for r in rows), 'Missing key'
assert len({tuple(r[k] for k in keys) for r in rows})==len(rows), 'Duplicate key'
missing={c:sum(r[c]=='' for r in rows) for c in reader.fieldnames}
report={'rows':len(rows),'unique_keys':True,'missing_by_column':missing,'file_integrity':'verified'}
if manifest['case_id']=='sleep':
assert all(18<=float(r['RIDAGEYR'])<=80 for r in rows)
assert all(0<=float(r['PHQ9_SCORE'])<=27 for r in rows if r['PHQ9_SCORE'])
assert all(0<=float(r['PHQ9_WITHOUT_SLEEP'])<=24 for r in rows if r['PHQ9_WITHOUT_SLEEP'])
complete=sum(bool(r['SLD012']) and bool(r['PHQ9_SCORE']) for r in rows)
assert complete==manifest['complete_pairs'], 'Complete-pair count mismatch'
report['complete_sleep_phq9_pairs']=complete
report['zero_MEC_weights']=sum(float(r['WTMEC2YR'])==0 for r in rows)
report['interpretation']='Unweighted file audit, not a population estimate or association analysis.'
elif manifest['case_id']=='trials':
report['status_counts']=dict(collections.Counter(r['status'] for r in rows))
report['interpretation']='One retained API page; enrollment is not a count of downloaded patients.'
else:
assert [int(r['year']) for r in rows]==manifest['expected_years']
assert all(r['country_iso3']=='RUS' for r in rows)
assert all(0<=float(r['unemployment_pct_labor_force'])<=100 for r in rows)
report['interpretation']='Population time series; no individual risk or causal effect is estimated.'
(root/'data-check.json').write_text(json.dumps(report,ensure_ascii=False,indent=2)+'\n')
print(json.dumps(report,ensure_ascii=False,indent=2))