[R] plotting the cumulative hazard function of a process whose intensity function is specified

2013-04-11 Thread Elodie Gillain
I would like to simulate a stochastic process by specifying an intensity 
function, say 
lambda(t)=0.05 + 3  exp(−t)


I have the following code, but it has a number of problems. One issue I have is 
I do not know where the time variable is. I would appreciate your help with 
this code.



library("survival")
n <- 5000
lamc<-0.08
k1<-0.05
k2<-3
ld<-function(t){k1+k2}
l<-function(t){k1+k2*exp(-t)}
gendata<-function(n,lamc,k1,k2)
  {
re<-rexp(5*n)/(k1+k2)
ru<-runif(5*n)
y<-rep(0,n)
k<-1
for (i in 1:n){
  u<-re[k]
} 
while (ru[k] __
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] a function to compute the cumulative distribution function (cdf) of the gamma

2007-10-06 Thread elodie gillain
Dear Forum,

I would need to write a function to calculate the cumulative distribution
function (cdf) of the gamma random variable. I am allowed to use the
following precoded functions: rgamma, pgamma, and dgamma. I am a little
overwhelmed by this project,  I am wondering how I should start.  Should I
sum dgamma (or pgamma) from 0 to x, in order to obtain the cdf at x?

Thanks in advance for your input.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.