Skip to content

Commit

Permalink
Ethnicity mediators
Browse files Browse the repository at this point in the history
  • Loading branch information
viyaasan committed Jan 11, 2024
1 parent f59ebd1 commit 012f9b9
Show file tree
Hide file tree
Showing 3 changed files with 178 additions and 1 deletion.
80 changes: 80 additions & 0 deletions analysis/cox_forest_2017_ethnicity_esrd_mediators.do
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
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_esrd_mediators.log, replace t
cap file close tablecontent
file open tablecontent using ./output/cox_forest_2017_ethnicity_esrd_mediators.csv, write text replace
file write tablecontent _tab ("HR (95% CI)") _tab ("hr") _tab ("ll") _tab ("ul") _n

use ./output/analysis_complete_2017.dta, clear

qui stset exit_date_esrd, fail(esrd_date) origin(index_date_esrd) id(unique) scale(365.25)

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)
qui lincom 1.case, eform
local int_1b = r(estimate)
local int_1ll = r(lb)
local int_1ul = r(ub)
forvalues i=2/5 {
qui 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') _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
}

local mediators "imd urban bmi smoking ckd_stage aki_baseline cardiovascular diabetes hypertension immunosuppressed non_haem_cancer gp_consults admissions"

local imd_lab "IMD"
local urban_lab "rural/urban"
local bmi_lab "BMI"
local smoking_lab "smoking"
local ckd_stage_lab "CKD stage"
local aki_baseline_lab "previous AKI"
local cardiovascular_lab "cardiovascular diseases"
local diabetes_lab "diabetes"
local hypertension_lab "hypertension"
local immunosuppressed_lab "immunosuppressed"
local non_haem_cancer_lab "non-haematological cancer"
local gp_consults_lab "GP consultations"
local admissions_lab "previous hospital admissions"

foreach med of local mediators {

file write tablecontent ("After adjustment for ``med'_lab'") _n
forvalues i=1/5 {
local label_`i': label ethnicity `i'
}

qui stcox i.case##i.ethnicity i.`med', strata(set_id)
qui lincom 1.case, eform
local int_1b = r(estimate)
local int_1ll = r(lb)
local int_1ul = r(ub)
forvalues i=2/5 {
qui 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') _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
81 changes: 81 additions & 0 deletions analysis/cox_forest_2020_ethnicity_esrd_mediators.do
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
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_esrd_mediators.log, replace t
cap file close tablecontent
file open tablecontent using ./output/cox_forest_2020_ethnicity_esrd_mediators.csv, write text replace
file write tablecontent _tab ("HR (95% CI)") _tab ("hr") _tab ("ll") _tab ("ul") _n

use ./output/analysis_complete_2020.dta, clear

qui stset exit_date_esrd, fail(esrd_date) origin(index_date_esrd) id(unique) scale(365.25)

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)
qui lincom 1.case, eform
local int_1b = r(estimate)
local int_1ll = r(lb)
local int_1ul = r(ub)
forvalues i=2/5 {
qui 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') _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
}

local mediators "imd urban bmi smoking ckd_stage aki_baseline cardiovascular diabetes hypertension immunosuppressed non_haem_cancer gp_consults admissions covid_vax"

local imd_lab "IMD"
local urban_lab "rural/urban"
local bmi_lab "BMI"
local smoking_lab "smoking"
local ckd_stage_lab "CKD stage"
local aki_baseline_lab "previous AKI"
local cardiovascular_lab "cardiovascular diseases"
local diabetes_lab "diabetes"
local hypertension_lab "hypertension"
local immunosuppressed_lab "immunosuppressed"
local non_haem_cancer_lab "non-haematological cancer"
local gp_consults_lab "GP consultations"
local admissions_lab "previous hospital admissions"
local covid_vax_lab "COVID-19 vaccination"

foreach med of local mediators {

file write tablecontent ("After adjustment for ``med'_lab'") _n
forvalues i=1/5 {
local label_`i': label ethnicity `i'
}

qui stcox i.case##i.ethnicity i.`med', strata(set_id)
qui lincom 1.case, eform
local int_1b = r(estimate)
local int_1ll = r(lb)
local int_1ul = r(ub)
forvalues i=2/5 {
qui 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') _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
18 changes: 17 additions & 1 deletion project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1571,7 +1571,23 @@ actions:
outputs:
moderately_sensitive:
log: logs/cox_forest_2020_ethnicity_esrd.log
output: output/cox_forest_2020_ethnicity_esrd.csv
output: output/cox_forest_2020_ethnicity_esrd.csv

cox_forest_2017_ethnicity_esrd_mediators:
run: stata-mp:latest analysis/cox_forest_2017_ethnicity_esrd_mediators.do
needs: [analysis_complete]
outputs:
moderately_sensitive:
log: logs/cox_forest_2017_ethnicity_esrd_mediators.log
output: output/cox_forest_2017_ethnicity_esrd_mediators.csv

cox_forest_2020_ethnicity_esrd_mediators:
run: stata-mp:latest analysis/cox_forest_2020_ethnicity_esrd_mediators.do
needs: [analysis_complete]
outputs:
moderately_sensitive:
log: logs/cox_forest_2020_ethnicity_esrd_mediators.log
output: output/cox_forest_2020_ethnicity_esrd_mediators.csv

events_cca_2017:
run: stata-mp:latest analysis/events_cca_2017.do
Expand Down

0 comments on commit 012f9b9

Please sign in to comment.