From 1c4d0843f33d981d84e141d4b200baf8fd23c606 Mon Sep 17 00:00:00 2001 From: Viyaasan Mahalingasivam Date: Tue, 23 Jan 2024 13:40:27 +0000 Subject: [PATCH] Secondary outcomes by ethnicity --- analysis/cox_forest_2017_ethnicity.do | 85 ++++++++++++++++++++++ analysis/cox_forest_2017_ethnicity_esrd.do | 2 +- analysis/cox_forest_2020_ethnicity.do | 85 ++++++++++++++++++++++ project.yaml | 18 ++++- 4 files changed, 188 insertions(+), 2 deletions(-) create mode 100644 analysis/cox_forest_2017_ethnicity.do create mode 100644 analysis/cox_forest_2020_ethnicity.do diff --git a/analysis/cox_forest_2017_ethnicity.do b/analysis/cox_forest_2017_ethnicity.do new file mode 100644 index 0000000..2209427 --- /dev/null +++ b/analysis/cox_forest_2017_ethnicity.do @@ -0,0 +1,85 @@ +clear +sysdir set PLUS ./analysis/adofiles +sysdir set PERSONAL ./analysis/adofiles +pwd +cap log close +macro drop hr +log using ./logs/cox_forest_2017_ethnicity.log, replace t +cap file close tablecontent +file open tablecontent using ./output/cox_forest_2017_ethnicity.csv, write text replace +file write tablecontent _tab ("HR (95% CI)") _tab ("hr") _tab ("ll") _tab ("ul") _tab ("p-value for interaction") _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" + +use ./output/analysis_complete_2017.dta, clear + +foreach out of local outcomes { + +qui stset exit_date_`out', fail(`out'_date) origin(index_date_`out') id(unique) scale(365.25) + +file write tablecontent ("``out'_lab'") _n + +file write tablecontent ("Minimally-adjusted") _n +forvalues i=1/5 { +local label_`i': label ethnicity `i' +} +qui stcox i.case i.ethnicity, strata(set_id) +est store a +qui stcox i.case##i.ethnicity, strata(set_id) +est store b +qui lrtest b a +local p = r(p) +lincom 1.case, eform +local int_1b = r(estimate) +local int_1ll = r(lb) +local int_1ul = r(ub) +forvalues i=2/5 { +lincom 1.case + 1.case#`i'.ethnicity, eform +local int_`i'b = r(estimate) +local int_`i'll = r(lb) +local int_`i'ul = r(ub) +} +file write tablecontent ("`label_1'") +file write tablecontent _tab %4.2f (`int_1b') (" (") %4.2f (`int_1ll') ("-") %4.2f (`int_1ul') (")") _tab %4.2f (`int_1b') _tab %4.2f (`int_1ll') _tab %4.2f (`int_1ul') _tab %5.4f (`p') _n +forvalues i=2/5 { +file write tablecontent ("`label_`i''") +file write tablecontent _tab %4.2f (`int_`i'b') (" (") %4.2f (`int_`i'll') ("-") %4.2f (`int_`i'ul') (")") _tab %4.2f (`int_`i'b') _tab %4.2f (`int_`i'll') _tab %4.2f (`int_`i'ul') _n +} + + +file write tablecontent ("After adjustment for potential confounders") _n +forvalues i=1/5 { +local label_`i': label ethnicity `i' +} + +qui stcox i.case i.ethnicity i.imd i.urban 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, strata(set_id) +est store a +qui stcox i.case##i.ethnicity i.imd i.urban 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, strata(set_id) +est store b +qui lrtest b a +local p = r(p) +lincom 1.case, eform +local int_1b = r(estimate) +local int_1ll = r(lb) +local int_1ul = r(ub) +forvalues i=2/5 { +lincom 1.case + 1.case#`i'.ethnicity, eform +local int_`i'b = r(estimate) +local int_`i'll = r(lb) +local int_`i'ul = r(ub) +} +file write tablecontent ("`label_1'") +file write tablecontent _tab %4.2f (`int_1b') (" (") %4.2f (`int_1ll') ("-") %4.2f (`int_1ul') (")") _tab %4.2f (`int_1b') _tab %4.2f (`int_1ll') _tab %4.2f (`int_1ul') _tab %5.4f (`p') _n +forvalues i=2/5 { +file write tablecontent ("`label_`i''") +file write tablecontent _tab %4.2f (`int_`i'b') (" (") %4.2f (`int_`i'll') ("-") %4.2f (`int_`i'ul') (")") _tab %4.2f (`int_`i'b') _tab %4.2f (`int_`i'll') _tab %4.2f (`int_`i'ul') _n +} +} + +file close tablecontent \ No newline at end of file diff --git a/analysis/cox_forest_2017_ethnicity_esrd.do b/analysis/cox_forest_2017_ethnicity_esrd.do index cd26ba0..769a040 100644 --- a/analysis/cox_forest_2017_ethnicity_esrd.do +++ b/analysis/cox_forest_2017_ethnicity_esrd.do @@ -41,7 +41,7 @@ file write tablecontent _tab %4.2f (`int_`i'b') (" (") %4.2f (`int_`i'll') ("-") } -file write tablecontent ("After adjustment for potential mediators") _n +file write tablecontent ("After adjustment for potential confounders") _n forvalues i=1/5 { local label_`i': label ethnicity `i' } diff --git a/analysis/cox_forest_2020_ethnicity.do b/analysis/cox_forest_2020_ethnicity.do new file mode 100644 index 0000000..a620535 --- /dev/null +++ b/analysis/cox_forest_2020_ethnicity.do @@ -0,0 +1,85 @@ +clear +sysdir set PLUS ./analysis/adofiles +sysdir set PERSONAL ./analysis/adofiles +pwd +cap log close +macro drop hr +log using ./logs/cox_forest_2020_ethnicity.log, replace t +cap file close tablecontent +file open tablecontent using ./output/cox_forest_2020_ethnicity.csv, write text replace +file write tablecontent _tab ("HR (95% CI)") _tab ("hr") _tab ("ll") _tab ("ul") _tab ("p-value for interaction") _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" + +use ./output/analysis_complete_2020.dta, clear + +foreach out of local outcomes { + +qui stset exit_date_`out', fail(`out'_date) origin(index_date_`out') id(unique) scale(365.25) + +file write tablecontent ("``out'_lab'") _n + +file write tablecontent ("Minimally-adjusted") _n +forvalues i=1/5 { +local label_`i': label ethnicity `i' +} +qui stcox i.case i.ethnicity, strata(set_id) +est store a +qui stcox i.case##i.ethnicity, strata(set_id) +est store b +qui lrtest b a +local p = r(p) +lincom 1.case, eform +local int_1b = r(estimate) +local int_1ll = r(lb) +local int_1ul = r(ub) +forvalues i=2/5 { +lincom 1.case + 1.case#`i'.ethnicity, eform +local int_`i'b = r(estimate) +local int_`i'll = r(lb) +local int_`i'ul = r(ub) +} +file write tablecontent ("`label_1'") +file write tablecontent _tab %4.2f (`int_1b') (" (") %4.2f (`int_1ll') ("-") %4.2f (`int_1ul') (")") _tab %4.2f (`int_1b') _tab %4.2f (`int_1ll') _tab %4.2f (`int_1ul') _tab %5.4f (`p') _n +forvalues i=2/5 { +file write tablecontent ("`label_`i''") +file write tablecontent _tab %4.2f (`int_`i'b') (" (") %4.2f (`int_`i'll') ("-") %4.2f (`int_`i'ul') (")") _tab %4.2f (`int_`i'b') _tab %4.2f (`int_`i'll') _tab %4.2f (`int_`i'ul') _n +} + + +file write tablecontent ("After adjustment for potential confounders") _n +forvalues i=1/5 { +local label_`i': label ethnicity `i' +} + +qui stcox i.case i.ethnicity i.imd i.urban 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.covid_vax, strata(set_id) +est store a +qui stcox i.case##i.ethnicity i.imd i.urban 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.covid_vax, strata(set_id) +est store b +qui lrtest b a +local p = r(p) +lincom 1.case, eform +local int_1b = r(estimate) +local int_1ll = r(lb) +local int_1ul = r(ub) +forvalues i=2/5 { +lincom 1.case + 1.case#`i'.ethnicity, eform +local int_`i'b = r(estimate) +local int_`i'll = r(lb) +local int_`i'ul = r(ub) +} +file write tablecontent ("`label_1'") +file write tablecontent _tab %4.2f (`int_1b') (" (") %4.2f (`int_1ll') ("-") %4.2f (`int_1ul') (")") _tab %4.2f (`int_1b') _tab %4.2f (`int_1ll') _tab %4.2f (`int_1ul') _tab %5.4f (`p') _n +forvalues i=2/5 { +file write tablecontent ("`label_`i''") +file write tablecontent _tab %4.2f (`int_`i'b') (" (") %4.2f (`int_`i'll') ("-") %4.2f (`int_`i'ul') (")") _tab %4.2f (`int_`i'b') _tab %4.2f (`int_`i'll') _tab %4.2f (`int_`i'ul') _n +} +} + +file close tablecontent \ No newline at end of file diff --git a/project.yaml b/project.yaml index cef4d4f..7b443c6 100644 --- a/project.yaml +++ b/project.yaml @@ -1699,4 +1699,20 @@ actions: outputs: moderately_sensitive: log: logs/selection_hospitalised.log - output: output/selection_hospitalised.csv \ No newline at end of file + output: output/selection_hospitalised.csv + + cox_forest_2017_ethnicity: + run: stata-mp:latest analysis/cox_forest_2017_ethnicity.do + needs: [analysis_complete] + outputs: + moderately_sensitive: + log: logs/cox_forest_2017_ethnicity.log + output: output/cox_forest_2017_ethnicity.csv + + cox_forest_2020_ethnicity: + run: stata-mp:latest analysis/cox_forest_2020_ethnicity.do + needs: [analysis_complete] + outputs: + moderately_sensitive: + log: logs/cox_forest_2020_ethnicity.log + output: output/cox_forest_2020_ethnicity.csv \ No newline at end of file