Code:

mixed scores i.timepoint || class: || student: matrix define rtable = r(table) // r(table) is a 9 x 7 matrix (columns 5,6,7 are random effects, and row 2 is standard errors) matlist r(table) matrix define rtable = r(table) display exp(2*rtable[1,5]) // this correctly displays the random intercept variance estimate for class * the above estimate can also be shown as .display exp(2*_b[lns1_1_1:_cons] display exp(2*rtable[2,5]) // this line does NOT give the estimated standard error corresponding to the random class intercept display exp(2*rtable[5,5]) // this line does NOT give the estimated lower confidence bound corresponding to the random class intercept display exp(2*rtable[6,5]) // this line does NOT give the estimated upper confidence bound corresponding to the random class intercept

]]>

Code:

clear *Data on extreme weather events input float year int distt_id str12 disaster_type 1950 1 "Flood" 1950 2 "Flood" 1950 3 "Flood" 1951 1 "Heatwave" 1951 2 "Flood" 1951 3 "Flood" 1951 4 "Heatwave" 1953 2 "Drought" 1953 3 "Flood" 1953 5 "Heatwave" 2006 1 "Flood" 2006 3 "Flood" 2006 6 "Drought" 2008 2 "Flood" 2008 5 "Flood" 2008 10 "Flood" 2008 11 "Flood" 2012 1 "Flood" 2012 2 "Flood" 2012 15 "Drought" 2014 10 "Flood" 2014 15 "Flood" 2014 11 "Drought" end capture drop events gen events=0 replace events=1 if inlist(disaster_type,"Flood","Heatwave","Drought") save "D:\Data\Thesis Data\weather data.dta", replace

Code:

input float year int distt_id age *there are many other variables on demographics, income, and labor market 2006 1 20 2006 3 18 2006 6 30 2008 2 5 2008 10 42 2008 13 50 2008 15 35 2012 1 14 2012 3 12 2014 15 29 2014 10 32 2014 15 2 2014 3 2 end capture drop birth_cohort gen birth_cohort=year-age merge m:1 year distt_id using "D:\Data\Thesis Data\weather data.dta" bysort year distt_id birth_cohort:egen tot_events=sum(events) capture drop exposure gen exposure=tot_events/age save "D:\Data\Thesis Data\pslm.dta", replace

Many thanks in advance.]]>

Data: The data are set up with multiple observations per individual. There are two groups of subjects: those who ever used treatment (_treated==1) and those who never used treatment (_treated==0). The data are organized by visit number (vnum) and subjects are matched by several variables (not shown). On the day of starting treatment (niv_rx==1) the users are matched to a never user. The survival (match_time) since the date of matching (match_visit==1) is then compared to see if treatment has an effect on survival.

In addition, I have a time-varying covariate (niv_hrs) which indicates the number of hours per day that the subject was using therapy.

An example of two matched pairs is below

Array

The code and output for my survival analysis is as follows, looking at the survival by receiving therapy, stratified by pair, with niv_hrs as a time-varying covariate. You will see that there is a trend towards a benefit to niv_rx:

stcox niv_rx, strata(pair) tvc(niv_hrs) vce(robust)

Array

However, I cannot do stcurve after this analysis as stcurve is not compatible with stratified analyses. Sts graph does not have an obvious way to both stratify by pairs and adjust for the time-varying covariate. Is there another way to accurately represent this survival curve? Such as through graphing a twoway line to do this with post-estimation commands?

Thank you so much in advance for your time and effort!

JT]]>

Data: The data are set up with multiple observations per individual. There are two groups of subjects: those who ever used treatment (_treated==1) and those who never used treatment (_treated==0). The data are organized by visit number (vnum) and subjects are matched by several variables (not shown). On the day of starting treatment (niv_rx==1) the users are matched to a never user. The survival (match_time) since the date of matching (match_visit==1) is then compared to see if treatment has an effect on survival.

In addition, I have a time-varying covariate (niv_hrs) which indicates the number of hours per day that the subject was using therapy.

An example of two matched pairs is below

| subject_id pair vnum match_visit match_time _treated niv_rx niv_hrs

|--------------------------------------------------------------------------------------------------

| 116572 3191 1 0 -5.6 Untreated 0 0 |

| 116572 3191 2 0 -3.5 Untreated 0 0 |

| 116572 3191 3 1 0 Untreated 0 0 |

| 116572 3191 4 0 3.5 Untreated 0 0 |

| 116572 3191 5 0 5.133333 Untreated 0 0 |

|-----------------------------------------------------------------------------------|

| 116572 3191 6 0 7.933333 Untreated 0 0 |

| 116572 3191 7 0 8.633333 Untreated 0 0 |

| 116572 3191 8 0 10.73333 Untreated 0 0 |

| 116572 3191 9 0 13.53333 Untreated 0 0 |

| 116572 3191 10 0 16.1 Untreated 0 0 |

|-----------------------------------------------------------------------------------|

| 116572 3191 11 0 22.13333 Untreated 0 0 |

| 109006 3191 1 0 -5.6 Treated 0 0 |

| 109006 3191 2 0 -2.566667 Treated 0 0 |

| 109006 3191 3 1 0 Treated 1 4 |

| 109006 3191 4 0 3.5 Treated 1 4 |

|-----------------------------------------------------------------------------------|

| 116686 3199 1 0 -5.7 Untreated 0 0 |

| 116686 3199 2 0 -.8 Untreated 0 0 |

| 116686 3199 3 1 0 Untreated 0 0 |

| 120295 3199 1 0 -6.066667 Treated 0 0 |

| 120295 3199 2 0 -2.333333 Treated 0 0 |

|-----------------------------------------------------------------------------------|

| 120295 3199 3 1 0 Treated 1 0 |

| 120295 3199 4 0 3.266667 Treated 1 8 |

| 120295 3199 5 0 6.533333 Treated 1 8 |

| 120295 3199 6 0 19.86667 Treated 1 8 |

The code and output for my survival analysis is as follows, looking at the survival by receiving therapy, stratified by pair, with niv_hrs as a time-varying covariate. You will see that there is a trend towards a benefit to niv_rx:

stcox niv_rx, strata(pair) tvc(niv_hrs) vce(robust)

------------------------------------------------------------------------------

| Robust

_t | Haz. Ratio Std. Err. z P>|z| [95% Conf. Interval]

-------------+----------------------------------------------------------------

main |

niv_rx | .7963576 .096347 -1.88 0.060 .6282403 1.009463

-------------+----------------------------------------------------------------

tvc |

bipaphours | 1.00039 .0011905 0.33 0.743 .9980599 1.002727

------------------------------------------------------------------------------

Stratified by pair

However, I cannot do stcurve after this analysis as stcurve is not compatible with stratified analyses. Sts graph does not have an obvious way to both stratify by pairs and adjust for the time-varying covariate. Is there another way to accurately represent this survival curve? Such as through graphing a twoway line to do this with post-estimation commands?

Thank you so much in advance for your time and effort!

JT]]>