
/*We assessed two indicators of SRAD severity. The first was the number of symptoms as it has been defined for disorder severity in DSM-5. 
Predictors and outcomes were both z-standardized, yielding standardized regression coefficients that have the same range as correlations. */

//baseline
gen bl_sud_symp=bl_tob_symp + bl_alc_symp
gen bl_nd_symp=bl_int_symp + bl_game_symp + bl_gamb_symp+ bl_shop_symp
//z-standardization, later co-variate in the second analyses
egen std_bl_sud_symp=std(bl_sud_symp)
egen std_bl_nd_symp=std(bl_nd_symp)

//follow-up
gen fu1_sud_symp=fu1_tob_symp + fu1_alc_symp
gen fu1_nd_symp=fu1_int_symp + fu1_game_symp + fu1_gamb_symp+ fu1_shop_symp

//We calculated delta as differences between SRAD symptoms and quantity-frequency-indices at follow-up minus baseline. 
gen symp_sud_delta=fu1_sud_symp - bl_sud_symp
gen symp_nd_delta=fu1_nd_symp - bl_nd_symp

//z-standardization
egen std_symp_sud_delta=std(symp_sud_delta)
egen std_symp_nd_delta=std(symp_nd_delta)

/*The second indicator was the quantity-frequency index of use. 

Frequency was assessed by using the following categories: almost daily, 3–4 times per week, 1–2 times per week, 1–3 times per month, less often than monthly. 

Quantity was assessed either by standard drinks (alcohol), cigarettes (tobacco), or hours of use (Internet, gaming, gambling, shopping). 
A standard drink was defined as 9 g of pure alcohol (about 0.1 litre wine with 11% alcohol by volume). The quantity–frequency index was computed 
by multiplying the maximum of the categorie. */

//baseline
gen bl_qfi_tob=bl_quant_tob*bl_frequ_tob
gen bl_qfi_alc=bl_quant_alc*bl_frequ_alc
gen bl_qfi_int=bl_quant_int*bl_frequ_int
gen bl_qfi_game=bl_quant_game*bl_frequ_game
gen bl_qfi_gamb=bl_quant_gamb*bl_frequ_gamb
gen bl_qfi_shop=bl_quant_shop*bl_frequ_shop

//1 year follow-up
gen fu1_qfi_tob=fu1_quant_tob*fu1_frequ_tob
gen fu1_qfi_alc=fu1_quant_alc*fu1_frequ_alc
gen fu1_qfi_int=fu1_quant_int*fu1_frequ_int
gen fu1_qfi_game=fu1_quant_game*fu1_frequ_game
gen fu1_qfi_gamb=fu1_quant_gamb*fu1_frequ_gamb
gen fu1_qfi_shop=fu1_quant_shop*fu1_frequ_shop

//As dependent variable, we z-standardized the quantity–frequency indices to make them comparable (gram, cigarettes, and hours per week), 
//summed up the values separately for substance use and non-substance-related addictive behaviours and z-standardized them again.

//baseline
for any bl_qfi_tob bl_qfi_alc bl_qfi_int bl_qfi_game bl_qfi_gamb bl_qfi_shop: egen std_X=std(X)

egen bl_qfi_sud=rowtotal(std_bl_qfi_tob std_bl_qfi_alc)
egen bl_qfi_ba=rowtotal(std_bl_qfi_int std_bl_qfi_game std_bl_qfi_gamb std_bl_qfi_shop)

egen std_bl_qfi_sud=std(bl_qfi_sud)
egen std_bl_qfi_ba=std(bl_qfi_ba)

//1 year follow-up
for any fu1_qfi_tob fu1_qfi_alc fu1_qfi_int fu1_qfi_game fu1_qfi_gamb fu1_qfi_shop: egen std_X=std(X)

egen fu1_qfi_sud=rowtotal(std_fu1_qfi_tob std_fu1_qfi_alc)
egen fu1_qfi_ba=rowtotal(std_fu1_qfi_int std_fu1_qfi_game std_fu1_qfi_gamb std_fu1_qfi_shop)

egen std_fu1_qfi_sud=std(fu1_qfi_sud)
egen std_fu1_qfi_ba=std(fu1_qfi_ba)

//We calculated delta as differences between SRAD symptoms and quantity-frequency-indices at follow-up minus baseline. 
gen qfi_sud_delta= std_fu1_qfi_sud- std_bl_qfi_sud
gen qfi_ba_delta= std_fu1_qfi_ba- std_bl_qfi_ba

//z-standardization
egen std_qfi_sud_delta=std(qfi_sud_delta)
egen std_qfi_ba_delta=std(qfi_ba_delta)
