Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: st: RE: generating data from AFT survival models with frailty. Feiveson, Alan H. (JSC-SK311) (Wed Mar 16 11:10:17 2011)
From
Nick Cox <[email protected]>
To
"'[email protected]'" <[email protected]>
Subject
RE: st: RE: generating data from AFT survival models with frailty. Feiveson, Alan H. (JSC-SK311) (Wed Mar 16 11:10:17 2011)
Date
Thu, 17 Mar 2011 12:28:43 +0000
Pedantic comment here:
The code
tempname vlambda
tempvar `vlambda'
creates a tempname which would be later referred to as `vlambda' and _another_ tempname (identified as a variable name) which would be later referred to ``vlambda'' (except that is not done).
Antoine can do exactly what he intends (and nothing else) with the single line
tempvar vlambda
Nick
[email protected]
Antoine Terracol
you can generate a gamma variate with -rgamma()-
to draw from a Weibull distribution, you can use this bit of code:
cap prog drop draweib
program define draweib
syntax newvarlist [if] [in] , LAmbda(string) ALpha(string) [double]
tokenize "`varlist'"
while "`1'"!="" {
tempname vlambda
tempvar `vlambda'
gen `vlambda' = exp(ln(`lambda')/`alpha')
g `double' `1' =((log(1/uniform()))^(1/`alpha'))/`vlambda' `if' `in'
mac shift
}
end
so, to simulate data from a weibull with gamma frailty, you could
clear
set obs 1000
generate frailty=rgamma(1,1)
drawnorm x1 x2
draweib t, alpha(.75) lambda(exp(1+x1+x2)*frailty)
and estimate the model with
stset t
streg x1 x2, dist(weib) frailty(gamma) nohr
You could of course censor the durations as you see fit, and change the
-stset- declaration accordingly.
To draw from an exponential, jut use alpha(1) in -draweib-
Since the weibull/exponential are both PH and AFT you can choose
whatever metric you like, , the coefficients in the AFT metric beeing
equal to -(coeff in PH metric)/alpha
I'm sure it's also possible to simulate from log-normals and
log-logistics with frailty as well, but I have no code to implement it...
Antoine
On 16/03/2011 19:58, Albert Navarro wrote:
> Thank you very much, Alan. Do you know any paper/document where it is implemented in a particular model?
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/