For each failure-time distribution, generate 1,000 right-censored samples, fit the appropriate model, and get point and interval estimates for lambda (in the exponential model) or for lambda and gamma (for the Weibull and log-logistic models). Are the point estimates close to the true values? Do the 95% confidence intervals contain the true values? In each part, use an exponential(1) distribution as the censoring distribution.

  1. Exponential(3)
f<-rexp(1000, rate=3) ###Follow up time
c<-rexp(1000, rate=1) ####Censoring time
t<-pmin(c,f)
d<-ifelse(c<f,0,1)
exdata<-data.frame(time=t, delta=d)
library(survival)
expfit <- survreg(Surv(time, delta) ~1, data=exdata, dist="exponential")
summary(expfit)
## 
## Call:
## survreg(formula = Surv(time, delta) ~ 1, data = exdata, dist = "exponential")
##              Value Std. Error     z      p
## (Intercept) -1.051      0.037 -28.4 <2e-16
## 
## Scale fixed at 1 
## 
## Exponential distribution
## Loglik(model)= 37   Loglik(intercept only)= 37
## Number of Newton-Raphson Iterations: 5 
## n= 1000
exp(-coef(expfit))
## (Intercept) 
##    2.859395
confint(expfit)
##                 2.5 %     97.5 %
## (Intercept) -1.123052 -0.9781677
exp(-confint(expfit))
##                2.5 %   97.5 %
## (Intercept) 3.074224 2.659579

The value of lambda is close to true value 3 and also this value falls in 95% CIs.

  1. Weibull(1.5, 0.5), meaning lambda = 1.5 and gamma= 0.5.
w<-rweibull(1000, shape=0.5, scale=0.66667) ###Follow up time
tw<-pmin(c,w)
dw<-ifelse(c<w,0,1)

widata<-data.frame(time=tw, delta=dw)
library(survival)
weibfit <- survreg(Surv(time, delta) ~1, data=widata, dist="weibull")
summary(weibfit)
## 
## Call:
## survreg(formula = Surv(time, delta) ~ 1, data = widata, dist = "weibull")
##               Value Std. Error     z       p
## (Intercept) -0.5219     0.0812 -6.42 1.3e-10
## Log(scale)   0.6817     0.0342 19.95 < 2e-16
## 
## Scale= 1.98 
## 
## Weibull distribution
## Loglik(model)= 17.3   Loglik(intercept only)= 17.3
## Number of Newton-Raphson Iterations: 6 
## n= 1000
###Point estimates
lambda<-exp(-coef(weibfit))
lambda
## (Intercept) 
##    1.685221
gamma<- 1/weibfit$scale
gamma
## [1] 0.505744
#####Interval estimates
exp(-confint(weibfit)) #interval for lambda
##                2.5 %   97.5 %
## (Intercept) 1.976118 1.437145
#interval for gamma
vcov(weibfit)
##              (Intercept)   Log(scale)
## (Intercept) 0.0066007867 0.0004981218
## Log(scale)  0.0004981218 0.0011678623
lnRscaleCI<-log(weibfit$scale) + c(-1,1)*1.96*sqrt(vcov(weibfit)[2,2])
exp(-log(weibfit$scale))
## [1] 0.505744
exp(-lnRscaleCI)
## [1] 0.5407796 0.4729784

true value of lambda is close to the rweibull prediction and also in the interval of the 95% CIs value. Also gamma prediction is close to the 0.5.

  1. Log-logistic(1.5, 0.5)
x<-rlogis(1000, location = -log(1.5), scale = 1/0.5)
l<-exp(x)
tl<-pmin(c,l)
dl<-ifelse(c<l,0,1)
ldata<-data.frame(time=tl, delta=dl)

llogfit<-survreg(Surv(time,delta) ~ 1, data=ldata, dist="loglogistic")

summary(llogfit)
## 
## Call:
## survreg(formula = Surv(time, delta) ~ 1, data = ldata, dist = "loglogistic")
##               Value Std. Error    z       p
## (Intercept) -0.4335     0.1205 -3.6 0.00032
## Log(scale)   0.6311     0.0392 16.1 < 2e-16
## 
## Scale= 1.88 
## 
## Log logistic distribution
## Loglik(model)= -163.3   Loglik(intercept only)= -163.3
## Number of Newton-Raphson Iterations: 4 
## n= 1000
###Point estimates
lambda<-exp(-coef(llogfit))
lambda
## (Intercept) 
##    1.542602
gamma<- 1/llogfit$scale
gamma
## [1] 0.5320009
#####Interval estimates
exp(-confint(llogfit)) #interval for lambda
##                2.5 %   97.5 %
## (Intercept) 1.953575 1.218085
#interval for gamma
vcov(llogfit)
##             (Intercept)  Log(scale)
## (Intercept) 0.014522059 0.001595956
## Log(scale)  0.001595956 0.001537622
lnRscaleCI<-log(llogfit$scale) + c(-1,1)*1.96*sqrt(vcov(llogfit)[2,2])
exp(-log(llogfit$scale))
## [1] 0.5320009
exp(-lnRscaleCI)
## [1] 0.5745009 0.4926449

The lambda value is close the true value of 1.5 and true value falls in the 95%confidence interval. gamma value is close to the true value and also in the range of 95% CIs.