Hi there,
I am trying to simulate survival data by rearranging the Weibull parametric survival function and can't seem to do it. If I use the survsim command it simulates the data perfectly but I want to understand how. Here is what I'm doing:
survsim - hazard rate=0.1, shape parameter=1.2, and HR=2 or log(HR) =0.693
set obs 500
gen trt = rbinomial(1,0.5)
survsim t, dist(weibull) lambda(0.1) gamma(1.2) covariates(trt 0.693)
this generates 500 survival times based of the specified parameters and weibull distribution, if I continue to make an event variable based of these survival times and then run a cox or weibull regression I get a HR for trt variable of 2 which is what I'm looking for.
rearranging weibull equation to solve for t using parameters above
set obs 500
gen trt = rbinomial(1,0.5)
gen t=(-ln(uniform())/0.1*exp(-2.30+0.693*trt))^(1/1.2)
this is the equation I've got for generating t for weibull distribution. However if I run this in stata I don't get the distribution of survival times I'm looking for, if I generate event variable based on survival time and run cox or weibull regression I dont get a hazard ratio of 2 for trt variable. I am definitely doing something wrong with the equation....... any suggestions?
Thanks,
Ben
I am trying to simulate survival data by rearranging the Weibull parametric survival function and can't seem to do it. If I use the survsim command it simulates the data perfectly but I want to understand how. Here is what I'm doing:
survsim - hazard rate=0.1, shape parameter=1.2, and HR=2 or log(HR) =0.693
set obs 500
gen trt = rbinomial(1,0.5)
survsim t, dist(weibull) lambda(0.1) gamma(1.2) covariates(trt 0.693)
this generates 500 survival times based of the specified parameters and weibull distribution, if I continue to make an event variable based of these survival times and then run a cox or weibull regression I get a HR for trt variable of 2 which is what I'm looking for.
rearranging weibull equation to solve for t using parameters above
set obs 500
gen trt = rbinomial(1,0.5)
gen t=(-ln(uniform())/0.1*exp(-2.30+0.693*trt))^(1/1.2)
this is the equation I've got for generating t for weibull distribution. However if I run this in stata I don't get the distribution of survival times I'm looking for, if I generate event variable based on survival time and run cox or weibull regression I dont get a hazard ratio of 2 for trt variable. I am definitely doing something wrong with the equation....... any suggestions?
Thanks,
Ben