n <- 200
beta1 <- 1
beta2 <- 2
z1 <- rbinom(n,1,0.5)
z2 <- runif(n,-1,1)
w <- exp(beta1*z1+beta2*z2)
x <- rexp(n, rate=0.3*w)
delta <- 1*(x<=2.5)
x <- pmin(x,2.5)
# compute MLE
mle <- find.shapeCPH(x, cbind(z1,z2) , delta, print=TRUE, type="decreasing")
# estimates of the effect parameter
mle$beta
# plot resulting estimate of baseline hazard
plot(mle)
abline(h=0.3, col="red") # add true baseline
rug(x)
Run the code above in your browser using DataLab