Hello,
I am trying to create 10 datasets of simulated survival data and store the estimates in one table.
I have created the following code:
foreach sim of num 1/10 {
clear
set obs 1000
gen trt=rbinomial(1,0.3)
survsim time state event , hazard1(dist(weibull) lambda(0.1) gamma(1.6) covariates (trt 0.7)) hazard2(dist(weibull) lambda(0.1) gamma(1.6) covariates(trt 0.7)) maxtime(5)
stset time1, failure (state1==2)
eststo stcox1_`sim': stcox i.trt, nohr
eststo stccreg1_`sim': stcrreg i.trt, compete(state1==3) noshr
stset time1, failure (state1==3)
eststo stcox2_`sim': stcox i.trt, nohr
eststo stcrreg2_`sim': stcrreg i.trt, compete(state1==2) noshr
}
esttab _all using estimates, p scalars(N_compete N_censor N_fail)
There are 4 regression per dataset. In the end I need to store 40 estimates and their mean survival times as well. However, I cannot store mean survival times because p50 is an r-class variable and esttab only produces e-class variables.
Also when I run the above code, it only saves the estimate for the last data set.
Any help would be greatly appreciated!
Thank you.
Related Posts with Survival Analysis: help with survsim and creating a loop/program to save estimates into a table
Problem with generating a binary variable with individual's state and year specificationsHi all. I am currently doing my dissertation based off the same methodology from Goldin and Katz (2…
looping across multiple variablesHi, I have a dataset that includes several observations for one id and i need to create a sequencin…
Testing heteroskedasticity and autocorrelation in xtlogit without time variableHello all, I have an unbalanced panel data set. For this, STATA (14.2) wants me to define a panel I…
-oaxaca- using normalize option for categorical predictor variablesHi! I know that results from regular -oaxaca- depend on the omitted base category for categorical va…
Create a new string variable containing words of other string variablesDear Statalist: I have a set of string variables that contain each a word related to symptoms of a …
Subscribe to:
Post Comments (Atom)
0 Response to Survival Analysis: help with survsim and creating a loop/program to save estimates into a table
Post a Comment