# Complete data
x = runif(n <- 1000)
y = rweibull(n, shape=2+exp(1+x), scale = exp(-0.5))
fit = vglm(y ~ x, weibull, tra=TRUE)
coef(fit, mat=TRUE)
Coef(fit)
# Type-I right censored data
cutpt = 0.6 # Making this too small results in numerical problems
rcensored = y > cutpt
cy = ifelse(rcensored, cutpt, y)
table(rcensored)
par(mfrow=1:2)
hist(y, xlim=range(y))
hist(cy, xlim=range(y), main="Censored y")
cfit = vglm(cy ~ x, weibull, trace=TRUE, crit="l",
extra=list(rightcensored=rcensored))
coef(cfit, mat=TRUE)
summary(cfit)
Run the code above in your browser using DataLab