******************************************************************** * File HALCyon cortisol syntax_BoydOrr.do * BY Mike Gardner, University of Bristol * FOR HALCyon cross-cohort collaboration (funded by the New Dynamics of Ageing (RES-353-25-0001)) * DATASET Boyd Orr Cohort study * Date Created 24/03/2010 * last modified 24/03/2010 * PURPOSE Cleans and derives cortisol and smoking variables ************************************************************************************* set more off ** clean cortisol. sum b3cortisol li uniq_id b3cortisol if b3cortisol==0 & b3cortisol!=. ** variable "601904" had cortisol values as "0" and hence replaced as missing replace b3cortisol=. if b3cortisol==0 sum b3cortisol **PHASE 3 TIME ADJUSTED CORTISOL VALUES **Generate time in hours when cortisol sampled generate time=((b3hrs_blood__taken*60) + (b3min_blood__taken))/60 sum time, detail **Need recode cortisol and time so omit those 35 out of 405 not fasting sum b3cortisol sum time gen b3cortisolfast=b3cortisol if b3fast6==1 gen timefast=time if b3fast6==1 sum b3cortisolfast sum timefast scatter b3cortisolfast timefast **As want morning cortisol and to be comparable with CaPS phase 1, **limit cortisol and time to morning gen b3morncortisol=b3cortisolfast if timefast<12 gen morntime=timefast if timefast<12 scatter b3morncortisol morntime **Distribution of morning cortisol is not skewed and approx. normal hence not transform sum b3morncortisol, detail hist b3morncortisol **Now need to adjust cortisol for time of day by fitting linear and fractional polynomial **First Linear regress b3morncortisol morntime predict res1, residual hist res1 qnorm res1 fracpoly, compare: regress b3morncortisol morntime fracplot morntime fracpred resfp, dresid hist resfp qnorm resfp **There is a significant negative linear fit and fractional polynomial fit **where p1=-2 and p2=-2 wasn't significantly better. However use fractional **polynomial fit (as in case of phase 1 fasting morning cortisol in CaPS) **Now generate time adjusted cortisol. Mean of b3morncortisol is 441.94 gen b3cortadj=resfp+441.94 sum b3cortadj, detail **Minimum value is greater than 0 (159.23) **Need to replace those participants taking oral corticosteroids **li uniq_id b3medcode if( b3medcode=="06.03.02") was used in file * uniq_id b3medc~e | * |--------------------| * | 403307 06.03.02 | * | 411009 06.03.02 | * | 1106803 06.03.02 | * | 1381307 06.03.02 | * | 600407 06.03.02 | * |--------------------| * | 1100206 06.03.02 | * | 802907 06.03.02 | * | 1109907 06.03.02 | * | 209403 06.03.02 | * | 900304 06.03.02 | * |--------------------| * | 804403 06.03.02 | * | 1508105 06.03.02 | * | 1505005 06.03.02 | * +--------------------+ replace b3cortadj=. if(uniq_id==403307) replace b3cortadj=. if(uniq_id==411009) replace b3cortadj=. if(uniq_id==1106803) replace b3cortadj=. if(uniq_id==1381307) replace b3cortadj=. if(uniq_id==600407) replace b3cortadj=. if(uniq_id==1100206) replace b3cortadj=. if(uniq_id==802907) replace b3cortadj=. if(uniq_id==1109907) replace b3cortadj=. if(uniq_id==209403) replace b3cortadj=. if(uniq_id==900304) replace b3cortadj=. if(uniq_id==804403) replace b3cortadj=. if(uniq_id==1508105) replace b3cortadj=. if(uniq_id==1505005) sum b3cortadj, detail **Label morning adjusted cortisol variable and morning time label variable b3cortadj "Time adjusted morning cortisol" label variable morntime "Morning b3 cortisol time" **Now zscore phase 3 morning cortisol zscore b3cortadj **Now put phase 3 time adjusted morning cortisol into quartiles xtile b3cortquart=b3cortadj, nq(4) table b3cortquart, c(n b3cortadj min b3cortadj max b3cortadj) **Smoking status to **Never, ex and current. tab b3smokingstatus gen b3smokeindex1 = b3smokingstatus recode b3smokeindex1 (1 = 6)(2 = 5)(3 = 4), generate (b3smokeindex2) tab b3smokeindex2 recode b3smokeindex2 (4 = 0)(5 = 1)(6 = 2), generate (b3smokeindex3) tab b3smokeindex3