Skip to content

Generating by inverting function

6 messages · Salma Wafi, R. Michael Weylandt, David Winsemius

#
On Sat, Sep 29, 2012 at 6:23 PM, Salma Wafi <salmawafi76 at yahoo.com> wrote:
If F is a standard distribution, the q*** functions are what you are
likely looking for. If F is an empirical fit, you'll have to roll your
own but it's not hard. Take a look at the ?ecdf function for some
inspiration.

Michael
#
On Sep 29, 2012, at 10:23 AM, Salma Wafi wrote:

            
This looks a bit confused. 

S(t) = 1- exp( -integral( h(t)dt )
where h(t) is the instantaneous hazard. That integral is the cumulative hazard function.
We do? Seems dubious. That would seem especially unlikely if we assumed that S(t) =exp( b* CDF_normal(t))
You may want to look at the Quantile2 function in package Hmisc. It is designed to generate simulated times for varying hazard ratios when offered survival probabilities. Harrell also has a Lognorm2, a Gompertz2, and Weibull2 functions.


--
David Winsemius, MD
Alameda, CA, USA
#
On Sun, Sep 30, 2012 at 10:51 AM, Salma Wafi <salmawafi76 at yahoo.com> wrote:
I repeat myself: if you have fit F() to a log-normal or Weibull
distribution, just use qlnorm() or qweibull() included in base R. If
you still need to fit those distributions, use MASS::fitdistr.

Cheers,

Michael
#
On Sep 30, 2012, at 5:34 AM, R. Michael Weylandt wrote:

            
No, it does NOT in general or in any of the scenarios you have painted have a uniform distribution. It does, of course, have a range of [0,1].
And I repeat myself, too. If you want to simulate one of a) an arbitrary survival vector, or b) a lognormal or c) a Weibull, then the Hmisc package has facilities to do each of those.

-- 
David.