******************************************************************** * File HALCyon cortisol syntax_Caerphilly.do * BY Mike Gardner, University of Bristol * FOR HALCyon cross-cohort collaboration (funded by the New Dynamics of Ageing (RES-353-25-0001)) * DATASET Caerphilly Prospective Study (CaPS) * Date Created 26/11/2009 * last modified 27/06/2011 * syntax from 3 separate do files created by MG combined (by RC, 23/6/14) * PURPOSE Cleans and derives cortisol and smoking variables (waves 1 and 2) ************************************************************************************* set more off *PHASE 1 *remove missing data in cortisol* mvdecode c1cortisol, mv(9999) *remove missing data for time blood taken* mvdecode c1hrstimebloodtaken, mv(99) mvdecode c1mintimebloodtaken, mv(99) *PHASE 5 **Two subjects only have data for times and not cortisol when run **Therefore drop these two subjects ie 5901 and 7256 drop if c0surveyno==5901 drop if c0surveyno==7256 duplicates re c0surveyno **Generate time in hours when cortisol sampled generate c5time1day1 = ((day1wakinghrs*60.0) + (day1wakingmin))/60 generate c5time2day1 = ((day130minsafterwakinghrs*60) + (day130minsafterwakingmin))/60 generate c5time3day1 = ((day12pmhrs*60) + (day12pmmin))/60 generate c5time4day1 = ((day110pmhrs*60) + (day110pmmin))/60 generate c5time1day2 = ((day2wakinghrs*60) + (day2wakingmin))/60 generate c5time2day2 = ((day230minsafterwakinghrs*60) + (day230minsafterwakingmin))/60 generate c5time3day2 = ((day22pmhrs*60) + (day22pmmins))/60 generate c5time4day2 = ((day210pmhrs*60) + (day210pmmin))/60 **Only want to include values of cortisol less than 100nmol/L sum cortisolnmoll1_1 cortisolnmoll1_2 cortisolnmoll1_3 cortisolnmoll1_4 cortisolnmoll2_1 cortisolnmoll2_2 cortisolnmoll2_3 cortisolnmoll2_4 list c0surveyno cortisolnmoll1_1 cortisolnmoll2_1 if (cortisolnmoll1_1>100 & cortisolnmoll1_1 ~=.) list c0surveyno cortisolnmoll1_1 cortisolnmoll2_1 if (cortisolnmoll2_1>100 & cortisolnmoll2_1 ~=.) list c0surveyno cortisolnmoll1_2 cortisolnmoll2_2 if (cortisolnmoll1_2>100 & cortisolnmoll1_2 ~=.) list c0surveyno cortisolnmoll1_2 cortisolnmoll2_2 if (cortisolnmoll2_2>100 & cortisolnmoll2_2 ~=.) list c0surveyno cortisolnmoll1_3 cortisolnmoll2_3 if (cortisolnmoll1_3>100 & cortisolnmoll1_3 ~=.) list c0surveyno cortisolnmoll1_3 cortisolnmoll2_3 if (cortisolnmoll2_3>100 & cortisolnmoll2_3 ~=.) list c0surveyno cortisolnmoll1_4 cortisolnmoll2_4 if (cortisolnmoll1_4>100 & cortisolnmoll1_4 ~=.) list c0surveyno cortisolnmoll1_4 cortisolnmoll2_4 if (cortisolnmoll2_4>100 & cortisolnmoll2_4 ~=.) **Now replace phase 5 cortisol values with missing if greater than 100nmol/L replace cortisolnmoll1_1=. if cortisolnmoll1_1>100 replace cortisolnmoll2_1=. if cortisolnmoll2_1>100 replace cortisolnmoll1_2=. if cortisolnmoll1_2>100 replace cortisolnmoll2_2=. if cortisolnmoll2_2>100 replace cortisolnmoll1_3=. if cortisolnmoll1_3>100 replace cortisolnmoll2_3=. if cortisolnmoll2_3>100 replace cortisolnmoll1_4=. if cortisolnmoll1_4>100 replace cortisolnmoll2_4=. if cortisolnmoll2_4>100 sum cortisolnmoll1_1 cortisolnmoll1_2 cortisolnmoll1_3 cortisolnmoll1_4 cortisolnmoll2_1 cortisolnmoll2_2 cortisolnmoll2_3 cortisolnmoll2_4 rename cortisolnmoll1_1 c5corttime1day1 rename cortisolnmoll1_2 c5corttime2day1 rename cortisolnmoll1_3 c5corttime3day1 rename cortisolnmoll1_4 c5corttime4day1 rename cortisolnmoll2_1 c5corttime1day2 rename cortisolnmoll2_2 c5corttime2day2 rename cortisolnmoll2_3 c5corttime3day2 rename cortisolnmoll2_4 c5corttime4day2 ******************************************************************************************* twoway (scatter c5corttime1day1 c5time1day1) twoway (scatter c5corttime2day1 c5time2day1) twoway (scatter c5corttime3day1 c5time3day1) twoway (scatter c5corttime4day1 c5time4day1) twoway (scatter c5corttime1day2 c5time1day2) twoway (scatter c5corttime2day2 c5time2day2) twoway (scatter c5corttime3day2 c5time3day2) twoway (scatter c5corttime4day2 c5time4day2) ** Replace time1day1 with missing if before 5am and after 11am li c0surveyno if c5time1day1<5 li c0surveyno if c5time1day1>11 & c5time1day1~=. replace c5corttime1day1=. if c5time1day1<5 replace c5corttime1day1=. if c5time1day1>11 & c5time1day1~=. replace c5time1day1=. if c5time1day1<5 replace c5time1day1=. if c5time1day1>11 & c5time1day1~=. ** Replace time2day1 with missing if before 5am and after 12am li c0surveyno if c5time2day1<5 li c0surveyno if c5time2day1>12 & c5time2day1~=. replace c5corttime2day1=. if c5time2day1<5 replace c5corttime2day1=. if c5time2day1>12 & c5time2day1~=. replace c5time2day1=. if c5time2day1<5 replace c5time2day1=. if c5time2day1>12 & c5time2day1~=. ** Replace time3day1 with missing if before 12pm and after 5pm li c0surveyno if c5time3day1<12 li c0surveyno if c5time3day1>17 & c5time3day1~=. replace c5corttime3day1=. if c5time3day1<12 replace c5corttime3day1=. if c5time3day1>17 & c5time3day1~=. replace c5time3day1=. if c5time3day1<12 replace c5time3day1=. if c5time3day1>17 & c5time3day1~=. ** Replace time4day1 with missing if before 8pm li c0surveyno if c5time4day1<20 replace c5corttime4day1=. if c5time4day1<20 replace c5time4day1=. if c5time4day1<20 ** Replace time1day2 with missing if before 5am and after 11am li c0surveyno if c5time1day2<5 li c0surveyno if c5time1day2>11 & c5time1day2~=. replace c5corttime1day2=. if c5time1day2<5 replace c5corttime1day2=. if c5time1day2>11 & c5time1day2~=. replace c5time1day2=. if c5time1day2<5 replace c5time1day2=. if c5time1day2>11 & c5time1day2~=. ** Replace time2day2 with missing if before 5am and after 12am li c0surveyno if c5time2day2<5 li c0surveyno if c5time2day2>12 & c5time2day2~=. replace c5corttime2day2=. if c5time2day2<5 replace c5corttime2day2=. if c5time2day2>12 & c5time2day2~=. replace c5time2day2=. if c5time2day2<5 replace c5time2day2=. if c5time2day2>12 & c5time2day2~=. ** Replace time3day2 with missing if before 12pm and after 5pm li c0surveyno if c5time3day2<12 li c0surveyno if c5time3day2>17 & c5time3day2~=. replace c5corttime3day2=. if c5time3day2<12 replace c5corttime3day2=. if c5time3day2>17 & c5time3day2~=. replace c5time3day2=. if c5time3day2<12 replace c5time3day2=. if c5time3day2>17 & c5time3day2~=. ** Replace time4day2 with missing if before 8pm li c0surveyno if c5time4day2<20 replace c5corttime4day2=. if c5time4day2<20 replace c5time4day2=. if c5time4day2<20 ******************************************************************************************** **Phase 1 recodes for smoking status tab c1smokestatus replace c1smokestatus=. if c1smokestatus==5 recode c1smokestatus (1 2 3 4 = 1) (6 = 2) (7 = 3) (8 = 4), generate (c1smokeindex) tab c1smokeindex label define c1smokerstatus 0 "Never smoked" 1 "Ex-smokers" 2 "1-14 per day" 3 "15-24 per day" 4 "25 plus per day" label values c1smokeindex c1smokerstatus tab c1smokeindex **Generate binary index of phase 1 smoking- non-smoker vs current smoker gen c1binsmoke = c1smokeindex recode c1binsmoke (0 1 = 0) (2 3 4 = 1), generate (c1binsmokeindex) label define c1binsmokerstatus 0 "Non-Smoker" 1 "Current Smoker" label values c1binsmokeindex c1binsmokerstatus **Phase 5 recodes for smoking status gen c5exsmoker = c5q53bwhendidyougiveupsmoking recode c5exsmoker (1 2 3 4 = 2), generate (c5exsmokernew) label define c5exsmokers 2 "ex-smoker" label values c5exsmokernew c5exsmokers tab c5exsmokernew gen c5smokestatus = c5q52asmoking replace c5smokestatus=2 if c5exsmokernew==2 tab c5smokestatus tab c5q52asmoking li c0surveyno if (c5q52asmoking==. & c5smokestatus==2) **Replace c5smokestatus as missing for those with following c0surveyno **as were down as missing for c5q52asmoking yet down as ex smokers in c5smokestatus replace c5smokestatus =. if c0surveyno==2984 replace c5smokestatus =. if c0surveyno==5231 replace c5smokestatus =. if c0surveyno==5292 replace c5smokestatus =. if c0surveyno==7267 tab c5smokestatus gen c5cigarettenumber= c5q52c1howmanycigs recode c5cigarettenumber (1 2 3 4 5 6 8 10 11 12 = 1) (13 14 15 18 20 25 30 35 40 = 2), generate (c5cigarettenumbernew) tab c5cigarettenumbernew label define c5cigarettesperday 1 "1-12 per day" 2 "13 plus per day" label values c5cigarettenumbernew c5cigarettesperday replace c5smokestatus=3 if c5cigarettenumbernew==1 replace c5smokestatus=4 if c5cigarettenumbernew==2 tab c5smokestatus replace c5smokestatus=. if c5smokestatus==1 recode c5smokestatus (2 = 1) (3 = 2) (4 = 3), generate (c5smokeindex) label define c5smokerstatus 0 "Never smoked" 1 "Ex-smokers" 2 "1-12 per day" 3 "13 plus per day" label values c5smokeindex c5smokerstatus tab c5smokeindex **Generate binary index of phase 5 smoking- non-smoker vs current smoker gen c5binsmoke = c5smokeindex recode c5binsmoke (0 1 = 0) (2 3 = 1), generate (c5binsmokeindex) label define c5binsmokerstatus 0 "Non-Smoker" 1 "Current Smoker" label values c5binsmokeindex c5binsmokerstatus **************************************************************************************** **Now derive time adjusted phase 1 cortisol values ** Generate time in hours when serum cortisol sampled ** Morning serum cortisol samples limited to between 6am and 12pm ** Adjust for time of sampling by fitting linear, quadratic or fractional polynomials ** to cortisol against time ** Label variables c1corttime, c1cortmorn and time adjusted cortisol ** First generate time in hours with decimal* generate c1hoursdecblood=((c1hrstimebloodtaken*60)+(c1mintimebloodtaken))/60 ** Plot histograms and summary prior to correcting for time* hist c1hoursdecblood sum c1hoursdecblood, detail scatter c1cortisol c1hoursdecblood||lfit c1cortisol c1hoursdecblood list c1hoursdecblood if c1hoursdecblood>11 list c1hoursdecblood if c1hoursdecblood<6 *As data is skewed for time do morning samples 6am to 12pm* *Before 6am 4.9%, 6-7am 17%, 7-8am 28.1%, 8-9am 24.8%, 9-12am 20.7%* *2-11pm 4.6% and this is what skews the data for time of sampling* generate c1corttime= c1hoursdecblood if c1hoursdecblood>6 & c1hoursdecblood<12 generate c1cortmorn=c1cortisol if c1hoursdecblood>6 & c1hoursdecblood<12 twoway (scatter c1cortmorn c1corttime) *We now need to adjust for time of day by fitting linear, quadratic or fractional polynomial* *Linear* regress c1cortmorn c1corttime scatter c1cortmorn c1corttime||lfit c1cortmorn c1corttime predict res1short, residual hist res1short qnorm res1short *Quadratic* gen c1corttimesq=c1corttime*c1corttime regress c1cortmorn c1corttime c1corttimesq scatter c1cortmorn c1corttime||qfit c1cortmorn c1corttime predict res2short, residual hist res2short qnorm res2short *Fractional Polynomial* fracpoly, compare: regress c1cortmorn c1corttime scatter c1cortmorn c1corttime||fpfit c1cortmorn c1corttime fracpred resfp, dresid hist resfp qnorm resfp ************************************************************************ *Now obtain time adjusted cortisol levels from frac. poly*************** *Mean of c1cortmorn is 443.47 and this is added to residuals************ gen cortadj=resfp+443.47 sum cortadj, detail hist cortadj *Problem that minimum value of cortadj is -14.63 gen cortadj1=cortadj if cortadj>0 hist cortadj1 sum cortadj1, detail ************************************************************************************************** ** Now derive phase 5 cortisol averages, CAR and diurnal slope *Below is method for calculating phase 5 averages *First need to generate averages over days 1 and 2 egen c5corttime1avg=rowmean(c5corttime1day1 c5corttime1day2) egen c5corttime2avg=rowmean(c5corttime2day1 c5corttime2day2) egen c5corttime3avg=rowmean(c5corttime3day1 c5corttime3day2) egen c5corttime4avg=rowmean(c5corttime4day1 c5corttime4day2) egen c5time1avg=rowmean(c5time1day1 c5time1day2) egen c5time2avg=rowmean(c5time2day1 c5time2day2) egen c5time3avg=rowmean(c5time3day1 c5time3day2) egen c5time4avg=rowmean(c5time4day1 c5time4day2) sum c5corttime1avg c5corttime2avg c5corttime3avg c5corttime4avg sum c5time1avg c5time2avg c5time3avg c5time4avg **Need to start adjusting for time of cortisol **First, time 1 averaged regress c5corttime1avg c5time1avg fracpoly, compare: regress c5corttime1avg c5time1avg scatter c5corttime1avg c5time1avg||lfit c5corttime1avg c5time1avg scatter c5corttime1avg c5time1avg||fpfit c5corttime1avg c5time1avg **So at this stage don't need to adjust time 1 cortisol for time of sampling **as linear fit is not significant and fpfit is not significantly better fit **Now time 2 averaged regress c5corttime2avg c5time2avg fracpoly, compare: regress c5corttime2avg c5time2avg scatter c5corttime2avg c5time2avg||lfit c5corttime2avg c5time2avg scatter c5corttime2avg c5time2avg||fpfit c5corttime2avg c5time2avg **So at this stage don't need to adjust time 2 cortisol for time of sampling **as linear fit is not significant and fpfit is not significantly better fit **aside- -2, -2 is best fpfit and is as CaP1 **Now time 3 averaged regress c5corttime3avg c5time3avg fracpoly, compare: regress c5corttime3avg c5time3avg scatter c5corttime3avg c5time3avg|| lfit c5corttime3avg c5time3avg scatter c5corttime3avg c5time3avg|| fpfit c5corttime3avg c5time3avg **So at this stage don't need to adjust time 3 cortisol for time of sampling **as linear fit is not significant and fpfit is not significantly better fit **aside- -2, -2 is best fpfit and is as CaP1 **Now time 4 averaged **For now, replace those individuals with missing if before 8pm regress c5corttime4avg c5time4avg fracpoly, compare: regress c5corttime4avg c5time4avg scatter c5corttime4avg c5time4avg|| lfit c5corttime4avg c5time4avg scatter c5corttime4avg c5time4avg|| fpfit c5corttime4avg c5time4avg **Not a significant linear fit and fracpol not sign better *******Hence not adjusting phase 5 measures for time of sampling **Now generate c5 cortisol morning average, CAR average, diurnal slope average and AUCG (total) average *Next generate an average morning salivary cortisol value egen c5cortmornavg=rowmean(c5corttime1avg c5corttime2avg) sum c5cortmornavg, detail gen deltaavg = (c5corttime2avg - c5corttime1avg) sum deltaavg, detail gen diurnaldropavg = (c5cortmornavg - c5corttime4avg) sum diurnaldropavg, detail **Generating area under the curve for 4 time points (averaged) using formula for trapezoid gen m1 = c5corttime1avg gen m2 = c5corttime2avg gen m3 = c5corttime3avg gen m4 = c5corttime4avg gen t1 = (c5time2avg - c5time1avg) gen t2 = (c5time3avg - c5time2avg) gen t3 = (c5time4avg - c5time3avg) gen AUCG = (((m2 + m1)*t1/2) + ((m3 + m2)*t2/2) + ((m4 + m3)*t3/2)) ************************************************************************************************* **Need to omit those taking oral corticosteroids **1) Firstly derive variables for taking corticosteroids **2) Next Look at effect of taking corticosteroids on phase 5 cortisol levels **3) Thirdly omit those participants who are taking oral corticosteroids **1) Deriving variables for participants taking corticosteroids or not **Need to change to missing data for each of corticosteroid medications not having corticosteroids replace c5bnf_code2="." if( c5bnf_code2!="03.02" & c5bnf_code2!="03.02.01" & c5bnf_code2!="03.02.02" & c5bnf_code2!="03.02.04") tab c5bnf_code2 replace c5bnf_code3="." if( c5bnf_code3!="06.03.02.01" & c5bnf_code3!="06.03.02.06") tab c5bnf_code3 replace c5bnf_code4="." if( c5bnf_code4!="11.04.01.01" & c5bnf_code4!="11.04.01.02" & c5bnf_code4!="11.04.01.05") tab c5bnf_code4 replace c5bnf_code5="." if( c5bnf_code5!="12.01.01") tab c5bnf_code5 replace c5bnf_code6="." if( c5bnf_code6!="12.02.01" & c5bnf_code6!="12.02.01.02.01" & c5bnf_code6!="12.02.01.02.03" & c5bnf_code6!="12.02.01.02.05" & c5bnf_code6!="12.02.01.02.06" & c5bnf_code6!="12.02.01.02.07" & c5bnf_code6!="12.02.01.02.08" ) tab c5bnf_code6 replace c5bnf_code7="." if( c5bnf_code7!="13.04.01" & c5bnf_code7!="13.04.04" & c5bnf_code7!="13.04.06" & c5bnf_code7!="13.04.14" ) tab c5bnf_code7 **Hence 90 participants had inhaled corticosteroids, 14 oral corticosteroids, 3 eye corticosteroids, 2 ** ear corticosteroids, 40 nasal corticosteroids and 7 topical corticosteroids. **Need check code below gen takingcorticosteroids=c5bnf_code1 replace takingcorticosteroids="1" if(c5bnf_code2=="." & c5bnf_code3=="." & c5bnf_code4=="." & c5bnf_code5=="." & c5bnf_code6=="." & c5bnf_code7==".") replace takingcorticosteroids="2" if c5bnf_code2!="." replace takingcorticosteroids="3" if c5bnf_code3!="." replace takingcorticosteroids="4" if c5bnf_code4!="." replace takingcorticosteroids="5" if c5bnf_code5!="." replace takingcorticosteroids="6" if c5bnf_code6!="." replace takingcorticosteroids="7" if c5bnf_code7!="." **There are 9 participants taking 2 or groups of corticosteroids and code these 8 replace takingcorticosteroids="8" if c0surveyno==2522 replace takingcorticosteroids="8" if c0surveyno==3313 replace takingcorticosteroids="8" if c0surveyno==3490 replace takingcorticosteroids="8" if c0surveyno==5491 replace takingcorticosteroids="8" if c0surveyno==5714 replace takingcorticosteroids="8" if c0surveyno==6518 replace takingcorticosteroids="8" if c0surveyno==7005 replace takingcorticosteroids="8" if c0surveyno==7072 replace takingcorticosteroids="8" if c0surveyno==7238 encode takingcorticosteroids, generate(takingcorticosteroids2) label variable takingcorticosteroids2 "Taking corticosteroids at phase 5" label define takesteroids 1 "No steroids" 2 "Inhaled" 3 "Oral" 4 "Eye" 5 "Ear" 6 "Nasal" 7 "Topical" 8 "Multiple steroids" label values takingcorticosteroids2 takesteroids tab takingcorticosteroids2 gen takingcorticosteroidsnew=takingcorticosteroids2 recode takingcorticosteroidsnew (2 3 4 5 6 7 8 = 2) label variable takingcorticosteroidsnew "Taking corticosteroids or not at phase 5" label define takingsteroids 1 "No steroids" 2 "corticosteroids" label values takingcorticosteroidsnew takingsteroids tab takingcorticosteroidsnew **2) Effect of taking corticosteroids on phase 5 cortisol levels **Were there differences in phase 5 morning cortisol, night time cortisol **diurnal drop and CAR whether corticosteroids were taken or not? sum c5cortmornavg if takingcorticosteroidsnew==1 sum c5cortmornavg if takingcorticosteroidsnew==2 xi: regress c5cortmornavg i.takingcorticosteroidsnew sum c5corttime4avg if takingcorticosteroidsnew==1 sum c5corttime4avg if takingcorticosteroidsnew==2 xi: regress c5corttime4avg i.takingcorticosteroidsnew sum diurnaldropavg if takingcorticosteroidsnew==1 sum diurnaldropavg if takingcorticosteroidsnew==2 xi: regress diurnaldropavg i.takingcorticosteroidsnew sum deltaavg if takingcorticosteroidsnew==1 sum deltaavg if takingcorticosteroidsnew==2 xi: regress deltaavg i.takingcorticosteroidsnew **Were there differences in phase 5 morning cortisol depending on type of corticosteroid taken? **Firstly morning cortisol at phase 5 sum c5cortmornavg if takingcorticosteroids2==1 sum c5cortmornavg if takingcorticosteroids2==2 sum c5cortmornavg if takingcorticosteroids2==3 sum c5cortmornavg if takingcorticosteroids2==4 sum c5cortmornavg if takingcorticosteroids2==5 sum c5cortmornavg if takingcorticosteroids2==6 sum c5cortmornavg if takingcorticosteroids2==7 sum c5cortmornavg if takingcorticosteroids2==8 xi: regress c5cortmornavg i.takingcorticosteroids2 **Secondly night time cortisol at phase 5 sum c5corttime4avg if takingcorticosteroids2==1 sum c5corttime4avg if takingcorticosteroids2==2 sum c5corttime4avg if takingcorticosteroids2==3 sum c5corttime4avg if takingcorticosteroids2==4 sum c5corttime4avg if takingcorticosteroids2==5 sum c5corttime4avg if takingcorticosteroids2==6 sum c5corttime4avg if takingcorticosteroids2==7 sum c5corttime4avg if takingcorticosteroids2==8 xi: regress c5corttime4avg i.takingcorticosteroids2 **Thirdly diurnal drop at phase 5 sum diurnaldropavg if takingcorticosteroids2==1 sum diurnaldropavg if takingcorticosteroids2==2 sum diurnaldropavg if takingcorticosteroids2==3 sum diurnaldropavg if takingcorticosteroids2==4 sum diurnaldropavg if takingcorticosteroids2==5 sum diurnaldropavg if takingcorticosteroids2==6 sum diurnaldropavg if takingcorticosteroids2==7 sum diurnaldropavg if takingcorticosteroids2==8 xi: regress diurnaldropavg i.takingcorticosteroids2 **Fourthly CAR at phase 5 sum deltaavg if takingcorticosteroids2==1 sum deltaavg if takingcorticosteroids2==2 sum deltaavg if takingcorticosteroids2==3 sum deltaavg if takingcorticosteroids2==4 sum deltaavg if takingcorticosteroids2==5 sum deltaavg if takingcorticosteroids2==6 sum deltaavg if takingcorticosteroids2==7 sum deltaavg if takingcorticosteroids2==8 xi: regress deltaavg i.takingcorticosteroids2 **3) Omit those participants who are taking oral corticosteroids sum c5cortmornavg c5corttime4avg deltaavg diurnaldropavg AUCG replace c5cortmornavg=. if takingcorticosteroids2==3 replace c5corttime1avg=. if takingcorticosteroids2==3 replace c5corttime2avg=. if takingcorticosteroids2==3 replace c5corttime3avg=. if takingcorticosteroids2==3 replace c5corttime4avg=. if takingcorticosteroids2==3 replace diurnaldropavg=. if takingcorticosteroids2==3 replace deltaavg=. if takingcorticosteroids2==3 replace AUCG=. if takingcorticosteroids2==3 sum c5cortmornavg c5corttime4avg deltaavg diurnaldropavg AUCG **Ln transform night time cortisol as evidence of skewness gen lognighttimecortisol = ln(c5corttime4avg) hist c5corttime4avg sum c5corttime4avg, detail hist lognighttimecortisol sum lognighttimecortisol, detail **Ln transform AUCG as evidence of skewness gen logAUCG = ln(AUCG) *Label variable c1corttime, c1cortmorn and cortadj1 label variable c1corttime "Morning c1 time" label variable c1cortmorn "Morning c1 cortisol" label variable cortadj1 "Time adjusted c1cortisol" **Now label variables for phase 5 cortisol label variable c5cortmornavg "Morning salivary cortisol" label variable c5corttime4avg "Night time salivary cortisol" label variable lognighttimecortisol "Loge of night time cortisol" label variable deltaavg "CAR" label variable diurnaldropavg "Diurnal cortisol slope" label variable AUCG "Total area under the curve of cortisol data points" label variable logAUCG "Loge of total area under the curve of cortisol data points" *************************************************************************************************** ** Now z score phase 1 and phase 5 cortisol measures egen z_cortadj1=std(cortadj1) egen z_c5cortmornavg=std(c5cortmornavg) egen z_c5corttime4avg=std(c5corttime4avg) egen z_lognighttimecortisol=std(lognighttimecortisol) egen z_diurnaldropavg=std(diurnaldropavg) egen z_deltaavg=std(deltaavg) egen z_AUCG=std(AUCG) egen z_logAUCG=std(logAUCG) ** Now put phase 1 cortisol into quartiles xtile c1cortquart=cortadj1, nq(4) table c1cortquart, c(n cortadj1 min cortadj1 max cortadj1) ** Now put phase 5 morning cortisol into quartiles xtile c5morncortquart=c5cortmornavg, nq(4) table c5morncortquart, c(n c5cortmornavg min c5cortmornavg max c5cortmornavg) xtile c5nightcortquart=c5corttime4avg, nq(4) xtile c5diurnalcortquart=diurnaldropavg, nq(4) xtile c5deltacortquart=deltaavg, nq(4) xtile c1cortbin=cortadj1, nq(2) xtile c5cortbin=c5cortmornavg, nq(2) xtile c5cortnightbin=c5corttime4avg, nq(2) xtile c5diurnalbin=diurnaldropavg, nq(2) **Now put morning cortisol at phase 1 and 5, night time cortisol at phase 5 **diurnal drop, CAR and AUCG into tertiles following meetings with YBS on 25/06/10 and 13/07/10 xtile c1corttert=cortadj1, nq(3) xtile c5morncorttert=c5cortmornavg, nq(3) xtile c5nightcorttert=c5corttime4avg, nq(3) xtile c5diurnalcorttert=diurnaldropavg, nq(3) xtile c5deltacorttert=deltaavg, nq(3) xtile c5AUCGcorttert=AUCG, nq(3) gen cortdiff = z_c5cortmornavg - z_cortadj1 xtile cortdiffquart=cortdiff, nq(4) gen c5cortmornmeasured=. recode c5cortmornmeasured .=1 if c5cortmornavg==. recode c5cortmornmeasured .=2 if c5cortmornavg~=. label define c5cortmornmeasured 1 "yes" 2 "no" label values c5cortmornmeasured c5cortmornmeasured gen z_cortadj1mod = z_cortadj1 if z_cortadj1>=-3 & z_cortadj1<=3 gen z_diurnaldropavgmod = z_diurnaldropavg if z_diurnaldropavg>=-3 & z_diurnaldropavg<=3 ** First need to convert c5q28initials variable from string to numeric for ANOVA encode c5q28initials, generate(c5q28initialsnum) **Initially using variables c2ghq and c4ghqindex **Generating new variable for each so that either less than or = 4 or greater than 4(depressed) **or for chronicity, >=13 for caseness generate c2ghqgroup=c2ghq recode c2ghqgroup min/4=1 4/max=2 tab c2ghqgroup generate c4ghqindexgroup=c4ghqindex recode c4ghqindexgroup min/4=1 4/max=2 tab c4ghqindexgroup generate c2ghqgroupc=c2ghqc recode c2ghqgroupc min/12=1 12/max=2 tab c2ghqgroupc generate c4ghqindexgroupc=c4ghqcindex recode c4ghqindexgroupc min/12=1 12/max=2 tab c4ghqindexgroupc **First reduce skewness of data for continuous regression in depression hist c2ghq hist c4ghqindex gen logc2ghq = ln(c2ghq) gen logc4ghqindex = ln(c4ghqindex) **Following meeting with YBS on 18th June 2010 cross tabulations with phase 1 morning cortisol and each of **phase 5 morning, night time and diurnal drop for frequencies of get up and go speed were undertaken and ** low-medium to high, low-medium to low-medium, high to low medium and high to high categories were set-up **Firstly phase 1 morning cortisol and phase 5 morning cortisol gen c1corttertc5morncorttertgug=. recode c1corttertc5morncorttertgug .=3 if (c1corttert==3 & c5morncorttert==3 & avgugspeedmpermin!=.) recode c1corttertc5morncorttertgug .=1 if (c1corttert==3 & (c5morncorttert==1 | c5morncorttert==2) & avgugspeedmpermin!=.) recode c1corttertc5morncorttertgug .=2 if ((c1corttert==1 | c1corttert==2) & c5morncorttert==3 & avgugspeedmpermin!=.) recode c1corttertc5morncorttertgug .=0 if ((c1corttert==1 | c1corttert==2) & (c5morncorttert==1 | c5morncorttert==2) & avgugspeedmpermin!=.) label variable c1corttertc5morncorttertgug "Phase 1 and Phase 5 morning cortisol high and low-medium categories for GUG" label define phase15morncortLMtoHgug 0 "LMtoLM" 1 "HtoLM" 2 "LMtoH" 3 "HtoH" label values c1corttertc5morncorttertgug phase15morncortLMtoHgug **Secondly phase 1 morning cortisol and phase 5 night time cortisol gen c1corttertc5nightcorttertgug=. recode c1corttertc5nightcorttertgug .=3 if (c1corttert==3 & c5nightcorttert==3 & avgugspeedmpermin!=.) recode c1corttertc5nightcorttertgug .=1 if (c1corttert==3 & (c5nightcorttert==1 | c5nightcorttert==2) & avgugspeedmpermin!=.) recode c1corttertc5nightcorttertgug .=2 if ((c1corttert==1 | c1corttert==2) & c5nightcorttert==3 & avgugspeedmpermin!=.) recode c1corttertc5nightcorttertgug .=0 if ((c1corttert==1 | c1corttert==2) & (c5nightcorttert==1 | c5nightcorttert==2) & avgugspeedmpermin!=.) label variable c1corttertc5nightcorttertgug "Phase 1 morning and Phase 5 night cortisol high and low-medium categories for GUG" label define phase1morn5nightcortLMtoHgug 0 "LMtoLM" 1 "HtoLM" 2 "LMtoH" 3 "HtoH" label values c1corttertc5nightcorttertgug phase1morn5nightcortLMtoHgug **Thirdly phase 1 morning cortisol and phase 5 diurnal drop gen c1corttertc5diurnalcorttertgug=. recode c1corttertc5diurnalcorttertgug .=0 if (c1corttert==3 & c5diurnalcorttert==3 & avgugspeedmpermin!=.) recode c1corttertc5diurnalcorttertgug .=2 if (c1corttert==3 & (c5diurnalcorttert==1 | c5diurnalcorttert==2) & avgugspeedmpermin!=.) recode c1corttertc5diurnalcorttertgug .=1 if ((c1corttert==1 | c1corttert==2) & c5diurnalcorttert==3 & avgugspeedmpermin!=.) recode c1corttertc5diurnalcorttertgug .=3 if ((c1corttert==1 | c1corttert==2) & (c5diurnalcorttert==1 | c5diurnalcorttert==2) & avgugspeedmpermin!=.) label variable c1corttertc5diurnalcorttertgug "Phase 1 morning and Phase 5 diurnal cortisol high and low-medium categories for GUG" label define phase1morn5diurnalcortLMtoHgug 0 "HtoH" 1 "LMtoH" 2 "HtoLM" 3 "LMtoLM" label values c1corttertc5diurnalcorttertgug phase1morn5diurnalcortLMtoHgug **Fourthly phase 1 morning cortisol and phase 5 CAR gen c1corttertc5deltacorttertgug=. recode c1corttertc5deltacorttertgug .=3 if (c1corttert==3 & c5deltacorttert==3 & avgugspeedmpermin!=.) recode c1corttertc5deltacorttertgug .=1 if (c1corttert==3 & (c5deltacorttert==1 | c5deltacorttert==2) & avgugspeedmpermin!=.) recode c1corttertc5deltacorttertgug .=2 if ((c1corttert==1 | c1corttert==2) & c5deltacorttert==3 & avgugspeedmpermin!=.) recode c1corttertc5deltacorttertgug .=0 if ((c1corttert==1 | c1corttert==2) & (c5deltacorttert==1 | c5deltacorttert==2) & avgugspeedmpermin!=.) label variable c1corttertc5deltacorttertgug "Phase 1 morning and Phase 5 CAR high and low-medium categories for GUG" label define phase1morn5deltacortLMtoHgug 0 "LMtoLM" 1 "HtoLM" 2 "LMtoH" 3 "HtoH" label values c1corttertc5deltacorttertgug phase1morn5deltacortLMtoHgug **Following meeting with YBS on 13th July 2010 cross tabulations with phase 1 morning cortisol and each of **phase 5 morning, night time and diurnal drop for frequencies of flam_low were undertaken and ** low-medium to high, low-medium to low-medium, high to low medium and high to high categories were set-up **Firstly phase 1 morning cortisol and phase 5 morning cortisol **Firstly phase 1 morning cortisol and phase 5 morning cortisol gen c1corttertc5morncorttertflam=. recode c1corttertc5morncorttertflam .=3 if (c1corttert==3 & c5morncorttert==3 & flam_low!=.) recode c1corttertc5morncorttertflam .=1 if (c1corttert==3 & (c5morncorttert==1 | c5morncorttert==2) & flam_low!=.) recode c1corttertc5morncorttertflam .=2 if ((c1corttert==1 | c1corttert==2) & c5morncorttert==3 & flam_low!=.) recode c1corttertc5morncorttertflam .=0 if ((c1corttert==1 | c1corttert==2) & (c5morncorttert==1 | c5morncorttert==2) & flam_low!=.) label variable c1corttertc5morncorttertflam "Phase 1 and Phase 5 morning cortisol high and low-medium categories for Flamingo" label define phase15morncortLMtoHflam 0 "LMtoLM" 1 "HtoLM" 2 "LMtoH" 3 "HtoH" label values c1corttertc5morncorttertflam phase15morncortLMtoHflam **Secondly phase 1 morning cortisol and phase 5 night time cortisol gen c1corttertc5nightcorttertflam=. recode c1corttertc5nightcorttertflam .=3 if (c1corttert==3 & c5nightcorttert==3 & flam_low!=.) recode c1corttertc5nightcorttertflam .=1 if (c1corttert==3 & (c5nightcorttert==1 | c5nightcorttert==2) & flam_low!=.) recode c1corttertc5nightcorttertflam .=2 if ((c1corttert==1 | c1corttert==2) & c5nightcorttert==3 & flam_low!=.) recode c1corttertc5nightcorttertflam .=0 if ((c1corttert==1 | c1corttert==2) & (c5nightcorttert==1 | c5nightcorttert==2) & flam_low!=.) label variable c1corttertc5nightcorttertflam "Phase 1 morning and Phase 5 night cortisol high and low-medium categories for Flamingo" label define phase1morn5nightcortLMtoHflam 0 "LMtoLM" 1 "HtoLM" 2 "LMtoH" 3 "HtoH" label values c1corttertc5nightcorttertflam phase1morn5nightcortLMtoHflam **Thirdly phase 1 morning cortisol and phase 5 diurnal drop gen c1corttertc5diurnalcorttertflam=. recode c1corttertc5diurnalcorttertflam .=0 if (c1corttert==3 & c5diurnalcorttert==3 & flam_low!=.) recode c1corttertc5diurnalcorttertflam .=2 if (c1corttert==3 & (c5diurnalcorttert==1 | c5diurnalcorttert==2) & flam_low!=.) recode c1corttertc5diurnalcorttertflam .=1 if ((c1corttert==1 | c1corttert==2) & c5diurnalcorttert==3 & flam_low!=.) recode c1corttertc5diurnalcorttertflam .=3 if ((c1corttert==1 | c1corttert==2) & (c5diurnalcorttert==1 | c5diurnalcorttert==2) & flam_low!=.) label variable c1corttertc5diurnalcorttertflam "Phase 1 morning and Phase 5 diurnal cortisol high and low-medium categories for Flamingo" label define phase1morn5diurnalcortLMtoHflam 0 "HtoH" 1 "LMtoH" 2 "HtoLM" 3 "LMtoLM" label values c1corttertc5diurnalcorttertflam phase1morn5diurnalcortLMtoHflam **Fourthly phase 1 morning cortisol and phase 5 CAR gen c1corttertc5deltacorttertflam=. recode c1corttertc5deltacorttertflam .=3 if (c1corttert==3 & c5deltacorttert==3 & flam_low!=.) recode c1corttertc5deltacorttertflam .=1 if (c1corttert==3 & (c5deltacorttert==1 | c5deltacorttert==2) & flam_low!=.) recode c1corttertc5deltacorttertflam .=2 if ((c1corttert==1 | c1corttert==2) & c5deltacorttert==3 & flam_low!=.) recode c1corttertc5deltacorttertflam .=0 if ((c1corttert==1 | c1corttert==2) & (c5deltacorttert==1 | c5deltacorttert==2) & flam_low!=.) label variable c1corttertc5deltacorttertflam "Phase 1 morning and Phase 5 CAR high and low-medium categories for Flamingo" label define phase1morn5deltacortLMtoHflam 0 "LMtoLM" 1 "HtoLM" 2 "LMtoH" 3 "HtoH" label values c1corttertc5deltacorttertflam phase1morn5deltacortLMtoHflam **For meta-analysis as at 4th November 2011, for sensitivity use 30 minutes post waking ** measure as morning cortisol measure and as anchor in diurnal drop egen z_c5corttime2avg=std(c5corttime2avg) gen diurnaldropavgsens = (c5corttime2avg - c5corttime4avg) egen z_diurnaldropavgsens=std(diurnaldropavgsens)