Database (step 5)

Date created: 4 Aug 2022.

Install commands that are unavailable or out of date.

. clear all

. 
. cap noi which predictms
C:\Users\CISS Fondecyt\ado\plus\p\predictms.ado
*! version 4.3.0 14mar2021 MJC

. if _rc==111 {
.         cap noi net install multistate, from("https://www.mjcrowther.co.uk/code/multistate") 
.         }

. cap noi which merlin
C:\Users\CISS Fondecyt\ado\plus\m\merlin.ado
*! version 2.0.2 19mar2021 MJC

. if _rc==111 {
.         cap noi net install merlin, from("https://www.mjcrowther.co.uk/code/merlin/") 
.         }

. cap noi which sumat
C:\Users\CISS Fondecyt\ado\plus\s\sumat.ado
*! Part of package matrixtools v. 0.25
*! Support: Niels Henrik Bruun, niels.henrik.bruun@gmail.com
*! 2021-01-03 toxl added

. if _rc==111 {
.         cap noi scc install matrixtools
.         }

. cap noi which estwrite
C:\Users\CISS Fondecyt\ado\plus\e\estwrite.ado
*! version 1.2.4 04sep2009
*! version 1.0.1 15may2007 (renamed from -eststo- to -estwrite-; -append- added)
*! version 1.0.0 29apr2005 Ben Jann (ETH Zurich)

. if _rc==111 {
.         cap noi ssc install estwrite
.         }       

.         
. cap noi which scurve_tvc
C:\Users\CISS Fondecyt\ado\plus\s\scurve_tvc.ado

. if _rc==111 {
.         cap noi net install st0458.pkg
.         }

. cap noi which strmcure  
C:\Users\CISS Fondecyt\ado\plus\s\strmcure.ado
*! Version 4.0 31-Aug-2015

. if _rc==111 {
.         net install st0374_1.pkg
.         }

. cap noi which stjmgraph 
C:\Users\CISS Fondecyt\ado\plus\s\stjmgraph.ado
*! version 1.0.2 01Jun2011 MJC

. if _rc==111 {
.         net install st0289.pkg
.         }       

We need to obtain the file and the work folder.

. mata : st_numscalar("OK", direxists("/volumes/sdrive/data//"))

. if scalar(OK) == 1 {
.         cap noi cd "/volumes/sdrive/data//"
.         global pathdata "/volumes/sdrive/data//"
.         di "Location= ${pathdata}; Date: `c(current_date)', considering an OS `c(os)' for the user: `c(username)'"
. }

. else display "This file does not exist"
This file does not exist

