Skip to content

Commit

Permalink
graph axis updates
Browse files Browse the repository at this point in the history
  • Loading branch information
rc16 committed May 10, 2023
1 parent 672da7d commit a24c623
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 179 deletions.
58 changes: 30 additions & 28 deletions analysis/305_cox_ph.do
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ cap mkdir ./output/graphs
foreach period in pre pandemic /*wave1 easing1 wave2 easing2 wave3 easing3*/ {
use ./output/prep_survival_`period', clear
describe
foreach outcome in stroke mi hf vte dm_keto depress anx asthma {
foreach outcome in stroke mi hf vte dm_keto depress anx {
* Drop events that occur on index date
drop if `outcome'_admit_date==index_date

* Update study population for diabetes and respiratory outcomes
drop if diabetes_subgroup==0 & "`outcome'"== "dm_keto"
drop if has_asthma==0 & "`outcome'"== "asthma"


* Cox model for each outcome category
* Generate flags and end dates for each outcome
gen `outcome'_admit=(`outcome'_admit_date!=.)
Expand All @@ -34,7 +33,7 @@ foreach period in pre pandemic /*wave1 easing1 wave2 easing2 wave3 easing3*/ {

stset `outcome'_end, fail(`outcome'_admit) id(patient_id) enter(index_date) origin(index_date)
* Kaplan-Meier plot
sts graph, by(eth5) ylabel(.99(.002)1) title("`period'") graphregion(fcolor(white))
sts graph, by(eth5) ylabel(.99(0.01)1) title("`period'") graphregion(fcolor(white))
graph export ./output/graphs/km_`outcome'_`period'.svg, as(svg) replace
/*qui stcox eth5, strata(stp)
estat phtest
Expand Down Expand Up @@ -78,37 +77,40 @@ foreach period in pre pandemic wave1 easing1 wave2 easing2 wave3 easing3 {
}
} */

* T2 DM plots
* T2 DM and asthma plots
foreach period in pre pandemic /*wave1 easing1 wave2 easing2 wave3 easing3*/ {
use ./output/prep_survival_`period', clear
describe
foreach outcome in asthma t2dm {
* Drop events that occur on index date
drop if t2dm_admit_date==index_date
drop if `outcome'_admit_date==index_date

* Update study population for diabetes and respiratory outcomes
drop if has_t2_diabetes==0
* Update study population for diabetes and respiratory outcomes
drop if has_t2_diabetes==0 & "`outcome'"== "t2dm"
drop if has_asthma==0 & "`outcome'"== "asthma"

* Cox model for each outcome category
* Generate flags and end dates for each outcome
gen t2dm_admit=(t2dm_admit_date!=.)
tab t2dm_admit
count if t2dm_admit_date!=.
if r(N) > 10 {
gen t2dm_end = end_date
replace t2dm_end = t2dm_admit_date if t2dm_admit==1
* Cox model for each outcome category
* Generate flags and end dates for each outcome
gen `outcome'_admit=(`outcome'_admit_date!=.)
tab `outcome'_admit
count if `outcome'_admit_date!=.
if r(N) > 10 {
gen `outcome'_end = end_date
replace `outcome'_end = `outcome'_admit_date if `outcome'_admit==1

stset t2dm_end, fail(t2dm_admit) id(patient_id) enter(index_date) origin(index_date)
* Kaplan-Meier plot
sts graph, by(eth5) ylabel(.95(.01)1) title("`period'") graphregion(fcolor(white))
graph export ./output/graphs/km_t2dm_`period'.svg, as(svg) replace
/*qui stcox eth5, strata(stp)
estat phtest
qui stcox eth5 i.age_cat i.male, strata(stp)
estat phtest
qui stcox eth5 i.age_cat i.male i.urban_rural_bin i.imd i.shielded, strata(stp)
estat phtest*/
}
}
stset `outcome'_end, fail(`outcome'_admit) id(patient_id) enter(index_date) origin(index_date)
* Kaplan-Meier plot
sts graph, by(eth5) ylabel(.95(.01)1) title("`period'") graphregion(fcolor(white))
graph export ./output/graphs/km_`outcome'_`period'.svg, as(svg) replace
/*qui stcox eth5, strata(stp)
estat phtest
qui stcox eth5 i.age_cat i.male, strata(stp)
estat phtest
qui stcox eth5 i.age_cat i.male i.urban_rural_bin i.imd i.shielded, strata(stp)
estat phtest*/
}
}
}

/* COPD plots
foreach period in pre pandemic wave1 easing1 wave2 easing2 wave3 easing3 {
Expand Down
Loading

0 comments on commit a24c623

Please sign in to comment.