// version 16.1 include project_paths.do ***** Clusters for High-risk Pregnancy Episodes ///// Clusters for All Trimesters use "`out_dir'/MCA_prep_cluster_posthoc", clear keep if risk == "High-Risk" cluster wardslinkage $rate_vars, measure(L2) name(clus_high) save "`out_dir'/Clusters/cluster_high.dta", replace include project_paths.do use "`out_dir'/Clusters/cluster_high.dta", clear cluster dendrogram clus_high, cutnumber(15) graph export "`fig_dir'/clusters_dendogram_highpreg.pdf", as(pdf) replace cluster stop, rule(duda) cluster stop, rule(calinski) cluster generate cluster = groups(4), name(clus_high) ties(error) tab cluster, gen(cluster) // hist prop_messaging, by(cluster) // graph export "`fig_dir'/hist_clusters/high_messaging.pdf", as(pdf) replace // hist prop_visits, by(cluster) // graph export "`fig_dir'/hist_clusters/high_visits.pdf", as(pdf) replace // hist prop_myrecord, by(cluster) // graph export "`fig_dir'/hist_clusters/high_myrecord.pdf", as(pdf) replace // hist prop_billing, by(cluster) // graph export "`fig_dir'/hist_clusters/high_billing.pdf", as(pdf) replace // hist se_max_alltri_fin, by(cluster) // graph export "`fig_dir'/hist_clusters/high_se_max_alltri_fin.pdf", as(pdf) replace // hist epi_length, by(cluster) // graph export "`fig_dir'/hist_clusters/high_epi_length_alltri.pdf", as(pdf) replace // hist ttstart_tri1, by(cluster) // graph export "`fig_dir'/hist_clusters/high_ttstart_alltri.pdf", as(pdf) replace // hist ttend_alltri, by(cluster) // graph export "`fig_dir'/hist_clusters/high_ttend_alltri.pdf", as(pdf) replace // hist tt_del, by(cluster) // graph export "`fig_dir'/hist_clusters/high_tt_del_alltri.pdf", as(pdf) replace // hist tt_estdel, by(cluster) // graph export "`fig_dir'/hist_clusters/high_tt_estdel_alltri.pdf", as(pdf) replace // hist mm_cnt, by(cluster) // graph export "`fig_dir'/hist_clusters/high_mm_cnt_alltri.pdf", as(pdf) replace // hist ob_cnt, by(cluster) // graph export "`fig_dir'/hist_clusters/high_ob_cnt_alltri.pdf", as(pdf) replace // hist visits_cnt, by(cluster) // graph export "`fig_dir'/hist_clusters/high_visits_cnt_alltri.pdf", as(pdf) replace bysort cluster: asdoc tabstat $rate_vars, replace stat(N p50) save(highpreg_alltri_t1.doc) export delimited "`out_dir'/sigtestR/cluster_high.csv", replace // Post hoc analysis - all trimester tabstat se_max_alltri_fin, statistics (n p50 mean iqr) by(cluster) tabstat epi_length, statistics (n p50 mean iqr) by(cluster) tabstat ttstart_tri1, statistics (n p50 mean iqr) by(cluster) tabstat ttend_alltri, statistics (n p50 mean iqr) by(cluster) tabstat tt_del, statistics (n p50 mean iqr) by(cluster) tabstat tt_estdel, statistics (n p50 mean iqr) by(cluster) tabstat mm_cnt, statistics (n p50 mean iqr) by(cluster) tabstat ob_cnt, statistics (n p50 mean iqr) by(cluster) tabstat visits_cnt, statistics (n p50 mean iqr) by(cluster) tabstat cci_index, statistics (n median) by(cluster) tab race_ethn_cat cluster, column dunntest prop_messaging, by(cluster) dunntest prop_visits, by(cluster) dunntest prop_myrecord, by(cluster) dunntest prop_billing, by(cluster) dunntest se_max_alltri_fin, by(cluster) dunntest epi_length, by(cluster) dunntest ttstart_tri1, by(cluster) dunntest ttend_alltri, by(cluster) dunntest tt_del, by(cluster) dunntest tt_estdel, by(cluster) dunntest mm_cnt, by(cluster) dunntest ob_cnt, by(cluster) dunntest visits_cnt, by(cluster) dunntest race_ethn_cat, by(cluster) ///// Clusters for Trimester 1 use "`out_dir'/MCA_prep_cluster_posthoc", clear keep if risk == "High-Risk" cluster wardslinkage $rate_vars_tri1, measure(L2) name(clus_high_tri1) save "`out_dir'/Clusters/cluster_high_tri1.dta", replace include project_paths.do use "`out_dir'/Clusters/cluster_high_tri1.dta", clear cluster dendrogram clus_high_tri1, cutnumber(15) graph export "`fig_dir'/clusters_dendogram_highpreg_tri1.pdf", as(pdf) replace cluster stop, rule(duda) cluster stop, rule(calinski) cluster generate cluster = groups(5), name(clus_high_tri1) ties(error) tab cluster, gen(cluster) // hist prop_GR1_tri1, by(cluster) // graph export "`fig_dir'/hist_clusters/high_GR1_tri1.pdf", as(pdf) replace // hist prop_GR2_tri1, by(cluster) // graph export "`fig_dir'/hist_clusters/high_GR2_tri1.pdf", as(pdf) replace // hist prop_GR3_tri1, by(cluster) // graph export "`fig_dir'/hist_clusters/high_GR3_tri1.pdf", as(pdf) replace // hist prop_GR5_tri1, by(cluster) // graph export "`fig_dir'/hist_clusters/high_GR5_tri1.pdf", as(pdf) replace // hist se_max_tri1_fin, by(cluster) // graph export "`fig_dir'/hist_clusters/high_se_max_tri1_fin.pdf", as(pdf) replace // hist ttstart_tri1, by(cluster) // graph export "`fig_dir'/hist_clusters/high_ttstart_tri1.pdf", as(pdf) replace // hist ttend_tri1, by(cluster) // graph export "`fig_dir'/hist_clusters/high_ttend_tri1.pdf", as(pdf) replace // hist mm_cnt, by(cluster) // graph export "`fig_dir'/hist_clusters/high_mm_cnt_tri1.pdf", as(pdf) replace // hist ob_cnt, by(cluster) // graph export "`fig_dir'/hist_clusters/high_ob_cnt_tri1.pdf", as(pdf) replace // hist visits_cnt, by(cluster) // graph export "`fig_dir'/hist_clusters/high_visits_cnt_tri1.pdf", as(pdf) replace bysort cluster: asdoc tabstat $rate_vars_tri1, replace stat(N p50) save(highpreg_tri1_t1.doc) export delimited "`out_dir'/sigtestR/cluster_high_tri1.csv", replace // Post hoc analysis - trimester 1 tabstat se_max_tri1_fin, statistics (n p50 mean iqr) by(cluster) tabstat ttstart_tri1, statistics (n p50 mean iqr) by(cluster) tabstat ttend_tri1, statistics (n p50 mean iqr) by(cluster) tabstat mm_cnt, statistics (n p50 mean iqr) by(cluster) tabstat ob_cnt, statistics (n p50 mean iqr) by(cluster) tabstat visits_cnt, statistics (n p50 mean iqr) by(cluster) tabstat cci_index, statistics (n median) by(cluster) tab race_ethn_cat cluster, column dunntest prop_GR1_tri1, by(cluster) dunntest prop_GR2_tri1, by(cluster) dunntest prop_GR3_tri1, by(cluster) dunntest prop_GR5_tri1, by(cluster) dunntest se_max_tri1_fin, by(cluster) dunntest ttstart_tri1, by(cluster) dunntest ttend_tri1, by(cluster) dunntest race_ethn_cat, by(cluster) ///// Clusters for Trimester 2 use "`out_dir'/MCA_prep_cluster_posthoc", clear keep if risk == "High-Risk" cluster wardslinkage $rate_vars_tri2, measure(L2) name(clus_high_tri2) save "`out_dir'/Clusters/cluster_high_tri2.dta", replace include project_paths.do use "`out_dir'/Clusters/cluster_high_tri2.dta", clear cluster dendrogram clus_high_tri2, cutnumber(15) graph export "`fig_dir'/clusters_dendogram_highpreg_tri2.pdf", as(pdf) replace cluster stop, rule(duda) cluster stop, rule(calinski) cluster generate cluster = groups(4), name(clus_high_tri2) ties(error) tab cluster, gen(cluster) // hist prop_GR1_tri2, by(cluster) // graph export "`fig_dir'/hist_clusters/high_GR1_tri2.pdf", as(pdf) replace // hist prop_GR2_tri2, by(cluster) // graph export "`fig_dir'/hist_clusters/high_GR2_tri2.pdf", as(pdf) replace // hist prop_GR3_tri2, by(cluster) // graph export "`fig_dir'/hist_clusters/high_GR3_tri2.pdf", as(pdf) replace // hist prop_GR5_tri2, by(cluster) // graph export "`fig_dir'/hist_clusters/high_GR5_tri2.pdf", as(pdf) replace // hist se_max_tri2_fin, by(cluster) // graph export "`fig_dir'/hist_clusters/high_se_max_tri2_fin.pdf", as(pdf) replace // hist ttstart_tri2, by(cluster) // graph export "`fig_dir'/hist_clusters/high_ttstart_tri2.pdf", as(pdf) replace // hist ttend_tri2, by(cluster) // graph export "`fig_dir'/hist_clusters/high_ttend_tri2.pdf", as(pdf) replace // hist mm_cnt, by(cluster) // graph export "`fig_dir'/hist_clusters/high_mm_cnt_tri2.pdf", as(pdf) replace // hist ob_cnt, by(cluster) // graph export "`fig_dir'/hist_clusters/high_ob_cnt_tri2.pdf", as(pdf) replace // hist visits_cnt, by(cluster) // graph export "`fig_dir'/hist_clusters/high_visits_cnt_tri2.pdf", as(pdf) replace bysort cluster: asdoc tabstat $rate_vars_tri2, replace stat(N p50) save(highpreg_tri2_t1.doc) export delimited "`out_dir'/sigtestR/cluster_high_tri2.csv", replace // Post hoc analysis - trimester 2 tabstat se_max_tri1_fin, statistics (n p50 mean iqr) by(cluster) tabstat ttstart_tri1, statistics (n p50 mean iqr) by(cluster) tabstat ttend_tri1, statistics (n p50 mean iqr) by(cluster) tabstat mm_cnt, statistics (n p50 mean iqr) by(cluster) tabstat ob_cnt, statistics (n p50 mean iqr) by(cluster) tabstat visits_cnt, statistics (n p50 mean iqr) by(cluster) tabstat cci_index, statistics (n median) by(cluster) tab race_ethn_cat cluster, column dunntest prop_GR1_tri2, by(cluster) dunntest prop_GR2_tri2, by(cluster) dunntest prop_GR3_tri2, by(cluster) dunntest prop_GR5_tri2, by(cluster) dunntest se_max_tri2_fin, by(cluster) dunntest ttstart_tri2, by(cluster) dunntest ttend_tri2, by(cluster) dunntest race_ethn_cat, by(cluster) ///// Cluster for Trimester 3 use "`out_dir'/MCA_prep_cluster_posthoc", clear keep if risk == "High-Risk" cluster wardslinkage $rate_vars_tri3, measure(L2) name(clus_high_tri3) save "`out_dir'/Clusters/cluster_high_tri3.dta", replace include project_paths.do use "`out_dir'/Clusters/cluster_high_tri3.dta", clear cluster dendrogram clus_high_tri3, cutnumber(15) graph export "`fig_dir'/clusters_dendogram_highpreg_tri3.pdf", as(pdf) replace cluster stop, rule(duda) cluster stop, rule(calinski) cluster generate cluster = groups(4), name(clus_high_tri3) ties(error) tab cluster, gen(cluster) // hist prop_GR1_tri3, by(cluster) // graph export "`fig_dir'/hist_clusters/high_GR1_tri3.pdf", as(pdf) replace // hist prop_GR2_tri3, by(cluster) // graph export "`fig_dir'/hist_clusters/high_GR2_tri3.pdf", as(pdf) replace // hist prop_GR3_tri3, by(cluster) // graph export "`fig_dir'/hist_clusters/high_GR3_tri3.pdf", as(pdf) replace // hist prop_GR5_tri3, by(cluster) // graph export "`fig_dir'/hist_clusters/high_GR5_tri3.pdf", as(pdf) replace // hist se_max_tri3_fin, by(cluster) // graph export "`fig_dir'/hist_clusters/high_se_max_tri3_fin.pdf", as(pdf) replace // hist ttstart_tri3, by(cluster) // graph export "`fig_dir'/hist_clusters/high_ttstart_tri3.pdf", as(pdf) replace // hist ttend_tri3, by(cluster) // graph export "`fig_dir'/hist_clusters/high_ttend_tri3.pdf", as(pdf) replace // hist mm_cnt, by(cluster) // graph export "`fig_dir'/hist_clusters/high_mm_cnt_tri3.pdf", as(pdf) replace // hist ob_cnt, by(cluster) // graph export "`fig_dir'/hist_clusters/high_ob_cnt_tri3.pdf", as(pdf) replace // hist visits_cnt, by(cluster) // graph export "`fig_dir'/hist_clusters/high_visits_cnt_tri3.pdf", as(pdf) replace bysort cluster: asdoc tabstat $rate_vars_tri3, replace stat(N p50) save(highpreg_tri3_t1.doc) export delimited "`out_dir'/sigtestR/cluster_high_tri3.csv", replace // Post hoc analysis - trimester 3 tabstat se_max_tri1_fin, statistics (n p50 mean iqr) by(cluster) tabstat ttstart_tri1, statistics (n p50 mean iqr) by(cluster) tabstat ttend_tri1, statistics (n p50 mean iqr) by(cluster) tabstat mm_cnt, statistics (n p50 mean iqr) by(cluster) tabstat ob_cnt, statistics (n p50 mean iqr) by(cluster) tabstat visits_cnt, statistics (n p50 mean iqr) by(cluster) tabstat cci_index, statistics (n median) by(cluster) tab race_ethn_cat cluster, column dunntest prop_GR1_tri3, by(cluster) dunntest prop_GR2_tri3, by(cluster) dunntest prop_GR3_tri3, by(cluster) dunntest prop_GR5_tri3, by(cluster) dunntest se_max_tri3_fin, by(cluster) dunntest ttstart_tri3, by(cluster) dunntest ttend_tri3, by(cluster) dunntest race_ethn_cat, by(cluster)