Skip to content

Commit

Permalink
Secondary outcomes by ethnicity
Browse files Browse the repository at this point in the history
  • Loading branch information
viyaasan committed Jan 23, 2024
1 parent d5e58ca commit 1c4d084
Show file tree
Hide file tree
Showing 4 changed files with 188 additions and 2 deletions.
85 changes: 85 additions & 0 deletions analysis/cox_forest_2017_ethnicity.do
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion analysis/cox_forest_2017_ethnicity_esrd.do
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down
85 changes: 85 additions & 0 deletions analysis/cox_forest_2020_ethnicity.do
Original file line number Diff line number Diff line change
@@ -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
18 changes: 17 additions & 1 deletion project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1699,4 +1699,20 @@ actions:
outputs:
moderately_sensitive:
log: logs/selection_hospitalised.log
output: output/selection_hospitalised.csv
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

0 comments on commit 1c4d084

Please sign in to comment.