/******************************************************************
Scale ID: 			CIDI-Depression
Scale Name: 		Composite International Diagnostic Interview – Short Form (Depression)
TILDA Variables: 	MHcidi_depression
Dataset:      		TILDA Waves 2,3,4,5,6r
Author:       
Institution:  		The Irish Longitudinal Study on Ageing (TILDA)

Description:
Cleans and codes up summed score from the Depression subscale of the Composite International Diagnostic Interview.

Version:      1.0
Date:         2026-09-01
Language:     Stata

******************************************************************/

egen mdd_a_1new = anycount (mh101 mh102 mh103), values (1,2)
recode mdd_a_1new (1/2=0) (3=1)
label variable mdd_a_1new "endorses 1st set of stem questions"

egen mdd_a_2new = anycount (mh120 mh121 mh122), values (1,2)
recode mdd_a_2new (1/2=0) (3=1)
recode mdd_a_2new 1=0 if mdd_a_1new==1
label variable mdd_a_2new "endorses 2nd set of stem questions"

egen mdd_symptom_count_new = anycount (mh104 mh105 mh108 mh110 mh111 mh112 mh113), values (1,2)
recode mdd_symptom_count_new 5=0 if mh103==98
label variable mdd_symptom_count_new "number of additional symptoms from first set"

egen mdd_symptom_count_2new = anycount (mdd_a_2new mh123 mh126 mh128 mh129 mh130 mh131), values (1,2)
label variable mdd_symptom_count_2new "number of additional symptoms from second set"

gen mdd_diagnosis1= (mdd_a_1new) & (mdd_symptom_count_new>=3)
label variable mdd_diagnosis1 "fulfills first set of criteria for diagnosis of MD episode"

gen mdd_diagnosis2= (mdd_a_2new) & (mdd_symptom_count_2new>=3)
label variable mdd_diagnosis2 "fulfills second set of criteria for diagnosis of MD episode"


gen MHcidi_depression = (mdd_diagnosis1|mdd_diagnosis2)
replace MHcidi_depression =. if (mh101==-1|mh101>=98|mh102>=98|mh103>=98)&(mh120==-1|mh120>=98|mh121>=98|mh122>=98)
label variable MHcidi_depression "Fulfills criteria for a major depressive episode in the last 12 months"

label def MHcidi_depression 0 "No" 1 "Yes"
label val MHcidi_depression MHcidi_depression

drop mdd_a_1new mdd_a_2new mdd_symptom_count_new mdd_symptom_count_2new mdd_diagnosis1 mdd_diagnosis2

notes MHcidi_depression: Major depressive episode in the last 12 months
notes MHcidi_depression: Individuals who answer DK/RF to the early symptoms in the scale are routed past the additional ///
questions required to fulfill criteria for a major depressive episode in last 12 months and are subsequently coded as missing.
