Skip to content

Instantly share code, notes, and snippets.

@smancuso
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smancuso/cbaecfee3d21bec0989d to your computer and use it in GitHub Desktop.
Save smancuso/cbaecfee3d21bec0989d to your computer and use it in GitHub Desktop.
**********************************************************************
* Project: Classification of Eating Disorders using EDE-Q
* Coded by: Sam Mancuso
* Version: 1.0
* Date: 22 July 2014
***********************************************************************
** NB
* bmi_at_assessment = Clinician assessed BMI
* menstrual_status_on_admission = Clinician assessed menstrual status
label define yesno 0 "No" 1 "Yes"
* Recode Menstrual Status
label define menstrual ///
0 "Regular menstruation" ///
1 "Irregular menstruation" ///
2 "Amenorrhoea unrelated to AN" ///
3 "Primary amenorrhoea" ///
4 "Secondary amenorrhoea" ///
5 "Menstrual cycle with medications"
encode menstrual_status_on_admission, g(menstrualstatus) l(menstrual)
* Drop if EDE-Q items are missing
drop if edeq10 == . | (edeq22 == . & edeq23 == .) | edeq15 == .| (edeq16 == . & edeq17 == . & edeq18 == .)
**** DSM-IV ****
gen calorie_restriction = .
replace calorie_restriction = 0 if edeq1 < 4 & edeq2 < 4 & edeq3 < 4 & edeq4 < 4
replace calorie_restriction = 1 if edeq1 >= 4 | edeq2 >= 4 | edeq3 >= 4 | edeq4 >= 4
** Anorexia Nervosa **
* Criterion A: BMI below or equal to 17.5
gen an_dsm4_a = 0
replace an_dsm4_a = 1 if bmi_at_assessment <= 17.5
replace an_dsm4_a = . if bmi_at_assessment == .
label variable an_dsm4_a "AN DSM-IV A"
label values an_dsm4_a yesno
* Criterion B: Intense fear of gaining weight or becoming fat
gen an_dsm4_b = 0 if edeq10 < 4
replace an_dsm4_b = 1 if edeq10 >= 4
replace an_dsm4_b = . if edeq10 == .
label variable an_dsm4_b "AN DSM-IV B"
label values an_dsm4_b yesno
* Criterion C: Body image disturbance
* Importance of weight >= 4
* Importance of shape >= 4
gen an_dsm4_c = 0 if edeq22 < 4 & edeq23 < 4
replace an_dsm4_c = 1 if edeq22 >= 4 | edeq23 >= 4
replace an_dsm4_c = . if edeq22 == . & edeq23 == .
label variable an_dsm4_c "AN DSM-IV C"
label values an_dsm4_c yesno
* Criterion D: Amenorrhea
gen an_dsm4_d = 0
replace an_dsm4_d = 1 if menstrualstatus == 4 | menstrualstatus == 5
replace an_dsm4_d = . if menstrualstatus == .
replace an_dsm4_d = 1 if gender == "Male"
label variable an_dsm4_d "AN DSM-IV D"
label values an_dsm4_d yesno
** Diagnosis
gen an_dsm4_diagnosis = 0
replace an_dsm4_diagnosis = . if an_dsm4_a == . & an_dsm4_b == . & an_dsm4_c == . & an_dsm4_d == .
replace an_dsm4_diagnosis = 1 if an_dsm4_a == 1 & an_dsm4_b == 1 & an_dsm4_c == 1 & an_dsm4_d == 1
label variable an_dsm4_diagnosis "AN DSM-IV Diagnosis"
label values an_dsm4_diagnosis yesno
** Bulimia Nervosa **
* Criterion A: 24 or more objective bulimic episodes (OBE) within 3 months
* EDE-Q: 8 or more OBE within 1 month
gen bn_dsm4_a = 0
replace bn_dsm4_a = 1 if edeq15 >= 8
replace bn_dsm4_a = . if edeq15 == .
label variable bn_dsm4_a "BN DSM-IV A"
label values bn_dsm4_a yesno
* Criterion B: 24 or more inappropriate compensatory behaviours within 3 months
* EDE-Q: 8 or more inappropriate compensatory behaviours within 1 month
egen comp_bx = rowtotal(edeq16 edeq17 edeq18)
gen bn_dsm4_b = 0
replace bn_dsm4_b = 1 if comp_bx >= 8
replace bn_dsm4_b = . if comp_bx == .
label variable bn_dsm4_b "BN DSM-IV B"
label values bn_dsm4_b yesno
* Criterion C: OBE and inappropriate compensatory behaviours occur, on average
* at least twice a week for three months.
gen bn_dsm4_c = 0
replace bn_dsm4_c = 1 if bn_dsm4_a == 1 & bn_dsm4_b == 1
replace bn_dsm4_c = . if bn_dsm4_a == . & bn_dsm4_b == .
label variable bn_dsm4_c "BN DSM-IV C"
label values bn_dsm4_c yesno
* Criterion D: Undue influence of body image
gen bn_dsm4_d = 0
replace bn_dsm4_d = 1 if edeq22 >= 4 | edeq23 >= 4
replace bn_dsm4_d = . if edeq22 == . & edeq23 == .
label variable bn_dsm4_d "BN DSM-IV D"
label values bn_dsm4_c yesno
* Criterion E: Disturbance occurs outside of AN (see below)
** Diagnosis
gen bn_dsm4_diagnosis = 0
replace bn_dsm4_diagnosis = 1 if bn_dsm4_a == 1 & bn_dsm4_b == 1 ///
& bn_dsm4_c == 1 & bn_dsm4_d == 1 & an_dsm4_diagnosis == 0 // AN diagnosis not present
replace bn_dsm4_diagnosis = . if bn_dsm4_a == . & bn_dsm4_b == . ///
& bn_dsm4_c == . & bn_dsm4_d == .
label variable bn_dsm4_diagnosis "BN DSM-IV Diagnosis"
label values bn_dsm4_diagnosis yesno
** EDNOS
* Diagnosis of EDNOS if criteria for AN or BN not met.
gen ednos_dsm4_diagnosis = 0
replace ednos_dsm4_diagnosis = 1 if an_dsm4_diagnosis == 0 & bn_dsm4_diagnosis == 0
replace ednos_dsm4_diagnosis = . if an_dsm4_diagnosis == . & bn_dsm4_diagnosis == .
label variable ednos_dsm4_diagnosis "EDNOS DSM-IV Diagnosis"
label values ednos_dsm4_diagnosis yesno
**** DSM-5 ****
** Anorexia Nervosa **
* Criterion A: BMI below or equal to 18.5
gen an_dsm5_a = 0
replace an_dsm5_a = 1 if bmi_at_assessment <= 18.5
replace an_dsm5_a = . if bmi_at_assessment == .
label variable an_dsm5_a "AN DSM-5 A"
label values an_dsm5_a yesno
* Criterion B: Intense fear of gaining weight or becoming fat
gen an_dsm5_b = 0
replace an_dsm5_b = 1 if edeq10 >= 4
replace an_dsm5_b = . if edeq10 == .
label variable an_dsm5_b "AN DSM-5 B"
label values an_dsm5_b yesno
* Criterion C: Body image disturbance
gen an_dsm5_c = 0 if edeq22 < 4 & edeq23 < 4
replace an_dsm5_c = 1 if edeq22 >= 4 | edeq23 >= 4
replace an_dsm5_c = . if edeq22 == . & edeq23 == .
label variable an_dsm5_c "AN DSM-5 C"
label values an_dsm5_c yesno
** Diagnosis
gen an_dsm5_diagnosis = 0
replace an_dsm5_diagnosis = . if an_dsm5_a == . & an_dsm5_b == . & an_dsm5_c == .
replace an_dsm5_diagnosis = 1 if an_dsm5_a == 1 & an_dsm5_b == 1 & an_dsm5_c == 1
label variable an_dsm5_diagnosis "AN DSM-5 Diagnosis"
label values an_dsm5_diagnosis yesno
** Bulimia Nervosa **
* Criterion A: 12 or more objective bulimic episodes (OBE) within 3 months
* EDE-Q: 4 or more OBE within 1 month
gen bn_dsm5_a = 0
replace bn_dsm5_a = 1 if edeq15 >= 4
replace bn_dsm5_a = . if edeq15 == .
label variable bn_dsm5_a "BN DSM-5 A"
label values bn_dsm5_a yesno
* Criterion B: 12 or more inappropriate compensatory behaviours within 3 months
* EDE-Q: 4 or more inappropriate compensatory behaviours within 1 month
gen bn_dsm5_b = 0
replace bn_dsm5_b = 1 if comp_bx >= 4
replace bn_dsm5_b = . if comp_bx == .
label variable bn_dsm5_b "BN DSM-5 B"
label values bn_dsm5_b yesno
* Criterion C: OBE and inappropriate compensatory behaviours occur, on average
* at least once a week for three months.
gen bn_dsm5_c = 0
replace bn_dsm5_c = 1 if bn_dsm5_a == 1 & bn_dsm5_b == 1
replace bn_dsm5_c = . if bn_dsm5_a == . & bn_dsm5_b == .
label variable bn_dsm5_c "BN DSM-5 C"
label values bn_dsm5_c yesno
* Criterion D: Undue influence of body image
gen bn_dsm5_d = 0
replace bn_dsm5_d = 1 if edeq22 >= 4 | edeq23 >= 4
replace bn_dsm5_d = . if edeq22 == . & edeq23 == .
label variable bn_dsm5_d "BN DSM-IV D"
label values bn_dsm5_c yesno
* Criterion E: Disturbance occurs outside of AN (see below)
** Diagnosis
gen bn_dsm5_diagnosis = 0
replace bn_dsm5_diagnosis = 1 if bn_dsm5_a == 1 & bn_dsm5_b == 1 ///
& bn_dsm5_c == 1 & bn_dsm5_d == 1 & an_dsm5_diagnosis == 0 // AN diagnosis not present
replace bn_dsm5_diagnosis = . if bn_dsm5_a == . & bn_dsm5_b == . ///
& bn_dsm5_c == . & bn_dsm5_d == .
label variable bn_dsm5_diagnosis "BN DSM-5 Diagnosis"
label values bn_dsm5_diagnosis yesno
** Binge Eating Disorder **
* Criterion A: Recurrent OBEs
* EDE-Q: 4 or more OBEs within 1 month
gen bed_dsm5_a = bn_dsm5_a
label variable bed_dsm5_a "BED DSM-5 A"
label values bed_dsm5_a yesno
* Criterion B: Binge episode features
* Not assessed by the EDE-Q
* Criterion C: Marked distress regarding binge eating
* Not assessed by the EDE-Q
* Criterion D: OBEs occurs, on average, at least once a week for three months
* Calculated for Criterion A
* Criterion E: Binge eating is not associated with the recurrent use of ///
* inappropriate compensatory behaviour nor during the course of BN or AN.
gen bed_dsm5_e = 1 if bn_dsm5_b == 0
replace bed_dsm5_e = 0 if bn_dsm5_b == 1
replace bed_dsm5_e = 0 if bn_dsm5_diagnosis == 1 | an_dsm5_diagnosis == 1 | comp_bx >= 4
replace bed_dsm5_e = . if bn_dsm5_b == .
label variable bed_dsm5_e "BED DSM-5 E"
label values bed_dsm5_e yesno
** Diagnosis
gen bed_dsm5_diagnosis = 0
replace bed_dsm5_diagnosis = 1 if bed_dsm5_a == 1 & bed_dsm5_e == 1
replace bed_dsm5_diagnosis = . if bed_dsm5_a == . & bed_dsm5_e == .
label variable bed_dsm5_diagnosis "BED DSM-5 Diagnosis"
label values bed_dsm5_diagnosis yesno
** EDNOS
* Diagnosis of EDNOS if criteria for AN, BN, or BED not met.
gen ednos_dsm5_diagnosis = 0
replace ednos_dsm5_diagnosis = 1 if an_dsm5_diagnosis == 0 & bn_dsm5_diagnosis == 0 & bed_dsm5_diagnosis == 0
replace ednos_dsm5_diagnosis = . if an_dsm5_diagnosis == . & bn_dsm5_diagnosis == . & bed_dsm5_diagnosis == .
label variable ednos_dsm5_diagnosis "EDNOS DSM-IV Diagnosis"
label values ednos_dsm5_diagnosis yesno
*** Table of DSM-IV diagnoses
gen dsm4_diagnosis = .
replace dsm4_diagnosis = 1 if an_dsm4_diagnosis == 1
replace dsm4_diagnosis = 2 if bn_dsm4_diagnosis == 1
replace dsm4_diagnosis = 3 if ednos_dsm4_diagnosis == 1
label variable dsm4_diagnosis "DSM-IV Diagnosis"
** Label for DSM-IV diagnoses
label define dsm_iv ///
1 "AN" ///
2 "BN" ///
3 "EDNOS"
label values dsm4_diagnosis dsm_iv
*** Table of DSM-5 diagnoses
gen dsm5_diagnosis = .
replace dsm5_diagnosis = 1 if an_dsm5_diagnosis == 1
replace dsm5_diagnosis = 2 if bn_dsm5_diagnosis == 1
replace dsm5_diagnosis = 3 if bed_dsm5_diagnosis == 1
replace dsm5_diagnosis = 4 if ednos_dsm5_diagnosis == 1
label variable dsm5_diagnosis "DSM-5 Diagnosis"
** Label for DSM-V diagnoses
label define dsm_5 ///
1 "AN" ///
2 "BN" ///
3 "BED" ///
4 "OSFED/UFED"
label values dsm5_diagnosis dsm_5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment