Description Usage Arguments Author(s) See Also Examples
Plot function for objects of class "iHaz". This function plots the estimated hazard function and the estimated survival function. This is a generic S3
plot function and accepts additional arguments such as line type, color etc.
1 2 |
x |
An object of class "iHaz", the output of our |
... |
Additonal arguments to be passed to the plot function. All additional arguments can be passed to the plot functions except |
Asad Haris, Gary Chan
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | library(iHaz)
#Generate some data
#Here event time is distributed Exponential(1)
#Simulation study from Pan et al. (1998)
n<- 500
x<- rexp(n)
t<- runif(n, min = 0, max = 1.5)
xnew<- x[(x>=t)]
tnew<- t[x>=t]
t<- tnew
a<- xnew
b<- xnew
a[xnew<= tnew+0.5]<- tnew[xnew<= tnew+0.5]
b[xnew<= tnew+0.5]<- tnew[xnew<= tnew+0.5] +0.5
a[xnew > tnew+0.5]<- tnew[xnew > tnew+0.5] +0.5
b[xnew > tnew+0.5]<- Inf
dat<- list("a" = a, "b" = b, "t" = t)
#Fit an 'iHaz' object
fit<- iHaz(dat, ini.index = 1:3 ,verbose =TRUE)
#Veiw/plot extimated hazard function
fit$hazard
plot(fit$hazard, main = "Hazard Function")
#View the survival function
fit$survival
#Estimated survival probabilitcies at some time points
fit$survival(c(0.5,0.8,1,1.5))
#Code NOT RUN
#Plot iHaz object
#plot(fit, col = "red", type = "o", lwd = 1, pch = 16, cex = 0.5)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.