Bookmark and Share

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   Antoine Terracol <[email protected]>
To   [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   Wed, 16 Mar 2011 23:08:21 +0100

Hi Albert,

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?

Albert Navarro




*
*   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/



--
Ce message a ete verifie par MailScanner
pour des virus ou des polluriels et rien de
suspect n'a ete trouve.

*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index