generated from opensafely/research-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
188 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters