From 1cc9413529fe34d2b061494922898e31072e85c4 Mon Sep 17 00:00:00 2001 From: Viyaasan Mahalingasivam Date: Wed, 10 Jan 2024 13:47:52 +0000 Subject: [PATCH] New pneumonia comparator tables --- analysis/cox_forest_hospitalised.do | 98 +++++++ analysis/cox_forest_hospitalised_aki.do | 249 ----------------- analysis/cox_forest_hospitalised_death.do | 249 ----------------- analysis/cox_forest_hospitalised_egfr_half.do | 254 ------------------ analysis/cox_forest_hospitalised_esrd.do | 249 ----------------- .../cox_forest_hospitalised_exposures_esrd.do | 117 ++++++++ analysis/events_cca_hospitalised.do | 48 ++++ .../events_cca_hospitalised_exposures_esrd.do | 47 ++++ project.yaml | 56 ++-- 9 files changed, 338 insertions(+), 1029 deletions(-) create mode 100644 analysis/cox_forest_hospitalised.do delete mode 100644 analysis/cox_forest_hospitalised_aki.do delete mode 100644 analysis/cox_forest_hospitalised_death.do delete mode 100644 analysis/cox_forest_hospitalised_egfr_half.do delete mode 100644 analysis/cox_forest_hospitalised_esrd.do create mode 100644 analysis/cox_forest_hospitalised_exposures_esrd.do create mode 100644 analysis/events_cca_hospitalised.do create mode 100644 analysis/events_cca_hospitalised_exposures_esrd.do diff --git a/analysis/cox_forest_hospitalised.do b/analysis/cox_forest_hospitalised.do new file mode 100644 index 0000000..f552e94 --- /dev/null +++ b/analysis/cox_forest_hospitalised.do @@ -0,0 +1,98 @@ +sysdir set PLUS ./analysis/adofiles +sysdir set PERSONAL ./analysis/adofiles +pwd +cap log close +macro drop hr +log using ./logs/cox_forest_hospitalised.log, replace t + +cap file close tablecontent +file open tablecontent using ./output/cox_forest_hospitalised.csv, write text replace +file write tablecontent ("outcome") _tab ("period") _tab ("hr_text") _tab ("hr") _tab ("ll") _tab ("ul") _tab ("rate_text") _tab ("rate") _tab ("rate_ll") _tab ("rate_ul") _tab ("ard_text") _tab ("ard") _tab ("ard_ll") _tab ("ard_ul") _n +use ./output/analysis_hospitalised.dta, clear + +*Time to event +local period "29 89 179 max" + +local lab29 "0-29 days" +local lab89 "30-89 days" +local lab179 "90-179 days" +local labmax "180+ days" + +local outcomes "esrd egfr_half aki death" + +local esrd_lab "Kidney failure" +local egfr_half_lab "50% reduction in eGFR" +local aki_lab "AKI" +local death_lab "Death" + +foreach out of local outcomes { + +qui stset exit_date_`out', fail(`out'_date) origin(index_date_`out') id(unique) scale(365.25) +drop age1 age2 age3 +mkspline age = age if _st==1&sex!=.ðnicity!=.&imd!=.&urban!=.®ion!=.&bmi!=.&smoking!=., cubic nknots(4) + +**COVID overall + +*Rates +bysort case: egen total_follow_up = total(_t) +qui su total_follow_up if case==1 +local cases_multip = 100000 / r(mean) +drop total_follow_up +qui safecount if case==1 & _d==1 & _st==1 +local cases_events = round(r(N),5) +local cases_rate : di %3.2f (`cases_events' * `cases_multip') +local cases_ef = exp(1.96/(sqrt(`cases_events'))) +local cases_ul = `cases_rate' * `cases_ef' +local cases_ll = `cases_rate' / `cases_ef' + +*HR +qui stcox i.case i.sex i.ethnicity i.imd i.urban i.stp i.bmi i.smoking i.ckd_stage i.aki_baseline i.cardiovascular i.diabetes i.hypertension i.immunosuppressed i.non_haem_cancer i.gp_consults i.admissions i.month age1 age2 age3, vce(cluster practice_id) +matrix table = r(table) +local full_overall_b: display %4.2f table[1,2] +local full_overall_ll: display %4.2f table[5,2] +local full_overall_ul: display %4.2f table[6,2] + +*Adjusted rate difference - confidence intervals based on crude rate in exposed with uncertainty expressed by confidence intervals for HRs +local ard_b: di %3.2f `cases_rate' - ((1/`full_overall_b') * `cases_rate') +local ard_ll: di %3.2f `cases_rate' - ((1/`full_overall_ll') * `cases_rate') +local ard_ul: di %3.2f `cases_rate' - ((1/`full_overall_ul') * `cases_rate') + +*Stratified by time to event +foreach x of local period { +qui stset exit_date`x'_`out', fail(`out'_date`x') origin(index_date`x'_`out') id(unique) scale(365.25) + +*Rate +bysort case: egen total_follow_up`x' = total(_t) +qui su total_follow_up`x' if case==1 +local cases_multip = 100000 / r(mean) +drop total_follow_up`x' +qui safecount if case==1 & _d==1 & _st==1 +local cases_events = round(r(N),5) +local cases_rate`x' : di %3.2f (`cases_events' * `cases_multip') +local cases_ef = exp(1.96/(sqrt(`cases_events'))) +local cases_ul`x' = `cases_rate`x'' * `cases_ef' +local cases_ll`x' = `cases_rate`x'' / `cases_ef' + +*HR +qui stcox i.case i.sex i.ethnicity i.imd i.urban i.stp i.bmi i.smoking i.ckd_stage i.aki_baseline i.cardiovascular i.diabetes i.hypertension i.immunosuppressed i.non_haem_cancer i.gp_consults i.admissions i.month age1 age2 age3, vce(cluster practice_id) +matrix table = r(table) +local full_overall_b`x': display %4.2f table[1,2] +local full_overall_ll`x': display %4.2f table[5,2] +local full_overall_ul`x': display %4.2f table[6,2] + +*Adjusted rate difference +local ard_b`x': di %3.2f `cases_rate`x'' - ((1/`full_overall_b`x'') * `cases_rate`x'') +local ard_ll`x': di %3.2f `cases_rate`x'' - ((1/`full_overall_ll`x'') * `cases_rate`x'') +local ard_ul`x': di %3.2f `cases_rate`x'' - ((1/`full_overall_ul`x'') * `cases_rate`x'') +} + + +file write tablecontent ("``out'_lab'") _tab ("Overall") _tab %4.2f (`full_overall_b') (" (") %4.2f (`full_overall_ll') ("-") %4.2f (`full_overall_ul') (")") _tab %4.2f (`full_overall_b') _tab %4.2f (`full_overall_ll') _tab (`full_overall_ul') _tab ("`cases_rate'") (" (") %3.2f (`cases_ll') ("-") %3.2f (`cases_ul') (")") _tab ("`cases_rate'") _tab ("`cases_ll'") _tab ("`cases_ul'") _tab ("`ard_b'") (" (") %3.2f (`ard_ll') ("-") %3.2f (`ard_ul') (")") _tab ("`ard_b'") _tab ("`ard_ll'") _tab ("`ard_ul'") _n + +foreach x of local period { +file write tablecontent ("``out'_lab'") _tab ("`lab`x''") _tab %4.2f (`full_overall_b`x'') (" (") %4.2f (`full_overall_ll`x'') ("-") %4.2f (`full_overall_ul`x'') (")") _tab %4.2f (`full_overall_b`x'') _tab %4.2f (`full_overall_ll`x'') _tab (`full_overall_ul`x'') _tab ("`cases_rate`x''") (" (") %3.2f (`cases_ll`x'') ("-") %3.2f (`cases_ul`x'') (")") _tab ("`cases_rate`x''") _tab ("`cases_ll`x''") _tab ("`cases_ul`x''") _tab ("`ard_b`x''") (" (") %3.2f (`ard_ll`x'') ("-") %3.2f (`ard_ul`x'') (")") _tab ("`ard_b`x''") _tab ("`ard_ll`x''") _tab ("`ard_ul`x''") _n +} +} + + +file close tablecontent \ No newline at end of file diff --git a/analysis/cox_forest_hospitalised_aki.do b/analysis/cox_forest_hospitalised_aki.do deleted file mode 100644 index 47bce0e..0000000 --- a/analysis/cox_forest_hospitalised_aki.do +++ /dev/null @@ -1,249 +0,0 @@ -sysdir set PLUS ./analysis/adofiles -sysdir set PERSONAL ./analysis/adofiles -pwd -cap log close -macro drop hr -log using ./logs/cox_forest_hospitalised_aki.log, replace t - -cap file close tablecontent -file open tablecontent using ./output/cox_forest_hospitalised_aki.csv, write text replace -file write tablecontent _tab ("Rate (/100000 person years) (95% CI)") _tab ("rate") _tab ("Fully-adjusted HR (95% CI)") _tab ("hr") _tab ("ll") _tab ("ul") _n -file write tablecontent ("Hospitalised COVID-19 overall") _n -file write tablecontent ("Overall") _tab -use ./output/analysis_hospitalised.dta, clear -stset exit_date_aki, fail(aki_date) origin(index_date_aki) id(unique) scale(365.25) -drop age1 age2 age3 -mkspline age = age if _st==1&sex!=.ðnicity!=.&imd!=.&urban!=.®ion!=.&bmi!=.&smoking!=., cubic nknots(4) -bysort case: egen total_follow_up = total(_t) -qui su total_follow_up if case==1 -local cases_py = r(mean) -local cases_multip = 100000 / r(mean) -qui su total_follow_up if case==0 -local controls_multip = 100000 / r(mean) -qui safecount if case==1 & _d==1 & _st==1 -local cases_events = round(r(N),5) -local cases_rate : di %3.2f (`cases_events' * `cases_multip') -local cases_ef = exp(1.96/(sqrt(`cases_events'))) -local cases_ul = `cases_rate' * `cases_ef' -local cases_ll = `cases_rate' / `cases_ef' -file write tablecontent ("`cases_rate'") (" (") %3.2f (`cases_ll') ("-") %3.2f (`cases_ul') (")") _tab ("`cases_rate'") _tab -qui stcox i.case i.sex i.ethnicity i.imd i.urban i.stp i.bmi i.smoking i.ckd_stage i.aki_baseline i.cardiovascular i.diabetes i.hypertension i.immunosuppressed i.non_haem_cancer i.gp_consults i.admissions i.month age1 age2 age3, vce(cluster practice_id) -matrix table = r(table) -local full_overall_b: display %4.2f table[1,2] -local full_overall_ll: display %4.2f table[5,2] -local full_overall_ul: display %4.2f table[6,2] - -file write tablecontent %4.2f (`full_overall_b') (" (") %4.2f (`full_overall_ll') ("-") %4.2f (`full_overall_ul') (")") _tab %4.2f (`full_overall_b') _tab %4.2f (`full_overall_ll') _tab (`full_overall_ul') _n - -local period "29 89 179 max" - -local lab29 "0-29 days" -local lab89 "30-89 days" -local lab179 "90-179 days" -local labmax "180+ days" - -foreach x of local period { -file write tablecontent ("`lab`x''") _tab -stset exit_date`x'_aki, fail(aki_date`x') origin(index_date`x'_aki) id(unique) scale(365.25) -drop age1 age2 age3 -mkspline age = age if _st==1&sex!=.ðnicity!=.&imd!=.&urban!=.®ion!=.&bmi!=.&smoking!=., cubic nknots(4) -bysort case: egen total_follow_up`x' = total(_t) -qui su total_follow_up`x' if case==1 -local cases_py = r(mean) -local cases_multip = 100000 / r(mean) -qui su total_follow_up`x' if case==0 -local controls_multip = 100000 / r(mean) -qui safecount if case==1 & _d==1 & _st==1 -local cases_events = round(r(N),5) -local cases_rate : di %3.2f (`cases_events' * `cases_multip') -local cases_ef = exp(1.96/(sqrt(`cases_events'))) -local cases_ul = `cases_rate' * `cases_ef' -local cases_ll = `cases_rate' / `cases_ef' -qui safecount if case==0 & _d==1 & _st==1 -local controls_events = round(r(N),5) -local controls_rate : di %3.2f (`controls_events' * `controls_multip') -local controls_ef = exp(1.96/(sqrt(`controls_events'))) -local controls_ul = `controls_rate' * `controls_ef' -local controls_ll = `controls_rate' / `controls_ef' -file write tablecontent ("`cases_rate'") (" (") %3.2f (`cases_ll') ("-") %3.2f (`cases_ul') (")") _tab ("`cases_rate'") _tab - -qui stcox i.case i.sex i.ethnicity i.imd i.urban i.stp i.bmi i.smoking i.ckd_stage i.aki_baseline i.cardiovascular i.diabetes i.hypertension i.immunosuppressed i.non_haem_cancer i.gp_consults i.admissions i.month age1 age2 age3, vce(cluster practice_id) -matrix table = r(table) -local full_overall_b: display %4.2f table[1,2] -local full_overall_ll: display %4.2f table[5,2] -local full_overall_ul: display %4.2f table[6,2] - -file write tablecontent %4.2f (`full_overall_b') (" (") %4.2f (`full_overall_ll') ("-") %4.2f (`full_overall_ul') (")") _tab %4.2f (`full_overall_b') _tab %4.2f (`full_overall_ll') _tab (`full_overall_ul') _n -} -file write tablecontent _n - -file write tablecontent ("By COVID-19 wave") _n - -use ./output/analysis_hospitalised.dta, clear - -local wave1: label wave 1 -local wave2: label wave 2 -local wave3: label wave 3 -local wave4: label wave 4 - -stset exit_date_aki, fail(aki_date) origin(index_date_aki) id(unique) scale(365.25) -drop age1 age2 age3 -mkspline age = age if _st==1&sex!=.ðnicity!=.&imd!=.&urban!=.®ion!=.&bmi!=.&smoking!=., cubic nknots(4) -qui stcox i.wave i.sex i.ethnicity i.imd i.urban i.stp i.bmi i.smoking i.ckd_stage i.aki_baseline i.cardiovascular i.diabetes i.hypertension i.immunosuppressed i.non_haem_cancer i.gp_consults i.admissions i.month age1 age2 age3, vce(cluster practice_id) -matrix table = r(table) -local full_wave_1b: display %4.2f table[1,2] -local full_wave_1ll: display %4.2f table[5,2] -local full_wave_1ul: display %4.2f table[6,2] -local full_wave_2b: display %4.2f table[1,3] -local full_wave_2ll: display %4.2f table[5,3] -local full_wave_2ul: display %4.2f table[6,3] -local full_wave_3b: display %4.2f table[1,4] -local full_wave_3ll: display %4.2f table[5,4] -local full_wave_3ul: display %4.2f table[6,4] -local full_wave_4b: display %4.2f table[1,5] -local full_wave_4ll: display %4.2f table[5,5] -local full_wave_4ul: display %4.2f table[6,5] - -bysort wave: egen total_follow_up = total(_t) -forvalues i=1/4 { -qui su total_follow_up if wave==`i' -local cases`i'_py = r(mean) -local cases`i'_multip = 100000 / r(mean) -qui safecount if wave==`i' & _d==1 & _st==1 -local cases`i'_events = round(r(N),5) -local cases`i'_rate : di %3.2f (`cases`i'_events' * `cases`i'_multip') -local cases`i'_ef = exp(1.96/(sqrt(`cases`i'_events'))) -local cases`i'_ul = `cases`i'_rate' * `cases`i'_ef' -local cases`i'_ll = `cases`i'_rate' / `cases`i'_ef' -} - -foreach x of local period { -stset exit_date`x'_aki, fail(aki_date`x') origin(index_date`x'_aki) id(unique) scale(365.25) -drop age1 age2 age3 -mkspline age = age if _st==1&sex!=.ðnicity!=.&imd!=.&urban!=.®ion!=.&bmi!=.&smoking!=., cubic nknots(4) -qui stcox i.wave i.sex i.ethnicity i.imd i.urban i.stp i.bmi i.smoking i.ckd_stage i.aki_baseline i.cardiovascular i.diabetes i.hypertension i.immunosuppressed i.non_haem_cancer i.gp_consults i.admissions i.month age1 age2 age3, vce(cluster practice_id) -matrix table = r(table) -local full_wave_1b`x': display %4.2f table[1,2] -local full_wave_1ll`x': display %4.2f table[5,2] -local full_wave_1ul`x': display %4.2f table[6,2] -local full_wave_2b`x': display %4.2f table[1,3] -local full_wave_2ll`x': display %4.2f table[5,3] -local full_wave_2ul`x': display %4.2f table[6,3] -local full_wave_3b`x': display %4.2f table[1,4] -local full_wave_3ll`x': display %4.2f table[5,4] -local full_wave_3ul`x': display %4.2f table[6,4] -local full_wave_4b`x': display %4.2f table[1,5] -local full_wave_4ll`x': display %4.2f table[5,5] -local full_wave_4ul`x': display %4.2f table[6,5] - -bysort wave: egen total_follow_up`x' = total(_t) -forvalues i=1/4 { -qui su total_follow_up`x' if wave==`i' -local cases`i'_py = r(mean) -local cases`i'_multip = 100000 / r(mean) -qui safecount if wave==`i' & _d==1 & _st==1 -local cases`i'_events = round(r(N),5) -local cases`i'_rate`x' : di %3.2f (`cases`i'_events' * `cases`i'_multip') -local cases`i'_ef = exp(1.96/(sqrt(`cases`i'_events'))) -local cases`i'_ul`x' = `cases`i'_rate`x'' * `cases`i'_ef' -local cases`i'_ll`x' = `cases`i'_rate`x'' / `cases`i'_ef' -} -} - -forvalues i=1/4 { -file write tablecontent ("`wave`i''") _n -file write tablecontent ("Overall") _tab ("`cases`i'_rate'") (" (") %3.2f (`cases`i'_ll') ("-") %3.2f (`cases`i'_ul') (")") _tab ("`cases`i'_rate'") _tab %4.2f (`full_wave_`i'b') (" (") %4.2f (`full_wave_`i'll') ("-") %4.2f (`full_wave_`i'ul') (")") _tab %4.2f (`full_wave_`i'b') _tab %4.2f (`full_wave_`i'll') _tab (`full_wave_`i'ul') _n -foreach x of local period { -file write tablecontent ("`lab`x''") _tab ("`cases`i'_rate`x''") (" (") %3.2f (`cases`i'_ll`x'') ("-") %3.2f (`cases`i'_ul`x'') (")") _tab ("`cases`i'_rate`x''") _tab %4.2f (`full_wave_`i'b`x'') (" (") %4.2f (`full_wave_`i'll`x'') ("-") %4.2f (`full_wave_`i'ul`x'') (")") _tab %4.2f (`full_wave_`i'b`x'') _tab %4.2f (`full_wave_`i'll`x'') _tab %4.2f (`full_wave_`i'ul`x'') _n -} -} -file write tablecontent _n - -file write tablecontent ("By COVID-19 vaccination status") _n - -use ./output/analysis_hospitalised.dta, clear - -local vax1: label covid_vax 1 -local vax2: label covid_vax 2 -local vax3: label covid_vax 3 -local vax4: label covid_vax 4 -local vax5: label covid_vax 5 - -stset exit_date_aki, fail(aki_date) origin(index_date_aki) id(unique) scale(365.25) -drop age1 age2 age3 -mkspline age = age if _st==1&sex!=.ðnicity!=.&imd!=.&urban!=.®ion!=.&bmi!=.&smoking!=., cubic nknots(4) -qui stcox i.covid_vax i.sex i.ethnicity i.imd i.urban i.stp i.bmi i.smoking i.ckd_stage i.aki_baseline i.cardiovascular i.diabetes i.hypertension i.immunosuppressed i.non_haem_cancer i.gp_consults i.admissions i.month age1 age2 age3, vce(cluster practice_id) -matrix table = r(table) -local full_vax_1b: display %4.2f table[1,2] -local full_vax_1ll: display %4.2f table[5,2] -local full_vax_1ul: display %4.2f table[6,2] -local full_vax_2b: display %4.2f table[1,3] -local full_vax_2ll: display %4.2f table[5,3] -local full_vax_2ul: display %4.2f table[6,3] -local full_vax_3b: display %4.2f table[1,4] -local full_vax_3ll: display %4.2f table[5,4] -local full_vax_3ul: display %4.2f table[6,4] -local full_vax_4b: display %4.2f table[1,5] -local full_vax_4ll: display %4.2f table[5,5] -local full_vax_4ul: display %4.2f table[6,5] -local full_vax_5b: display %4.2f table[1,6] -local full_vax_5ll: display %4.2f table[5,6] -local full_vax_5ul: display %4.2f table[6,6] - -bysort covid_vax: egen total_follow_up = total(_t) -forvalues i=1/5 { -qui su total_follow_up if covid_vax==`i' -local cases`i'_py = r(mean) -local cases`i'_multip = 100000 / r(mean) -qui safecount if covid_vax==`i' & _d==1 & _st==1 -local cases`i'_events = round(r(N),5) -local cases`i'_rate : di %3.2f (`cases`i'_events' * `cases`i'_multip') -local cases`i'_ef = exp(1.96/(sqrt(`cases`i'_events'))) -local cases`i'_ul = `cases`i'_rate' * `cases`i'_ef' -local cases`i'_ll = `cases`i'_rate' / `cases`i'_ef' -} - -foreach x of local period { -stset exit_date`x'_aki, fail(aki_date`x') origin(index_date`x'_aki) id(unique) scale(365.25) -drop age1 age2 age3 -mkspline age = age if _st==1&sex!=.ðnicity!=.&imd!=.&urban!=.®ion!=.&bmi!=.&smoking!=., cubic nknots(4) -qui stcox i.covid_vax i.sex i.ethnicity i.imd i.urban i.stp i.bmi i.smoking i.ckd_stage i.aki_baseline i.cardiovascular i.diabetes i.hypertension i.immunosuppressed i.non_haem_cancer i.gp_consults i.admissions i.month age1 age2 age3, vce(cluster practice_id) -matrix table = r(table) -local full_vax_1b`x': display %4.2f table[1,2] -local full_vax_1ll`x': display %4.2f table[5,2] -local full_vax_1ul`x': display %4.2f table[6,2] -local full_vax_2b`x': display %4.2f table[1,3] -local full_vax_2ll`x': display %4.2f table[5,3] -local full_vax_2ul`x': display %4.2f table[6,3] -local full_vax_3b`x': display %4.2f table[1,4] -local full_vax_3ll`x': display %4.2f table[5,4] -local full_vax_3ul`x': display %4.2f table[6,4] -local full_vax_4b`x': display %4.2f table[1,5] -local full_vax_4ll`x': display %4.2f table[5,5] -local full_vax_4ul`x': display %4.2f table[6,5] -local full_vax_5b`x': display %4.2f table[1,6] -local full_vax_5ll`x': display %4.2f table[5,6] -local full_vax_5ul`x': display %4.2f table[6,6] - -bysort covid_vax: egen total_follow_up`x' = total(_t) -forvalues i=1/5 { -qui su total_follow_up`x' if covid_vax==`i' -local cases`i'_py = r(mean) -local cases`i'_multip = 100000 / r(mean) -qui safecount if covid_vax==`i' & _d==1 & _st==1 -local cases`i'_events = round(r(N),5) -local cases`i'_rate`x' : di %3.2f (`cases`i'_events' * `cases`i'_multip') -local cases`i'_ef = exp(1.96/(sqrt(`cases`i'_events'))) -local cases`i'_ul`x' = `cases`i'_rate`x'' * `cases`i'_ef' -local cases`i'_ll`x' = `cases`i'_rate`x'' / `cases`i'_ef' -} -} - -forvalues i=1/5 { -file write tablecontent ("`vax`i''") _n -file write tablecontent ("Overall") _tab ("`cases`i'_rate'") (" (") %3.2f (`cases`i'_ll') ("-") %3.2f (`cases`i'_ul') (")") _tab ("`cases`i'_rate'") _tab %4.2f (`full_vax_`i'b') (" (") %4.2f (`full_vax_`i'll') ("-") %4.2f (`full_vax_`i'ul') (")") _tab %4.2f (`full_vax_`i'b') _tab %4.2f (`full_vax_`i'll') _tab (`full_vax_`i'ul') _n -foreach x of local period { -file write tablecontent ("`lab`x''") _tab ("`cases`i'_rate`x''") (" (") %3.2f (`cases`i'_ll`x'') ("-") %3.2f (`cases`i'_ul`x'') (")") _tab ("`cases`i'_rate`x''") _tab %4.2f (`full_vax_`i'b`x'') (" (") %4.2f (`full_vax_`i'll`x'') ("-") %4.2f (`full_vax_`i'ul`x'') (")") _tab %4.2f (`full_vax_`i'b`x'') _tab %4.2f (`full_vax_`i'll`x'') _tab %4.2f (`full_vax_`i'ul`x'') _n -} -} -file close tablecontent \ No newline at end of file diff --git a/analysis/cox_forest_hospitalised_death.do b/analysis/cox_forest_hospitalised_death.do deleted file mode 100644 index a2e66b8..0000000 --- a/analysis/cox_forest_hospitalised_death.do +++ /dev/null @@ -1,249 +0,0 @@ -sysdir set PLUS ./analysis/adofiles -sysdir set PERSONAL ./analysis/adofiles -pwd -cap log close -macro drop hr -log using ./logs/cox_forest_hospitalised_death.log, replace t - -cap file close tablecontent -file open tablecontent using ./output/cox_forest_hospitalised_death.csv, write text replace -file write tablecontent _tab ("Rate (/100000 person years) (95% CI)") _tab ("rate") _tab ("Fully-adjusted HR (95% CI)") _tab ("hr") _tab ("ll") _tab ("ul") _n -file write tablecontent ("Hospitalised COVID-19 overall") _n -file write tablecontent ("Overall") _tab -use ./output/analysis_hospitalised.dta, clear -stset exit_date_death, fail(death_date) origin(index_date_death) id(unique) scale(365.25) -drop age1 age2 age3 -mkspline age = age if _st==1&sex!=.ðnicity!=.&imd!=.&urban!=.®ion!=.&bmi!=.&smoking!=., cubic nknots(4) -bysort case: egen total_follow_up = total(_t) -qui su total_follow_up if case==1 -local cases_py = r(mean) -local cases_multip = 100000 / r(mean) -qui su total_follow_up if case==0 -local controls_multip = 100000 / r(mean) -qui safecount if case==1 & _d==1 & _st==1 -local cases_events = round(r(N),5) -local cases_rate : di %3.2f (`cases_events' * `cases_multip') -local cases_ef = exp(1.96/(sqrt(`cases_events'))) -local cases_ul = `cases_rate' * `cases_ef' -local cases_ll = `cases_rate' / `cases_ef' -file write tablecontent ("`cases_rate'") (" (") %3.2f (`cases_ll') ("-") %3.2f (`cases_ul') (")") _tab ("`cases_rate'") _tab -qui stcox i.case i.sex i.ethnicity i.imd i.urban i.stp i.bmi i.smoking i.ckd_stage i.aki_baseline i.cardiovascular i.diabetes i.hypertension i.immunosuppressed i.non_haem_cancer i.gp_consults i.admissions i.month age1 age2 age3, vce(cluster practice_id) -matrix table = r(table) -local full_overall_b: display %4.2f table[1,2] -local full_overall_ll: display %4.2f table[5,2] -local full_overall_ul: display %4.2f table[6,2] - -file write tablecontent %4.2f (`full_overall_b') (" (") %4.2f (`full_overall_ll') ("-") %4.2f (`full_overall_ul') (")") _tab %4.2f (`full_overall_b') _tab %4.2f (`full_overall_ll') _tab (`full_overall_ul') _n - -local period "29 89 179 max" - -local lab29 "0-29 days" -local lab89 "30-89 days" -local lab179 "90-179 days" -local labmax "180+ days" - -foreach x of local period { -file write tablecontent ("`lab`x''") _tab -stset exit_date`x'_death, fail(death_date`x') origin(index_date`x'_death) id(unique) scale(365.25) -drop age1 age2 age3 -mkspline age = age if _st==1&sex!=.ðnicity!=.&imd!=.&urban!=.®ion!=.&bmi!=.&smoking!=., cubic nknots(4) -bysort case: egen total_follow_up`x' = total(_t) -qui su total_follow_up`x' if case==1 -local cases_py = r(mean) -local cases_multip = 100000 / r(mean) -qui su total_follow_up`x' if case==0 -local controls_multip = 100000 / r(mean) -qui safecount if case==1 & _d==1 & _st==1 -local cases_events = round(r(N),5) -local cases_rate : di %3.2f (`cases_events' * `cases_multip') -local cases_ef = exp(1.96/(sqrt(`cases_events'))) -local cases_ul = `cases_rate' * `cases_ef' -local cases_ll = `cases_rate' / `cases_ef' -qui safecount if case==0 & _d==1 & _st==1 -local controls_events = round(r(N),5) -local controls_rate : di %3.2f (`controls_events' * `controls_multip') -local controls_ef = exp(1.96/(sqrt(`controls_events'))) -local controls_ul = `controls_rate' * `controls_ef' -local controls_ll = `controls_rate' / `controls_ef' -file write tablecontent ("`cases_rate'") (" (") %3.2f (`cases_ll') ("-") %3.2f (`cases_ul') (")") _tab ("`cases_rate'") _tab - -qui stcox i.case i.sex i.ethnicity i.imd i.urban i.stp i.bmi i.smoking i.ckd_stage i.aki_baseline i.cardiovascular i.diabetes i.hypertension i.immunosuppressed i.non_haem_cancer i.gp_consults i.admissions i.month age1 age2 age3, vce(cluster practice_id) -matrix table = r(table) -local full_overall_b: display %4.2f table[1,2] -local full_overall_ll: display %4.2f table[5,2] -local full_overall_ul: display %4.2f table[6,2] - -file write tablecontent %4.2f (`full_overall_b') (" (") %4.2f (`full_overall_ll') ("-") %4.2f (`full_overall_ul') (")") _tab %4.2f (`full_overall_b') _tab %4.2f (`full_overall_ll') _tab (`full_overall_ul') _n -} -file write tablecontent _n - -file write tablecontent ("By COVID-19 wave") _n - -use ./output/analysis_hospitalised.dta, clear - -local wave1: label wave 1 -local wave2: label wave 2 -local wave3: label wave 3 -local wave4: label wave 4 - -stset exit_date_death, fail(death_date) origin(index_date_death) id(unique) scale(365.25) -drop age1 age2 age3 -mkspline age = age if _st==1&sex!=.ðnicity!=.&imd!=.&urban!=.®ion!=.&bmi!=.&smoking!=., cubic nknots(4) -qui stcox i.wave i.sex i.ethnicity i.imd i.urban i.stp i.bmi i.smoking i.ckd_stage i.aki_baseline i.cardiovascular i.diabetes i.hypertension i.immunosuppressed i.non_haem_cancer i.gp_consults i.admissions i.month age1 age2 age3, vce(cluster practice_id) -matrix table = r(table) -local full_wave_1b: display %4.2f table[1,2] -local full_wave_1ll: display %4.2f table[5,2] -local full_wave_1ul: display %4.2f table[6,2] -local full_wave_2b: display %4.2f table[1,3] -local full_wave_2ll: display %4.2f table[5,3] -local full_wave_2ul: display %4.2f table[6,3] -local full_wave_3b: display %4.2f table[1,4] -local full_wave_3ll: display %4.2f table[5,4] -local full_wave_3ul: display %4.2f table[6,4] -local full_wave_4b: display %4.2f table[1,5] -local full_wave_4ll: display %4.2f table[5,5] -local full_wave_4ul: display %4.2f table[6,5] - -bysort wave: egen total_follow_up = total(_t) -forvalues i=1/4 { -qui su total_follow_up if wave==`i' -local cases`i'_py = r(mean) -local cases`i'_multip = 100000 / r(mean) -qui safecount if wave==`i' & _d==1 & _st==1 -local cases`i'_events = round(r(N),5) -local cases`i'_rate : di %3.2f (`cases`i'_events' * `cases`i'_multip') -local cases`i'_ef = exp(1.96/(sqrt(`cases`i'_events'))) -local cases`i'_ul = `cases`i'_rate' * `cases`i'_ef' -local cases`i'_ll = `cases`i'_rate' / `cases`i'_ef' -} - -foreach x of local period { -stset exit_date`x'_death, fail(death_date`x') origin(index_date`x'_death) id(unique) scale(365.25) -drop age1 age2 age3 -mkspline age = age if _st==1&sex!=.ðnicity!=.&imd!=.&urban!=.®ion!=.&bmi!=.&smoking!=., cubic nknots(4) -qui stcox i.wave i.sex i.ethnicity i.imd i.urban i.stp i.bmi i.smoking i.ckd_stage i.aki_baseline i.cardiovascular i.diabetes i.hypertension i.immunosuppressed i.non_haem_cancer i.gp_consults i.admissions i.month age1 age2 age3, vce(cluster practice_id) -matrix table = r(table) -local full_wave_1b`x': display %4.2f table[1,2] -local full_wave_1ll`x': display %4.2f table[5,2] -local full_wave_1ul`x': display %4.2f table[6,2] -local full_wave_2b`x': display %4.2f table[1,3] -local full_wave_2ll`x': display %4.2f table[5,3] -local full_wave_2ul`x': display %4.2f table[6,3] -local full_wave_3b`x': display %4.2f table[1,4] -local full_wave_3ll`x': display %4.2f table[5,4] -local full_wave_3ul`x': display %4.2f table[6,4] -local full_wave_4b`x': display %4.2f table[1,5] -local full_wave_4ll`x': display %4.2f table[5,5] -local full_wave_4ul`x': display %4.2f table[6,5] - -bysort wave: egen total_follow_up`x' = total(_t) -forvalues i=1/4 { -qui su total_follow_up`x' if wave==`i' -local cases`i'_py = r(mean) -local cases`i'_multip = 100000 / r(mean) -qui safecount if wave==`i' & _d==1 & _st==1 -local cases`i'_events = round(r(N),5) -local cases`i'_rate`x' : di %3.2f (`cases`i'_events' * `cases`i'_multip') -local cases`i'_ef = exp(1.96/(sqrt(`cases`i'_events'))) -local cases`i'_ul`x' = `cases`i'_rate`x'' * `cases`i'_ef' -local cases`i'_ll`x' = `cases`i'_rate`x'' / `cases`i'_ef' -} -} - -forvalues i=1/4 { -file write tablecontent ("`wave`i''") _n -file write tablecontent ("Overall") _tab ("`cases`i'_rate'") (" (") %3.2f (`cases`i'_ll') ("-") %3.2f (`cases`i'_ul') (")") _tab ("`cases`i'_rate'") _tab %4.2f (`full_wave_`i'b') (" (") %4.2f (`full_wave_`i'll') ("-") %4.2f (`full_wave_`i'ul') (")") _tab %4.2f (`full_wave_`i'b') _tab %4.2f (`full_wave_`i'll') _tab (`full_wave_`i'ul') _n -foreach x of local period { -file write tablecontent ("`lab`x''") _tab ("`cases`i'_rate`x''") (" (") %3.2f (`cases`i'_ll`x'') ("-") %3.2f (`cases`i'_ul`x'') (")") _tab ("`cases`i'_rate`x''") _tab %4.2f (`full_wave_`i'b`x'') (" (") %4.2f (`full_wave_`i'll`x'') ("-") %4.2f (`full_wave_`i'ul`x'') (")") _tab %4.2f (`full_wave_`i'b`x'') _tab %4.2f (`full_wave_`i'll`x'') _tab %4.2f (`full_wave_`i'ul`x'') _n -} -} -file write tablecontent _n - -file write tablecontent ("By COVID-19 vaccination status") _n - -use ./output/analysis_hospitalised.dta, clear - -local vax1: label covid_vax 1 -local vax2: label covid_vax 2 -local vax3: label covid_vax 3 -local vax4: label covid_vax 4 -local vax5: label covid_vax 5 - -stset exit_date_death, fail(death_date) origin(index_date_death) id(unique) scale(365.25) -drop age1 age2 age3 -mkspline age = age if _st==1&sex!=.ðnicity!=.&imd!=.&urban!=.®ion!=.&bmi!=.&smoking!=., cubic nknots(4) -qui stcox i.covid_vax i.sex i.ethnicity i.imd i.urban i.stp i.bmi i.smoking i.ckd_stage i.aki_baseline i.cardiovascular i.diabetes i.hypertension i.immunosuppressed i.non_haem_cancer i.gp_consults i.admissions i.month age1 age2 age3, vce(cluster practice_id) -matrix table = r(table) -local full_vax_1b: display %4.2f table[1,2] -local full_vax_1ll: display %4.2f table[5,2] -local full_vax_1ul: display %4.2f table[6,2] -local full_vax_2b: display %4.2f table[1,3] -local full_vax_2ll: display %4.2f table[5,3] -local full_vax_2ul: display %4.2f table[6,3] -local full_vax_3b: display %4.2f table[1,4] -local full_vax_3ll: display %4.2f table[5,4] -local full_vax_3ul: display %4.2f table[6,4] -local full_vax_4b: display %4.2f table[1,5] -local full_vax_4ll: display %4.2f table[5,5] -local full_vax_4ul: display %4.2f table[6,5] -local full_vax_5b: display %4.2f table[1,6] -local full_vax_5ll: display %4.2f table[5,6] -local full_vax_5ul: display %4.2f table[6,6] - -bysort covid_vax: egen total_follow_up = total(_t) -forvalues i=1/5 { -qui su total_follow_up if covid_vax==`i' -local cases`i'_py = r(mean) -local cases`i'_multip = 100000 / r(mean) -qui safecount if covid_vax==`i' & _d==1 & _st==1 -local cases`i'_events = round(r(N),5) -local cases`i'_rate : di %3.2f (`cases`i'_events' * `cases`i'_multip') -local cases`i'_ef = exp(1.96/(sqrt(`cases`i'_events'))) -local cases`i'_ul = `cases`i'_rate' * `cases`i'_ef' -local cases`i'_ll = `cases`i'_rate' / `cases`i'_ef' -} - -foreach x of local period { -stset exit_date`x'_death, fail(death_date`x') origin(index_date`x'_death) id(unique) scale(365.25) -drop age1 age2 age3 -mkspline age = age if _st==1&sex!=.ðnicity!=.&imd!=.&urban!=.®ion!=.&bmi!=.&smoking!=., cubic nknots(4) -qui stcox i.covid_vax i.sex i.ethnicity i.imd i.urban i.stp i.bmi i.smoking i.ckd_stage i.aki_baseline i.cardiovascular i.diabetes i.hypertension i.immunosuppressed i.non_haem_cancer i.gp_consults i.admissions i.month age1 age2 age3, vce(cluster practice_id) -matrix table = r(table) -local full_vax_1b`x': display %4.2f table[1,2] -local full_vax_1ll`x': display %4.2f table[5,2] -local full_vax_1ul`x': display %4.2f table[6,2] -local full_vax_2b`x': display %4.2f table[1,3] -local full_vax_2ll`x': display %4.2f table[5,3] -local full_vax_2ul`x': display %4.2f table[6,3] -local full_vax_3b`x': display %4.2f table[1,4] -local full_vax_3ll`x': display %4.2f table[5,4] -local full_vax_3ul`x': display %4.2f table[6,4] -local full_vax_4b`x': display %4.2f table[1,5] -local full_vax_4ll`x': display %4.2f table[5,5] -local full_vax_4ul`x': display %4.2f table[6,5] -local full_vax_5b`x': display %4.2f table[1,6] -local full_vax_5ll`x': display %4.2f table[5,6] -local full_vax_5ul`x': display %4.2f table[6,6] - -bysort covid_vax: egen total_follow_up`x' = total(_t) -forvalues i=1/5 { -qui su total_follow_up`x' if covid_vax==`i' -local cases`i'_py = r(mean) -local cases`i'_multip = 100000 / r(mean) -qui safecount if covid_vax==`i' & _d==1 & _st==1 -local cases`i'_events = round(r(N),5) -local cases`i'_rate`x' : di %3.2f (`cases`i'_events' * `cases`i'_multip') -local cases`i'_ef = exp(1.96/(sqrt(`cases`i'_events'))) -local cases`i'_ul`x' = `cases`i'_rate`x'' * `cases`i'_ef' -local cases`i'_ll`x' = `cases`i'_rate`x'' / `cases`i'_ef' -} -} - -forvalues i=1/5 { -file write tablecontent ("`vax`i''") _n -file write tablecontent ("Overall") _tab ("`cases`i'_rate'") (" (") %3.2f (`cases`i'_ll') ("-") %3.2f (`cases`i'_ul') (")") _tab ("`cases`i'_rate'") _tab %4.2f (`full_vax_`i'b') (" (") %4.2f (`full_vax_`i'll') ("-") %4.2f (`full_vax_`i'ul') (")") _tab %4.2f (`full_vax_`i'b') _tab %4.2f (`full_vax_`i'll') _tab (`full_vax_`i'ul') _n -foreach x of local period { -file write tablecontent ("`lab`x''") _tab ("`cases`i'_rate`x''") (" (") %3.2f (`cases`i'_ll`x'') ("-") %3.2f (`cases`i'_ul`x'') (")") _tab ("`cases`i'_rate`x''") _tab %4.2f (`full_vax_`i'b`x'') (" (") %4.2f (`full_vax_`i'll`x'') ("-") %4.2f (`full_vax_`i'ul`x'') (")") _tab %4.2f (`full_vax_`i'b`x'') _tab %4.2f (`full_vax_`i'll`x'') _tab %4.2f (`full_vax_`i'ul`x'') _n -} -} -file close tablecontent \ No newline at end of file diff --git a/analysis/cox_forest_hospitalised_egfr_half.do b/analysis/cox_forest_hospitalised_egfr_half.do deleted file mode 100644 index df261a4..0000000 --- a/analysis/cox_forest_hospitalised_egfr_half.do +++ /dev/null @@ -1,254 +0,0 @@ -sysdir set PLUS ./analysis/adofiles -sysdir set PERSONAL ./analysis/adofiles -pwd -cap log close -macro drop hr -log using ./logs/cox_forest_hospitalised_egfr_half.log, replace t - -cap file close tablecontent -file open tablecontent using ./output/cox_forest_hospitalised_egfr_half.csv, write text replace -file write tablecontent _tab ("Rate (/100000 person years) (95% CI)") _tab ("rate") _tab ("Fully-adjusted HR (95% CI)") _tab ("hr") _tab ("ll") _tab ("ul") _n -file write tablecontent ("Hospitalised COVID-19 overall") _n -file write tablecontent ("Overall") _tab -use ./output/analysis_hospitalised.dta, clear -*50% reduction in eGFR outcome -drop if baseline_egfr==. - -stset exit_date_egfr_half, fail(egfr_half_date) origin(index_date_egfr_half) id(unique) scale(365.25) -drop age1 age2 age3 -mkspline age = age if _st==1&sex!=.ðnicity!=.&imd!=.&urban!=.®ion!=.&bmi!=.&smoking!=., cubic nknots(4) -bysort case: egen total_follow_up = total(_t) -qui su total_follow_up if case==1 -local cases_py = r(mean) -local cases_multip = 100000 / r(mean) -qui su total_follow_up if case==0 -local controls_multip = 100000 / r(mean) -qui safecount if case==1 & _d==1 & _st==1 -local cases_events = round(r(N),5) -local cases_rate : di %3.2f (`cases_events' * `cases_multip') -local cases_ef = exp(1.96/(sqrt(`cases_events'))) -local cases_ul = `cases_rate' * `cases_ef' -local cases_ll = `cases_rate' / `cases_ef' -drop total_follow_up -file write tablecontent ("`cases_rate'") (" (") %3.2f (`cases_ll') ("-") %3.2f (`cases_ul') (")") _tab ("`cases_rate'") _tab -qui stcox i.case i.sex i.ethnicity i.imd i.urban i.stp i.bmi i.smoking i.ckd_stage i.aki_baseline i.cardiovascular i.diabetes i.hypertension i.immunosuppressed i.non_haem_cancer i.gp_consults i.admissions i.month age1 age2 age3, vce(cluster practice_id) -matrix table = r(table) -local full_overall_b: display %4.2f table[1,2] -local full_overall_ll: display %4.2f table[5,2] -local full_overall_ul: display %4.2f table[6,2] - -file write tablecontent %4.2f (`full_overall_b') (" (") %4.2f (`full_overall_ll') ("-") %4.2f (`full_overall_ul') (")") _tab %4.2f (`full_overall_b') _tab %4.2f (`full_overall_ll') _tab (`full_overall_ul') _n - -local period "29 89 179 max" - -local lab29 "0-29 days" -local lab89 "30-89 days" -local lab179 "90-179 days" -local labmax "180+ days" - -foreach x of local period { -file write tablecontent ("`lab`x''") _tab -stset exit_date`x'_egfr_half, fail(egfr_half_date`x') origin(index_date`x'_egfr_half) id(unique) scale(365.25) -drop age1 age2 age3 -mkspline age = age if _st==1&sex!=.ðnicity!=.&imd!=.&urban!=.®ion!=.&bmi!=.&smoking!=., cubic nknots(4) -bysort case: egen total_follow_up`x' = total(_t) -qui su total_follow_up`x' if case==1 -local cases_py = r(mean) -local cases_multip = 100000 / r(mean) -qui su total_follow_up`x' if case==0 -local controls_multip = 100000 / r(mean) -qui safecount if case==1 & _d==1 & _st==1 -local cases_events = round(r(N),5) -local cases_rate : di %3.2f (`cases_events' * `cases_multip') -local cases_ef = exp(1.96/(sqrt(`cases_events'))) -local cases_ul = `cases_rate' * `cases_ef' -local cases_ll = `cases_rate' / `cases_ef' -qui safecount if case==0 & _d==1 & _st==1 -local controls_events = round(r(N),5) -local controls_rate : di %3.2f (`controls_events' * `controls_multip') -local controls_ef = exp(1.96/(sqrt(`controls_events'))) -local controls_ul = `controls_rate' * `controls_ef' -local controls_ll = `controls_rate' / `controls_ef' -drop total_follow_up`x' -file write tablecontent ("`cases_rate'") (" (") %3.2f (`cases_ll') ("-") %3.2f (`cases_ul') (")") _tab ("`cases_rate'") _tab - -qui stcox i.case i.sex i.ethnicity i.imd i.urban i.stp i.bmi i.smoking i.ckd_stage i.aki_baseline i.cardiovascular i.diabetes i.hypertension i.immunosuppressed i.non_haem_cancer i.gp_consults i.admissions i.month age1 age2 age3, vce(cluster practice_id) -matrix table = r(table) -local full_overall_b: display %4.2f table[1,2] -local full_overall_ll: display %4.2f table[5,2] -local full_overall_ul: display %4.2f table[6,2] - -file write tablecontent %4.2f (`full_overall_b') (" (") %4.2f (`full_overall_ll') ("-") %4.2f (`full_overall_ul') (")") _tab %4.2f (`full_overall_b') _tab %4.2f (`full_overall_ll') _tab (`full_overall_ul') _n -} -file write tablecontent _n - -file write tablecontent ("By COVID-19 wave") _n - -local wave1: label wave 1 -local wave2: label wave 2 -local wave3: label wave 3 -local wave4: label wave 4 - -stset exit_date_egfr_half, fail(egfr_half_date) origin(index_date_egfr_half) id(unique) scale(365.25) -drop age1 age2 age3 -mkspline age = age if _st==1&sex!=.ðnicity!=.&imd!=.&urban!=.®ion!=.&bmi!=.&smoking!=., cubic nknots(4) -qui stcox i.wave i.sex i.ethnicity i.imd i.urban i.stp i.bmi i.smoking i.ckd_stage i.aki_baseline i.cardiovascular i.diabetes i.hypertension i.immunosuppressed i.non_haem_cancer i.gp_consults i.admissions i.month age1 age2 age3, vce(cluster practice_id) -matrix table = r(table) -local full_wave_1b: display %4.2f table[1,2] -local full_wave_1ll: display %4.2f table[5,2] -local full_wave_1ul: display %4.2f table[6,2] -local full_wave_2b: display %4.2f table[1,3] -local full_wave_2ll: display %4.2f table[5,3] -local full_wave_2ul: display %4.2f table[6,3] -local full_wave_3b: display %4.2f table[1,4] -local full_wave_3ll: display %4.2f table[5,4] -local full_wave_3ul: display %4.2f table[6,4] -local full_wave_4b: display %4.2f table[1,5] -local full_wave_4ll: display %4.2f table[5,5] -local full_wave_4ul: display %4.2f table[6,5] - -bysort wave: egen total_follow_up = total(_t) -forvalues i=1/4 { -qui su total_follow_up if wave==`i' -local cases`i'_py = r(mean) -local cases`i'_multip = 100000 / r(mean) -qui safecount if wave==`i' & _d==1 & _st==1 -local cases`i'_events = round(r(N),5) -local cases`i'_rate : di %3.2f (`cases`i'_events' * `cases`i'_multip') -local cases`i'_ef = exp(1.96/(sqrt(`cases`i'_events'))) -local cases`i'_ul = `cases`i'_rate' * `cases`i'_ef' -local cases`i'_ll = `cases`i'_rate' / `cases`i'_ef' -} -drop total_follow_up - -foreach x of local period { -stset exit_date`x'_egfr_half, fail(egfr_half_date`x') origin(index_date`x'_egfr_half) id(unique) scale(365.25) -drop age1 age2 age3 -mkspline age = age if _st==1&sex!=.ðnicity!=.&imd!=.&urban!=.®ion!=.&bmi!=.&smoking!=., cubic nknots(4) -qui stcox i.wave i.sex i.ethnicity i.imd i.urban i.stp i.bmi i.smoking i.ckd_stage i.aki_baseline i.cardiovascular i.diabetes i.hypertension i.immunosuppressed i.non_haem_cancer i.gp_consults i.admissions i.month age1 age2 age3, vce(cluster practice_id) -matrix table = r(table) -local full_wave_1b`x': display %4.2f table[1,2] -local full_wave_1ll`x': display %4.2f table[5,2] -local full_wave_1ul`x': display %4.2f table[6,2] -local full_wave_2b`x': display %4.2f table[1,3] -local full_wave_2ll`x': display %4.2f table[5,3] -local full_wave_2ul`x': display %4.2f table[6,3] -local full_wave_3b`x': display %4.2f table[1,4] -local full_wave_3ll`x': display %4.2f table[5,4] -local full_wave_3ul`x': display %4.2f table[6,4] -local full_wave_4b`x': display %4.2f table[1,5] -local full_wave_4ll`x': display %4.2f table[5,5] -local full_wave_4ul`x': display %4.2f table[6,5] - -bysort wave: egen total_follow_up`x' = total(_t) -forvalues i=1/4 { -qui su total_follow_up`x' if wave==`i' -local cases`i'_py = r(mean) -local cases`i'_multip = 100000 / r(mean) -qui safecount if wave==`i' & _d==1 & _st==1 -local cases`i'_events = round(r(N),5) -local cases`i'_rate`x' : di %3.2f (`cases`i'_events' * `cases`i'_multip') -local cases`i'_ef = exp(1.96/(sqrt(`cases`i'_events'))) -local cases`i'_ul`x' = `cases`i'_rate`x'' * `cases`i'_ef' -local cases`i'_ll`x' = `cases`i'_rate`x'' / `cases`i'_ef' -} -drop total_follow_up`x' -} - -forvalues i=1/4 { -file write tablecontent ("`wave`i''") _n -file write tablecontent ("Overall") _tab ("`cases`i'_rate'") (" (") %3.2f (`cases`i'_ll') ("-") %3.2f (`cases`i'_ul') (")") _tab ("`cases`i'_rate'") _tab %4.2f (`full_wave_`i'b') (" (") %4.2f (`full_wave_`i'll') ("-") %4.2f (`full_wave_`i'ul') (")") _tab %4.2f (`full_wave_`i'b') _tab %4.2f (`full_wave_`i'll') _tab (`full_wave_`i'ul') _n -foreach x of local period { -file write tablecontent ("`lab`x''") _tab ("`cases`i'_rate`x''") (" (") %3.2f (`cases`i'_ll`x'') ("-") %3.2f (`cases`i'_ul`x'') (")") _tab ("`cases`i'_rate`x''") _tab %4.2f (`full_wave_`i'b`x'') (" (") %4.2f (`full_wave_`i'll`x'') ("-") %4.2f (`full_wave_`i'ul`x'') (")") _tab %4.2f (`full_wave_`i'b`x'') _tab %4.2f (`full_wave_`i'll`x'') _tab %4.2f (`full_wave_`i'ul`x'') _n -} -} -file write tablecontent _n - -file write tablecontent ("By COVID-19 vaccination status") _n - -local vax1: label covid_vax 1 -local vax2: label covid_vax 2 -local vax3: label covid_vax 3 -local vax4: label covid_vax 4 -local vax5: label covid_vax 5 - -stset exit_date_egfr_half, fail(egfr_half_date) origin(index_date_egfr_half) id(unique) scale(365.25) -drop age1 age2 age3 -mkspline age = age if _st==1&sex!=.ðnicity!=.&imd!=.&urban!=.®ion!=.&bmi!=.&smoking!=., cubic nknots(4) -qui stcox i.covid_vax i.sex i.ethnicity i.imd i.urban i.stp i.bmi i.smoking i.ckd_stage i.aki_baseline i.cardiovascular i.diabetes i.hypertension i.immunosuppressed i.non_haem_cancer i.gp_consults i.admissions i.month age1 age2 age3, vce(cluster practice_id) -matrix table = r(table) -local full_vax_1b: display %4.2f table[1,2] -local full_vax_1ll: display %4.2f table[5,2] -local full_vax_1ul: display %4.2f table[6,2] -local full_vax_2b: display %4.2f table[1,3] -local full_vax_2ll: display %4.2f table[5,3] -local full_vax_2ul: display %4.2f table[6,3] -local full_vax_3b: display %4.2f table[1,4] -local full_vax_3ll: display %4.2f table[5,4] -local full_vax_3ul: display %4.2f table[6,4] -local full_vax_4b: display %4.2f table[1,5] -local full_vax_4ll: display %4.2f table[5,5] -local full_vax_4ul: display %4.2f table[6,5] -local full_vax_5b: display %4.2f table[1,6] -local full_vax_5ll: display %4.2f table[5,6] -local full_vax_5ul: display %4.2f table[6,6] - -bysort covid_vax: egen total_follow_up = total(_t) -forvalues i=1/5 { -qui su total_follow_up if covid_vax==`i' -local cases`i'_py = r(mean) -local cases`i'_multip = 100000 / r(mean) -qui safecount if covid_vax==`i' & _d==1 & _st==1 -local cases`i'_events = round(r(N),5) -local cases`i'_rate : di %3.2f (`cases`i'_events' * `cases`i'_multip') -local cases`i'_ef = exp(1.96/(sqrt(`cases`i'_events'))) -local cases`i'_ul = `cases`i'_rate' * `cases`i'_ef' -local cases`i'_ll = `cases`i'_rate' / `cases`i'_ef' -} -drop total_follow_up - -foreach x of local period { -stset exit_date`x'_egfr_half, fail(egfr_half_date`x') origin(index_date`x'_egfr_half) id(unique) scale(365.25) -drop age1 age2 age3 -mkspline age = age if _st==1&sex!=.ðnicity!=.&imd!=.&urban!=.®ion!=.&bmi!=.&smoking!=., cubic nknots(4) -qui stcox i.covid_vax i.sex i.ethnicity i.imd i.urban i.stp i.bmi i.smoking i.ckd_stage i.aki_baseline i.cardiovascular i.diabetes i.hypertension i.immunosuppressed i.non_haem_cancer i.gp_consults i.admissions i.month age1 age2 age3, vce(cluster practice_id) -matrix table = r(table) -local full_vax_1b`x': display %4.2f table[1,2] -local full_vax_1ll`x': display %4.2f table[5,2] -local full_vax_1ul`x': display %4.2f table[6,2] -local full_vax_2b`x': display %4.2f table[1,3] -local full_vax_2ll`x': display %4.2f table[5,3] -local full_vax_2ul`x': display %4.2f table[6,3] -local full_vax_3b`x': display %4.2f table[1,4] -local full_vax_3ll`x': display %4.2f table[5,4] -local full_vax_3ul`x': display %4.2f table[6,4] -local full_vax_4b`x': display %4.2f table[1,5] -local full_vax_4ll`x': display %4.2f table[5,5] -local full_vax_4ul`x': display %4.2f table[6,5] -local full_vax_5b`x': display %4.2f table[1,6] -local full_vax_5ll`x': display %4.2f table[5,6] -local full_vax_5ul`x': display %4.2f table[6,6] - -bysort covid_vax: egen total_follow_up`x' = total(_t) -forvalues i=1/5 { -qui su total_follow_up`x' if covid_vax==`i' -local cases`i'_py = r(mean) -local cases`i'_multip = 100000 / r(mean) -qui safecount if covid_vax==`i' & _d==1 & _st==1 -local cases`i'_events = round(r(N),5) -local cases`i'_rate`x' : di %3.2f (`cases`i'_events' * `cases`i'_multip') -local cases`i'_ef = exp(1.96/(sqrt(`cases`i'_events'))) -local cases`i'_ul`x' = `cases`i'_rate`x'' * `cases`i'_ef' -local cases`i'_ll`x' = `cases`i'_rate`x'' / `cases`i'_ef' -} -drop total_follow_up`x' -} - -forvalues i=1/5 { -file write tablecontent ("`vax`i''") _n -file write tablecontent ("Overall") _tab ("`cases`i'_rate'") (" (") %3.2f (`cases`i'_ll') ("-") %3.2f (`cases`i'_ul') (")") _tab ("`cases`i'_rate'") _tab %4.2f (`full_vax_`i'b') (" (") %4.2f (`full_vax_`i'll') ("-") %4.2f (`full_vax_`i'ul') (")") _tab %4.2f (`full_vax_`i'b') _tab %4.2f (`full_vax_`i'll') _tab (`full_vax_`i'ul') _n -foreach x of local period { -file write tablecontent ("`lab`x''") _tab ("`cases`i'_rate`x''") (" (") %3.2f (`cases`i'_ll`x'') ("-") %3.2f (`cases`i'_ul`x'') (")") _tab ("`cases`i'_rate`x''") _tab %4.2f (`full_vax_`i'b`x'') (" (") %4.2f (`full_vax_`i'll`x'') ("-") %4.2f (`full_vax_`i'ul`x'') (")") _tab %4.2f (`full_vax_`i'b`x'') _tab %4.2f (`full_vax_`i'll`x'') _tab %4.2f (`full_vax_`i'ul`x'') _n -} -} -file close tablecontent \ No newline at end of file diff --git a/analysis/cox_forest_hospitalised_esrd.do b/analysis/cox_forest_hospitalised_esrd.do deleted file mode 100644 index 9b112a2..0000000 --- a/analysis/cox_forest_hospitalised_esrd.do +++ /dev/null @@ -1,249 +0,0 @@ -sysdir set PLUS ./analysis/adofiles -sysdir set PERSONAL ./analysis/adofiles -pwd -cap log close -macro drop hr -log using ./logs/cox_forest_hospitalised_esrd.log, replace t - -cap file close tablecontent -file open tablecontent using ./output/cox_forest_hospitalised_esrd.csv, write text replace -file write tablecontent _tab ("Rate (/100000 person years) (95% CI)") _tab ("rate") _tab ("Fully-adjusted HR (95% CI)") _tab ("hr") _tab ("ll") _tab ("ul") _n -file write tablecontent ("Hospitalised COVID-19 overall") _n -file write tablecontent ("Overall") _tab -use ./output/analysis_hospitalised.dta, clear -stset exit_date_esrd, fail(esrd_date) origin(index_date_esrd) id(unique) scale(365.25) -drop age1 age2 age3 -mkspline age = age if _st==1&sex!=.ðnicity!=.&imd!=.&urban!=.®ion!=.&bmi!=.&smoking!=., cubic nknots(4) -bysort case: egen total_follow_up = total(_t) -qui su total_follow_up if case==1 -local cases_py = r(mean) -local cases_multip = 100000 / r(mean) -qui su total_follow_up if case==0 -local controls_multip = 100000 / r(mean) -qui safecount if case==1 & _d==1 & _st==1 -local cases_events = round(r(N),5) -local cases_rate : di %3.2f (`cases_events' * `cases_multip') -local cases_ef = exp(1.96/(sqrt(`cases_events'))) -local cases_ul = `cases_rate' * `cases_ef' -local cases_ll = `cases_rate' / `cases_ef' -file write tablecontent ("`cases_rate'") (" (") %3.2f (`cases_ll') ("-") %3.2f (`cases_ul') (")") _tab ("`cases_rate'") _tab -qui stcox i.case i.sex i.ethnicity i.imd i.urban i.stp i.bmi i.smoking i.ckd_stage i.aki_baseline i.cardiovascular i.diabetes i.hypertension i.immunosuppressed i.non_haem_cancer i.gp_consults i.admissions i.month age1 age2 age3, vce(cluster practice_id) -matrix table = r(table) -local full_overall_b: display %4.2f table[1,2] -local full_overall_ll: display %4.2f table[5,2] -local full_overall_ul: display %4.2f table[6,2] - -file write tablecontent %4.2f (`full_overall_b') (" (") %4.2f (`full_overall_ll') ("-") %4.2f (`full_overall_ul') (")") _tab %4.2f (`full_overall_b') _tab %4.2f (`full_overall_ll') _tab (`full_overall_ul') _n - -local period "29 89 179 max" - -local lab29 "0-29 days" -local lab89 "30-89 days" -local lab179 "90-179 days" -local labmax "180+ days" - -foreach x of local period { -file write tablecontent ("`lab`x''") _tab -stset exit_date`x'_esrd, fail(esrd_date`x') origin(index_date`x'_esrd) id(unique) scale(365.25) -drop age1 age2 age3 -mkspline age = age if _st==1&sex!=.ðnicity!=.&imd!=.&urban!=.®ion!=.&bmi!=.&smoking!=., cubic nknots(4) -bysort case: egen total_follow_up`x' = total(_t) -qui su total_follow_up`x' if case==1 -local cases_py = r(mean) -local cases_multip = 100000 / r(mean) -qui su total_follow_up`x' if case==0 -local controls_multip = 100000 / r(mean) -qui safecount if case==1 & _d==1 & _st==1 -local cases_events = round(r(N),5) -local cases_rate : di %3.2f (`cases_events' * `cases_multip') -local cases_ef = exp(1.96/(sqrt(`cases_events'))) -local cases_ul = `cases_rate' * `cases_ef' -local cases_ll = `cases_rate' / `cases_ef' -qui safecount if case==0 & _d==1 & _st==1 -local controls_events = round(r(N),5) -local controls_rate : di %3.2f (`controls_events' * `controls_multip') -local controls_ef = exp(1.96/(sqrt(`controls_events'))) -local controls_ul = `controls_rate' * `controls_ef' -local controls_ll = `controls_rate' / `controls_ef' -file write tablecontent ("`cases_rate'") (" (") %3.2f (`cases_ll') ("-") %3.2f (`cases_ul') (")") _tab ("`cases_rate'") _tab - -qui stcox i.case i.sex i.ethnicity i.imd i.urban i.stp i.bmi i.smoking i.ckd_stage i.aki_baseline i.cardiovascular i.diabetes i.hypertension i.immunosuppressed i.non_haem_cancer i.gp_consults i.admissions i.month age1 age2 age3, vce(cluster practice_id) -matrix table = r(table) -local full_overall_b: display %4.2f table[1,2] -local full_overall_ll: display %4.2f table[5,2] -local full_overall_ul: display %4.2f table[6,2] - -file write tablecontent %4.2f (`full_overall_b') (" (") %4.2f (`full_overall_ll') ("-") %4.2f (`full_overall_ul') (")") _tab %4.2f (`full_overall_b') _tab %4.2f (`full_overall_ll') _tab (`full_overall_ul') _n -} -file write tablecontent _n - -file write tablecontent ("By COVID-19 wave") _n - -use ./output/analysis_hospitalised.dta, clear - -local wave1: label wave 1 -local wave2: label wave 2 -local wave3: label wave 3 -local wave4: label wave 4 - -stset exit_date_esrd, fail(esrd_date) origin(index_date_esrd) id(unique) scale(365.25) -drop age1 age2 age3 -mkspline age = age if _st==1&sex!=.ðnicity!=.&imd!=.&urban!=.®ion!=.&bmi!=.&smoking!=., cubic nknots(4) -qui stcox i.wave i.sex i.ethnicity i.imd i.urban i.stp i.bmi i.smoking i.ckd_stage i.aki_baseline i.cardiovascular i.diabetes i.hypertension i.immunosuppressed i.non_haem_cancer i.gp_consults i.admissions i.month age1 age2 age3, vce(cluster practice_id) -matrix table = r(table) -local full_wave_1b: display %4.2f table[1,2] -local full_wave_1ll: display %4.2f table[5,2] -local full_wave_1ul: display %4.2f table[6,2] -local full_wave_2b: display %4.2f table[1,3] -local full_wave_2ll: display %4.2f table[5,3] -local full_wave_2ul: display %4.2f table[6,3] -local full_wave_3b: display %4.2f table[1,4] -local full_wave_3ll: display %4.2f table[5,4] -local full_wave_3ul: display %4.2f table[6,4] -local full_wave_4b: display %4.2f table[1,5] -local full_wave_4ll: display %4.2f table[5,5] -local full_wave_4ul: display %4.2f table[6,5] - -bysort wave: egen total_follow_up = total(_t) -forvalues i=1/4 { -qui su total_follow_up if wave==`i' -local cases`i'_py = r(mean) -local cases`i'_multip = 100000 / r(mean) -qui safecount if wave==`i' & _d==1 & _st==1 -local cases`i'_events = round(r(N),5) -local cases`i'_rate : di %3.2f (`cases`i'_events' * `cases`i'_multip') -local cases`i'_ef = exp(1.96/(sqrt(`cases`i'_events'))) -local cases`i'_ul = `cases`i'_rate' * `cases`i'_ef' -local cases`i'_ll = `cases`i'_rate' / `cases`i'_ef' -} - -foreach x of local period { -stset exit_date`x'_esrd, fail(esrd_date`x') origin(index_date`x'_esrd) id(unique) scale(365.25) -drop age1 age2 age3 -mkspline age = age if _st==1&sex!=.ðnicity!=.&imd!=.&urban!=.®ion!=.&bmi!=.&smoking!=., cubic nknots(4) -qui stcox i.wave i.sex i.ethnicity i.imd i.urban i.stp i.bmi i.smoking i.ckd_stage i.aki_baseline i.cardiovascular i.diabetes i.hypertension i.immunosuppressed i.non_haem_cancer i.gp_consults i.admissions i.month age1 age2 age3, vce(cluster practice_id) -matrix table = r(table) -local full_wave_1b`x': display %4.2f table[1,2] -local full_wave_1ll`x': display %4.2f table[5,2] -local full_wave_1ul`x': display %4.2f table[6,2] -local full_wave_2b`x': display %4.2f table[1,3] -local full_wave_2ll`x': display %4.2f table[5,3] -local full_wave_2ul`x': display %4.2f table[6,3] -local full_wave_3b`x': display %4.2f table[1,4] -local full_wave_3ll`x': display %4.2f table[5,4] -local full_wave_3ul`x': display %4.2f table[6,4] -local full_wave_4b`x': display %4.2f table[1,5] -local full_wave_4ll`x': display %4.2f table[5,5] -local full_wave_4ul`x': display %4.2f table[6,5] - -bysort wave: egen total_follow_up`x' = total(_t) -forvalues i=1/4 { -qui su total_follow_up`x' if wave==`i' -local cases`i'_py = r(mean) -local cases`i'_multip = 100000 / r(mean) -qui safecount if wave==`i' & _d==1 & _st==1 -local cases`i'_events = round(r(N),5) -local cases`i'_rate`x' : di %3.2f (`cases`i'_events' * `cases`i'_multip') -local cases`i'_ef = exp(1.96/(sqrt(`cases`i'_events'))) -local cases`i'_ul`x' = `cases`i'_rate`x'' * `cases`i'_ef' -local cases`i'_ll`x' = `cases`i'_rate`x'' / `cases`i'_ef' -} -} - -forvalues i=1/4 { -file write tablecontent ("`wave`i''") _n -file write tablecontent ("Overall") _tab ("`cases`i'_rate'") (" (") %3.2f (`cases`i'_ll') ("-") %3.2f (`cases`i'_ul') (")") _tab ("`cases`i'_rate'") _tab %4.2f (`full_wave_`i'b') (" (") %4.2f (`full_wave_`i'll') ("-") %4.2f (`full_wave_`i'ul') (")") _tab %4.2f (`full_wave_`i'b') _tab %4.2f (`full_wave_`i'll') _tab (`full_wave_`i'ul') _n -foreach x of local period { -file write tablecontent ("`lab`x''") _tab ("`cases`i'_rate`x''") (" (") %3.2f (`cases`i'_ll`x'') ("-") %3.2f (`cases`i'_ul`x'') (")") _tab ("`cases`i'_rate`x''") _tab %4.2f (`full_wave_`i'b`x'') (" (") %4.2f (`full_wave_`i'll`x'') ("-") %4.2f (`full_wave_`i'ul`x'') (")") _tab %4.2f (`full_wave_`i'b`x'') _tab %4.2f (`full_wave_`i'll`x'') _tab %4.2f (`full_wave_`i'ul`x'') _n -} -} -file write tablecontent _n - -file write tablecontent ("By COVID-19 vaccination status") _n - -use ./output/analysis_hospitalised.dta, clear - -local vax1: label covid_vax 1 -local vax2: label covid_vax 2 -local vax3: label covid_vax 3 -local vax4: label covid_vax 4 -local vax5: label covid_vax 5 - -stset exit_date_esrd, fail(esrd_date) origin(index_date_esrd) id(unique) scale(365.25) -drop age1 age2 age3 -mkspline age = age if _st==1&sex!=.ðnicity!=.&imd!=.&urban!=.®ion!=.&bmi!=.&smoking!=., cubic nknots(4) -qui stcox i.covid_vax i.sex i.ethnicity i.imd i.urban i.stp i.bmi i.smoking i.ckd_stage i.aki_baseline i.cardiovascular i.diabetes i.hypertension i.immunosuppressed i.non_haem_cancer i.gp_consults i.admissions i.month age1 age2 age3, vce(cluster practice_id) -matrix table = r(table) -local full_vax_1b: display %4.2f table[1,2] -local full_vax_1ll: display %4.2f table[5,2] -local full_vax_1ul: display %4.2f table[6,2] -local full_vax_2b: display %4.2f table[1,3] -local full_vax_2ll: display %4.2f table[5,3] -local full_vax_2ul: display %4.2f table[6,3] -local full_vax_3b: display %4.2f table[1,4] -local full_vax_3ll: display %4.2f table[5,4] -local full_vax_3ul: display %4.2f table[6,4] -local full_vax_4b: display %4.2f table[1,5] -local full_vax_4ll: display %4.2f table[5,5] -local full_vax_4ul: display %4.2f table[6,5] -local full_vax_5b: display %4.2f table[1,6] -local full_vax_5ll: display %4.2f table[5,6] -local full_vax_5ul: display %4.2f table[6,6] - -bysort covid_vax: egen total_follow_up = total(_t) -forvalues i=1/5 { -qui su total_follow_up if covid_vax==`i' -local cases`i'_py = r(mean) -local cases`i'_multip = 100000 / r(mean) -qui safecount if covid_vax==`i' & _d==1 & _st==1 -local cases`i'_events = round(r(N),5) -local cases`i'_rate : di %3.2f (`cases`i'_events' * `cases`i'_multip') -local cases`i'_ef = exp(1.96/(sqrt(`cases`i'_events'))) -local cases`i'_ul = `cases`i'_rate' * `cases`i'_ef' -local cases`i'_ll = `cases`i'_rate' / `cases`i'_ef' -} - -foreach x of local period { -stset exit_date`x'_esrd, fail(esrd_date`x') origin(index_date`x'_esrd) id(unique) scale(365.25) -drop age1 age2 age3 -mkspline age = age if _st==1&sex!=.ðnicity!=.&imd!=.&urban!=.®ion!=.&bmi!=.&smoking!=., cubic nknots(4) -qui stcox i.covid_vax i.sex i.ethnicity i.imd i.urban i.stp i.bmi i.smoking i.ckd_stage i.aki_baseline i.cardiovascular i.diabetes i.hypertension i.immunosuppressed i.non_haem_cancer i.gp_consults i.admissions i.month age1 age2 age3, vce(cluster practice_id) -matrix table = r(table) -local full_vax_1b`x': display %4.2f table[1,2] -local full_vax_1ll`x': display %4.2f table[5,2] -local full_vax_1ul`x': display %4.2f table[6,2] -local full_vax_2b`x': display %4.2f table[1,3] -local full_vax_2ll`x': display %4.2f table[5,3] -local full_vax_2ul`x': display %4.2f table[6,3] -local full_vax_3b`x': display %4.2f table[1,4] -local full_vax_3ll`x': display %4.2f table[5,4] -local full_vax_3ul`x': display %4.2f table[6,4] -local full_vax_4b`x': display %4.2f table[1,5] -local full_vax_4ll`x': display %4.2f table[5,5] -local full_vax_4ul`x': display %4.2f table[6,5] -local full_vax_5b`x': display %4.2f table[1,6] -local full_vax_5ll`x': display %4.2f table[5,6] -local full_vax_5ul`x': display %4.2f table[6,6] - -bysort covid_vax: egen total_follow_up`x' = total(_t) -forvalues i=1/5 { -qui su total_follow_up`x' if covid_vax==`i' -local cases`i'_py = r(mean) -local cases`i'_multip = 100000 / r(mean) -qui safecount if covid_vax==`i' & _d==1 & _st==1 -local cases`i'_events = round(r(N),5) -local cases`i'_rate`x' : di %3.2f (`cases`i'_events' * `cases`i'_multip') -local cases`i'_ef = exp(1.96/(sqrt(`cases`i'_events'))) -local cases`i'_ul`x' = `cases`i'_rate`x'' * `cases`i'_ef' -local cases`i'_ll`x' = `cases`i'_rate`x'' / `cases`i'_ef' -} -} - -forvalues i=1/5 { -file write tablecontent ("`vax`i''") _n -file write tablecontent ("Overall") _tab ("`cases`i'_rate'") (" (") %3.2f (`cases`i'_ll') ("-") %3.2f (`cases`i'_ul') (")") _tab ("`cases`i'_rate'") _tab %4.2f (`full_vax_`i'b') (" (") %4.2f (`full_vax_`i'll') ("-") %4.2f (`full_vax_`i'ul') (")") _tab %4.2f (`full_vax_`i'b') _tab %4.2f (`full_vax_`i'll') _tab (`full_vax_`i'ul') _n -foreach x of local period { -file write tablecontent ("`lab`x''") _tab ("`cases`i'_rate`x''") (" (") %3.2f (`cases`i'_ll`x'') ("-") %3.2f (`cases`i'_ul`x'') (")") _tab ("`cases`i'_rate`x''") _tab %4.2f (`full_vax_`i'b`x'') (" (") %4.2f (`full_vax_`i'll`x'') ("-") %4.2f (`full_vax_`i'ul`x'') (")") _tab %4.2f (`full_vax_`i'b`x'') _tab %4.2f (`full_vax_`i'll`x'') _tab %4.2f (`full_vax_`i'ul`x'') _n -} -} -file close tablecontent \ No newline at end of file diff --git a/analysis/cox_forest_hospitalised_exposures_esrd.do b/analysis/cox_forest_hospitalised_exposures_esrd.do new file mode 100644 index 0000000..c807efa --- /dev/null +++ b/analysis/cox_forest_hospitalised_exposures_esrd.do @@ -0,0 +1,117 @@ +sysdir set PLUS ./analysis/adofiles +sysdir set PERSONAL ./analysis/adofiles +pwd +cap log close +macro drop hr +log using ./logs/cox_forest_hospitalised_exposures_esrd.log, replace t + +cap file close tablecontent +file open tablecontent using ./output/cox_forest_hospitalised_exposures_esrd.csv, write text replace +file write tablecontent ("stratum") _tab ("hr_text") _tab ("hr") _tab ("ll") _tab ("ul") _tab ("rate_text") _tab ("rate") _tab ("rate_ll") _tab ("rate_ul") _tab ("ard_text") _tab ("ard") _tab ("ard_ll") _tab ("ard_ul") _n +use ./output/analysis_hospitalised.dta, clear + +rename covid_vax covvax + +local wave1 "COVID-19 Feb20-Aug20" +local wave2 "COVID-19 Sep20-Jun21" +local wave3 "COVID-19 Jul21-Nov21" +local wave4 "COVID-19 Dec21-Dec22" + +local covvax1 "COVID-19 pre-vaccination" +local covvax2 "COVID-19 1 vaccination dose" +local covvax3 "COVID-19 2 vaccination doses" +local covvax4 "COVID-19 3 vaccination doses" +local covvax5 "COVID-19 4 vaccination doses" + +qui stset exit_date_esrd, fail(esrd_date) origin(index_date_esrd) id(unique) scale(365.25) +drop age1 age2 age3 +mkspline age = age if _st==1&sex!=.ðnicity!=.&imd!=.&urban!=.®ion!=.&bmi!=.&smoking!=., cubic nknots(4) + +**By COVID wave +*Rates +forvalues i=1/4 { +bysort wave: egen total_follow_up = total(_t) +qui su total_follow_up if wave==`i' +local cases`i'_multip = 100000 / r(mean) +drop total_follow_up +qui safecount if wave==`i' & _d==1 & _st==1 +local cases`i'_events = round(r(N),5) +local cases`i'wave_rate : di %3.2f (`cases`i'_events' * `cases`i'_multip') +local cases`i'_ef = exp(1.96/(sqrt(`cases`i'_events'))) +local cases`i'wave_ul = `cases`i'wave_rate' * `cases`i'_ef' +local cases`i'wave_ll = `cases`i'wave_rate' / `cases`i'_ef' +} + +*HR +qui stcox i.wave i.sex i.ethnicity i.imd i.urban i.stp i.bmi i.smoking i.ckd_stage i.aki_baseline i.cardiovascular i.diabetes i.hypertension i.immunosuppressed i.non_haem_cancer i.gp_consults i.admissions i.month age1 age2 age3, vce(cluster practice_id) +matrix table = r(table) +local full_wave_1b: display %4.2f table[1,2] +local full_wave_1ll: display %4.2f table[5,2] +local full_wave_1ul: display %4.2f table[6,2] +local full_wave_2b: display %4.2f table[1,3] +local full_wave_2ll: display %4.2f table[5,3] +local full_wave_2ul: display %4.2f table[6,3] +local full_wave_3b: display %4.2f table[1,4] +local full_wave_3ll: display %4.2f table[5,4] +local full_wave_3ul: display %4.2f table[6,4] +local full_wave_4b: display %4.2f table[1,5] +local full_wave_4ll: display %4.2f table[5,5] +local full_wave_4ul: display %4.2f table[6,5] + +*Adjusted rate difference +forvalues i=1/4 { +local ard`i'wave_b: di %3.2f `cases`i'wave_rate' - ((1/`full_wave_`i'b') * `cases`i'wave_rate') +local ard`i'wave_ll: di %3.2f `cases`i'wave_rate' - ((1/`full_wave_`i'll') * `cases`i'wave_rate') +local ard`i'wave_ul: di %3.2f `cases`i'wave_rate' - ((1/`full_wave_`i'ul') * `cases`i'wave_rate') +} + + +**By COVID vaccination status +*Rates +forvalues i=1/5 { +bysort covvax: egen total_follow_up = total(_t) +qui su total_follow_up if covvax==`i' +local cases`i'_multip = 100000 / r(mean) +drop total_follow_up +qui safecount if covvax==`i' & _d==1 & _st==1 +local cases`i'_events = round(r(N),5) +local cases`i'covvax_rate : di %3.2f (`cases`i'_events' * `cases`i'_multip') +local cases`i'_ef = exp(1.96/(sqrt(`cases`i'_events'))) +local cases`i'covvax_ul = `cases`i'covvax_rate' * `cases`i'_ef' +local cases`i'covvax_ll = `cases`i'covvax_rate' / `cases`i'_ef' +} + +*HR +qui stcox i.covvax i.sex i.ethnicity i.imd i.urban i.stp i.bmi i.smoking i.ckd_stage i.aki_baseline i.cardiovascular i.diabetes i.hypertension i.immunosuppressed i.non_haem_cancer i.gp_consults i.admissions i.month age1 age2 age3, vce(cluster practice_id) +matrix table = r(table) +local full_covvax_1b: display %4.2f table[1,2] +local full_covvax_1ll: display %4.2f table[5,2] +local full_covvax_1ul: display %4.2f table[6,2] +local full_covvax_2b: display %4.2f table[1,3] +local full_covvax_2ll: display %4.2f table[5,3] +local full_covvax_2ul: display %4.2f table[6,3] +local full_covvax_3b: display %4.2f table[1,4] +local full_covvax_3ll: display %4.2f table[5,4] +local full_covvax_3ul: display %4.2f table[6,4] +local full_covvax_4b: display %4.2f table[1,5] +local full_covvax_4ll: display %4.2f table[5,5] +local full_covvax_4ul: display %4.2f table[6,5] +local full_covvax_5b: display %4.2f table[1,6] +local full_covvax_5ll: display %4.2f table[5,6] +local full_covvax_5ul: display %4.2f table[6,6] + +*Adjusted rate difference +forvalues i=1/5 { +local ard`i'covvax_b: di %3.2f `cases`i'covvax_rate' - ((1/`full_covvax_`i'b') * `cases`i'covvax_rate') +local ard`i'covvax_ll: di %3.2f `cases`i'covvax_rate' - ((1/`full_covvax_`i'll') * `cases`i'covvax_rate') +local ard`i'covvax_ul: di %3.2f `cases`i'covvax_rate' - ((1/`full_covvax_`i'ul') * `cases`i'covvax_rate') +} + +forvalues i=1/4 { +file write tablecontent ("`wave`i''") _tab %4.2f (`full_wave_`i'b') (" (") %4.2f (`full_wave_`i'll') ("-") %4.2f (`full_wave_`i'ul') (")") _tab %4.2f (`full_wave_`i'b') _tab %4.2f (`full_wave_`i'll') _tab (`full_wave_`i'ul') _tab ("`cases`i'wave_rate'") (" (") %3.2f (`cases`i'wave_ll') ("-") %3.2f (`cases`i'wave_ul') (")") _tab ("`cases`i'wave_rate'") _tab ("`cases`i'wave_ll'") _tab ("`cases`i'wave_ul'") _tab ("`ard`i'wave_b'") (" (") %3.2f (`ard`i'wave_ll') ("-") %3.2f (`ard`i'wave_ul') (")") _tab ("`ard`i'wave_b'") _tab ("`ard`i'wave_ll'") _tab ("`ard`i'wave_ul'") _n +} +forvalues i=1/5 { +file write tablecontent ("`covvax`i''") _tab %4.2f (`full_covvax_`i'b') (" (") %4.2f (`full_covvax_`i'll') ("-") %4.2f (`full_covvax_`i'ul') (")") _tab %4.2f (`full_covvax_`i'b') _tab %4.2f (`full_covvax_`i'll') _tab (`full_covvax_`i'ul') _tab ("`cases`i'covvax_rate'") (" (") %3.2f (`cases`i'covvax_ll') ("-") %3.2f (`cases`i'covvax_ul') (")") _tab ("`cases`i'covvax_rate'") _tab ("`cases`i'covvax_ll'") _tab ("`cases`i'covvax_ul'") _tab ("`ard`i'covvax_b'") (" (") %3.2f (`ard`i'covvax_ll') ("-") %3.2f (`ard`i'covvax_ul') (")") _tab ("`ard`i'covvax_b'") _tab ("`ard`i'covvax_ll'") _tab ("`ard`i'covvax_ul'") _n +} + +file close tablecontent \ No newline at end of file diff --git a/analysis/events_cca_hospitalised.do b/analysis/events_cca_hospitalised.do new file mode 100644 index 0000000..c82601e --- /dev/null +++ b/analysis/events_cca_hospitalised.do @@ -0,0 +1,48 @@ +sysdir set PLUS ./analysis/adofiles +sysdir set PERSONAL ./analysis/adofiles +pwd +cap log close +macro drop hr +log using ./logs/events_cca_hospitalised.log, replace t + +cap file close tablecontent +use ./output/analysis_hospitalised.dta, clear + +file open tablecontent using ./output/events_cca_hospitalised.csv, write text replace +file write tablecontent ("outcome") _tab ("period") _tab ("events_covid") _tab ("events_control") _n + +local outcomes "esrd egfr_half aki death" + +local esrd_lab "Kidney failure" +local egfr_half_lab "50% reduction in eGFR" +local aki_lab "AKI" +local death_lab "Death" + +local period "29 89 179 max" +local lab29 "0-29 days" +local lab89 "30-89 days" +local lab179 "90-179 days" +local labmax "180+ days" + +foreach out of local outcomes { + +qui stset exit_date_`out', fail(`out'_date) origin(index_date_`out') id(unique) scale(365.25) +drop age1 age2 age3 +mkspline age = age if _st==1&sex!=.ðnicity!=.&imd!=.&urban!=.®ion!=.&bmi!=.&smoking!=., cubic nknots(4) +qui safecount if case==1 & _d==1 & _st==1 +local cases_events = round(r(N),5) +qui safecount if case==0 & _d==1 & _st==1 +local controls_events = round(r(N),5) +file write tablecontent ("``out'_lab'") _tab ("Overall") _tab (`cases_events') _tab (`controls_events') _n + +foreach x of local period { +qui stset exit_date`x'_`out', fail(`out'_date`x') origin(index_date`x'_`out') id(unique) scale(365.25) +qui safecount if case==1 & _d==1 & _st==1 +local cases_events = round(r(N),5) +qui safecount if case==0 & _d==1 & _st==1 +local controls_events = round(r(N),5) +file write tablecontent ("``out'_lab'") _tab ("`lab`x''") _tab (`cases_events') _tab (`controls_events') _n +} +} + +file close tablecontent \ No newline at end of file diff --git a/analysis/events_cca_hospitalised_exposures_esrd.do b/analysis/events_cca_hospitalised_exposures_esrd.do new file mode 100644 index 0000000..0884d72 --- /dev/null +++ b/analysis/events_cca_hospitalised_exposures_esrd.do @@ -0,0 +1,47 @@ +sysdir set PLUS ./analysis/adofiles +sysdir set PERSONAL ./analysis/adofiles +pwd +cap log close +macro drop hr +log using ./logs/events_cca_hospitalised_exposures_esrd.log, replace t + +cap file close tablecontent +use ./output/analysis_hospitalised.dta, clear + +file open tablecontent using ./output/events_cca_hospitalised_exposures_esrd.csv, write text replace +file write tablecontent ("stratum") _tab ("events") _n + +rename covid_vax covvax + +local wave1 "COVID-19 Feb20-Aug20" +local wave2 "COVID-19 Sep20-Jun21" +local wave3 "COVID-19 Jul21-Nov21" +local wave4 "COVID-19 Dec21-Dec22" + +local covvax1 "COVID-19 pre-vaccination" +local covvax2 "COVID-19 1 vaccination dose" +local covvax3 "COVID-19 2 vaccination doses" +local covvax4 "COVID-19 3 vaccination doses" +local covvax5 "COVID-19 4 vaccination doses" + +qui stset exit_date_esrd, fail(esrd_date) origin(index_date_esrd) id(unique) scale(365.25) +drop age1 age2 age3 +mkspline age = age if _st==1&sex!=.ðnicity!=.&imd!=.&urban!=.®ion!=.&bmi!=.&smoking!=., cubic nknots(4) + +qui safecount if case==0 & _d==1 & _st==1 +local events = round(r(N),5) +file write tablecontent ("Pneumonia (pre-pandemic)") _tab (`events') _n + +forvalues i=1/4 { +qui safecount if wave==`i' & _d==1 & _st==1 +local events = round(r(N),5) +file write tablecontent ("`wave`i''") _tab (`events') _n +} + +forvalues i=1/5 { +qui safecount if covvax==`i' & _d==1 & _st==1 +local events = round(r(N),5) +file write tablecontent ("`covvax`i''") _tab (`events') _n +} + +file close tablecontent \ No newline at end of file diff --git a/project.yaml b/project.yaml index efa32f9..62ffd86 100644 --- a/project.yaml +++ b/project.yaml @@ -1436,37 +1436,13 @@ actions: log: logs/crude_rates_death_hospitalised.log output: output/crude_rates_death_hospitalised.csv - cox_forest_hospitalised_esrd: - run: stata-mp:latest analysis/cox_forest_hospitalised_esrd.do + cox_forest_hospitalised: + run: stata-mp:latest analysis/cox_forest_hospitalised.do needs: [analysis_hospitalised] outputs: moderately_sensitive: - log: logs/cox_forest_hospitalised_esrd.log - output: output/cox_forest_hospitalised_esrd.csv - - cox_forest_hospitalised_egfr_half: - run: stata-mp:latest analysis/cox_forest_hospitalised_egfr_half.do - needs: [analysis_hospitalised] - outputs: - moderately_sensitive: - log: logs/cox_forest_hospitalised_egfr_half.log - output: output/cox_forest_hospitalised_egfr_half.csv - - cox_forest_hospitalised_aki: - run: stata-mp:latest analysis/cox_forest_hospitalised_aki.do - needs: [analysis_hospitalised] - outputs: - moderately_sensitive: - log: logs/cox_forest_hospitalised_aki.log - output: output/cox_forest_hospitalised_aki.csv - - cox_forest_hospitalised_death: - run: stata-mp:latest analysis/cox_forest_hospitalised_death.do - needs: [analysis_hospitalised] - outputs: - moderately_sensitive: - log: logs/cox_forest_hospitalised_death.log - output: output/cox_forest_hospitalised_death.csv + log: logs/cox_forest_hospitalised.log + output: output/cox_forest_hospitalised.csv cox_forest_2017_covid_severity_esrd: run: stata-mp:latest analysis/cox_forest_2017_covid_severity_esrd.do @@ -1613,6 +1589,14 @@ actions: log: logs/events_cca_2020.log output: output/events_cca_2020.csv + events_cca_hospitalised: + run: stata-mp:latest analysis/events_cca_hospitalised.do + needs: [analysis_hospitalised] + outputs: + moderately_sensitive: + log: logs/events_cca_hospitalised.log + output: output/events_cca_hospitalised.csv + cox_forest_2017_exposures_esrd: run: stata-mp:latest analysis/cox_forest_2017_exposures_esrd.do needs: [analysis_complete] @@ -1629,6 +1613,14 @@ actions: log: logs/cox_forest_2020_exposures_esrd.log output: output/cox_forest_2020_exposures_esrd.csv + cox_forest_hospitalised_exposures_esrd: + run: stata-mp:latest analysis/cox_forest_hospitalised_exposures_esrd.do + needs: [analysis_hospitalised] + outputs: + moderately_sensitive: + log: logs/cox_forest_hospitalised_exposures_esrd.log + output: output/cox_forest_hospitalised_exposures_esrd.csv + events_cca_2017_exposures_esrd: run: stata-mp:latest analysis/events_cca_2017_exposures_esrd.do needs: [analysis_complete] @@ -1645,6 +1637,14 @@ actions: log: logs/events_cca_2020_exposures_esrd.log output: output/events_cca_2020_exposures_esrd.csv + events_cca_hospitalised_exposures_esrd: + run: stata-mp:latest analysis/events_cca_hospitalised_exposures_esrd.do + needs: [analysis_hospitalised] + outputs: + moderately_sensitive: + log: logs/events_cca_hospitalised_exposures_esrd.log + output: output/events_cca_hospitalised_exposures_esrd.csv + cox_forest_2017_case_esrd: run: stata-mp:latest analysis/cox_forest_2017_case_esrd.do needs: [analysis_complete]