. 
. mata : st_numscalar("OK", direxists("E:\Mi unidad\Alvacast\SISTRAT 2019 (github)\_mult_state_ags\"))

. if scalar(OK) == 1 {
.         cap noi cd "E:\Mi unidad\Alvacast\SISTRAT 2019 (github)\_mult_state_ags"
.         global pathdata "E:\Mi unidad\Alvacast\SISTRAT 2019 (github)\_mult_state_ags"
.         global pathdata2 "E:/Mi unidad/Alvacast/SISTRAT 2019 (github)/_mult_state_ags/"
.         di "Location= ${pathdata}; Date: `c(current_date)', considering an OS `c(os)' for the user: `c(username)'"
. }

. else display "This file does not exist"
This file does not exist

. 
. mata : st_numscalar("OK", direxists("G:\Mi unidad\Alvacast\SISTRAT 2019 (github)\_mult_state_ags\"))

. if scalar(OK) == 1 {
.         cap noi cd "G:\Mi unidad\Alvacast\SISTRAT 2019 (github)\_mult_state_ags"
.         global pathdata "G:\Mi unidad\Alvacast\SISTRAT 2019 (github)\_mult_state_ags"
.         global pathdata2 "G:/Mi unidad/Alvacast/SISTRAT 2019 (github)/_mult_state_ags/"
.         di "Location= ${pathdata}; Date: `c(current_date)', considering an OS `c(os)' for the user: `c(username)'"
. }

. else display "This file does not exist"
This file does not exist

.                 
. mata : st_numscalar("OK", direxists("C:\Users\CISS Fondecyt\Mi unidad\Alvacast\SISTRAT 2019 (github)\_mult_state_ags\"))

. if scalar(OK) == 1 {
.         cap noi cd "C:\Users\CISS Fondecyt\Mi unidad\Alvacast\SISTRAT 2019 (github)"
C:\Users\CISS Fondecyt\Mi unidad\Alvacast\SISTRAT 2019 (github)
.         global pathdata "C:\Users\CISS Fondecyt\Mi unidad\Alvacast\SISTRAT 2019 (github)\_mult_state_ags"
.         global pathdata2 "C:/Users/CISS Fondecyt/Mi unidad/Alvacast/SISTRAT 2019 (github)/_mult_state_ags/"
.         di "Location= ${pathdata}; Date: `c(current_date)', considering an OS `c(os)' for the user: `c(username)'"
Location= C:\Users\CISS Fondecyt\Mi unidad\Alvacast\SISTRAT 2019 (github)\_mult_state_ags; Date:  4 Aug 2022, considering an OS Windows for the user: CISS Fondecyt
. }

. else display "This file does not exist"

. 
. mata : st_numscalar("OK", direxists("C:\Users\andre\Desktop\_mult_state_ags\"))

. if scalar(OK) == 1 {
.         cap noi cd "C:\Users\andre\Desktop\_mult_state_ags"
.         global pathdata "C:\Users\andre\Desktop\_mult_state_ags"
.         global pathdata2 "C:/Users/andre/Desktop/_mult_state_ags/"
.         di "Location= ${pathdata}; Date: `c(current_date)', considering an OS `c(os)' for the user: `c(username)'"
. }

. else display "This file does not exist"
This file does not exist

. 
. mata : st_numscalar("OK", direxists("C:\Users\CISS Fondecyt\OneDrive\Documentos\"))

. if scalar(OK) == 1 {
.         cap noi cd "C:\Users\CISS Fondecyt\Mi unidad\Alvacast\SISTRAT 2019 (github)\_mult_state_ags"
C:\Users\CISS Fondecyt\Mi unidad\Alvacast\SISTRAT 2019 (github)\_mult_state_ags
.         global pathdata "C:\Users\CISS Fondecyt\Mi unidad\Alvacast\SISTRAT 2019 (github)\_mult_state_ags"
.         global pathdata2 "C:/Users/CISS Fondecyt/Mi unidad/Alvacast/SISTRAT 2019 (github)/_mult_state_ags/"
.         di "Location= ${pathdata}; Date: `c(current_date)', considering an OS `c(os)' for the user: `c(username)'"
Location= C:\Users\CISS Fondecyt\Mi unidad\Alvacast\SISTRAT 2019 (github)\_mult_state_ags; Date:  4 Aug 2022, considering an OS Windows for the user: CISS Fondecyt
. }

. else display "This file does not exist"

. 

Path data= C:\Users\CISS Fondecyt\Mi unidad\Alvacast\SISTRAT 2019 (github)_mult_state_ags;

Timestamp: 4 Aug 2022, considering that is a Windows OS for the username: CISS Fondecyt

The file is located and named as: C:/Users/CISS Fondecyt/Mi unidad/Alvacast/SISTRAT 2019 (github)/_mult_state_ags/archivo_multiestado2_jun_22.dta

. use “${pathdata2}archivo_multiestado2_jun_22.dta”, clear

. gen timevar01 = timevar0/365.25 (31,275 missing values generated)

. gen _t_scaled= _t/365.25

. *a= Ambulatory . *b= residential . . *.24640657 =90 days . *.48537963 = 6 months . *.98987835 = 1 year . *3.0078732 = 3 years . *4.9993157 = 5 years

Defined transition matrix.

=============================================================================

Tables- Residential vs. Ambulatory of the First Treatment (At 3 years)

=============================================================================

PR_Residential_vs_Ambulatory_3y_First transition

. 
. *fdiff_prob_from-> diff. between residential and ambulatory treatment
. *fdiff_prob_from1_2_lci_rp_0 fdiff_prob_from1_2_uci_rp_0 fdiff_prob_from1_2_rp_0
. *fdiff_prob_from1_2_lci_rp_3y fdiff_prob_from1_2_uci_rp_3y fdiff_prob_from1_2_rp_3y
. *fdiff_prob_from1_2_lci_0_2 fdiff_prob_from1_2_uci_0_2 fdiff_prob_from1_2_0_2
. *fdiff_prob_from1_2_lci_3y_2 fdiff_prob_from1_2_uci_3y_2 fdiff_prob_from1_2_3y_2
. *fprob2_from1a_*_3y- 
. 
. foreach var of varlist fdiff_prob_from1_2_3y fdiff_prob_from1_2_lci_3y fdiff_prob_from1_2_uci_3y fdiff2_prob_from1_2_3y fdiff2_prob_from1_2_lci_3y fdiff2_prob_from1_2_uci_3y {
  2.                 scalar variable = "`var'"
  3.                                         qui summarize `var' if inrange(timevar01, .32, .34)
  4.                                         scalar e3m_`var' = round(round(r(mean),.001)*100,.1)
  5.                                         qui summarize `var' if inrange(timevar01, .999, 1.02)
  6.                                         scalar e1y_`var' = round(round(r(mean),.001)*100,.1)
  7.                                         qui summarize `var' if inrange(timevar01, 2.99, 3.02)
  8.                                         scalar e3y_`var' = round(round(r(mean),.001)*100,.1)
  9.                                         qui summarize `var' if inrange(timevar01,  4.999, 5.02)
 10.                                         scalar e5y_`var' = round(round(r(mean),.001)*100,.1)
 11.         // di %9.2f "`var': " "3 months" "(`=scalar(e3m_`var')')" "; 1 year"  "(`=scalar(e1y_`var')')" "; 3 years"  "(`=scalar(e3y_`var')')" "; 5 years" "(`=scalar(e5y_`var')')"
.          cap noi matrix ests_`var' = (`=scalar(e3m_`var')'\  `=scalar(e1y_`var')'\ `=scalar(scalar(e3y_`var'))'\ `=scalar(scalar(e5y_`var'))')
 12.          matrix colnames ests_`var' = `var'
 13.          matrix rownames ests_`var' = 3_mths 1_yr 3_yrs 5_yrs
 14.                 }

. 
. matrix est_diff11 = (ests_fdiff_prob_from1_2_3y, ests_fdiff_prob_from1_2_lci_3y, ests_fdiff_prob_from1_2_uci_3y, ests_fdiff2_prob_from1_2_3y, ests_fdiff2_prob_from1_2_lci_3y, ests_fdiff2_prob_from1_2_uci_3y)

. matrix colnames est_diff11 =  "Not_Completed" "Not_Completed_lo" "Not_Completed_hi" "Completed" "Completed_lo" "Completed_hi" 

. 
. esttab matrix(est_diff11) using "${pathdata2}diff_probs_res_out_mod_t1_3y_22.html", replace 
(output written to C:/Users/CISS Fondecyt/Mi unidad/Alvacast/SISTRAT 2019 (github)/_mult_state_ags/diff_probs_res_out_mod_t1_3y_22.html)

The transition probabilities are presented here:


est_diff11
Not_CompletedNot_Completed_loNot_Completed_hi CompletedCompleted_loCompleted_hi

3_mths 2.8 2.4 3.2 1.3 1.1 1.5
1_yr 6.3 5.6 7.1 4.3 3.8 4.8
3_yrs 6.7 5.8 7.6 6.2 5.5 7
5_yrs 6 5 6.9 5.9 5.1 6.7

PR_Residential_vs_Ambulatory_3y_Second transition

. foreach var of varlist fdiff_prob_from2_3_3y fdiff_prob_from2_3_lci_3y fdiff_prob_from2_3_uci_3y fdiff2_prob_from2_3_3y fdiff2_prob_from2_3_lci_3y fdiff2_prob_from2_3_uci_3y  {
  2.                 scalar variable = "`var'"
  3.                                         qui summarize `var' if inrange(timevar01, .32, .34)
  4.                                         scalar e3m_`var' = round(round(r(mean),.001)*100,.1)
  5.                                         qui summarize `var' if inrange(timevar01, .999, 1.02)
  6.                                         scalar e1y_`var' = round(round(r(mean),.001)*100,.1)
  7.                                         qui summarize `var' if inrange(timevar01, 2.99, 3.02)
  8.                                         scalar e3y_`var' = round(round(r(mean),.001)*100,.1)
  9.                                         qui summarize `var' if inrange(timevar01,  4.999, 5.02)
 10.                                         scalar e5y_`var' = round(round(r(mean),.001)*100,.1)
 11.         // di %9.2f "`var': " "3 months" "(`=scalar(e3m_`var')')" "; 1 year"  "(`=scalar(e1y_`var')')" "; 3 years"  "(`=scalar(e3y_`var')')" "; 5 years" "(`=scalar(e5y_`var')')"
.          cap noi matrix ests_`var' = (`=scalar(e3m_`var')'\  `=scalar(e1y_`var')'\ `=scalar(scalar(e3y_`var'))'\ `=scalar(scalar(e5y_`var'))')
 12.          matrix colnames ests_`var' = `var'
 13.          matrix rownames ests_`var' = 3_mths 1_yr 3_yrs 5_yrs
 14.                 }

. 
. matrix est_diff21 = (ests_fdiff_prob_from2_3_3y, ests_fdiff_prob_from2_3_lci_3y, ests_fdiff_prob_from2_3_uci_3y, ests_fdiff2_prob_from2_3_3y, ests_fdiff2_prob_from2_3_lci_3y, ests_fdiff2_prob_from2_3_uci_3y)

. matrix colnames est_diff21 =  "Not_Completed" "Not_Completed_lo" "Not_Completed_hi" "Completed" "Completed_lo" "Completed_hi" 

. 
. esttab matrix(est_diff21) using "${pathdata2}diff_probs_res_out_mod_t2_3y_22.html", replace 
(output written to C:/Users/CISS Fondecyt/Mi unidad/Alvacast/SISTRAT 2019 (github)/_mult_state_ags/diff_probs_res_out_mod_t2_3y_22.html)

The transition probabilities are presented here:


est_diff21
Not_CompletedNot_Completed_loNot_Completed_hi CompletedCompleted_loCompleted_hi

3_mths 0 -.5 .6 0 -.6 .6
1_yr .1 -1.1 1.4 .2 -1.2 1.5
3_yrs -.8 -2.5 .9 -.6 -2.4 1.1
5_yrs -1.2 -3 .7 -1 -2.9 .9

PR_Residential_vs_Ambulatory_3y_Third transition

. foreach var of varlist fdiff_prob_from3_4_3y fdiff_prob_from3_4_lci_3y fdiff_prob_from3_4_uci_3y fdiff2_prob_from3_4_3y fdiff2_prob_from3_4_lci_3y fdiff2_prob_from3_4_uci_3y  {
  2.                 scalar variable = "`var'"
  3.                                         qui summarize `var' if inrange(timevar01, .32, .34)
  4.                                         scalar e3m_`var' = round(round(r(mean),.001)*100,.1)
  5.                                         qui summarize `var' if inrange(timevar01, .999, 1.02)
  6.                                         scalar e1y_`var' = round(round(r(mean),.001)*100,.1)
  7.                                         qui summarize `var' if inrange(timevar01, 2.99, 3.02)
  8.                                         scalar e3y_`var' = round(round(r(mean),.001)*100,.1)
  9.                                         qui summarize `var' if inrange(timevar01,  4.999, 5.02)
 10.                                         scalar e5y_`var' = round(round(r(mean),.001)*100,.1)
 11.          // di %9.2f "`var': " "3 months" "(`=scalar(e3m_`var')')" "; 1 year"  "(`=scalar(e1y_`var')')" "; 3 years"  "(`=scalar(e3y_`var')')" "; 5 years" "(`=scalar(e5y_`var')')"
.          cap noi matrix ests_`var' = (`=scalar(e3m_`var')'\  `=scalar(e1y_`var')'\ `=scalar(scalar(e3y_`var'))'\ `=scalar(scalar(e5y_`var'))')
 12.          matrix colnames ests_`var' = `var'
 13.          matrix rownames ests_`var' = 3_mths 1_yr 3_yrs 5_yrs
 14.                 }

. 
. matrix est_diff31 = (ests_fdiff_prob_from3_4_3y, ests_fdiff_prob_from3_4_lci_3y, ests_fdiff_prob_from3_4_uci_3y, ests_fdiff2_prob_from3_4_3y, ests_fdiff2_prob_from3_4_lci_3y, ests_fdiff2_prob_from3_4_uci_3y)

. matrix colnames est_diff31 =  "Not_Completed" "Not_Completed_lo" "Not_Completed_hi" "Completed" "Completed_lo" "Completed_hi" 

. 
. esttab matrix(est_diff31) using "${pathdata2}diff_probs_res_out_mod_t3_3y_22.html", replace 
(output written to C:/Users/CISS Fondecyt/Mi unidad/Alvacast/SISTRAT 2019 (github)/_mult_state_ags/diff_probs_res_out_mod_t3_3y_22.html)

The transition probabilities are presented here:


est_diff31
Not_CompletedNot_Completed_loNot_Completed_hi CompletedCompleted_loCompleted_hi

3_mths 1.2 0 2.4 1.2 .1 2.3
1_yr 2.7 .1 5.3 2.8 .3 5.4
3_yrs 2.2 -1.2 5.5 2.8 -.6 6.1
5_yrs 1.3 -2.5 5.2 1.7 -2.1 5.5

PR_Residential_vs_Ambulatory_3y_Fourth transition

. foreach var of varlist fdiff_prob_from4_5_3y fdiff_prob_from4_5_lci_3y fdiff_prob_from4_5_uci_3y fdiff2_prob_from4_5_3y fdiff2_prob_from4_5_lci_3y fdiff2_prob_from4_5_uci_3y  {
  2.                 scalar variable = "`var'"
  3.                                         qui summarize `var' if inrange(timevar01, .32, .34)
  4.                                         scalar e3m_`var' = round(round(r(mean),.001)*100,.1)
  5.                                         qui summarize `var' if inrange(timevar01, .999, 1.02)
  6.                                         scalar e1y_`var' = round(round(r(mean),.001)*100,.1)
  7.                                         qui summarize `var' if inrange(timevar01, 2.99, 3.02)
  8.                                         scalar e3y_`var' = round(round(r(mean),.001)*100,.1)
  9.                                         qui summarize `var' if inrange(timevar01,  4.999, 5.02)
 10.                                         scalar e5y_`var' = round(round(r(mean),.001)*100,.1)
 11.          // di %9.2f "`var': " "3 months" "(`=scalar(e3m_`var')')" "; 1 year"  "(`=scalar(e1y_`var')')" "; 3 years"  "(`=scalar(e3y_`var')')" "; 5 years" "(`=scalar(e5y_`var')')"
.          cap noi matrix ests_`var' = (`=scalar(e3m_`var')'\  `=scalar(e1y_`var')'\ `=scalar(scalar(e3y_`var'))'\ `=scalar(scalar(e5y_`var'))')
 12.          matrix colnames ests_`var' = `var'
 13.          matrix rownames ests_`var' = 3_mths 1_yr 3_yrs 5_yrs
 14.                 }

. 
. matrix est_diff41 = (ests_fdiff_prob_from4_5_3y, ests_fdiff_prob_from4_5_lci_3y, ests_fdiff_prob_from4_5_uci_3y, ests_fdiff2_prob_from4_5_3y, ests_fdiff2_prob_from4_5_lci_3y, ests_fdiff2_prob_from4_5_uci_3y)

. matrix colnames est_diff41 = "Not_Completed" "Not_Completed_lo" "Not_Completed_hi" "Completed" "Completed_lo" "Completed_hi"

. 
. esttab matrix(est_diff41) using "${pathdata2}diff_probs_res_out_mod_t4_3y_22.html", replace 
(output written to C:/Users/CISS Fondecyt/Mi unidad/Alvacast/SISTRAT 2019 (github)/_mult_state_ags/diff_probs_res_out_mod_t4_3y_22.html)

The transition probabilities are presented here:


est_diff41
Not_CompletedNot_Completed_loNot_Completed_hi CompletedCompleted_loCompleted_hi

3_mths .3 -2 2.6 .3 -1.8 2.3
1_yr .7 -4.6 6.1 .8 -4.2 5.7
3_yrs 1.3 -6.3 9 1.3 -6.2 8.7
5_yrs 1.6 -6.3 9.4 1.6 -6.3 9.4

PR_Residential_vs_Ambulatory_3y_RP_First transition

We had to rename some columns due to the extension of the variable name.

. **rename columns
. 
. local trans `" "1_2" "2_3" "3_4" "4_5" "' 

. local names `" "_3y_rp" "_lci_3y_rp" "_uci_3y_rp" "' 

. local fdiff `" "fdiff" "fdiff2" "' 

. foreach opts in `trans' {
  2. foreach c in `names' {
  3. local fd `" "fd" "fd2" "' 
  4. foreach fdiffmod in `fdiff' {
  5.         gettoken fdmod fd:fd
  6.         local dbname `fdiffmod'_prob_from`opts'`c'
  7.         local dbnameout `fdmod'_pr_from`opts'`c'
  8.         local new = "From `dbname' to `dbnameout'"
  9.         di "`new'"
 10.         cap noi gen `dbnameout'=`dbname'
 11.         }
 12.  }
 13. }
From fdiff_prob_from1_2_3y_rp to fd_pr_from1_2_3y_rp
(31,275 missing values generated)
From fdiff2_prob_from1_2_3y_rp to fd2_pr_from1_2_3y_rp
(31,275 missing values generated)
From fdiff_prob_from1_2_lci_3y_rp to fd_pr_from1_2_lci_3y_rp
(31,275 missing values generated)
From fdiff2_prob_from1_2_lci_3y_rp to fd2_pr_from1_2_lci_3y_rp
(31,275 missing values generated)
From fdiff_prob_from1_2_uci_3y_rp to fd_pr_from1_2_uci_3y_rp
(31,275 missing values generated)
From fdiff2_prob_from1_2_uci_3y_rp to fd2_pr_from1_2_uci_3y_rp
(31,275 missing values generated)
From fdiff_prob_from2_3_3y_rp to fd_pr_from2_3_3y_rp
(31,275 missing values generated)
From fdiff2_prob_from2_3_3y_rp to fd2_pr_from2_3_3y_rp
(31,275 missing values generated)
From fdiff_prob_from2_3_lci_3y_rp to fd_pr_from2_3_lci_3y_rp
(31,275 missing values generated)
From fdiff2_prob_from2_3_lci_3y_rp to fd2_pr_from2_3_lci_3y_rp
(31,275 missing values generated)
From fdiff_prob_from2_3_uci_3y_rp to fd_pr_from2_3_uci_3y_rp
(31,275 missing values generated)
From fdiff2_prob_from2_3_uci_3y_rp to fd2_pr_from2_3_uci_3y_rp
(31,275 missing values generated)
From fdiff_prob_from3_4_3y_rp to fd_pr_from3_4_3y_rp
(31,275 missing values generated)
From fdiff2_prob_from3_4_3y_rp to fd2_pr_from3_4_3y_rp
(31,275 missing values generated)
From fdiff_prob_from3_4_lci_3y_rp to fd_pr_from3_4_lci_3y_rp
(31,275 missing values generated)
From fdiff2_prob_from3_4_lci_3y_rp to fd2_pr_from3_4_lci_3y_rp
(31,275 missing values generated)
From fdiff_prob_from3_4_uci_3y_rp to fd_pr_from3_4_uci_3y_rp
(31,275 missing values generated)
From fdiff2_prob_from3_4_uci_3y_rp to fd2_pr_from3_4_uci_3y_rp
(31,275 missing values generated)
From fdiff_prob_from4_5_3y_rp to fd_pr_from4_5_3y_rp
(31,275 missing values generated)
From fdiff2_prob_from4_5_3y_rp to fd2_pr_from4_5_3y_rp
(31,275 missing values generated)
From fdiff_prob_from4_5_lci_3y_rp to fd_pr_from4_5_lci_3y_rp
(31,275 missing values generated)
From fdiff2_prob_from4_5_lci_3y_rp to fd2_pr_from4_5_lci_3y_rp
(31,275 missing values generated)
From fdiff_prob_from4_5_uci_3y_rp to fd_pr_from4_5_uci_3y_rp
(31,275 missing values generated)
From fdiff2_prob_from4_5_uci_3y_rp to fd2_pr_from4_5_uci_3y_rp
(31,275 missing values generated)

. *fdiff_prob_from-> diff. between residential and ambulatory treatment
. *fdiff_prob_from1_2_lci_rp_0 fdiff_prob_from1_2_uci_rp_0 fdiff_prob_from1_2_rp_0
. *fdiff_prob_from1_2_lci_rp_3y fdiff_prob_from1_2_uci_rp_3y fdiff_prob_from1_2_rp_3y
. *fdiff_prob_from1_2_lci_0_2 fdiff_prob_from1_2_uci_0_2 fdiff_prob_from1_2_0_2
. *fdiff_prob_from1_2_lci_3y_2 fdiff_prob_from1_2_uci_3y_2 fdiff_prob_from1_2_3y_2
. *fprob2_from1a_*_3y- 
. 
. foreach var of varlist fd_pr_from1_2_3y_rp fd_pr_from1_2_lci_3y_rp fd_pr_from1_2_uci_3y_rp fd2_pr_from1_2_3y_rp fd2_pr_from1_2_lci_3y_rp fd2_pr_from1_2_uci_3y_rp {
  2.                 scalar variable = "`var'"
  3.                                         qui summarize `var' if inrange(timevar01, .32, .34)
  4.                                         scalar e3m_`var' = round(round(r(mean),.001)*100,.1)
  5.                                         qui summarize `var' if inrange(timevar01, .999, 1.02)
  6.                                         scalar e1y_`var' = round(round(r(mean),.001)*100,.1)
  7.                                         qui summarize `var' if inrange(timevar01, 2.99, 3.02)
  8.                                         scalar e3y_`var' = round(round(r(mean),.001)*100,.1)
  9.                                         qui summarize `var' if inrange(timevar01,  4.999, 5.02)
 10.                                         scalar e5y_`var' = round(round(r(mean),.001)*100,.1)
 11.          cap noi matrix ests_`var' = (`=scalar(e3m_`var')'\  `=scalar(e1y_`var')'\ `=scalar(scalar(e3y_`var'))'\ `=scalar(scalar(e5y_`var'))')
 12.          matrix colnames ests_`var' = `var'
 13.          matrix rownames ests_`var' = 3_mths 1_yr 3_yrs 5_yrs
 14.                 }

. matrix est_diff12 = (ests_fd_pr_from1_2_3y_rp, ests_fd_pr_from1_2_lci_3y_rp, ests_fd_pr_from1_2_uci_3y_rp, ests_fd2_pr_from1_2_3y_rp, ests_fd2_pr_from1_2_lci_3y_rp, ests_fd2_pr_from1_2_uci_3y_rp)

. matrix colnames est_diff12 =  "Not_Completed" "Not_Completed_lo" "Not_Completed_hi" "Completed" "Completed_lo" "Completed_hi" 

. 
. esttab matrix(est_diff12) using "${pathdata2}diff_probs_res_out_mod_t1_3y_rp_22.html", replace 
(output written to C:/Users/CISS Fondecyt/Mi unidad/Alvacast/SISTRAT 2019 (github)/_mult_state_ags/diff_probs_res_out_mod_t1_3y_rp_22.html)

The transition probabilities are presented here:


est_diff12
Not_CompletedNot_Completed_loNot_Completed_hi CompletedCompleted_loCompleted_hi

3_mths .7 .6 .9 .7 .5 .8
1_yr 3.7 3.1 4.2 3.3 2.8 3.8
3_yrs 6.7 5.7 7.8 5.7 4.8 6.6
5_yrs 7 5.8 8.2 5.8 4.8 6.9

PR_Residential_vs_Ambulatory_3y_RP_Second transition

. foreach var of varlist fd_pr_from2_3_3y_rp fd_pr_from2_3_lci_3y_rp fd_pr_from2_3_uci_3y_rp fd2_pr_from2_3_3y_rp fd2_pr_from2_3_lci_3y_rp fd2_pr_from2_3_uci_3y_rp {
  2.                 scalar variable = "`var'"
  3.                                         qui summarize `var' if inrange(timevar01, .32, .34)
  4.                                         scalar e3m_`var' = round(round(r(mean),.001)*100,.1)
  5.                                         qui summarize `var' if inrange(timevar01, .999, 1.02)
  6.                                         scalar e1y_`var' = round(round(r(mean),.001)*100,.1)
  7.                                         qui summarize `var' if inrange(timevar01, 2.99, 3.02)
  8.                                         scalar e3y_`var' = round(round(r(mean),.001)*100,.1)
  9.                                         qui summarize `var' if inrange(timevar01,  4.999, 5.02)
 10.                                         scalar e5y_`var' = round(round(r(mean),.001)*100,.1)
 11.          cap noi matrix ests_`var' = (`=scalar(e3m_`var')'\  `=scalar(e1y_`var')'\ `=scalar(scalar(e3y_`var'))'\ `=scalar(scalar(e5y_`var'))')
 12.          matrix colnames ests_`var' = `var'
 13.          matrix rownames ests_`var' = 3_mths 1_yr 3_yrs 5_yrs
 14.                 }

. 
. matrix est_diff22 = (ests_fd_pr_from2_3_3y_rp, ests_fd_pr_from2_3_lci_3y_rp, ests_fd_pr_from2_3_uci_3y_rp, ests_fd2_pr_from2_3_3y_rp, ests_fd2_pr_from2_3_lci_3y_rp, ests_fd2_pr_from2_3_uci_3y_rp)

. matrix colnames est_diff22 =  "Not_Completed" "Not_Completed_lo" "Not_Completed_hi" "Completed" "Completed_lo" "Completed_hi" 

. 
. esttab matrix(est_diff22) using "${pathdata2}diff_probs_res_out_mod_t2_3y_rp_22.html", replace 
(output written to C:/Users/CISS Fondecyt/Mi unidad/Alvacast/SISTRAT 2019 (github)/_mult_state_ags/diff_probs_res_out_mod_t2_3y_rp_22.html)

The transition probabilities are presented here:


est_diff22
Not_CompletedNot_Completed_loNot_Completed_hi CompletedCompleted_loCompleted_hi

3_mths 0 -.3 .3 0 -.3 .3
1_yr .5 -.5 1.5 .3 -.7 1.4
3_yrs 0 -2 1.9 0 -1.9 2
5_yrs -.4 -2.7 1.9 -.5 -2.8 1.9

PR_Residential_vs_Ambulatory_3y_RP_Third transition

. foreach var of varlist fd_pr_from3_4_3y_rp fd_pr_from3_4_lci_3y_rp fd_pr_from3_4_uci_3y_rp fd2_pr_from3_4_3y_rp fd2_pr_from3_4_lci_3y_rp fd2_pr_from3_4_uci_3y_rp {
  2.                 scalar variable = "`var'"
  3.                                         qui summarize `var' if inrange(timevar01, .32, .34)
  4.                                         scalar e3m_`var' = round(round(r(mean),.001)*100,.1)
  5.                                         qui summarize `var' if inrange(timevar01, .999, 1.02)
  6.                                         scalar e1y_`var' = round(round(r(mean),.001)*100,.1)
  7.                                         qui summarize `var' if inrange(timevar01, 2.99, 3.02)
  8.                                         scalar e3y_`var' = round(round(r(mean),.001)*100,.1)
  9.                                         qui summarize `var' if inrange(timevar01,  4.999, 5.02)
 10.                                         scalar e5y_`var' = round(round(r(mean),.001)*100,.1)
 11.          cap noi matrix ests_`var' = (`=scalar(e3m_`var')'\  `=scalar(e1y_`var')'\ `=scalar(scalar(e3y_`var'))'\ `=scalar(scalar(e5y_`var'))')
 12.          matrix colnames ests_`var' = `var'
 13.          matrix rownames ests_`var' = 3_mths 1_yr 3_yrs 5_yrs
 14.                 }

. 
. matrix est_diff32 = (ests_fd_pr_from3_4_3y_rp, ests_fd_pr_from3_4_lci_3y_rp, ests_fd_pr_from3_4_uci_3y_rp, ests_fd2_pr_from3_4_3y_rp, ests_fd2_pr_from3_4_lci_3y_rp, ests_fd2_pr_from3_4_uci_3y_rp)

. matrix colnames est_diff32 =  "Not_Completed" "Not_Completed_lo" "Not_Completed_hi" "Completed" "Completed_lo" "Completed_hi" 

. 
. esttab matrix(est_diff32) using "${pathdata2}diff_probs_res_out_mod_t3_3y_rp_22.html", replace 
(output written to C:/Users/CISS Fondecyt/Mi unidad/Alvacast/SISTRAT 2019 (github)/_mult_state_ags/diff_probs_res_out_mod_t3_3y_rp_22.html)

The transition probabilities are presented here:


est_diff32
Not_CompletedNot_Completed_loNot_Completed_hi CompletedCompleted_loCompleted_hi

3_mths .3 -.2 .8 .2 -.3 .7
1_yr 1.4 -.7 3.5 1.1 -.9 3
3_yrs 1.1 -2.8 4.9 .6 -3 4.3
5_yrs .1 -4.6 4.9 0 -4.5 4.4

PR_Residential_vs_Ambulatory_3y_RP_Fourth transition

. foreach var of varlist fd_pr_from4_5_3y_rp fd_pr_from4_5_lci_3y_rp fd_pr_from4_5_uci_3y_rp fd2_pr_from4_5_3y_rp fd2_pr_from4_5_lci_3y_rp fd2_pr_from4_5_uci_3y_rp {
  2.                 scalar variable = "`var'"
  3.                                         qui summarize `var' if inrange(timevar01, .32, .34)
  4.                                         scalar e3m_`var' = round(round(r(mean),.001)*100,.1)
  5.                                         qui summarize `var' if inrange(timevar01, .999, 1.02)
  6.                                         scalar e1y_`var' = round(round(r(mean),.001)*100,.1)
  7.                                         qui summarize `var' if inrange(timevar01, 2.99, 3.02)
  8.                                         scalar e3y_`var' = round(round(r(mean),.001)*100,.1)
  9.                                         qui summarize `var' if inrange(timevar01,  4.999, 5.02)
 10.                                         scalar e5y_`var' = round(round(r(mean),.001)*100,.1)
 11.          cap noi matrix ests_`var' = (`=scalar(e3m_`var')'\  `=scalar(e1y_`var')'\ `=scalar(scalar(e3y_`var'))'\ `=scalar(scalar(e5y_`var'))')
 12.          matrix colnames ests_`var' = `var'
 13.          matrix rownames ests_`var' = 3_mths 1_yr 3_yrs 5_yrs
 14.                 }

. 
. matrix est_diff42 = (ests_fd_pr_from4_5_3y_rp, ests_fd_pr_from4_5_lci_3y_rp, ests_fd_pr_from4_5_uci_3y_rp, ests_fd2_pr_from4_5_3y_rp, ests_fd2_pr_from4_5_lci_3y_rp, ests_fd2_pr_from4_5_uci_3y_rp)

. matrix colnames est_diff42 = "Not_Completed" "Not_Completed_lo" "Not_Completed_hi" "Completed" "Completed_lo" "Completed_hi"

. 
. esttab matrix(est_diff42) using "${pathdata2}diff_probs_res_out_mod_t4_3y_rp_22.html", replace 
(output written to C:/Users/CISS Fondecyt/Mi unidad/Alvacast/SISTRAT 2019 (github)/_mult_state_ags/diff_probs_res_out_mod_t4_3y_rp_22.html)

The transition probabilities are presented here:


est_diff42
Not_CompletedNot_Completed_loNot_Completed_hi CompletedCompleted_loCompleted_hi

3_mths .4 -.9 1.7 .4 -.8 1.5
1_yr 1.5 -3.1 6.1 1.5 -2.7 5.7
3_yrs 3.5 -5.6 12.4 3.2 -5.2 11.6
5_yrs 4 -6 13.8 3.7 -5.7 13.1

PR_Export_differences_between_residential_and_ambulatory

. ************************************
. ********************NOT COMPLETED****************************************************
. ************************************
. local x `""1_2_0" "1_2_lci_0" "1_2_uci_0""' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff_prob_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_prob", modify) cell(B1) firstrow(variables) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "2_3_0" "2_3_lci_0" "2_3_uci_0" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff_prob_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_prob", modify) cell(B6) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "3_4_0" "3_4_lci_0" "3_4_uci_0" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff_prob_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_prob", modify) cell(B10) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "4_5_0" "4_5_lci_0" "4_5_uci_0" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff_prob_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_prob", modify) cell(B14) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "1_2_0_rp" "1_2_lci_0_rp" "1_2_uci_0_rp" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff_prob_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_prob", modify) cell(B18) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "2_3_0_rp" "2_3_lci_0_rp" "2_3_uci_0_rp" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff_prob_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_prob", modify) cell(B22) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "3_4_0_rp" "3_4_lci_0_rp" "3_4_uci_0_rp" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff_prob_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_prob", modify) cell(B26) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "4_5_0_rp" "4_5_lci_0_rp" "4_5_uci_0_rp" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff_prob_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_prob", modify) cell(B30) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. 
. local x `""1_2_3y" "1_2_lci_3y" "1_2_uci_3y""' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff_prob_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_prob", modify) cell(B34) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "2_3_3y" "2_3_lci_3y" "2_3_uci_3y" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff_prob_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_prob", modify) cell(B38) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "3_4_3y" "3_4_lci_3y" "3_4_uci_3y" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff_prob_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_prob", modify) cell(B42) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "4_5_3y" "4_5_lci_3y" "4_5_uci_3y" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff_prob_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_prob", modify) cell(B46) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "1_2_3y_rp" "1_2_lci_3y_rp" "1_2_uci_3y_rp" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff_prob_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_prob", modify) cell(B50) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "2_3_3y_rp" "2_3_lci_3y_rp" "2_3_uci_3y_rp" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff_prob_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_prob", modify) cell(B54) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "3_4_3y_rp" "3_4_lci_3y_rp" "3_4_uci_3y_rp" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff_prob_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_prob", modify) cell(B58) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "4_5_3y_rp" "4_5_lci_3y_rp" "4_5_uci_3y_rp" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff_prob_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_prob", modify) cell(B62) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

.         
. ************************************
. ********************COMPLETED****************************************************
. ************************************
. local x `""1_2_3y" "1_2_lci_3y" "1_2_uci_3y""' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff2_prob_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_prob2", modify) cell(B1) firstrow(variables) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "2_3_3y" "2_3_lci_3y" "2_3_uci_3y" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff2_prob_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_prob2", modify) cell(B6) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "3_4_3y" "3_4_lci_3y" "3_4_uci_3y" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff2_prob_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_prob2", modify) cell(B10) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "4_5_3y" "4_5_lci_3y" "4_5_uci_3y" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff2_prob_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_prob2", modify) cell(B14) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "1_2_3y_rp" "1_2_lci_3y_rp" "1_2_uci_3y_rp" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff2_prob_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_prob2", modify) cell(B18) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "2_3_3y_rp" "2_3_lci_3y_rp" "2_3_uci_3y_rp" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff2_prob_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_prob2", modify) cell(B22) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "3_4_3y_rp" "3_4_lci_3y_rp" "3_4_uci_3y_rp" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff2_prob_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_prob2", modify) cell(B26) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "4_5_3y_rp" "4_5_lci_3y_rp" "4_5_uci_3y_rp" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff2_prob_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_prob2", modify) cell(B30) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

LOS_Residential_vs_Ambulatory_3y_First transition

. 
. *fdiff_prob_from-> diff. between residential and ambulatory treatment
. *fdiff_prob_from1_2_lci_rp_0 fdiff_prob_from1_2_uci_rp_0 fdiff_prob_from1_2_rp_0
. *fdiff_prob_from1_2_lci_rp_3y fdiff_prob_from1_2_uci_rp_3y fdiff_prob_from1_2_rp_3y
. *fdiff_prob_from1_2_lci_0_2 fdiff_prob_from1_2_uci_0_2 fdiff_prob_from1_2_0_2
. *fdiff_prob_from1_2_lci_3y_2 fdiff_prob_from1_2_uci_3y_2 fdiff_prob_from1_2_3y_2
. *fprob2_from1a_*_3y- 
. 
. foreach var of varlist fdiff_los_from1_2_3y fdiff_los_from1_2_lci_3y fdiff_los_from1_2_uci_3y fdiff2_los_from1_2_3y fdiff2_los_from1_2_lci_3y fdiff2_los_from1_2_uci_3y {
  2.                 scalar variable = "`var'"
  3.                                         qui summarize `var' if inrange(timevar01, .32, .34)
  4.                                         scalar e3m_`var' = round(round(r(mean),.001)*1,.1)
  5.                                         qui summarize `var' if inrange(timevar01, .999, 1.02)
  6.                                         scalar e1y_`var' = round(round(r(mean),.001)*1,.1)
  7.                                         qui summarize `var' if inrange(timevar01, 2.99, 3.02)
  8.                                         scalar e3y_`var' = round(round(r(mean),.001)*1,.1)
  9.                                         qui summarize `var' if inrange(timevar01,  4.999, 5.02)
 10.                                         scalar e5y_`var' = round(round(r(mean),.001)*1,.1)
 11.         // di %9.2f "`var': " "3 months" "(`=scalar(e3m_`var')')" "; 1 year"  "(`=scalar(e1y_`var')')" "; 3 years"  "(`=scalar(e3y_`var')')" "; 5 years" "(`=scalar(e5y_`var')')"
.          cap noi matrix ests_`var' = (`=scalar(e3m_`var')'\  `=scalar(e1y_`var')'\ `=scalar(scalar(e3y_`var'))'\ `=scalar(scalar(e5y_`var'))')
 12.          matrix colnames ests_`var' = `var'
 13.          matrix rownames ests_`var' = 3_mths 1_yr 3_yrs 5_yrs
 14.                 }

. 
. matrix est_diff11_l = (ests_fdiff_los_from1_2_3y, ests_fdiff_los_from1_2_lci_3y, ests_fdiff_los_from1_2_uci_3y, ests_fdiff2_los_from1_2_3y, ests_fdiff2_los_from1_2_lci_3y, ests_fdiff2_los_from1_2_uci_3y)

. matrix colnames est_diff11_l =  "Not_Completed" "Not_Completed_lo" "Not_Completed_hi" "Completed" "Completed_lo" "Completed_hi" 

. 
. esttab matrix(est_diff11_l) using "${pathdata2}diff_los_res_out_mod_t1_3y_22.html", replace 
(output written to C:/Users/CISS Fondecyt/Mi unidad/Alvacast/SISTRAT 2019 (github)/_mult_state_ags/diff_los_res_out_mod_t1_3y_22.html)

The transition probabilities are presented here:


est_diff11_l
Not_CompletedNot_Completed_loNot_Completed_hi CompletedCompleted_loCompleted_hi

3_mths 1.4 1.2 1.6 .5 .4 .6
1_yr 13.9 12.3 15.6 8.1 7.1 9.2
3_yrs 64.9 57.3 72.4 49.1 43.3 54.8
5_yrs 110.9 97.1 124.7 93.8 82.6 104.9

LOS_Residential_vs_Ambulatory_3y_Second transition

. foreach var of varlist fdiff_los_from2_3_3y fdiff_los_from2_3_lci_3y fdiff_los_from2_3_uci_3y fdiff2_los_from2_3_3y fdiff2_los_from2_3_lci_3y fdiff2_los_from2_3_uci_3y  {
  2.                 scalar variable = "`var'"
  3.                                         qui summarize `var' if inrange(timevar01, .32, .34)
  4.                                         scalar e3m_`var' = round(round(r(mean),.001)*1,.1)
  5.                                         qui summarize `var' if inrange(timevar01, .999, 1.02)
  6.                                         scalar e1y_`var' = round(round(r(mean),.001)*1,.1)
  7.                                         qui summarize `var' if inrange(timevar01, 2.99, 3.02)
  8.                                         scalar e3y_`var' = round(round(r(mean),.001)*1,.1)
  9.                                         qui summarize `var' if inrange(timevar01,  4.999, 5.02)
 10.                                         scalar e5y_`var' = round(round(r(mean),.001)*1,.1)
 11.         // di %9.2f "`var': " "3 months" "(`=scalar(e3m_`var')')" "; 1 year"  "(`=scalar(e1y_`var')')" "; 3 years"  "(`=scalar(e3y_`var')')" "; 5 years" "(`=scalar(e5y_`var')')"
.          cap noi matrix ests_`var' = (`=scalar(e3m_`var')'\  `=scalar(e1y_`var')'\ `=scalar(scalar(e3y_`var'))'\ `=scalar(scalar(e5y_`var'))')
 12.          matrix colnames ests_`var' = `var'
 13.          matrix rownames ests_`var' = 3_mths 1_yr 3_yrs 5_yrs
 14.                 }

. 
. matrix est_diff21_l = (ests_fdiff_los_from2_3_3y, ests_fdiff_los_from2_3_lci_3y, ests_fdiff_los_from2_3_uci_3y, ests_fdiff2_los_from2_3_3y, ests_fdiff2_los_from2_3_lci_3y, ests_fdiff2_los_from2_3_uci_3y)

. matrix colnames est_diff21_l =  "Not_Completed" "Not_Completed_lo" "Not_Completed_hi" "Completed" "Completed_lo" "Completed_hi" 

. 
. esttab matrix(est_diff21_l) using "${pathdata2}diff_los_res_out_mod_t2_3y_22.html", replace 
(output written to C:/Users/CISS Fondecyt/Mi unidad/Alvacast/SISTRAT 2019 (github)/_mult_state_ags/diff_los_res_out_mod_t2_3y_22.html)

The transition probabilities are presented here:


est_diff21_l
Not_CompletedNot_Completed_loNot_Completed_hi CompletedCompleted_loCompleted_hi

3_mths 0 -.3 .3 0 -.3 .3
1_yr .3 -2.4 3.1 .3 -2.6 3.2
3_yrs -2.3 -16.2 11.6 -1.9 -16.3 12.5
5_yrs -8.7 -35.2 17.7 -7.7 -34.8 19.4

LOS_Residential_vs_Ambulatory_3y_Third transition

. foreach var of varlist fdiff_los_from3_4_3y fdiff_los_from3_4_lci_3y fdiff_los_from3_4_uci_3y fdiff2_los_from3_4_3y fdiff2_los_from3_4_lci_3y fdiff2_los_from3_4_uci_3y  {
  2.                 scalar variable = "`var'"
  3.                                         qui summarize `var' if inrange(timevar01, .32, .34)
  4.                                         scalar e3m_`var' = round(round(r(mean),.001)*1,.1)
  5.                                         qui summarize `var' if inrange(timevar01, .999, 1.02)
  6.                                         scalar e1y_`var' = round(round(r(mean),.001)*1,.1)
  7.                                         qui summarize `var' if inrange(timevar01, 2.99, 3.02)
  8.                                         scalar e3y_`var' = round(round(r(mean),.001)*1,.1)
  9.                                         qui summarize `var' if inrange(timevar01,  4.999, 5.02)
 10.                                         scalar e5y_`var' = round(round(r(mean),.001)*1,.1)
 11.          // di %9.2f "`var': " "3 months" "(`=scalar(e3m_`var')')" "; 1 year"  "(`=scalar(e1y_`var')')" "; 3 years"  "(`=scalar(e3y_`var')')" "; 5 years" "(`=scalar(e5y_`var')')"
.          cap noi matrix ests_`var' = (`=scalar(e3m_`var')'\  `=scalar(e1y_`var')'\ `=scalar(scalar(e3y_`var'))'\ `=scalar(scalar(e5y_`var'))')
 12.          matrix colnames ests_`var' = `var'
 13.          matrix rownames ests_`var' = 3_mths 1_yr 3_yrs 5_yrs
 14.                 }

. 
. matrix est_diff31_l = (ests_fdiff_los_from3_4_3y, ests_fdiff_los_from3_4_lci_3y, ests_fdiff_los_from3_4_uci_3y, ests_fdiff2_los_from3_4_3y, ests_fdiff2_los_from3_4_lci_3y, ests_fdiff2_los_from3_4_uci_3y)

. matrix colnames est_diff31_l =  "Not_Completed" "Not_Completed_lo" "Not_Completed_hi" "Completed" "Completed_lo" "Completed_hi" 

. 
. esttab matrix(est_diff31_l) using "${pathdata2}diff_los_res_out_mod_t3_3y_22.html", replace 
(output written to C:/Users/CISS Fondecyt/Mi unidad/Alvacast/SISTRAT 2019 (github)/_mult_state_ags/diff_los_res_out_mod_t3_3y_22.html)

The transition probabilities are presented here:


est_diff31_l
Not_CompletedNot_Completed_loNot_Completed_hi CompletedCompleted_loCompleted_hi

3_mths .6 0 1.2 .6 0 1.1
1_yr 5.9 .2 11.6 6.1 .6 11.6
3_yrs 24.4 -2.9 51.7 27.9 .9 54.9
5_yrs 37.1 -14.6 88.9 44.4 -6.9 95.8

LOS_Residential_vs_Ambulatory_3y_Fourth transition

. foreach var of varlist fdiff_los_from4_5_3y fdiff_los_from4_5_lci_3y fdiff_los_from4_5_uci_3y fdiff2_los_from4_5_3y fdiff2_los_from4_5_lci_3y fdiff2_los_from4_5_uci_3y  {
  2.                 scalar variable = "`var'"
  3.                                         qui summarize `var' if inrange(timevar01, .32, .34)
  4.                                         scalar e3m_`var' = round(round(r(mean),.001)*1,.1)
  5.                                         qui summarize `var' if inrange(timevar01, .999, 1.02)
  6.                                         scalar e1y_`var' = round(round(r(mean),.001)*1,.1)
  7.                                         qui summarize `var' if inrange(timevar01, 2.99, 3.02)
  8.                                         scalar e3y_`var' = round(round(r(mean),.001)*1,.1)
  9.                                         qui summarize `var' if inrange(timevar01,  4.999, 5.02)
 10.                                         scalar e5y_`var' = round(round(r(mean),.001)*1,.1)
 11.          // di %9.2f "`var': " "3 months" "(`=scalar(e3m_`var')')" "; 1 year"  "(`=scalar(e1y_`var')')" "; 3 years"  "(`=scalar(e3y_`var')')" "; 5 years" "(`=scalar(e5y_`var')')"
.          cap noi matrix ests_`var' = (`=scalar(e3m_`var')'\  `=scalar(e1y_`var')'\ `=scalar(scalar(e3y_`var'))'\ `=scalar(scalar(e5y_`var'))')
 12.          matrix colnames ests_`var' = `var'
 13.          matrix rownames ests_`var' = 3_mths 1_yr 3_yrs 5_yrs
 14.                 }

. 
. matrix est_diff41_l = (ests_fdiff_los_from4_5_3y, ests_fdiff_los_from4_5_lci_3y, ests_fdiff_los_from4_5_uci_3y, ests_fdiff2_los_from4_5_3y, ests_fdiff2_los_from4_5_lci_3y, ests_fdiff2_los_from4_5_uci_3y)

. matrix colnames est_diff41_l = "Not_Completed" "Not_Completed_lo" "Not_Completed_hi" "Completed" "Completed_lo" "Completed_hi"

. 
. esttab matrix(est_diff41_l) using "${pathdata2}diff_los_res_out_mod_t4_3y_22.html", replace 
(output written to C:/Users/CISS Fondecyt/Mi unidad/Alvacast/SISTRAT 2019 (github)/_mult_state_ags/diff_los_res_out_mod_t4_3y_22.html)

The transition probabilities are presented here:


est_diff41_l
Not_CompletedNot_Completed_loNot_Completed_hi CompletedCompleted_loCompleted_hi

3_mths .2 -1.2 1.5 .1 -1 1.3
1_yr 1.8 -9.7 13.2 1.6 -8.9 12.1
3_yrs 9.5 -52 71.1 8.9 -49.4 67.2
5_yrs 20.2 -98.4 138.9 19 -95.3 133.4

LOS_Residential_vs_Ambulatory_3y_RP_First transition

We had to rename some columns due to the extension of the variable name.

. **rename columns
. 
. local trans `" "1_2" "2_3" "3_4" "4_5" "' 

. local names `" "_3y_rp" "_lci_3y_rp" "_uci_3y_rp" "' 

. local fdiff `" "fdiff" "fdiff2" "' 

. foreach opts in `trans' {
  2. foreach c in `names' {
  3. local fd `" "fd" "fd2" "' 
  4. foreach fdiffmod in `fdiff' {
  5.         gettoken fdmod fd:fd
  6.         local dbname `fdiffmod'_los_from`opts'`c'
  7.         local dbnameout `fdmod'_l_from`opts'`c'
  8.         local new = "From `dbname' to `dbnameout'"
  9.         di "`new'"
 10.         cap noi gen `dbnameout'=`dbname'
 11.         }
 12.  }
 13. }
From fdiff_los_from1_2_3y_rp to fd_l_from1_2_3y_rp
(31,275 missing values generated)
From fdiff2_los_from1_2_3y_rp to fd2_l_from1_2_3y_rp
(31,275 missing values generated)
From fdiff_los_from1_2_lci_3y_rp to fd_l_from1_2_lci_3y_rp
(31,275 missing values generated)
From fdiff2_los_from1_2_lci_3y_rp to fd2_l_from1_2_lci_3y_rp
(31,275 missing values generated)
From fdiff_los_from1_2_uci_3y_rp to fd_l_from1_2_uci_3y_rp
(31,275 missing values generated)
From fdiff2_los_from1_2_uci_3y_rp to fd2_l_from1_2_uci_3y_rp
(31,275 missing values generated)
From fdiff_los_from2_3_3y_rp to fd_l_from2_3_3y_rp
(31,275 missing values generated)
From fdiff2_los_from2_3_3y_rp to fd2_l_from2_3_3y_rp
(31,275 missing values generated)
From fdiff_los_from2_3_lci_3y_rp to fd_l_from2_3_lci_3y_rp
(31,275 missing values generated)
From fdiff2_los_from2_3_lci_3y_rp to fd2_l_from2_3_lci_3y_rp
(31,275 missing values generated)
From fdiff_los_from2_3_uci_3y_rp to fd_l_from2_3_uci_3y_rp
(31,275 missing values generated)
From fdiff2_los_from2_3_uci_3y_rp to fd2_l_from2_3_uci_3y_rp
(31,275 missing values generated)
From fdiff_los_from3_4_3y_rp to fd_l_from3_4_3y_rp
(31,275 missing values generated)
From fdiff2_los_from3_4_3y_rp to fd2_l_from3_4_3y_rp
(31,275 missing values generated)
From fdiff_los_from3_4_lci_3y_rp to fd_l_from3_4_lci_3y_rp
(31,275 missing values generated)
From fdiff2_los_from3_4_lci_3y_rp to fd2_l_from3_4_lci_3y_rp
(31,275 missing values generated)
From fdiff_los_from3_4_uci_3y_rp to fd_l_from3_4_uci_3y_rp
(31,275 missing values generated)
From fdiff2_los_from3_4_uci_3y_rp to fd2_l_from3_4_uci_3y_rp
(31,275 missing values generated)
From fdiff_los_from4_5_3y_rp to fd_l_from4_5_3y_rp
(31,275 missing values generated)
From fdiff2_los_from4_5_3y_rp to fd2_l_from4_5_3y_rp
(31,275 missing values generated)
From fdiff_los_from4_5_lci_3y_rp to fd_l_from4_5_lci_3y_rp
(31,275 missing values generated)
From fdiff2_los_from4_5_lci_3y_rp to fd2_l_from4_5_lci_3y_rp
(31,275 missing values generated)
From fdiff_los_from4_5_uci_3y_rp to fd_l_from4_5_uci_3y_rp
(31,275 missing values generated)
From fdiff2_los_from4_5_uci_3y_rp to fd2_l_from4_5_uci_3y_rp
(31,275 missing values generated)

. *fdiff_prob_from-> diff. between residential and ambulatory treatment
. *fdiff_prob_from1_2_lci_rp_0 fdiff_prob_from1_2_uci_rp_0 fdiff_prob_from1_2_rp_0
. *fdiff_prob_from1_2_lci_rp_3y fdiff_prob_from1_2_uci_rp_3y fdiff_prob_from1_2_rp_3y
. *fdiff_prob_from1_2_lci_0_2 fdiff_prob_from1_2_uci_0_2 fdiff_prob_from1_2_0_2
. *fdiff_prob_from1_2_lci_3y_2 fdiff_prob_from1_2_uci_3y_2 fdiff_prob_from1_2_3y_2
. *fprob2_from1a_*_3y- 
. 
. foreach var of varlist fd_l_from1_2_3y_rp fd_l_from1_2_lci_3y_rp fd_l_from1_2_uci_3y_rp fd2_l_from1_2_3y_rp fd2_l_from1_2_lci_3y_rp fd2_l_from1_2_uci_3y_rp {
  2.                 scalar variable = "`var'"
  3.                                         qui summarize `var' if inrange(timevar01, .32, .34)
  4.                                         scalar e3m_`var' = round(round(r(mean),.001)*1,.1)
  5.                                         qui summarize `var' if inrange(timevar01, .999, 1.02)
  6.                                         scalar e1y_`var' = round(round(r(mean),.001)*1,.1)
  7.                                         qui summarize `var' if inrange(timevar01, 2.99, 3.02)
  8.                                         scalar e3y_`var' = round(round(r(mean),.001)*1,.1)
  9.                                         qui summarize `var' if inrange(timevar01,  4.999, 5.02)
 10.                                         scalar e5y_`var' = round(round(r(mean),.001)*1,.1)
 11.          cap noi matrix ests_`var' = (`=scalar(e3m_`var')'\  `=scalar(e1y_`var')'\ `=scalar(scalar(e3y_`var'))'\ `=scalar(scalar(e5y_`var'))')
 12.          matrix colnames ests_`var' = `var'
 13.          matrix rownames ests_`var' = 3_mths 1_yr 3_yrs 5_yrs
 14.                 }

. matrix est_diff12_l = (ests_fd_l_from1_2_3y_rp, ests_fd_l_from1_2_lci_3y_rp, ests_fd_l_from1_2_uci_3y_rp, ests_fd2_l_from1_2_3y_rp, ests_fd2_l_from1_2_lci_3y_rp, ests_fd2_l_from1_2_uci_3y_rp)

. matrix colnames est_diff12_l =  "Not_Completed" "Not_Completed_lo" "Not_Completed_hi" "Completed" "Completed_lo" "Completed_hi" 

. 
. esttab matrix(est_diff12_l) using "${pathdata2}diff_los_res_out_mod_t1_3y_rp_22.html", replace 
(output written to C:/Users/CISS Fondecyt/Mi unidad/Alvacast/SISTRAT 2019 (github)/_mult_state_ags/diff_los_res_out_mod_t1_3y_rp_22.html)

The transition probabilities are presented here:


est_diff12_l
Not_CompletedNot_Completed_loNot_Completed_hi CompletedCompleted_loCompleted_hi

3_mths .4 .3 .5 .3 .2 .4
1_yr 5.9 4.9 6.9 5.2 4.3 6.1
3_yrs 47.7 40.7 54.6 41.5 35.5 47.6
5_yrs 98.5 83.7 113.3 83.2 70.3 96

LOS_Residential_vs_Ambulatory_3y_RP_Second transition

. foreach var of varlist fd_l_from2_3_3y_rp fd_l_from2_3_lci_3y_rp fd_l_from2_3_uci_3y_rp fd2_l_from2_3_3y_rp fd2_l_from2_3_lci_3y_rp fd2_l_from2_3_uci_3y_rp {
  2.                 scalar variable = "`var'"
  3.                                         qui summarize `var' if inrange(timevar01, .32, .34)
  4.                                         scalar e3m_`var' = round(round(r(mean),.001)*1,.1)
  5.                                         qui summarize `var' if inrange(timevar01, .999, 1.02)
  6.                                         scalar e1y_`var' = round(round(r(mean),.001)*1,.1)
  7.                                         qui summarize `var' if inrange(timevar01, 2.99, 3.02)
  8.                                         scalar e3y_`var' = round(round(r(mean),.001)*1,.1)
  9.                                         qui summarize `var' if inrange(timevar01,  4.999, 5.02)
 10.                                         scalar e5y_`var' = round(round(r(mean),.001)*1,.1)
 11.          cap noi matrix ests_`var' = (`=scalar(e3m_`var')'\  `=scalar(e1y_`var')'\ `=scalar(scalar(e3y_`var'))'\ `=scalar(scalar(e5y_`var'))')
 12.          matrix colnames ests_`var' = `var'
 13.          matrix rownames ests_`var' = 3_mths 1_yr 3_yrs 5_yrs
 14.                 }

. 
. matrix est_diff22_l = (ests_fd_l_from2_3_3y_rp, ests_fd_l_from2_3_lci_3y_rp, ests_fd_l_from2_3_uci_3y_rp, ests_fd2_l_from2_3_3y_rp, ests_fd2_l_from2_3_lci_3y_rp, ests_fd2_l_from2_3_uci_3y_rp)

. matrix colnames est_diff22_l =  "Not_Completed" "Not_Completed_lo" "Not_Completed_hi" "Completed" "Completed_lo" "Completed_hi" 

. 
. esttab matrix(est_diff22_l) using "${pathdata2}diff_los_res_out_mod_t2_3y_rp_22.html", replace 
(output written to C:/Users/CISS Fondecyt/Mi unidad/Alvacast/SISTRAT 2019 (github)/_mult_state_ags/diff_los_res_out_mod_t2_3y_rp_22.html)

The transition probabilities are presented here:


est_diff22_l
Not_CompletedNot_Completed_loNot_Completed_hi CompletedCompleted_loCompleted_hi

3_mths 0 -.2 .1 0 -.2 .2
1_yr .7 -1.1 2.4 .6 -1.2 2.4
3_yrs 2.8 -10.6 16.1 1.8 -11.8 15.5
5_yrs 1.2 -27.1 29.6 -.4 -29.3 28.6

LOS_Residential_vs_Ambulatory_3y_RP_Third transition

. foreach var of varlist fd_l_from3_4_3y_rp fd_l_from3_4_lci_3y_rp fd_l_from3_4_uci_3y_rp fd2_l_from3_4_3y_rp fd2_l_from3_4_lci_3y_rp fd2_l_from3_4_uci_3y_rp {
  2.                 scalar variable = "`var'"
  3.                                         qui summarize `var' if inrange(timevar01, .32, .34)
  4.                                         scalar e3m_`var' = round(round(r(mean),.001)*1,.1)
  5.                                         qui summarize `var' if inrange(timevar01, .999, 1.02)
  6.                                         scalar e1y_`var' = round(round(r(mean),.001)*1,.1)
  7.                                         qui summarize `var' if inrange(timevar01, 2.99, 3.02)
  8.                                         scalar e3y_`var' = round(round(r(mean),.001)*1,.1)
  9.                                         qui summarize `var' if inrange(timevar01,  4.999, 5.02)
 10.                                         scalar e5y_`var' = round(round(r(mean),.001)*1,.1)
 11.          cap noi matrix ests_`var' = (`=scalar(e3m_`var')'\  `=scalar(e1y_`var')'\ `=scalar(scalar(e3y_`var'))'\ `=scalar(scalar(e5y_`var'))')
 12.          matrix colnames ests_`var' = `var'
 13.          matrix rownames ests_`var' = 3_mths 1_yr 3_yrs 5_yrs
 14.                 }

. 
. matrix est_diff32_l = (ests_fd_l_from3_4_3y_rp, ests_fd_l_from3_4_lci_3y_rp, ests_fd_l_from3_4_uci_3y_rp, ests_fd2_l_from3_4_3y_rp, ests_fd2_l_from3_4_lci_3y_rp, ests_fd2_l_from3_4_uci_3y_rp)

. matrix colnames est_diff32_l =  "Not_Completed" "Not_Completed_lo" "Not_Completed_hi" "Completed" "Completed_lo" "Completed_hi" 

. 
. esttab matrix(est_diff32_l) using "${pathdata2}diff_los_res_out_mod_t3_3y_rp_22.html", replace 
(output written to C:/Users/CISS Fondecyt/Mi unidad/Alvacast/SISTRAT 2019 (github)/_mult_state_ags/diff_los_res_out_mod_t3_3y_rp_22.html)

The transition probabilities are presented here:


est_diff32_l
Not_CompletedNot_Completed_loNot_Completed_hi CompletedCompleted_loCompleted_hi

3_mths .1 -.1 .4 .1 -.2 .3
1_yr 2.5 -1.2 6.1 1.8 -1.6 5.2
3_yrs 12.2 -13.9 38.3 8.7 -16 33.4
5_yrs 16.2 -39.8 72.2 11 -42 64

LOS_Residential_vs_Ambulatory_3y_RP_Fourth transition

. foreach var of varlist fd_l_from4_5_3y_rp fd_l_from4_5_lci_3y_rp fd_l_from4_5_uci_3y_rp fd2_l_from4_5_3y_rp fd2_l_from4_5_lci_3y_rp fd2_l_from4_5_uci_3y_rp {
  2.                 scalar variable = "`var'"
  3.                                         qui summarize `var' if inrange(timevar01, .32, .34)
  4.                                         scalar e3m_`var' = round(round(r(mean),.001)*1,.1)
  5.                                         qui summarize `var' if inrange(timevar01, .999, 1.02)
  6.                                         scalar e1y_`var' = round(round(r(mean),.001)*1,.1)
  7.                                         qui summarize `var' if inrange(timevar01, 2.99, 3.02)
  8.                                         scalar e3y_`var' = round(round(r(mean),.001)*1,.1)
  9.                                         qui summarize `var' if inrange(timevar01,  4.999, 5.02)
 10.                                         scalar e5y_`var' = round(round(r(mean),.001)*1,.1)
 11.          cap noi matrix ests_`var' = (`=scalar(e3m_`var')'\  `=scalar(e1y_`var')'\ `=scalar(scalar(e3y_`var'))'\ `=scalar(scalar(e5y_`var'))')
 12.          matrix colnames ests_`var' = `var'
 13.          matrix rownames ests_`var' = 3_mths 1_yr 3_yrs 5_yrs
 14.                 }

. 
. matrix est_diff42_l = (ests_fd_l_from4_5_3y_rp, ests_fd_l_from4_5_lci_3y_rp, ests_fd_l_from4_5_uci_3y_rp, ests_fd2_l_from4_5_3y_rp, ests_fd2_l_from4_5_lci_3y_rp, ests_fd2_l_from4_5_uci_3y_rp)

. matrix colnames est_diff42_l = "Not_Completed" "Not_Completed_lo" "Not_Completed_hi" "Completed" "Completed_lo" "Completed_hi"

. 
. esttab matrix(est_diff42_l) using "${pathdata2}diff_los_res_out_mod_t4_3y_rp_22.html", replace 
(output written to C:/Users/CISS Fondecyt/Mi unidad/Alvacast/SISTRAT 2019 (github)/_mult_state_ags/diff_los_res_out_mod_t4_3y_rp_22.html)

The transition probabilities are presented here:


est_diff42_l
Not_CompletedNot_Completed_loNot_Completed_hi CompletedCompleted_loCompleted_hi

3_mths .2 -.5 .9 .2 -.5 .8
1_yr 2.8 -5.4 10.9 2.5 -4.9 9.9
3_yrs 22.4 -39.7 84.5 20.5 -36.8 77.9
5_yrs 49.4 -82.1 180.9 46.1 -76.8 168.9

LOS_Export_differences_between_residential_and_ambulatory

. ************************************
. ********************NOT COMPLETED****************************************************
. ************************************
. local x `""1_2_0" "1_2_lci_0" "1_2_uci_0""' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff_los_from`l'"
  3.         }

. //list timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02)    
. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_los", modify) cell(B1) firstrow(variables) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "2_3_0" "2_3_lci_0" "2_3_uci_0" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff_los_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_los", modify) cell(B6) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "3_4_0" "3_4_lci_0" "3_4_uci_0" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff_los_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_los", modify) cell(B10) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "4_5_0" "4_5_lci_0" "4_5_uci_0" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff_los_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_los", modify) cell(B14) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "1_2_0_rp" "1_2_lci_0_rp" "1_2_uci_0_rp" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff_los_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_los", modify) cell(B18) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "2_3_0_rp" "2_3_lci_0_rp" "2_3_uci_0_rp" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff_los_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_los", modify) cell(B22) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "3_4_0_rp" "3_4_lci_0_rp" "3_4_uci_0_rp" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff_los_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_los", modify) cell(B26) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "4_5_0_rp" "4_5_lci_0_rp" "4_5_uci_0_rp" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff_prob_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_los", modify) cell(B30) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. 
. local x `""1_2_3y" "1_2_lci_3y" "1_2_uci_3y""' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff_los_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_los", modify) cell(B34) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "2_3_3y" "2_3_lci_3y" "2_3_uci_3y" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff_los_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_los", modify) cell(B38) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "3_4_3y" "3_4_lci_3y" "3_4_uci_3y" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff_los_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_los", modify) cell(B42) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "4_5_3y" "4_5_lci_3y" "4_5_uci_3y" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff_los_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_los", modify) cell(B46) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "1_2_3y_rp" "1_2_lci_3y_rp" "1_2_uci_3y_rp" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff_los_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_los", modify) cell(B50) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "2_3_3y_rp" "2_3_lci_3y_rp" "2_3_uci_3y_rp" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff_los_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_los", modify) cell(B54) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "3_4_3y_rp" "3_4_lci_3y_rp" "3_4_uci_3y_rp" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff_los_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_los", modify) cell(B58) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "4_5_3y_rp" "4_5_lci_3y_rp" "4_5_uci_3y_rp" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff_los_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_los", modify) cell(B62) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

.         
. ************************************
. ********************COMPLETED****************************************************
. ************************************
. local x `""1_2_3y" "1_2_lci_3y" "1_2_uci_3y""' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff2_los_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_los2", modify) cell(B1) firstrow(variables) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "2_3_3y" "2_3_lci_3y" "2_3_uci_3y" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff2_los_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_los2", modify) cell(B6) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "3_4_3y" "3_4_lci_3y" "3_4_uci_3y" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff2_los_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_los2", modify) cell(B10) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "4_5_3y" "4_5_lci_3y" "4_5_uci_3y" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff2_los_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_los2", modify) cell(B14) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "1_2_3y_rp" "1_2_lci_3y_rp" "1_2_uci_3y_rp" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff2_los_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_los2", modify) cell(B18) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "2_3_3y_rp" "2_3_lci_3y_rp" "2_3_uci_3y_rp" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff2_los_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_los2", modify) cell(B22) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "3_4_3y_rp" "3_4_lci_3y_rp" "3_4_uci_3y_rp" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff2_los_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_los2", modify) cell(B26) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "4_5_3y_rp" "4_5_lci_3y_rp" "4_5_uci_3y_rp" "' 

. local wx ""

. foreach l of local x {
  2.         local wx "`wx' fdiff2_los_from`l'"
  3.         }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("diff_los2", modify) cell(B30) //*save to Excel worksheetcell(start)  cell(A6) 
file trans_prob_los_22_apr.xlsx saved

=============================================================================

Figures of Differences in Lengths of Stay

=============================================================================

. tw      (rarea fdiff_los_from1_1_lci_0 fdiff_los_from1_1_uci_0 timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (line fdiff_los_from1_1_0 timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         yline(0, lcolor(navy)) ///
>  xtitle(Time (years)) ytitle(Difference in Lengths) xlab(0(.3)5,labsize(small)) legend(order(1 "CI95%" 2 "Difference") pos(7) ring(0) c(1)) ///
>  title("Difference in Lengths of Stay (1st patient)") name(diff_los_mod11_0_22, replace) ///
>  subtitle("from Admission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(diff_los_mod11_0_22.gph, replace) 
(file diff_los_mod11_0_22.gph saved)

. tw      (rarea fdiff_los_from2_2_lci_0 fdiff_los_from2_2_uci_0 timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (line fdiff_los_from2_2_0 timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         yline(0, lcolor(navy)) ///
>  xtitle(Time (years)) ytitle(Difference in Lengths) xlab(0(.3)5,labsize(small)) legend(order(1 "CI95%" 2 "Difference") pos(7) ring(0) c(1)) ///
>  title("Difference in Lengths of Stay (1st patient)") name(diff_los_mod22_0_22, replace) ///
>  subtitle("from Readmission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(diff_los_mod22_0_22.gph, replace) 
(file diff_los_mod22_0_22.gph saved)

. tw      (rarea fdiff_los_from3_3_lci_0 fdiff_los_from3_3_uci_0 timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (line fdiff_los_from3_3_0 timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         yline(0, lcolor(navy)) ///
>  xtitle(Time (years)) ytitle(Difference in Lengths) xlab(0(.3)5,labsize(small)) legend(order(1 "CI95%" 2 "Difference") pos(7) ring(0) c(1)) ///
>  title("Difference in Lengths of Stay (1st patient)") name(diff_los_mod33_0_22, replace) ///
>  subtitle("from 2nd Readmission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(diff_los_mod33_0_22.gph, replace) 
(file diff_los_mod33_0_22.gph saved)

. tw      (rarea fdiff_los_from4_4_lci_0 fdiff_los_from4_4_uci_0 timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (line fdiff_los_from4_4_0 timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         yline(0, lcolor(navy)) ///
>  xtitle(Time (years)) ytitle(Difference in Lengths) xlab(0(.3)5,labsize(small)) legend(order(1 "CI95%" 2 "Difference") pos(7) ring(0) c(1)) ///
>  title("Difference in Lengths of Stay (1st patient)") name(diff_los_mod44_0_22, replace) ///
>  subtitle("from 3rd Readmission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(diff_los_mod44_0_22.gph, replace) 
(file diff_los_mod44_0_22.gph saved)

=============================================================================

Figures of Differences in Lengths of Stay (3 years)

=============================================================================

. tw      (rarea fdiff_los_from1_1_lci_3y fdiff_los_from1_1_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (line fdiff_los_from1_1_3y timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         yline(0, lcolor(navy)) ///
>  xtitle(Time (years)) ytitle(Difference in Lengths) xlab(0(.3)5,labsize(small)) legend(order(1 "CI95%" 2 "Difference") pos(7) ring(0) c(1)) ///
>  title("Difference in Lengths of Stay (1st patient) (3 years)") name(diff_los_mod11_3y_22, replace) ///
>  subtitle("from Admission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(diff_los_mod11_3y_22.gph, replace) 
(file diff_los_mod11_3y_22.gph saved)

. tw      (rarea fdiff_los_from2_2_lci_3y fdiff_los_from2_2_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (line fdiff_los_from2_2_3y timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         yline(0, lcolor(navy)) ///
>  xtitle(Time (years)) ytitle(Difference in Lengths) xlab(0(.3)5,labsize(small)) legend(order(1 "CI95%" 2 "Difference") pos(7) ring(0) c(1)) ///
>  title("Difference in Lengths of Stay (1st patient) (3 years)") name(diff_los_mod22_3y_22, replace) ///
>  subtitle("from Readmission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(diff_los_mod22_3y_22.gph, replace) 
(file diff_los_mod22_3y_22.gph saved)

. tw      (rarea fdiff_los_from3_3_lci_3y fdiff_los_from3_3_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (line fdiff_los_from3_3_3y timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         yline(0, lcolor(navy)) ///
>  xtitle(Time (years)) ytitle(Difference in Lengths) xlab(0(.3)5,labsize(small)) legend(order(1 "CI95%" 2 "Difference") pos(7) ring(0) c(1)) ///
>  title("Difference in Lengths of Stay (1st patient) (3 years)") name(diff_los_mod33_3y_22, replace) ///
>  subtitle("from 2nd Readmission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(diff_los_mod33_3y_22.gph, replace) 
(file diff_los_mod33_3y_22.gph saved)

. tw      (rarea fdiff_los_from4_4_lci_3y fdiff_los_from4_4_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (line fdiff_los_from4_4_3y timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         yline(0, lcolor(navy)) ///
>  xtitle(Time (years)) ytitle(Difference in Lengths) xlab(0(.3)5,labsize(small)) legend(order(1 "CI95%" 2 "Difference") pos(7) ring(0) c(1)) ///
>  title("Difference in Lengths of Stay (1st patient) (3 years)") name(diff_los_mod44_3y_22, replace) ///
>  subtitle("from 3rd Readmission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(diff_los_mod44_3y_22.gph, replace) 
(file diff_los_mod44_3y_22.gph saved)

=============================================================================

(RP) Figures of Differences in Lengths of Stay

=============================================================================

. tw      (rarea fdiff_los_from1_1_lci_0_rp fdiff_los_from1_1_uci_0_rp timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (line fdiff_los_from1_1_0_rp timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         yline(0, lcolor(navy)) ///
>  xtitle(Time (years)) ytitle(Difference in Lengths) xlab(0(.3)5,labsize(small)) legend(order(1 "CI95%" 2 "Difference") pos(7) ring(0) c(1)) ///
>  title("Difference in Lengths of Stay (1st patient) (RP)") name(diff_los_mod11_0_rp_22, replace) ///
>  subtitle("from Admission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(diff_los_mod11_0_rp_22.gph, replace) 
(file diff_los_mod11_0_rp_22.gph saved)

. tw      (rarea fdiff_los_from2_2_lci_0_rp fdiff_los_from2_2_uci_0_rp timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (line fdiff_los_from2_2_0_rp timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         yline(0, lcolor(navy)) ///
>  xtitle(Time (years)) ytitle(Difference in Lengths) xlab(0(.3)5,labsize(small)) legend(order(1 "CI95%" 2 "Difference") pos(7) ring(0) c(1)) ///
>  title("Difference in Lengths of Stay (1st patient) (RP)") name(diff_los_mod22_0_rp_22, replace) ///
>  subtitle("from Readmission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(diff_los_mod22_0_rp_22.gph, replace) 
(file diff_los_mod22_0_rp_22.gph saved)

. tw      (rarea fdiff_los_from3_3_lci_0_rp fdiff_los_from3_3_uci_0_rp timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (line fdiff_los_from3_3_0_rp timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         yline(0, lcolor(navy)) ///
>  xtitle(Time (years)) ytitle(Difference in Lengths) xlab(0(.3)5,labsize(small)) legend(order(1 "CI95%" 2 "Difference") pos(7) ring(0) c(1)) ///
>  title("Difference in Lengths of Stay (1st patient) (RP)") name(diff_los_mod33_0_rp_22, replace) ///
>  subtitle("from 2nd Readmission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(diff_los_mod33_0_rp_22.gph, replace) 
(file diff_los_mod33_0_rp_22.gph saved)

. tw      (rarea fdiff_los_from4_4_lci_0_rp fdiff_los_from4_4_uci_0_rp timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (line fdiff_los_from4_4_0_rp timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         yline(0, lcolor(navy)) ///
>  xtitle(Time (years)) ytitle(Difference in Lengths) xlab(0(.3)5,labsize(small)) legend(order(1 "CI95%" 2 "Difference") pos(7) ring(0) c(1)) ///
>  title("Difference in Lengths of Stay (1st patient) (RP)") name(diff_los_mod44_0_rp_22, replace) ///
>  subtitle("from 3rd Readmission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(diff_los_mod44_0_rp_22.gph, replace) 
(file diff_los_mod44_0_rp_22.gph saved)

=============================================================================

(RP) Figures of Differences in Lengths of Stay (3 years)

=============================================================================

. tw      (rarea fdiff_los_from1_1_lci_3y_rp fdiff_los_from1_1_uci_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (line fdiff_los_from1_1_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         yline(0, lcolor(navy)) ///
>  xtitle(Time (years)) ytitle(Difference in Lengths) xlab(0(.3)5,labsize(small)) legend(order(1 "CI95%" 2 "Difference") pos(7) ring(0) c(1)) ///
>  title("Difference in Lengths of Stay (1st patient) (3 years) (RP)") name(diff_los_mod11_3y_rp_22, replace) ///
>  subtitle("from Admission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(diff_los_mod11_3y_rp_22.gph, replace) 
(file diff_los_mod11_3y_rp_22.gph saved)

. tw      (rarea fdiff_los_from2_2_lci_3y_rp fdiff_los_from2_2_uci_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (line fdiff_los_from2_2_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         yline(0, lcolor(navy)) ///
>  xtitle(Time (years)) ytitle(Difference in Lengths) xlab(0(.3)5,labsize(small)) legend(order(1 "CI95%" 2 "Difference") pos(7) ring(0) c(1)) ///
>  title("Difference in Lengths of Stay (1st patient) (3 years) (RP)") name(diff_los_mod22_3y_rp_22, replace) ///
>  subtitle("from Readmission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(diff_los_mod22_3y_rp_22.gph, replace) 
(file diff_los_mod22_3y_rp_22.gph saved)

. tw      (rarea fdiff_los_from3_3_lci_3y_rp fdiff_los_from3_3_uci_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (line fdiff_los_from3_3_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         yline(0, lcolor(navy)) ///
>  xtitle(Time (years)) ytitle(Difference in Lengths) xlab(0(.3)5,labsize(small)) legend(order(1 "CI95%" 2 "Difference") pos(7) ring(0) c(1)) ///
>  title("Difference in Lengths of Stay (1st patient) (3 years) (RP)") name(diff_los_mod33_3y_rp_22, replace) ///
>  subtitle("from 2nd Readmission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(diff_los_mod33_3y_rp_22.gph, replace) 
(file diff_los_mod33_3y_rp_22.gph saved)

. tw      (rarea fdiff_los_from4_4_lci_3y_rp fdiff_los_from4_4_uci_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (line fdiff_los_from4_4_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         yline(0, lcolor(navy)) ///
>  xtitle(Time (years)) ytitle(Difference in Lengths) xlab(0(.3)5,labsize(small)) legend(order(1 "CI95%" 2 "Difference") pos(7) ring(0) c(1)) ///
>  title("Difference in Lengths of Stay (1st patient) (3 years) (RP)") name(diff_los_mod44_3y_rp_22, replace) ///
>  subtitle("from 3rd Readmission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(diff_los_mod44_3y_rp_22.gph, replace) 
(file diff_los_mod44_3y_rp_22.gph saved)

=============================================================================

Figures of Expected Lengths of Stay (3yrs) (2nd patient)

=============================================================================

. tw      (rarea flos2_from1a_1_lci_3y flos2_from1a_1_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%35)) ///
>         (rarea flos2_from1b_1_lci_3y flos2_from1b_1_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(black) color(black%35)) ///
>         (line flos2_from1a_1_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) lpattern("-")) ///
>         (line flos2_from1b_1_3y timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>  xtitle(Time (years)) ytitle(LOS (years)) xlab(0(.3)5,labsize(small)) ylab(0(180)1827, /// *730
>  angle(h) format(%4.0f)) legend(order(1 "Ambulatory CI95%" 2 "Residential CI95%" 3 "Ambulatory" 4 "Residential") pos(11) ring(0) c(1)) ///
>  title("Length of Stay (3yrs)") name(los2_models11_3y_22, replace) ///
>  subtitle("from Admission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(los2_models11_3y_22.gph, replace)   
(file los2_models11_3y_22.gph saved)

. *graph export rott_los2_models11.gph, replace

. tw      (rarea flos2_from2a_2_lci_3y flos2_from2a_2_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%35)) ///
>         (rarea flos2_from2b_2_lci_3y flos2_from2b_2_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(black) color(black%35)) ///
>         (line flos2_from2a_2_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) lpattern("-")) ///
>         (line flos2_from2b_2_3y timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>  xtitle(Time (years)) ytitle(LOS (years)) xlab(0(.3)5,labsize(small)) ylab(0(180)1827, /// *730
>  angle(h) format(%4.0f)) legend(order(1 "Ambulatory CI95%" 2 "Residential CI95%" 3 "Ambulatory" 4 "Residential") pos(11) ring(0) c(1)) ///
>  title("Length of Stay (3yrs)") name(los2_models22_3y, replace) ///
>  subtitle("from Readmission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(los2_models22_3y_22.gph, replace)  
(file los2_models22_3y_22.gph saved)

. *graph export rott_los2_models22.gph, replace

. tw      (rarea flos2_from3a_3_lci_3y flos2_from3a_3_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%35)) ///
>         (rarea flos2_from3b_3_lci_3y flos2_from3b_3_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(black) color(black%35)) ///
>         (line flos2_from3a_3_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) lpattern("-")) ///
>         (line flos2_from3b_3_3y timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>  xtitle(Time (years)) ytitle(LOS (years)) xlab(0(.3)5,labsize(small)) ylab(0(180)1827, /// *730
>  angle(h) format(%4.0f)) legend(order(1 "Ambulatory CI95%" 2 "Residential CI95%" 3 "Ambulatory" 4 "Residential") pos(11) ring(0) c(1)) ///
>  title("Length of Stay (3yrs)") name(los2_models33_3y_22, replace) ///
>  subtitle("from 2nd Readmission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(los2_models33_3y_22.gph, replace)   
(file los2_models33_3y_22.gph saved)

. *graph export rott_los2_models33_3y.gph, replace

. tw      (rarea flos2_from4a_4_lci_3y flos2_from4a_4_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%35)) ///
>         (rarea flos2_from4b_4_lci_3y flos2_from4b_4_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(black) color(black%35)) ///
>         (line flos2_from4a_4_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) lpattern("-")) ///
>         (line flos2_from4b_4_3y timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>  xtitle(Time (years)) ytitle(LOS (years)) xlab(0(.3)5,labsize(small)) ylab(0(180)1827, /// *730
>  angle(h) format(%4.0f)) legend(order(1 "Ambulatory CI95%" 2 "Residential CI95%" 3 "Ambulatory" 4 "Residential") pos(11) ring(0) c(1)) ///
>  title("Length of Stay (3yrs)") name(los2_models44_3y_22, replace) ///
>  subtitle("from 3rd Readmission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(los2_models44_3y_22.gph, replace) 
(file los2_models44_3y_22.gph saved)

. *graph export rott_los2_models44_3y.gph, replace

=============================================================================

Figures of Expected Lengths of Stay (3yrs) (RP) (2nd patient)

=============================================================================

. tw      (rarea flos2_from1a_1_lci_3y_rp flos2_from1a_1_uci_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%35)) ///
>         (rarea flos2_from1b_1_lci_3y_rp flos2_from1b_1_uci_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(black) color(black%35)) ///
>         (line flos2_from1a_1_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(gs8) lpattern("-")) ///
>         (line flos2_from1b_1_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>  xtitle(Time (years)) ytitle(LOS (years)) xlab(0(.3)5,labsize(small)) ylab(0(180)1827, /// *730
>  angle(h) format(%4.0f)) legend(order(1 "Ambulatory CI95%" 2 "Residential CI95%" 3 "Ambulatory (RP)" 4 "Residential (RP)") pos(11) ring(0) c(1)) ///
>  title("Length of Stay (3yrs)(RP)") name(los2_models11_rp_3y_22, replace) ///
>  subtitle("from Admission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(los2_models11_rp_3y_22.gph, replace) 
(file los2_models11_rp_3y_22.gph saved)

. *graph export rott_los2_models12_rp_3y.gph, replace

. tw      (rarea flos2_from2a_2_lci_3y_rp flos2_from2a_2_uci_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%35)) ///
>         (rarea flos2_from2b_2_lci_3y_rp flos2_from2b_2_uci_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(black) color(black%35)) ///
>         (line flos2_from2a_2_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(gs8) lpattern("-")) ///
>         (line flos2_from2b_2_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>  xtitle(Time (years)) ytitle(LOS (years)) xlab(0(.3)5,labsize(small)) ylab(0(180)1827, /// *730
>  angle(h) format(%4.0f)) legend(order(1 "Ambulatory CI95%" 2 "Residential CI95%" 3 "Ambulatory" 4 "Residential") pos(11) ring(0) c(1)) ///
>  title("Length of Stay (3yrs)(RP)") name(los2_models22_3y_rp_22, replace) ///
>  subtitle("from Readmission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(los2_models22_3y_rp_22.gph, replace)  
(file los2_models22_3y_rp_22.gph saved)

. *graph export rott_los2_models22_rp_3y.gph, replace

. tw      (rarea flos2_from3a_3_lci_3y_rp flos2_from3a_3_uci_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%35)) ///
>         (rarea flos2_from3b_3_lci_3y_rp flos2_from3b_3_uci_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(black) color(black%35)) ///
>         (line flos2_from3a_3_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(gs8) lpattern("-")) ///
>         (line flos2_from3b_3_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>  xtitle(Time (years)) ytitle(LOS (years)) xlab(0(.3)5,labsize(small)) ylab(0(180)1827, /// *730
>  angle(h) format(%4.0f)) legend(order(1 "Ambulatory CI95%" 2 "Residential CI95%" 3 "Ambulatory" 4 "Residential") pos(11) ring(0) c(1)) ///
>  title("Length of Stay (3yrs)(RP)") name(los2_models33_3y_rp_22, replace) ///
>  subtitle("from 2nd Readmission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(los2_models33_3y_rp_22.gph, replace)  
(file los2_models33_3y_rp_22.gph saved)

. *graph export rott_los2_models33_rp_3y.gph, replace

. tw      (rarea flos2_from4a_4_lci_3y_rp flos2_from4a_4_uci_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%35)) ///
>         (rarea flos2_from4b_4_lci_3y_rp flos2_from4b_4_uci_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(black) color(black%35)) ///
>         (line flos2_from4a_4_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(gs8) lpattern("-")) ///
>         (line flos2_from4b_4_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>  xtitle(Time (years)) ytitle(LOS (years)) xlab(0(.3)5,labsize(small)) ylab(0(180)1827, /// *730
>  angle(h) format(%4.0f)) legend(order(1 "Ambulatory CI95%" 2 "Residential CI95%" 3 "Ambulatory" 4 "Residential") pos(11) ring(0) c(1)) ///
>  title("Length of Stay (3yrs)(RP)") name(los2_models44_3y_rp_22, replace) ///
>  subtitle("from 4th Readmission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(los2_models44_3y_rp_22.gph, replace)  
(file los2_models44_3y_rp_22.gph saved)

. *graph export rott_los2_models44_rp.gph, replace

=============================================================================

Figures of Differences (3 years), with Treatment Completion at Baseline

=============================================================================

. *Assessing and relaxing the Markov assumption in the illness-death model
. *Jonathan Broomfield1, Caroline E. Weibull2, and Michael J. Crowther
. *fratio_from1_2_lci_0)(fratio_from1_2_uci_0)(fratio_from1_2_0)(fdiff_prob_from1_2_lci_0)(fdiff_prob_from1_2_uci_0)(fdiff_prob_from1_2_0)  
. tw      (rarea fdiff2_prob_from1_2_lci_3y fdiff2_prob_from1_2_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (line fdiff2_prob_from1_2_3y timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         yline(0, lcolor(navy)) ///
>  xtitle(Time (years)) ytitle(Difference in Probabilities) xlab(0(.3)5,labsize(small)) ylab(-.25(.05).25, /// *730
>  angle(h) format(%4.2f)) legend(order(1 "CI95%" 2 "Difference") pos(11) ring(0) c(1)) ///
>  title("Difference in Probabilities at 3 years (TC)") name(diff_mod12_3y_tc_22, replace) ///
>  subtitle("from Admission to Readmission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(diff_mod12_3y_tc_22.gph, replace)
(file diff_mod12_3y_tc_22.gph saved)

. *graph export prob_trans_12.gph, replace

. tw      (rarea fdiff2_prob_from2_3_lci_3y fdiff2_prob_from2_3_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (line fdiff2_prob_from2_3_3y timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         yline(0, lcolor(navy)) ///
>  xtitle(Time (years)) ytitle(Difference in Probabilities) xlab(0(.3)5,labsize(small)) ylab(-.25(.05).25, /// *730
>  angle(h) format(%4.2f)) legend(order(1 "CI95%" 2 "Difference") pos(11) ring(0) c(1)) ///
>  title("Difference in Probabilities at 3 years (TC)") name(diff_mod23_3y_tc_22, replace) ///
>  subtitle("from Readmission to 2nd Readmission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(diff_mod23_3y_tc_22.gph, replace)
(file diff_mod23_3y_tc_22.gph saved)

. *graph export prob_trans_23.gph, replace

. tw      (rarea fdiff2_prob_from3_4_lci_3y fdiff2_prob_from3_4_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (line fdiff2_prob_from3_4_3y timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         yline(0, lcolor(navy)) ///
>  xtitle(Time (years)) ytitle(Difference in Probabilities) xlab(0(.3)5,labsize(small)) ylab(-.25(.05).25, /// *730
>  angle(h) format(%4.2f)) legend(order(1 "CI95%" 2 "Difference") pos(11) ring(0) c(1)) ///
>  title("Difference in Probabilities at 3 years (TC)") name(diff_mod34_3y_tc_22, replace) ///
>  subtitle("from 2nd Readmission to 3rd Readmission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(diff_mod34_3y_tc_22.gph, replace)
(file diff_mod34_3y_tc_22.gph saved)

. *graph export prob_trans_34.gph, replace

. tw      (rarea fdiff2_prob_from4_5_lci_3y fdiff2_prob_from4_5_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (line fdiff2_prob_from4_5_3y timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         yline(0, lcolor(navy)) ///
>  xtitle(Time (years)) ytitle(Difference in Probabilities) xlab(0(.3)5,labsize(small)) ylab(-.25(.05).25, /// *730
>  angle(h) format(%4.2f)) legend(order(1 "CI95%" 2 "Difference") pos(11) ring(0) c(1)) ///
>  title("Difference in Probabilities at 3 years (TC)") name(diff_mod45_3y_tc_22, replace) ///
>  subtitle("from 3rd Readmission to 4th Readmission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(diff_mod45_3y_tc_22.gph, replace)
(file diff_mod45_3y_tc_22.gph saved)

. *graph export prob_trans_45.gph, replace

=============================================================================

(RP) Figures of Differences (3 years), with Treatment Completion at Baseline

=============================================================================

. *Assessing and relaxing the Markov assumption in the illness-death model
. *Jonathan Broomfield1, Caroline E. Weibull2, and Michael J. Crowther
. *fratio_from1_2_lci_0)(fratio_from1_2_uci_0)(fratio_from1_2_0)(fdiff_prob_from1_2_lci_0)(fdiff_prob_from1_2_uci_0)(fdiff_prob_from1_2_0)  
. tw      (rarea fdiff2_prob_from1_2_lci_3y_rp fdiff2_prob_from1_2_uci_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (line fdiff2_prob_from1_2_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         yline(0, lcolor(navy)) ///
>  xtitle(Time (years)) ytitle(Difference in Probabilities) xlab(0(.3)5,labsize(small)) ylab(-.25(.05).25, /// *730
>  angle(h) format(%4.2f)) legend(order(1 "CI95%" 2 "Difference") pos(11) ring(0) c(1)) ///
>  title("Difference in Probabilities at 3 years (TC) (RP)") name(diff_mod12_3y_rp_tc_22, replace) ///
>  subtitle("from Admission to Readmission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(diff_mod12_3y_rp_tc_22.gph, replace)
(file diff_mod12_3y_rp_tc_22.gph saved)

. *graph export prob_trans_12.gph, replace

. tw      (rarea fdiff2_prob_from2_3_lci_3y_rp fdiff2_prob_from2_3_uci_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (line fdiff2_prob_from2_3_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         yline(0, lcolor(navy)) ///
>  xtitle(Time (years)) ytitle(Difference in Probabilities) xlab(0(.3)5,labsize(small)) ylab(-.25(.05).25, /// *730
>  angle(h) format(%4.2f)) legend(order(1 "CI95%" 2 "Difference") pos(11) ring(0) c(1)) ///
>  title("Difference in Probabilities at 3 years (TC) (RP)") name(diff_mod23_3y_rp_tc_22, replace) ///
>  subtitle("from Readmission to 2nd Readmission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(diff_mod23_3y_rp_tc_22.gph, replace)
(file diff_mod23_3y_rp_tc_22.gph saved)

. *graph export prob_trans_23.gph, replace

. tw      (rarea fdiff2_prob_from3_4_lci_3y_rp fdiff2_prob_from3_4_uci_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (line fdiff2_prob_from3_4_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         yline(0, lcolor(navy)) ///
>  xtitle(Time (years)) ytitle(Difference in Probabilities) xlab(0(.3)5,labsize(small)) ylab(-.25(.05).25, /// *730
>  angle(h) format(%4.2f)) legend(order(1 "CI95%" 2 "Difference") pos(11) ring(0) c(1)) ///
>  title("Difference in Probabilities at 3 years (TC) (RP)") name(diff_mod34_3y_rp_tc_22, replace) ///
>  subtitle("from 2nd Readmission to 3rd Readmission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(diff_mod34_3y_rp_tc_22.gph, replace)
(file diff_mod34_3y_rp_tc_22.gph saved)

. *graph export prob_trans_34.gph, replace

. tw      (rarea fdiff2_prob_from4_5_lci_3y_rp fdiff2_prob_from4_5_uci_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (line fdiff2_prob_from4_5_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         yline(0, lcolor(navy)) ///
>  xtitle(Time (years)) ytitle(Difference in Probabilities) xlab(0(.3)5,labsize(small)) ylab(-.25(.05).25, /// *730
>  angle(h) format(%4.2f)) legend(order(1 "CI95%" 2 "Difference") pos(11) ring(0) c(1)) ///
>  title("Difference in Probabilities at 3 years (TC) (RP)") name(diff_mod45_3y_rp_tc_22, replace) ///
>  subtitle("from 3rd Readmission to 4th Readmission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(diff_mod45_3y_rp_tc_22.gph, replace)
(file diff_mod45_3y_rp_tc_22.gph saved)

. *graph export prob_trans_45.gph, replace

=============================================================================

Figures of Differences in Lengths of Stay, with Treatment Completion at Baseline (3yrs)

=============================================================================

. tw      (rarea fdiff2_los_from1_1_lci_3y fdiff2_los_from1_1_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (line fdiff2_los_from1_1_3y timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         yline(0, lcolor(navy)) ///
>  xtitle(Time (years)) ytitle(Difference in Lengths) xlab(0(.3)5,labsize(small)) legend(order(1 "CI95%" 2 "Difference") pos(7) ring(0) c(1)) ///
>  title("Difference in Lengths of Stay (2nd patient)") name(diff_los_mod11_3y_tc_22, replace) ///
>  subtitle("from Admission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(diff_los_mod11_3y_tc_22.gph, replace) 
(file diff_los_mod11_3y_tc_22.gph saved)

. tw      (rarea fdiff2_los_from2_2_lci_3y fdiff2_los_from2_2_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (line fdiff2_los_from2_2_3y timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         yline(0, lcolor(navy)) ///
>  xtitle(Time (years)) ytitle(Difference in Lengths) xlab(0(.3)5,labsize(small)) legend(order(1 "CI95%" 2 "Difference") pos(7) ring(0) c(1)) ///
>  title("Difference in Lengths of Stay (2nd patient)") name(diff_los_mod22_3y_tc_22, replace) ///
>  subtitle("from Readmission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(diff_los_mod22_3y_tc_22.gph, replace) 
(file diff_los_mod22_3y_tc_22.gph saved)

. tw      (rarea fdiff2_los_from3_3_lci_3y fdiff2_los_from3_3_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (line fdiff2_los_from3_3_3y timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         yline(0, lcolor(navy)) ///
>  xtitle(Time (years)) ytitle(Difference in Lengths) xlab(0(.3)5,labsize(small)) legend(order(1 "CI95%" 2 "Difference") pos(7) ring(0) c(1)) ///
>  title("Difference in Lengths of Stay (2nd patient)") name(diff_los_mod33_3y_tc_22, replace) ///
>  subtitle("from 2nd Readmission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(diff_los_mod33_3y_tc_22.gph, replace) 
(file diff_los_mod33_3y_tc_22.gph saved)

. tw      (rarea fdiff2_los_from4_4_lci_3y fdiff2_los_from4_4_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (line fdiff2_los_from4_4_3y timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         yline(0, lcolor(navy)) ///
>  xtitle(Time (years)) ytitle(Difference in Lengths) xlab(0(.3)5,labsize(small)) legend(order(1 "CI95%" 2 "Difference") pos(7) ring(0) c(1)) ///
>  title("Difference in Lengths of Stay (2nd patient)") name(diff_los_mod44_3y_tc_22, replace) ///
>  subtitle("from 3rd Readmission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(diff_los_mod44_3y_tc_22.gph, replace) 
(file diff_los_mod44_3y_tc_22.gph saved)

=============================================================================

(RP) Figures of Differences in Lengths of Stay, with Treatment Completion at Baseline (3yrs)

=============================================================================

. tw      (rarea fdiff2_los_from1_1_lci_3y_rp fdiff2_los_from1_1_uci_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (line fdiff2_los_from1_1_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         yline(0, lcolor(navy)) ///
>  xtitle(Time (years)) ytitle(Difference in Lengths) xlab(0(.3)5,labsize(small)) legend(order(1 "CI95%" 2 "Difference") pos(7) ring(0) c(1)) ///
>  title("Difference in Lengths of Stay (2nd patient)") name(diff_los_mod11_3y_rp_tc_22, replace) ///
>  subtitle("from Admission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(diff_los_mod11_3y_rp_tc_22.gph, replace) 
(file diff_los_mod11_3y_rp_tc_22.gph saved)

. tw      (rarea fdiff2_los_from2_2_lci_3y_rp fdiff2_los_from2_2_uci_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (line fdiff2_los_from2_2_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         yline(0, lcolor(navy)) ///
>  xtitle(Time (years)) ytitle(Difference in Lengths) xlab(0(.3)5,labsize(small)) legend(order(1 "CI95%" 2 "Difference") pos(7) ring(0) c(1)) ///
>  title("Difference in Lengths of Stay (2nd patient)") name(diff_los_mod22_3y_rp_tc_22, replace) ///
>  subtitle("from Readmission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(diff_los_mod22_3y_rp_tc_22.gph, replace) 
(file diff_los_mod22_3y_rp_tc_22.gph saved)

. tw      (rarea fdiff2_los_from3_3_lci_3y_rp fdiff2_los_from3_3_uci_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (line fdiff2_los_from3_3_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         yline(0, lcolor(navy)) ///
>  xtitle(Time (years)) ytitle(Difference in Lengths) xlab(0(.3)5,labsize(small)) legend(order(1 "CI95%" 2 "Difference") pos(7) ring(0) c(1)) ///
>  title("Difference in Lengths of Stay (2nd patient)") name(diff_los_mod33_3y_rp_tc_22, replace) ///
>  subtitle("from 2nd Readmission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(diff_los_mod33_3y_rp_tc_22.gph, replace) 
(file diff_los_mod33_3y_rp_tc_22.gph saved)

. tw      (rarea fdiff2_los_from4_4_lci_3y_rp fdiff2_los_from4_4_uci_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (line fdiff2_los_from4_4_3y_rp timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         yline(0, lcolor(navy)) ///
>  xtitle(Time (years)) ytitle(Difference in Lengths) xlab(0(.3)5,labsize(small)) legend(order(1 "CI95%" 2 "Difference") pos(7) ring(0) c(1)) ///
>  title("Difference in Lengths of Stay (2nd patient)") name(diff_los_mod44_3y_rp_tc_22, replace) ///
>  subtitle("from 3rd Readmission")  /// * text(0.2 4 "Ambulatory", size(small)) /// * text(0.29 4 "Residential", size(small)) ///
>  graphregion(col(white)) saving(diff_los_mod44_3y_rp_tc_22.gph, replace) 
(file diff_los_mod44_3y_rp_tc_22.gph saved)

=============================================================================

Figures_of_Differences_in_Probabilities,_Treatment_Completion_vs.Noncompletion_at_Baseline(3yrs)

=============================================================================

. tw      (rarea fdiff2a_prob_from1_2_lci_3y fdiff2a_prob_from1_2_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (rarea fdiff2b_prob_from1_2_lci_3y fdiff2b_prob_from1_2_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(gs3) color(gs3%65)) ///
>         (line fdiff2a_prob_from1_2_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) lpattern("-")) ///
>         (line fdiff2b_prob_from1_2_3y timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         xtitle(Time (years)) ytitle(Difference in Lengths) xlab(0(.3)5,labsize(small)) ///
>         legend(order(1 "CI95% Amb" 3 "Difference Amb" 2 "CI95% Res" 4 "Difference Res") pos(10) ring(0)) ///
>         title("Difference in Probabilities (Comp. vs. No-Comp.) 3yrs") name(fdiff_prob_1_2_3y_tcnc, replace) ///
>         subtitle("from Admission")  /// 
>         graphregion(col(white)) saving(diff_prob_mod12_3y_tcnc_22.gph, replace) 
(file diff_prob_mod12_3y_tcnc_22.gph saved)

. tw      (rarea fdiff2a_prob_from2_3_lci_3y fdiff2a_prob_from2_3_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (rarea fdiff2b_prob_from2_3_lci_3y fdiff2b_prob_from2_3_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(gs3) color(gs3%65)) ///
>         (line fdiff2a_prob_from2_3_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) lpattern("-")) ///
>         (line fdiff2b_prob_from2_3_3y timevar01, sort connect(stairstep stairstep) lcolor(black)) , ///
>         xtitle(Time (years)) ytitle(Difference in Lengths) xlab(0(.3)5,labsize(small)) ///
>         legend(order(1 "CI95% Amb" 3 "Difference Amb" 2 "CI95% Res" 4 "Difference Res") pos(7) ring(0)) ///
>         title("Difference in Probabilities (Comp. vs. No-Comp.) 3yrs") name(fdiff_prob_2_3_3y_tcnc, replace) ///
>         subtitle("from Readmission")  /// 
>         graphregion(col(white)) saving(diff_prob_mod23_3y_tcnc_22.gph, replace) 
(file diff_prob_mod23_3y_tcnc_22.gph saved)

. tw      (rarea fdiff2a_prob_from3_4_lci_3y fdiff2a_prob_from3_4_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (rarea fdiff2b_prob_from3_4_lci_3y fdiff2b_prob_from3_4_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(gs3) color(gs3%65))  ///
>         (line fdiff2a_prob_from3_4_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) lpattern("-")) ///
>         (line fdiff2b_prob_from3_4_3y timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         xtitle(Time (years)) ytitle(Difference in Lengths) xlab(0(.3)5,labsize(small)) ///
>         legend(order(1 "CI95% Amb" 3 "Difference Amb" 2 "CI95% Res" 4 "Difference Res") pos(10) ring(0)) ///
>         title("Difference in Probabilities (Comp. vs. No-Comp.) 3yrs") name(fdiff_prob_3_4_3y_tcnc, replace) ///
>         subtitle("from  2{sup:nd} Readmission")  /// 
>         graphregion(col(white)) saving(diff_prob_mod34_3y_tcnc_22.gph, replace) 
(file diff_prob_mod34_3y_tcnc_22.gph saved)

. tw      (rarea fdiff2a_prob_from4_5_lci_3y fdiff2a_prob_from4_5_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (rarea fdiff2b_prob_from4_5_lci_3y fdiff2b_prob_from4_5_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(gs3) color(gs3%65))  ///
>         (line fdiff2a_prob_from4_5_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) lpattern("-")) ///
>         (line fdiff2b_prob_from4_5_3y timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         xtitle(Time (years)) ytitle(Difference in Lengths) xlab(0(.3)5,labsize(small)) ///
>         legend(order(1 "CI95% Amb" 3 "Difference Amb" 2 "CI95% Res" 4 "Difference Res") pos(7) ring(0)) ///
>         title("Difference in Probabilities (Comp. vs. No-Comp.) 3yrs") name(fdiff_prob_4_5_3y_tcnc, replace) ///
>         subtitle("from  3{sup:rd} Readmission")  /// 
>         graphregion(col(white)) saving(diff_prob_mod45_3y_tcnc_22.gph, replace) 
(file diff_prob_mod45_3y_tcnc_22.gph saved)

=============================================================================

Figures_of_Differences_in_Lengths_of_Stay,_Treatment_Completion_vs.Noncompletion_at_Baseline(3yrs)

=============================================================================

. tw      (rarea fdiff2a_los_from1_1_lci_3y fdiff2a_los_from1_1_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65))  ///
>         (rarea fdiff2b_los_from1_1_lci_3y fdiff2b_los_from1_1_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(gs3) color(gs3%65)) ///
>         (line fdiff2a_los_from1_1_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) lpattern("-")) ///
>         (line fdiff2b_los_from1_1_3y timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         xtitle(Time (years)) ytitle(Difference in Lengths) xlab(0(.3)5,labsize(small)) ///
>         legend(order(1 "CI95% Amb" 3 "Difference Amb" 2 "CI95% Res" 4 "Difference Res") pos(10) ring(0)) ///
>         title("Difference in Lengths of Stay (Comp. vs. No-Comp.) 3yrs") name(fdiff_los_1_1_3y_tcnc, replace) ///
>         subtitle("from Admission")  /// 
>         graphregion(col(white)) saving(diff_los_mod11_3y_tcnc_22.gph, replace) 
(file diff_los_mod11_3y_tcnc_22.gph saved)

. tw      (rarea fdiff2a_los_from2_2_lci_3y fdiff2a_los_from2_2_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (rarea fdiff2b_los_from2_2_lci_3y fdiff2b_los_from2_2_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(gs3) color(gs3%65)) ///
>         (line fdiff2a_los_from2_2_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) lpattern("-")) ///
>         (line fdiff2b_los_from2_2_3y timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         xtitle(Time (years)) ytitle(Difference in Lengths) xlab(0(.3)5,labsize(small)) ///
>         legend(order(1 "CI95% Amb" 3 "Difference Amb" 2 "CI95% Res" 4 "Difference Res") pos(10) ring(0)) ///
>         title("Difference in Lengths of Stay (Comp. vs. No-Comp.) 3yrs") name(fdiff_los_2_2_3y_tcnc, replace) ///
>         subtitle("from Readmission")  /// 
>         graphregion(col(white)) saving(diff_los_mod22_3y_tcnc_22.gph, replace) 
(file diff_los_mod22_3y_tcnc_22.gph saved)

. tw      (rarea fdiff2a_los_from3_3_lci_3y fdiff2a_los_from3_3_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (rarea fdiff2b_los_from3_3_lci_3y fdiff2b_los_from3_3_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(gs3) color(gs3%65)) ///
>         (line fdiff2a_los_from3_3_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) lpattern("-")) ///
>         (line fdiff2b_los_from3_3_3y timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         xtitle(Time (years)) ytitle(Difference in Lengths) xlab(0(.3)5,labsize(small)) ///
>         legend(order(1 "CI95% Amb" 3 "Difference Amb" 2 "CI95% Res" 4 "Difference Res") pos(10) ring(0)) ///
>         title("Difference in Lengths of Stay (Comp. vs. No-Comp.) 3yrs") name(fdiff_los_3_3_3y_tcnc, replace) ///
>         subtitle("from 2{sup:nd} Readmission")  /// 
>         graphregion(col(white)) saving(diff_los_mod33_3y_tcnc_22.gph, replace) 
(file diff_los_mod33_3y_tcnc_22.gph saved)

. tw      (rarea fdiff2a_los_from4_4_lci_3y fdiff2a_los_from4_4_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) color(gs8%65)) ///
>         (rarea fdiff2b_los_from4_4_lci_3y fdiff2b_los_from4_4_uci_3y timevar01, sort connect(stairstep stairstep) lcolor(gs3) color(gs3%65)) ///
>         (line fdiff2a_los_from4_4_3y timevar01, sort connect(stairstep stairstep) lcolor(gs8) lpattern("-")) ///
>         (line fdiff2b_los_from4_4_3y timevar01, sort connect(stairstep stairstep) lcolor(black)), ///
>         xtitle(Time (years)) ytitle(Difference in Lengths) xlab(0(.3)5,labsize(small)) ///
>         legend(order(1 "CI95% Amb" 3 "Difference Amb" 2 "CI95% Res" 4 "Difference Res") pos(10) ring(0)) ///
>         title("Difference in Lengths of Stay (Comp. vs. No-Comp.) 3yrs") name(fdiff_los_2_2_3y_tcnc, replace) ///
>         subtitle("from 3{sup:rd} Readmission")  /// 
>         graphregion(col(white)) saving(diff_los_mod44_3y_tcnc_22.gph, replace) 
(file diff_los_mod44_3y_tcnc_22.gph saved)

=============================================================================

Analyses_by_transitions

=============================================================================

. graph combine "${pathdata}\diff_mod12_0_22.gph" "${pathdata}\diff_mod12_0_rp_22.gph" "${pathdata}\diff_mod12_3y_22.gph" "${pathdata}\diff_mod12_3y_22.gph" ///
> "${pathdata}\diff_mod12_3y_tc_22.gph" "${pathdata}\diff_mod12_3y_rp_tc_22.gph", ///
> colfirst ycommon xcommon iscale(*.5) imargin(tiny) graphregion(color(gs16)) ///
> title("Combination of the First Transition", size(medium)) cols(4) ///
> subtitle("{it: Treatment completion at baseline(last 2)}", size(small)) ///
> note("{it:              Note: Ordered by columns, from up to down, left to right}", size(tiny))

. graph export "_1st_transition_22.png", as(png) replace width(2000) height(1000)
(file _1st_transition_22.png written in PNG format)

. graph export "_1st_transition_22.pdf", as(pdf) replace //*width(2000) height(2000) orientation(landscape)
(file _1st_transition_22.pdf written in PDF format)

. *graph export "_Appendix2_Graph_Mean_SE_g32.svg", as(svg) replace height(20000) fontface (Helvetica)

. graph combine "${pathdata}\diff_mod23_0_22.gph" "${pathdata}\diff_mod23_0_rp_22.gph" "${pathdata}\diff_mod23_3y_22.gph" "${pathdata}\diff_mod23_3y_22.gph" ///
> "${pathdata}\diff_mod23_3y_tc_22.gph" "${pathdata}\diff_mod23_3y_rp_tc_22.gph", ///
> colfirst ycommon xcommon iscale(*.5) imargin(tiny) graphregion(color(gs16)) ///
> title("Combination of the Second Transition", size(medium)) cols(4) ///
> subtitle("{it: Treatment completion at baseline(last 2)}", size(small)) ///
> note("{it:              Note: Ordered by columns, from up to down, left to right}", size(tiny))

. graph export "_2nd_transition_22.png", as(png) replace width(2000) height(1000)
(file _2nd_transition_22.png written in PNG format)

. graph export "_2nd_transition_22.pdf", as(pdf) replace //*width(2000) height(2000) orientation(landscape)
(file _2nd_transition_22.pdf written in PDF format)

. *graph export "_Appendix2_Graph_Mean_SE_g32.svg", as(svg) replace height(20000) fontface (Helvetica)

. graph combine "${pathdata}\diff_mod34_0_22.gph" "${pathdata}\diff_mod34_0_rp_22.gph" "${pathdata}\diff_mod34_3y_22.gph" "${pathdata}\diff_mod34_3y_22.gph" ///
> "${pathdata}\diff_mod34_3y_tc_22.gph" "${pathdata}\diff_mod34_3y_rp_tc_22.gph", ///
> colfirst ycommon xcommon iscale(*.5) imargin(tiny) graphregion(color(gs16)) ///
> title("Combination of the Third Transition", size(medium)) cols(4) ///
> subtitle("{it: Treatment completion at baseline(last 2)}", size(small)) ///
> note("{it:              Note: Ordered by columns, from up to down, left to right}", size(tiny))

. graph export "_3rd_transition_22.png", as(png) replace width(2000) height(1000)
(file _3rd_transition_22.png written in PNG format)

. graph export "_3rd_transition_22.pdf", as(pdf) replace //*width(2000) height(2000) orientation(landscape)
(file _3rd_transition_22.pdf written in PDF format)

. *graph export "_Appendix2_Graph_Mean_SE_g32.svg", as(svg) replace height(20000) fontface (Helvetica)

. graph combine "${pathdata}\diff_mod45_0_22.gph" "${pathdata}\diff_mod45_0_rp_22.gph" "${pathdata}\diff_mod45_3y_22.gph" "${pathdata}\diff_mod45_3y_22.gph" ///
> "${pathdata}\diff_mod45_3y_tc_22.gph" "${pathdata}\diff_mod45_3y_rp_tc_22.gph", ///
> colfirst ycommon xcommon iscale(*.5) imargin(tiny) graphregion(color(gs16)) ///
> title("Combination of the Fourth Transition", size(medium)) cols(4) ///
> subtitle("{it: Treatment completion at baseline(last 2)}", size(small)) ///
> note("{it:              Note: Ordered by columns, from up to down, left to right}", size(tiny))

. graph export "_4th_transition_22.png", as(png) replace width(2000) height(1000)
(file _4th_transition_22.png written in PNG format)

. graph export "_4th_transition_22.pdf", as(pdf) replace //*width(2000) height(2000) orientation(landscape)
(file _4th_transition_22.pdf written in PDF format)

. *graph export "_Appendix2_Graph_Mean_SE_g32.svg", as(svg) replace height(20000) fontface (Helvetica)

Two plots of the four transitions, compared to AJ estimates (arrival at 0 days & no treatment completion at baseline).

. graph combine "${pathdata}\trans_models_12_0_22.gph" "${pathdata}\trans_models_23_0_22.gph" "${pathdata}\trans_models_34_0_22.gph" "${pathdata}\trans_models_45_0_22.gph" ///
> "${pathdata}\trans_models_12_0_rp_22.gph" "${pathdata}\trans_models_23_0_rp_22.gph" "${pathdata}\trans_models_34_0_rp_22.gph" "${pathdata}\trans_models_45_0_rp_22.gph", ///
> colfirst ycommon xcommon iscale(*.5) imargin(tiny) graphregion(color(gs16)) ///
> title("Combination of the Transition Probabilities", size(medium)) cols(4) ///
> subtitle("{it: in each transition}", size(small)) name(comb_probs_1st_pat_0_22, replace) ///
> note("{it:              Note: Ordered by columns, from up to down, left to right}", size(tiny))

. 
. set graphics off

. 
. gr_edit .plotregion1.graph2.legend.DragBy 19 -10

. gr_edit .plotregion1.graph3.legend.DragBy 19 -10

. gr_edit .plotregion1.graph6.legend.DragBy 19 -10

. gr_edit .plotregion1.graph7.legend.DragBy 19 -10

. 
. forvalues i = 1/8 {
  2. gr_edit .plotregion1.graph`i'.legend.plotregion1.label[1].text = {}
  3. gr_edit .plotregion1.graph`i'.legend.plotregion1.label[1].text.Arrpush Ambulatory CI95%
  4. gr_edit .plotregion1.graph`i'.legend.plotregion1.label[3].text = {}
  5. gr_edit .plotregion1.graph`i'.legend.plotregion1.label[3].text.Arrpush Ambulatory
  6. gr_edit .plotregion1.graph`i'.legend.plotregion1.label[5].text = {}
  7. gr_edit .plotregion1.graph`i'.legend.plotregion1.label[5].text.Arrpush `"Ambulatory(AJ)"'
  8. gr_edit .plotregion1.graph`i'.legend.plotregion1.label[6].text = {}
  9. gr_edit .plotregion1.graph`i'.legend.plotregion1.label[6].text.Arrpush `"Residential(AJ)"'
 10. }

. 
. set graphics on

. 
. gr_edit .plotregion1.graph2.legend.DragBy 0 0

. 
. *gr_edit .plotregion1.graph2.move legend above 7 5
. graph export "_probs_comb_0_22.png", as(png) replace width(2000) height(1000)
(file _probs_comb_0_22.png written in PNG format)

. graph export "_probs_comb_0_22.pdf", as(pdf) replace //*width(2000) height(2000) orientation(landscape)
(file _probs_comb_0_22.pdf written in PDF format)

. *graph export "_Appendix2_Graph_Mean_SE_g32.svg", as(svg) replace height(20000) fontface (Helvetica)

. graph combine "${pathdata}\los_models_11_0_22.gph" "${pathdata}\los_models_22_0_22.gph" "${pathdata}\los_models_33_0_22.gph" "${pathdata}\los_models_44_0_22.gph" ///
> "${pathdata}\los_models_11_0_rp_22.gph" "${pathdata}\los_models_22_0_rp_22.gph" "${pathdata}\los_models_33_0_rp_22.gph" "${pathdata}\los_models_44_0_rp_22.gph", ///
> colfirst ycommon xcommon iscale(*.5) imargin(tiny) graphregion(color(gs16)) ///
> title("Combination of the Lengths of Stay", size(medium)) cols(4) ///
> subtitle("{it: in each transition}", size(small)) name(comb_los_1st_pat_0_22, replace) ///
> note("{it:              Note: Ordered by columns, from up to down, left to right}", size(tiny)) ///
> l1(Probabilities, size(small)) b1(Time (in years), size(small)) 

. 
. set graphics off

. 
. forvalues i = 1/8 {
  2. gr_edit .plotregion1.graph`i'.legend.plotregion1.label[1].text = {}
  3. gr_edit .plotregion1.graph`i'.legend.plotregion1.label[1].text.Arrpush Ambulatory CI95%
  4. gr_edit .plotregion1.graph`i'.legend.plotregion1.label[3].text = {}
  5. gr_edit .plotregion1.graph`i'.legend.plotregion1.label[3].text.Arrpush Ambulatory
  6. 
. gr_edit .plotregion1.graph`i'.title.draw_view.setstyle, style(no)
  7. gr_edit .plotregion1.graph`i'.yaxis1.title.draw_view.setstyle, style(no)
  8. gr_edit .plotregion1.graph`i'.xaxis1.title.draw_view.setstyle, style(no)
  9. gr_edit .plotregion1.graph`i'.subtitle.style.editstyle size(medlarge) editcopy
 10. }

. //gr_edit .title.draw_view.setstyle, style(no)
. //gr_edit .subtitle.draw_view.setstyle, style(no)
. 
. set graphics on

. 
. gr_edit .plotregion1.graph2.legend.DragBy 0 0

. 
. graph export "_los_comb_0_22.png", as(png) replace width(2000) height(1000)
(file _los_comb_0_22.png written in PNG format)

. graph export "_los_comb_0_22.pdf", as(pdf) replace //*width(2000) height(2000) orientation(landscape)
(file _los_comb_0_22.pdf written in PDF format)

. *graph export "_Appendix2_Graph_Mean_SE_g32.svg", as(svg) replace height(20000) fontface (Helvetica)

. graph combine "${pathdata}\trans_models_12_3y_22.gph" "${pathdata}\trans_models_23_3y_22.gph" "${pathdata}\trans_models_34_3y_22.gph" "${pathdata}\trans_models_45_3y_22.gph" ///
> "${pathdata}\trans_models_12_3y_rp_22.gph" "${pathdata}\trans_models_23_3y_rp_22.gph" "${pathdata}\trans_models_34_3y_rp_22.gph" "${pathdata}\trans_models_45_3y_rp_22.gph", ///
> colfirst ycommon xcommon iscale(*.5) imargin(tiny) graphregion(color(gs16)) ///
> title("Combination of the Transition Probabilities", size(medium)) cols(4) ///
> subtitle("{it: in each transition}", size(small)) name(comb_probs_1st_pat_3y_22, replace) ///
> note("{it:              Note: Ordered by columns, from up to down, left to right}", size(tiny))

. 
. set graphics off

. 
. gr_edit .plotregion1.graph2.legend.DragBy 19 -10

. gr_edit .plotregion1.graph3.legend.DragBy 19 -10

. gr_edit .plotregion1.graph6.legend.DragBy 19 -10

. gr_edit .plotregion1.graph7.legend.DragBy 19 -10

. 
. forvalues i = 1/8 {
  2. gr_edit .plotregion1.graph`i'.legend.plotregion1.label[1].text = {}
  3. gr_edit .plotregion1.graph`i'.legend.plotregion1.label[1].text.Arrpush Ambulatory CI95%
  4. gr_edit .plotregion1.graph`i'.legend.plotregion1.label[3].text = {}
  5. gr_edit .plotregion1.graph`i'.legend.plotregion1.label[3].text.Arrpush Ambulatory
  6. gr_edit .plotregion1.graph`i'.legend.plotregion1.label[5].text = {}
  7. gr_edit .plotregion1.graph`i'.legend.plotregion1.label[5].text.Arrpush `"Ambulatory(AJ)"'
  8. gr_edit .plotregion1.graph`i'.legend.plotregion1.label[6].text = {}
  9. gr_edit .plotregion1.graph`i'.legend.plotregion1.label[6].text.Arrpush `"Residential(AJ)"'
 10. }

. 
. set graphics on

. 
. gr_edit .plotregion1.graph2.legend.DragBy 0 0

. 
. *gr_edit .plotregion1.graph2.move legend above 7 5
. graph export "_probs_comb_3y_22.png", as(png) replace width(2000) height(1000)
(file _probs_comb_3y_22.png written in PNG format)

. graph export "_probs_comb_3y_22.pdf", as(pdf) replace //*width(2000) height(2000) orientation(landscape)
(file _probs_comb_3y_22.pdf written in PDF format)

. *graph export "_Appendix2_Graph_Mean_SE_g32.svg", as(svg) replace height(20000) fontface (Helvetica)

. graph combine "${pathdata}\los_models_11_3y_22.gph" "${pathdata}\los_models_22_3y_22.gph" "${pathdata}\los_models_33_3y_22.gph" "${pathdata}\los_models_44_3y_22.gph" ///
> "${pathdata}\los_models_11_3y_rp_22.gph" "${pathdata}\los_models_22_3y_rp_22.gph" "${pathdata}\los_models_33_3y_rp_22.gph" "${pathdata}\los_models_44_3y_rp_22.gph", ///
> colfirst ycommon xcommon iscale(*.5) imargin(tiny) graphregion(color(gs16)) ///
> title("Combination of the Lengths of Stay", size(medium)) cols(4) ///
> subtitle("{it: in each transition}", size(small)) ///
> note("{it:              Note: Ordered by columns, from up to down, left to right}", size(tiny)) ///
> l1(Probabilities, size(small)) b1(Time (in years), size(small)) 

. 
. set graphics off

. 
. forvalues i = 1/8 {
  2. gr_edit .plotregion1.graph`i'.legend.plotregion1.label[1].text = {}
  3. gr_edit .plotregion1.graph`i'.legend.plotregion1.label[1].text.Arrpush Ambulatory CI95%
  4. gr_edit .plotregion1.graph`i'.legend.plotregion1.label[3].text = {}
  5. gr_edit .plotregion1.graph`i'.legend.plotregion1.label[3].text.Arrpush Ambulatory
  6. 
. gr_edit .plotregion1.graph`i'.title.draw_view.setstyle, style(no)
  7. gr_edit .plotregion1.graph`i'.yaxis1.title.draw_view.setstyle, style(no)
  8. gr_edit .plotregion1.graph`i'.xaxis1.title.draw_view.setstyle, style(no)
  9. gr_edit .plotregion1.graph`i'.subtitle.style.editstyle size(medlarge) editcopy
 10. }

. //gr_edit .title.draw_view.setstyle, style(no)
. //gr_edit .subtitle.draw_view.setstyle, style(no)
. 
. set graphics on

. 
. gr_edit .plotregion1.graph2.legend.DragBy 0 0

. 
. graph export "_los_comb_3y_22.png", as(png) replace width(2000) height(1000)
(file _los_comb_3y_22.png written in PNG format)

. graph export "_los_comb_3y_22.pdf", as(pdf) replace //*width(2000) height(2000) orientation(landscape)
(file _los_comb_3y_22.pdf written in PDF format)

. *graph export "_Appendix2_Graph_Mean_SE_g32.svg", as(svg) replace height(20000) fontface (Helvetica)

Analyses_by_transitions_Differences

. graph combine "${pathdata2}diff_mod12_0_22.gph" "${pathdata2}diff_mod23_0_22.gph" "${pathdata2}diff_mod34_0_22.gph" "${pathdata2}diff_mod45_0_22.gph", colfirst ycommon xcommon iscale(*.7) imargin(tiny) graphregion(color(gs16)) title("Combination of T
> ransitions", size(medium)) cols(2) l1(Differences in transition probabilities, size(small)) b1(Time (in years), size(small)) name(diff_probs_comb_sept_0_22, replace)

. 
. set graphics off

. 
. forvalues i = 1/4 {
  2.         gr_edit .plotregion1.graph`i'.title.draw_view.setstyle, style(no)
  3.         gr_edit .plotregion1.graph`i'.yaxis1.title.draw_view.setstyle, style(no)
  4.         gr_edit .plotregion1.graph`i'.xaxis1.title.draw_view.setstyle, style(no)
  5.         gr_edit .plotregion1.graph`i'.subtitle.style.editstyle size(medlarge) editcopy
  6.  }

.  gr_edit .plotregion1.graph1.legend.plotregion1.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph2.legend.plotregion1.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph4.legend.plotregion1.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph1.legend.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph2.legend.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph4.legend.draw_view.setstyle, style(no)

. 
. gr_edit .title.draw_view.setstyle, style(no)

. gr_edit .plotregion1.graph1.xaxis1.edit_tick 18 5.1 `"5.1   "', tickset(major)

. gr_edit .plotregion1.graph2.xaxis1.edit_tick 18 5.1 `"5.1   "', tickset(major)

. gr_edit .plotregion1.graph3.legend.DragBy .66 40

. 
. set graphics on

. 
. gr_edit .plotregion1.graph2.legend.DragBy 0 0

. 
. graph export "diff_probs_comb_sept_0_22.png", as(png) replace width(2000) height(1000)
(file diff_probs_comb_sept_0_22.png written in PNG format)

. graph export "diff_probs_comb_sept_0_22.pdf", as(pdf) replace //*width(2000) height(2000) orientation(landscape)
(file diff_probs_comb_sept_0_22.pdf written in PDF format)

. *graph export "_Appendix2_Graph_Mean_SE_g32.svg", as(svg) replace height(20000) fontface (Helvetica)
. graph save "diff_probs_comb_sept_0_22", asis replace
file diff_probs_comb_sept_0_22.gph saved

. graph combine "${pathdata2}diff_los_mod11_0_22.gph" "${pathdata2}diff_los_mod22_0_22.gph" "${pathdata2}diff_los_mod33_0_22.gph" "${pathdata2}diff_los_mod44_0_22.gph", colfirst ycommon xcommon iscale(*.7) imargin(tiny) graphregion(color(gs16)) title("
> Combination of Transitions", size(medium)) cols(2) l1(Differences in expected lengths of stay in current state, size(small)) b1(Time (in years), size(small)) name(diff_los_comb_sept_0_22, replace)

. 
. set graphics off

. 
. forvalues i = 1/4 {
  2.         gr_edit .plotregion1.graph`i'.title.draw_view.setstyle, style(no)
  3.         gr_edit .plotregion1.graph`i'.yaxis1.title.draw_view.setstyle, style(no)
  4.         gr_edit .plotregion1.graph`i'.xaxis1.title.draw_view.setstyle, style(no)
  5.         gr_edit .plotregion1.graph`i'.subtitle.style.editstyle size(medlarge) editcopy
  6.  }

.  gr_edit .plotregion1.graph1.legend.plotregion1.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph2.legend.plotregion1.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph4.legend.plotregion1.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph1.legend.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph2.legend.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph4.legend.draw_view.setstyle, style(no)

. 
. gr_edit .title.draw_view.setstyle, style(no)

. gr_edit .plotregion1.graph1.xaxis1.edit_tick 18 5.1 `"5.1   "', tickset(major)

. gr_edit .plotregion1.graph2.xaxis1.edit_tick 18 5.1 `"5.1   "', tickset(major)

. gr_edit .plotregion1.graph3.legend.DragBy .66 40

. 
. set graphics on

. 
. gr_edit .plotregion1.graph2.legend.DragBy 0 0

. 
. graph export "diff_los_comb_sept_0_22.png", as(png) replace width(2000) height(1000)
(file diff_los_comb_sept_0_22.png written in PNG format)

. graph export "diff_los_comb_sept_0_22.pdf", as(pdf) replace //*width(2000) height(2000) orientation(landscape)
(file diff_los_comb_sept_0_22.pdf written in PDF format)

. *graph export "_Appendix2_Graph_Mean_SE_g32.svg", as(svg) replace height(20000) fontface (Helvetica)
. graph save "diff_los_comb_sept_0_22", asis replace
file diff_los_comb_sept_0_22.gph saved

. graph combine "${pathdata2}diff_mod12_3y_22.gph" "${pathdata2}diff_mod23_3y_22.gph" "${pathdata2}diff_mod34_3y_22.gph" "${pathdata2}diff_mod45_3y_22.gph", colfirst ycommon xcommon iscale(*.7) imargin(tiny) graphregion(color(gs16)) title("Combination 
> of Transitions (3y)", size(medium)) cols(2) l1(Differences in transition probabilities, size(small)) b1(Time (in years), size(small)) name(diff_probs_comb_sept_3y_22, replace)

. 
. set graphics off

. 
. forvalues i = 1/4 {
  2.         gr_edit .plotregion1.graph`i'.title.draw_view.setstyle, style(no)
  3.         gr_edit .plotregion1.graph`i'.yaxis1.title.draw_view.setstyle, style(no)
  4.         gr_edit .plotregion1.graph`i'.xaxis1.title.draw_view.setstyle, style(no)
  5.         gr_edit .plotregion1.graph`i'.subtitle.style.editstyle size(medlarge) editcopy
  6.  }

.  gr_edit .plotregion1.graph1.legend.plotregion1.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph2.legend.plotregion1.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph4.legend.plotregion1.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph1.legend.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph2.legend.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph4.legend.draw_view.setstyle, style(no)

. 
. gr_edit .title.draw_view.setstyle, style(no)

. gr_edit .plotregion1.graph1.xaxis1.edit_tick 18 5.1 `"5.1   "', tickset(major)

. gr_edit .plotregion1.graph2.xaxis1.edit_tick 18 5.1 `"5.1   "', tickset(major)

. gr_edit .plotregion1.graph3.legend.DragBy .66 40

. 
. set graphics on

. 
. gr_edit .plotregion1.graph2.legend.DragBy 0 0

. 
. graph export "diff_probs_comb_sept_3y_22.png", as(png) replace width(2000) height(1000)
(file diff_probs_comb_sept_3y_22.png written in PNG format)

. graph export "diff_probs_comb_sept_3y_22.pdf", as(pdf) replace //*width(2000) height(2000) orientation(landscape)
(file diff_probs_comb_sept_3y_22.pdf written in PDF format)

. *graph export "_Appendix2_Graph_Mean_SE_g32.svg", as(svg) replace height(20000) fontface (Helvetica)
. graph save "diff_probs_comb_sept_3y_22", asis replace
file diff_probs_comb_sept_3y_22.gph saved

. graph combine "${pathdata2}diff_los_mod11_3y_22.gph" "${pathdata2}diff_los_mod22_3y_22.gph" "${pathdata2}diff_los_mod33_3y_22.gph" "${pathdata2}diff_los_mod44_3y_22.gph", colfirst ycommon xcommon iscale(*.7) imargin(tiny) graphregion(color(gs16)) tit
> le("Combination of Transitions (3y)", size(medium)) cols(2) l1(Differences in expected lengths of stay in current state, size(small)) b1(Time (in years), size(small)) name(diff_los_comb_sept_3y_22, replace)

. 
. set graphics off

. 
. forvalues i = 1/4 {
  2.         gr_edit .plotregion1.graph`i'.title.draw_view.setstyle, style(no)
  3.         gr_edit .plotregion1.graph`i'.yaxis1.title.draw_view.setstyle, style(no)
  4.         gr_edit .plotregion1.graph`i'.xaxis1.title.draw_view.setstyle, style(no)
  5.         gr_edit .plotregion1.graph`i'.subtitle.style.editstyle size(medlarge) editcopy
  6.  }

.  gr_edit .plotregion1.graph1.legend.plotregion1.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph2.legend.plotregion1.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph4.legend.plotregion1.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph1.legend.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph2.legend.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph4.legend.draw_view.setstyle, style(no)

. 
. gr_edit .title.draw_view.setstyle, style(no)

. gr_edit .plotregion1.graph1.xaxis1.edit_tick 18 5.1 `"5.1   "', tickset(major)

. gr_edit .plotregion1.graph2.xaxis1.edit_tick 18 5.1 `"5.1   "', tickset(major)

. gr_edit .plotregion1.graph3.legend.DragBy .66 40

. 
. set graphics on

. 
. gr_edit .plotregion1.graph2.legend.DragBy 0 0

. 
. graph export "diff_los_comb_sept_3y_22.png", as(png) replace width(2000) height(1000)
(file diff_los_comb_sept_3y_22.png written in PNG format)

. graph export "diff_los_comb_sept_3y_22.pdf", as(pdf) replace //*width(2000) height(2000) orientation(landscape)
(file diff_los_comb_sept_3y_22.pdf written in PDF format)

. *graph export "_Appendix2_Graph_Mean_SE_g32.svg", as(svg) replace height(20000) fontface (Helvetica)
. graph save "diff_los_comb_sept_3y_22", asis replace
file diff_los_comb_sept_3y_22.gph saved

. graph combine "${pathdata2}diff_mod12_0_rp_22.gph" "${pathdata2}diff_mod23_0_rp_22.gph" "${pathdata2}diff_mod34_0_rp_22.gph" "${pathdata2}diff_mod45_0_rp_22.gph", colfirst ycommon xcommon iscale(*.7) imargin(tiny) graphregion(color(gs16)) title("Comb
> ination of Transitions (RP)", size(medium)) cols(2) l1(Differences in transition probabilities, size(small)) b1(Time (in years), size(small)) name(diff_probs_comb_sept_0_rp_22, replace)

. 
. set graphics off

. 
. forvalues i = 1/4 {
  2.         gr_edit .plotregion1.graph`i'.title.draw_view.setstyle, style(no)
  3.         gr_edit .plotregion1.graph`i'.yaxis1.title.draw_view.setstyle, style(no)
  4.         gr_edit .plotregion1.graph`i'.xaxis1.title.draw_view.setstyle, style(no)
  5.         gr_edit .plotregion1.graph`i'.subtitle.style.editstyle size(medlarge) editcopy
  6.  }

.  gr_edit .plotregion1.graph1.legend.plotregion1.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph2.legend.plotregion1.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph4.legend.plotregion1.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph1.legend.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph2.legend.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph4.legend.draw_view.setstyle, style(no)

. 
. gr_edit .title.draw_view.setstyle, style(no)

. gr_edit .plotregion1.graph1.xaxis1.edit_tick 18 5.1 `"5.1   "', tickset(major)

. gr_edit .plotregion1.graph2.xaxis1.edit_tick 18 5.1 `"5.1   "', tickset(major)

. gr_edit .plotregion1.graph3.legend.DragBy .66 40

. 
. set graphics on

. 
. gr_edit .plotregion1.graph2.legend.DragBy 0 0

. 
. graph export "diff_probs_comb_sept_0_rp_22.png", as(png) replace width(2000) height(1000)
(file diff_probs_comb_sept_0_rp_22.png written in PNG format)

. graph export "diff_probs_comb_sept_0_rp_22.pdf", as(pdf) replace //*width(2000) height(2000) orientation(landscape)
(file diff_probs_comb_sept_0_rp_22.pdf written in PDF format)

. *graph export "_Appendix2_Graph_Mean_SE_g32.svg", as(svg) replace height(20000) fontface (Helvetica)
. graph save "diff_probs_comb_sept_0_rp_22", asis replace
file diff_probs_comb_sept_0_rp_22.gph saved

. graph combine "${pathdata2}diff_los_mod11_0_rp_22.gph" "${pathdata2}diff_los_mod22_0_rp_22.gph" "${pathdata2}diff_los_mod33_0_rp_22.gph" "${pathdata2}diff_los_mod44_0_rp_22.gph", colfirst ycommon xcommon iscale(*.7) imargin(tiny) graphregion(color(gs
> 16)) title("Combination of Transitions (RP)", size(medium)) cols(2) l1(Differences in expected lengths of stay in current state, size(small)) b1(Time (in years), size(small)) name(diff_los_comb_sept_0_rp_22, replace)

. 
. set graphics off

. 
. forvalues i = 1/4 {
  2.         gr_edit .plotregion1.graph`i'.title.draw_view.setstyle, style(no)
  3.         gr_edit .plotregion1.graph`i'.yaxis1.title.draw_view.setstyle, style(no)
  4.         gr_edit .plotregion1.graph`i'.xaxis1.title.draw_view.setstyle, style(no)
  5.         gr_edit .plotregion1.graph`i'.subtitle.style.editstyle size(medlarge) editcopy
  6.  }

.  gr_edit .plotregion1.graph1.legend.plotregion1.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph2.legend.plotregion1.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph4.legend.plotregion1.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph1.legend.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph2.legend.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph4.legend.draw_view.setstyle, style(no)

. 
. gr_edit .title.draw_view.setstyle, style(no)

. gr_edit .plotregion1.graph1.xaxis1.edit_tick 18 5.1 `"5.1   "', tickset(major)

. gr_edit .plotregion1.graph2.xaxis1.edit_tick 18 5.1 `"5.1   "', tickset(major)

. gr_edit .plotregion1.graph3.legend.DragBy .66 40

. 
. set graphics on

. 
. gr_edit .plotregion1.graph2.legend.DragBy 0 0

. 
. graph export "diff_los_comb_sept_0_rp_22.png", as(png) replace width(2000) height(1000)
(file diff_los_comb_sept_0_rp_22.png written in PNG format)

. graph export "diff_los_comb_sept_0_rp_22.pdf", as(pdf) replace //*width(2000) height(2000) orientation(landscape)
(file diff_los_comb_sept_0_rp_22.pdf written in PDF format)

. *graph export "_Appendix2_Graph_Mean_SE_g32.svg", as(svg) replace height(20000) fontface (Helvetica)
. graph save "diff_los_comb_sept_0_rp_22", asis replace
file diff_los_comb_sept_0_rp_22.gph saved

. graph combine "${pathdata2}diff_mod12_3y_rp_22.gph" "${pathdata2}diff_mod23_3y_rp_22.gph" "${pathdata2}diff_mod34_3y_rp_22.gph" "${pathdata2}diff_mod45_3y_rp_22.gph", colfirst ycommon xcommon iscale(*.7) imargin(tiny) graphregion(color(gs16)) title("
> Combination of Transitions (3y) (RP)", size(medium)) cols(2) l1(Differences in transition probabilities, size(small)) b1(Time (in years), size(small)) name(diff_probs_comb_sept_3y_rp_22, replace)

. 
. set graphics off

. 
. forvalues i = 1/4 {
  2.         gr_edit .plotregion1.graph`i'.title.draw_view.setstyle, style(no)
  3.         gr_edit .plotregion1.graph`i'.yaxis1.title.draw_view.setstyle, style(no)
  4.         gr_edit .plotregion1.graph`i'.xaxis1.title.draw_view.setstyle, style(no)
  5.         gr_edit .plotregion1.graph`i'.subtitle.style.editstyle size(medlarge) editcopy
  6.  }

.  gr_edit .plotregion1.graph1.legend.plotregion1.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph2.legend.plotregion1.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph4.legend.plotregion1.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph1.legend.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph2.legend.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph4.legend.draw_view.setstyle, style(no)

. 
. gr_edit .title.draw_view.setstyle, style(no)

. gr_edit .plotregion1.graph1.xaxis1.edit_tick 18 5.1 `"5.1   "', tickset(major)

. gr_edit .plotregion1.graph2.xaxis1.edit_tick 18 5.1 `"5.1   "', tickset(major)

. gr_edit .plotregion1.graph3.legend.DragBy .66 40

. 
. set graphics on

. 
. gr_edit .plotregion1.graph2.legend.DragBy 0 0

. 
. graph export "diff_probs_comb_sept_3y_rp_22.png", as(png) replace width(2000) height(1000)
(file diff_probs_comb_sept_3y_rp_22.png written in PNG format)

. graph export "diff_probs_comb_sept_3y_rp_22.pdf", as(pdf) replace //*width(2000) height(2000) orientation(landscape)
(file diff_probs_comb_sept_3y_rp_22.pdf written in PDF format)

. *graph export "_Appendix2_Graph_Mean_SE_g32.svg", as(svg) replace height(20000) fontface (Helvetica)
. graph save "diff_probs_comb_sept_3y_rp_22", asis replace
file diff_probs_comb_sept_3y_rp_22.gph saved

. graph combine "${pathdata2}diff_los_mod11_3y_rp_22.gph" "${pathdata2}diff_los_mod22_3y_rp_22.gph" "${pathdata2}diff_los_mod33_3y_rp_22.gph" "${pathdata2}diff_los_mod44_3y_rp_22.gph", colfirst ycommon xcommon iscale(*.7) imargin(tiny) graphregion(colo
> r(gs16)) title("Combination of Transitions (3y) (RP)", size(medium)) cols(2) l1(Differences in expected lengths of stay in current state, size(small)) b1(Time (in years), size(small)) name(diff_los_comb_sept_3y_rp_22, replace)

. 
. set graphics off

. 
. forvalues i = 1/4 {
  2.         gr_edit .plotregion1.graph`i'.title.draw_view.setstyle, style(no)
  3.         gr_edit .plotregion1.graph`i'.yaxis1.title.draw_view.setstyle, style(no)
  4.         gr_edit .plotregion1.graph`i'.xaxis1.title.draw_view.setstyle, style(no)
  5.         gr_edit .plotregion1.graph`i'.subtitle.style.editstyle size(medlarge) editcopy
  6.  }

.  gr_edit .plotregion1.graph1.legend.plotregion1.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph2.legend.plotregion1.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph4.legend.plotregion1.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph1.legend.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph2.legend.draw_view.setstyle, style(no)

.  gr_edit .plotregion1.graph4.legend.draw_view.setstyle, style(no)

. 
. gr_edit .title.draw_view.setstyle, style(no)

. gr_edit .plotregion1.graph1.xaxis1.edit_tick 18 5.1 `"5.1   "', tickset(major)

. gr_edit .plotregion1.graph2.xaxis1.edit_tick 18 5.1 `"5.1   "', tickset(major)

. gr_edit .plotregion1.graph3.legend.DragBy .66 40

. 
. 
. set graphics on

. 
. gr_edit .plotregion1.graph2.legend.DragBy 0 0

. 
. graph export "diff_los_comb_sept_3y_rp_22.png", as(png) replace width(2000) height(1000)
(file diff_los_comb_sept_3y_rp_22.png written in PNG format)

. graph export "diff_los_comb_sept_3y_rp_22.pdf", as(pdf) replace //*width(2000) height(2000) orientation(landscape)
(file diff_los_comb_sept_3y_rp_22.pdf written in PDF format)

. *graph export "_Appendix2_Graph_Mean_SE_g32.svg", as(svg) replace height(20000) fontface (Helvetica)
. graph save "diff_los_comb_sept_3y_rp_22", asis replace
file diff_los_comb_sept_3y_rp_22.gph saved

=============================================================================

Tables_Completion_vs._Not-Completion_of_the_First_Treatment

=============================================================================

Difference_Probabilities_First_transition_Comp_noComp_Three years

PR_Difference_Probabilities_Comp_noComp_First_transition_3y

. *fdiff2a-> ambulatory
. *fdiff2b-> residential
. *fdiff2b_prob_from4_5_3y fdiff2b_prob_from4_5_lci_3y fdiff2b_prob_from4_5_uci_3y
. foreach var of varlist fdiff2a_prob_from1_2_3y fdiff2a_prob_from1_2_lci_3y fdiff2a_prob_from1_2_uci_3y fdiff2b_prob_from1_2_3y  fdiff2b_prob_from1_2_lci_3y fdiff2b_prob_from1_2_uci_3y  {
  2.                 scalar variable = "`var'"
  3.                                         qui summarize `var' if inrange(timevar01, .32, .34)
  4.                                         scalar e3m_`var' = round(round(r(mean),.001)*100,.1)
  5.                                         qui summarize `var' if inrange(timevar01, .999, 1.02)
  6.                                         scalar e1y_`var' = round(round(r(mean),.001)*100,.1)
  7.                                         qui summarize `var' if inrange(timevar01, 2.99, 3.02)
  8.                                         scalar e3y_`var' = round(round(r(mean),.001)*100,.1)
  9.                                         qui summarize `var' if inrange(timevar01,  4.999, 5.02)
 10.                                         scalar e5y_`var' = round(round(r(mean),.001)*100,.1)
 11.          cap noi matrix ests_`var' = (`=scalar(e3m_`var')'\  `=scalar(e1y_`var')'\ `=scalar(scalar(e3y_`var'))'\ `=scalar(scalar(e5y_`var'))')
 12.          matrix colnames ests_`var' = `var'
 13.          matrix rownames ests_`var' = 3_mths 1_yr 3_yrs 5_yrs
 14.                 }

. 
. matrix est_ds12 = (ests_fdiff2a_prob_from1_2_3y, ests_fdiff2a_prob_from1_2_lci_3y, ests_fdiff2a_prob_from1_2_uci_3y, ests_fdiff2b_prob_from1_2_3y,  ests_fdiff2b_prob_from1_2_lci_3y, ests_fdiff2b_prob_from1_2_uci_3y)

. matrix colnames est_ds12 = Out Out_lci Out_uci Res Res_lci Res_uci

. 
. esttab matrix(est_ds12) using "${pathdata2}diff_probs_1st_2nd_pat_t1_3y_22.html", replace 
(output written to C:/Users/CISS Fondecyt/Mi unidad/Alvacast/SISTRAT 2019 (github)/_mult_state_ags/diff_probs_1st_2nd_pat_t1_3y_22.html)

The transition probabilities are presented here:


est_ds12
Out Out_lci Out_uci Res Res_lci Res_uci

3_mths -1.3 -1.5 -1.1 -2.8 -3.3 -2.4
1_yr -4.2 -4.8 -3.7 -6.1 -7 -5.3
3_yrs -6.4 -7.3 -5.5 -7 -8.1 -6
5_yrs -6.2 -7.1 -5.2 -6.3 -7.5 -5.2

PR_Difference_Probabilities_Comp_noComp_Second_transition_3y

. foreach var of varlist fdiff2a_prob_from2_3_3y fdiff2a_prob_from2_3_lci_3y fdiff2a_prob_from2_3_uci_3y fdiff2b_prob_from2_3_3y  fdiff2b_prob_from2_3_lci_3y fdiff2b_prob_from2_3_uci_3y  {
  2.                 scalar variable = "`var'"
  3.                                         qui summarize `var' if inrange(timevar01, .32, .34)
  4.                                         scalar e3m_`var' = round(round(r(mean),.001)*100,.1)
  5.                                         qui summarize `var' if inrange(timevar01, .999, 1.02)
  6.                                         scalar e1y_`var' = round(round(r(mean),.001)*100,.1)
  7.                                         qui summarize `var' if inrange(timevar01, 2.99, 3.02)
  8.                                         scalar e3y_`var' = round(round(r(mean),.001)*100,.1)
  9.                                         qui summarize `var' if inrange(timevar01,  4.999, 5.02)
 10.                                         scalar e5y_`var' = round(round(r(mean),.001)*100,.1)
 11.          cap noi matrix ests_`var' = (`=scalar(e3m_`var')'\  `=scalar(e1y_`var')'\ `=scalar(scalar(e3y_`var'))'\ `=scalar(scalar(e5y_`var'))')
 12.          matrix colnames ests_`var' = `var'
 13.          matrix rownames ests_`var' = 3_mths 1_yr 3_yrs 5_yrs
 14.                 }

. 
. matrix est_ds22 = (ests_fdiff2a_prob_from2_3_3y, ests_fdiff2a_prob_from2_3_lci_3y, ests_fdiff2a_prob_from2_3_uci_3y, ests_fdiff2b_prob_from2_3_3y,  ests_fdiff2b_prob_from2_3_lci_3y, ests_fdiff2b_prob_from2_3_uci_3y)

. matrix colnames est_ds22 = Out Out_lci Out_uci Res Res_lci Res_uci

. 
. esttab matrix(est_ds22) using "${pathdata2}diff_probs_1st_2nd_pat_t2_3y_22.html", replace 
(output written to C:/Users/CISS Fondecyt/Mi unidad/Alvacast/SISTRAT 2019 (github)/_mult_state_ags/diff_probs_1st_2nd_pat_t2_3y_22.html)

The transition probabilities are presented here:


est_ds22
Out Out_lci Out_uci Res Res_lci Res_uci

3_mths .1 -.6 .8 .1 -.6 .8
1_yr .5 -1.1 2.1 .6 -1 2.2
3_yrs .4 -1.7 2.6 .4 -1.7 2.5
5_yrs .7 -1.6 3.1 .5 -1.8 2.8

PR_Difference_Probabilities_Comp_noComp_Third_transition_3y

. foreach var of varlist fdiff2a_prob_from3_4_3y fdiff2a_prob_from3_4_lci_3y fdiff2a_prob_from3_4_uci_3y fdiff2b_prob_from3_4_3y  fdiff2b_prob_from3_4_lci_3y fdiff2b_prob_from3_4_uci_3y  {
  2.                 scalar variable = "`var'"
  3.                                         qui summarize `var' if inrange(timevar01, .32, .34)
  4.                                         scalar e3m_`var' = round(round(r(mean),.001)*100,.1)
  5.                                         qui summarize `var' if inrange(timevar01, .999, 1.02)
  6.                                         scalar e1y_`var' = round(round(r(mean),.001)*100,.1)
  7.                                         qui summarize `var' if inrange(timevar01, 2.99, 3.02)
  8.                                         scalar e3y_`var' = round(round(r(mean),.001)*100,.1)
  9.                                         qui summarize `var' if inrange(timevar01,  4.999, 5.02)
 10.                                         scalar e5y_`var' = round(round(r(mean),.001)*100,.1)
 11.          cap noi matrix ests_`var' = (`=scalar(e3m_`var')'\  `=scalar(e1y_`var')'\ `=scalar(scalar(e3y_`var'))'\ `=scalar(scalar(e5y_`var'))')
 12.          matrix colnames ests_`var' = `var'
 13.          matrix rownames ests_`var' = 3_mths 1_yr 3_yrs 5_yrs
 14.                 }

. 
. matrix est_ds32 = (ests_fdiff2a_prob_from3_4_3y, ests_fdiff2a_prob_from3_4_lci_3y, ests_fdiff2a_prob_from3_4_uci_3y, ests_fdiff2b_prob_from3_4_3y,  ests_fdiff2b_prob_from3_4_lci_3y, ests_fdiff2b_prob_from3_4_uci_3y)

. matrix colnames est_ds32 = Out Out_lci Out_uci Res Res_lci Res_uci

. 
. esttab matrix(est_ds32) using "${pathdata2}diff_probs_1st_2nd_pat_t3_3y_22.html", replace 
(output written to C:/Users/CISS Fondecyt/Mi unidad/Alvacast/SISTRAT 2019 (github)/_mult_state_ags/diff_probs_1st_2nd_pat_t3_3y_22.html)

The transition probabilities are presented here:


est_ds32
Out Out_lci Out_uci Res Res_lci Res_uci

3_mths -.3 -1.5 .9 -.3 -1.8 1.2
1_yr -.6 -3.5 2.3 -.5 -3.7 2.7
3_yrs 0 -4 3.9 .1 -4 4.3
5_yrs .5 -4 5 .9 -3.9 5.7

PR_Difference_Probabilities_Comp_noComp_Fourth_transition_3y

. foreach var of varlist fdiff2a_prob_from4_5_3y fdiff2a_prob_from4_5_lci_3y fdiff2a_prob_from4_5_uci_3y fdiff2b_prob_from4_5_3y  fdiff2b_prob_from4_5_lci_3y fdiff2b_prob_from4_5_uci_3y  {
  2.                 scalar variable = "`var'"
  3.                                         qui summarize `var' if inrange(timevar01, .32, .34)
  4.                                         scalar e3m_`var' = round(round(r(mean),.001)*100,.1)
  5.                                         qui summarize `var' if inrange(timevar01, .999, 1.02)
  6.                                         scalar e1y_`var' = round(round(r(mean),.001)*100,.1)
  7.                                         qui summarize `var' if inrange(timevar01, 2.99, 3.02)
  8.                                         scalar e3y_`var' = round(round(r(mean),.001)*100,.1)
  9.                                         qui summarize `var' if inrange(timevar01,  4.999, 5.02)
 10.                                         scalar e5y_`var' = round(round(r(mean),.001)*100,.1)
 11.          cap noi matrix ests_`var' = (`=scalar(e3m_`var')'\  `=scalar(e1y_`var')'\ `=scalar(scalar(e3y_`var'))'\ `=scalar(scalar(e5y_`var'))')
 12.          matrix colnames ests_`var' = `var'
 13.          matrix rownames ests_`var' = 3_mths 1_yr 3_yrs 5_yrs
 14.                 }

. 
. matrix est_ds42 = (ests_fdiff2a_prob_from4_5_3y, ests_fdiff2a_prob_from4_5_lci_3y, ests_fdiff2a_prob_from4_5_uci_3y, ests_fdiff2b_prob_from4_5_3y,  ests_fdiff2b_prob_from4_5_lci_3y, ests_fdiff2b_prob_from4_5_uci_3y)

. matrix colnames est_ds42 = Out Out_lci Out_uci Res Res_lci Res_uci

. 
. esttab matrix(est_ds42) using "${pathdata2}diff_probs_1st_2nd_pat_t4_3y_22.html", replace 
(output written to C:/Users/CISS Fondecyt/Mi unidad/Alvacast/SISTRAT 2019 (github)/_mult_state_ags/diff_probs_1st_2nd_pat_t4_3y_22.html)

The transition probabilities are presented here:


est_ds42
Out Out_lci Out_uci Res Res_lci Res_uci

3_mths -1 -3.6 1.6 -1 -3.8 1.7
1_yr -2.4 -8.6 3.8 -2.5 -8.9 4
3_yrs -3.4 -12.8 6 -3.4 -12.9 6.2
5_yrs -3.3 -13.2 6.6 -3.2 -13.1 6.7

Difference_Length_of_Stay_First_transition_Comp_noComp_Three years

LOS_Difference_LOS_Comp_noComp_First_transition_3y

. *fdiff2a-> ambulatory
. *fdiff2b-> residential
. foreach var of varlist fdiff2a_los_from1_1_3y fdiff2a_los_from1_1_lci_3y fdiff2a_los_from1_1_uci_3y fdiff2b_los_from1_1_3y  fdiff2b_los_from1_1_lci_3y fdiff2b_los_from1_1_uci_3y  {
  2.                 scalar variable = "`var'"
  3.                                         qui summarize `var' if inrange(timevar01, .32, .34)
  4.                                         scalar e3m_`var' = round(round(r(mean),.001)*1,.1)
  5.                                         qui summarize `var' if inrange(timevar01, .999, 1.02)
  6.                                         scalar e1y_`var' = round(round(r(mean),.001)*1,.1)
  7.                                         qui summarize `var' if inrange(timevar01, 2.99, 3.02)
  8.                                         scalar e3y_`var' = round(round(r(mean),.001)*1,.1)
  9.                                         qui summarize `var' if inrange(timevar01,  4.999, 5.02)
 10.                                         scalar e5y_`var' = round(round(r(mean),.001)*1,.1)
 11.          cap noi matrix ests_`var' = (`=scalar(e3m_`var')'\  `=scalar(e1y_`var')'\ `=scalar(scalar(e3y_`var'))'\ `=scalar(scalar(e5y_`var'))')
 12.          matrix colnames ests_`var' = `var'
 13.          matrix rownames ests_`var' = 3_mths 1_yr 3_yrs 5_yrs
 14.                 }

. 
. matrix est_ds12_l = (ests_fdiff2a_los_from1_1_3y, ests_fdiff2a_los_from1_1_lci_3y, ests_fdiff2a_los_from1_1_uci_3y, ests_fdiff2b_los_from1_1_3y,  ests_fdiff2b_los_from1_1_lci_3y, ests_fdiff2b_los_from1_1_uci_3y)

. matrix colnames est_ds12_l = Out Out_lci Out_uci Res Res_lci Res_uci

. 
. esttab matrix(est_ds12_l) using "${pathdata2}diff_los_1st_2nd_pat_t1_3y_22.html", replace 
(output written to C:/Users/CISS Fondecyt/Mi unidad/Alvacast/SISTRAT 2019 (github)/_mult_state_ags/diff_los_1st_2nd_pat_t1_3y_22.html)

The transition days are presented here:


est_ds12_l
Out Out_lci Out_uci Res Res_lci Res_uci

3_mths .5 .4 .6 1.4 1.2 1.6
1_yr 8.2 7.2 9.2 14.3 12.5 16.2
3_yrs 55.5 48.5 62.5 74.6 65.3 84
5_yrs 116 101.2 130.8 141.8 123.9 159.6

LOS_Difference_LOS_Comp_noComp_Second_transition_3y

. foreach var of varlist fdiff2a_los_from2_2_3y fdiff2a_los_from2_2_lci_3y fdiff2a_los_from2_2_uci_3y fdiff2b_los_from2_2_3y  fdiff2b_los_from2_2_lci_3y fdiff2b_los_from2_2_uci_3y  {
  2.                 scalar variable = "`var'"
  3.                                         qui summarize `var' if inrange(timevar01, .32, .34)
  4.                                         scalar e3m_`var' = round(round(r(mean),.001)*1,.1)
  5.                                         qui summarize `var' if inrange(timevar01, .999, 1.02)
  6.                                         scalar e1y_`var' = round(round(r(mean),.001)*1,.1)
  7.                                         qui summarize `var' if inrange(timevar01, 2.99, 3.02)
  8.                                         scalar e3y_`var' = round(round(r(mean),.001)*1,.1)
  9.                                         qui summarize `var' if inrange(timevar01,  4.999, 5.02)
 10.                                         scalar e5y_`var' = round(round(r(mean),.001)*1,.1)
 11.          cap noi matrix ests_`var' = (`=scalar(e3m_`var')'\  `=scalar(e1y_`var')'\ `=scalar(scalar(e3y_`var'))'\ `=scalar(scalar(e5y_`var'))')
 12.          matrix colnames ests_`var' = `var'
 13.          matrix rownames ests_`var' = 3_mths 1_yr 3_yrs 5_yrs
 14.                 }

. 
. matrix est_ds22_l = (ests_fdiff2a_los_from2_2_3y, ests_fdiff2a_los_from2_2_lci_3y, ests_fdiff2a_los_from2_2_uci_3y, ests_fdiff2b_los_from2_2_3y,  ests_fdiff2b_los_from2_2_lci_3y, ests_fdiff2b_los_from2_2_uci_3y)

. matrix colnames est_ds22_l = Out Out_lci Out_uci Res Res_lci Res_uci

. 
. esttab matrix(est_ds22_l) using "${pathdata2}diff_los_1st_2nd_pat_t2_3y_22.html", replace 
(output written to C:/Users/CISS Fondecyt/Mi unidad/Alvacast/SISTRAT 2019 (github)/_mult_state_ags/diff_los_1st_2nd_pat_t2_3y_22.html)

The transition days are presented here:


est_ds22_l
Out Out_lci Out_uci Res Res_lci Res_uci

3_mths -.1 -.4 .3 0 -.4 .3
1_yr -.9 -4.4 2.7 -1.1 -4.8 2.5
3_yrs -4.2 -23.9 15.5 -5.3 -25.1 14.5
5_yrs -8.6 -47.2 30.1 -9 -47.7 29.7

LOS_Difference_LOS_Comp_noComp_Third_transition_3y

. foreach var of varlist fdiff2a_los_from3_3_3y fdiff2a_los_from3_3_lci_3y fdiff2a_los_from3_3_uci_3y fdiff2b_los_from3_3_3y  fdiff2b_los_from3_3_lci_3y fdiff2b_los_from3_3_uci_3y  {
  2.                 scalar variable = "`var'"
  3.                                         qui summarize `var' if inrange(timevar01, .32, .34)
  4.                                         scalar e3m_`var' = round(round(r(mean),.001)*1,.1)
  5.                                         qui summarize `var' if inrange(timevar01, .999, 1.02)
  6.                                         scalar e1y_`var' = round(round(r(mean),.001)*1,.1)
  7.                                         qui summarize `var' if inrange(timevar01, 2.99, 3.02)
  8.                                         scalar e3y_`var' = round(round(r(mean),.001)*1,.1)
  9.                                         qui summarize `var' if inrange(timevar01,  4.999, 5.02)
 10.                                         scalar e5y_`var' = round(round(r(mean),.001)*1,.1)
 11.          cap noi matrix ests_`var' = (`=scalar(e3m_`var')'\  `=scalar(e1y_`var')'\ `=scalar(scalar(e3y_`var'))'\ `=scalar(scalar(e5y_`var'))')
 12.          matrix colnames ests_`var' = `var'
 13.          matrix rownames ests_`var' = 3_mths 1_yr 3_yrs 5_yrs
 14.                 }

. 
. matrix est_ds32_l = (ests_fdiff2a_los_from3_3_3y, ests_fdiff2a_los_from3_3_lci_3y, ests_fdiff2a_los_from3_3_uci_3y, ests_fdiff2b_los_from3_3_3y,  ests_fdiff2b_los_from3_3_lci_3y, ests_fdiff2b_los_from3_3_uci_3y)

. matrix colnames est_ds32_l = Out Out_lci Out_uci Res Res_lci Res_uci

. 
. esttab matrix(est_ds32_l) using "${pathdata2}diff_los_1st_2nd_pat_t3_3y_22.html", replace 
(output written to C:/Users/CISS Fondecyt/Mi unidad/Alvacast/SISTRAT 2019 (github)/_mult_state_ags/diff_los_1st_2nd_pat_t3_3y_22.html)

The transition days are presented here:


est_ds32_l
Out Out_lci Out_uci Res Res_lci Res_uci

3_mths .2 -.4 .8 .2 -.5 1
1_yr 1.6 -4.9 8.1 1.5 -6.2 9.1
3_yrs 9.4 -26.6 45.5 8.8 -29.9 47.4
5_yrs 18.1 -51.3 87.6 16.9 -55.2 89

LOS_Difference_LOS_Comp_noComp_Fourth_transition_3y

. foreach var of varlist fdiff2a_los_from4_4_3y fdiff2a_los_from4_4_lci_3y fdiff2a_los_from4_4_uci_3y fdiff2b_los_from4_4_3y  fdiff2b_los_from4_4_lci_3y fdiff2b_los_from4_4_uci_3y  {
  2.                 scalar variable = "`var'"
  3.                                         qui summarize `var' if inrange(timevar01, .32, .34)
  4.                                         scalar e3m_`var' = round(round(r(mean),.001)*1,.1)
  5.                                         qui summarize `var' if inrange(timevar01, .999, 1.02)
  6.                                         scalar e1y_`var' = round(round(r(mean),.001)*1,.1)
  7.                                         qui summarize `var' if inrange(timevar01, 2.99, 3.02)
  8.                                         scalar e3y_`var' = round(round(r(mean),.001)*1,.1)
  9.                                         qui summarize `var' if inrange(timevar01,  4.999, 5.02)
 10.                                         scalar e5y_`var' = round(round(r(mean),.001)*1,.1)
 11.          cap noi matrix ests_`var' = (`=scalar(e3m_`var')'\  `=scalar(e1y_`var')'\ `=scalar(scalar(e3y_`var'))'\ `=scalar(scalar(e5y_`var'))')
 12.          matrix colnames ests_`var' = `var'
 13.          matrix rownames ests_`var' = 3_mths 1_yr 3_yrs 5_yrs
 14.                 }

. 
. matrix est_ds42_l = (ests_fdiff2a_los_from4_4_3y, ests_fdiff2a_los_from4_4_lci_3y, ests_fdiff2a_los_from4_4_uci_3y, ests_fdiff2b_los_from4_4_3y,  ests_fdiff2b_los_from4_4_lci_3y, ests_fdiff2b_los_from4_4_uci_3y)

. matrix colnames est_ds42_l = Out Out_lci Out_uci Res Res_lci Res_uci

. 
. esttab matrix(est_ds42_l) using "${pathdata2}diff_los_1st_2nd_pat_t4_3y_22.html", replace 
(output written to C:/Users/CISS Fondecyt/Mi unidad/Alvacast/SISTRAT 2019 (github)/_mult_state_ags/diff_los_1st_2nd_pat_t4_3y_22.html)

The transition days are presented here:


est_ds42_l
Out Out_lci Out_uci Res Res_lci Res_uci

3_mths .6 -.9 2 .6 -.9 2.1
1_yr 4.8 -8.3 17.9 5.1 -8.6 18.7
3_yrs 27.3 -46 100.5 27.9 -47.4 103.1
5_yrs 52 -92.3 196.3 52.5 -94.3 199.2

=============================================================================

=============================================================================

PR_Export_tables_diff_complete_vs_not_completed_first_treatment

. *https://www.statalist.org/forums/forum/general-stata-discussion/general/1594605-twoway-graph-serset
. 
. local x `" "1_2_3y"     "1_2_lci_3y"    "1_2_uci_3y""' 

. local opt `" "a"        "b""' 

. local wx ""

. foreach s of local opt {
  2. foreach l of local x {
  3. 
.         local wx "`wx' fdiff2`s'_prob_from`l'"
  4.         }
  5. }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("comp_no_comp_diff", modify) cell(B1) firstrow(variables) //*save to Excel worksheetcell(start) cell(A1) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "2_3_3y"     "2_3_lci_3y"    "2_3_uci_3y""' 

. local opt `" "a"        "b""' 

. local wx ""

. foreach s of local opt {
  2. foreach l of local x {
  3. 
.         local wx "`wx' fdiff2`s'_prob_from`l'"
  4.         }
  5. }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("comp_no_comp_diff", modify) cell(B6) //*save to Excel worksheetcell(start) cell(A1) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "3_4_3y"     "3_4_lci_3y"    "3_4_uci_3y""' 

. local opt `" "a"        "b""' 

. local wx ""

. foreach s of local opt {
  2. foreach l of local x {
  3. 
.         local wx "`wx' fdiff2`s'_prob_from`l'"
  4.         }
  5. }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("comp_no_comp_diff", modify) cell(B10) //*save to Excel worksheetcell(start) cell(A1) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "4_5_3y"     "4_5_lci_3y"    "4_5_uci_3y""' 

. local opt `" "a"        "b""' 

. local wx ""

. foreach s of local opt {
  2. foreach l of local x {
  3. 
.         local wx "`wx' fdiff2`s'_prob_from`l'"
  4.         }
  5. }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("comp_no_comp_diff", modify) cell(B14) //*save to Excel worksheetcell(start) cell(A1) 
file trans_prob_los_22_apr.xlsx saved

. 
. 

LOS_Export_tables_diff_complete_vs_not_completed_first_treatment

. *https://www.statalist.org/forums/forum/general-stata-discussion/general/1594605-twoway-graph-serset
. 
. local x `" "1_1_3y"     "1_1_lci_3y"    "1_1_uci_3y""' 

. local opt `" "a"        "b""' 

. local wx ""

. foreach s of local opt {
  2. foreach l of local x {
  3. 
.         local wx "`wx' fdiff2`s'_los_from`l'"
  4.         }
  5. }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("comp_no_comp_diff_los", modify) cell(B1) firstrow(variables) //*save to Excel worksheetcell(start) cell(A1) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "2_2_3y"     "2_2_lci_3y"    "2_2_uci_3y""' 

. local opt `" "a"        "b""' 

. local wx ""

. foreach s of local opt {
  2. foreach l of local x {
  3. 
.         local wx "`wx' fdiff2`s'_los_from`l'"
  4.         }
  5. }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("comp_no_comp_diff_los", modify) cell(B6) //*save to Excel worksheetcell(start) cell(A1) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "3_3_3y"     "3_3_lci_3y"    "3_3_uci_3y""' 

. local opt `" "a"        "b""' 

. local wx ""

. foreach s of local opt {
  2. foreach l of local x {
  3. 
.         local wx "`wx' fdiff2`s'_los_from`l'"
  4.         }
  5. }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("comp_no_comp_diff_los", modify) cell(B10) //*save to Excel worksheetcell(start) cell(A1) 
file trans_prob_los_22_apr.xlsx saved

. 
. local x `" "4_4_3y"     "4_4_lci_3y"    "4_4_uci_3y""' 

. local opt `" "a"        "b""' 

. local wx ""

. foreach s of local opt {
  2. foreach l of local x {
  3. 
.         local wx "`wx' fdiff2`s'_los_from`l'"
  4.         }
  5. }

. export excel timevar01  `wx' if inrange(timevar01, .32, .34)|inrange(timevar01, .999, 1.02)|inrange(timevar01, 2.99, 3.02)|inrange(timevar01, 4.999, 5.02) ///
> using trans_prob_los_22_apr.xlsx, sheet("comp_no_comp_diff_los", modify) cell(B14) //*save to Excel worksheetcell(start) cell(A1) 
file trans_prob_los_22_apr.xlsx saved

. 
. 

Saved at= 21:27:38 4 Aug 2022