Hazard estimate of 'muhaz' function? library(muhaz)
nsam = 5000
time <- rexp(nsam,4)
cause0 = rbinom(nsam,1,.75)
haz = muhaz(time,cause0)
plot(haz)


I simulated failure time data which is exponentially distributed with parameter 4 and the proportion of non-censoring is 75%.
Using 'muhaz' function, I expected that the estimate of hazard is close to 4 which is the exponential parameter regardless of censoring.
But it is around 3 which seems to be 4 * 0.75.
Since the censoring indicators were independently generated from the failure time data, I believe that the estimates of hazard should be constantly 4 regardless of the proportion of censoring.
Am I misunderstanding something or did something go wrong in muhaz function?
 A: When you censor by simply choosing to randomly change the censoring variable, you are essentially leaving in all of the case-"times" under observation until just before they would have died during a complete observation model. (That is an egregious violation of the non-informative censoring assumption needed for survival analysis.) You need to change this to a model where the censoring process shortens time to a sensible (random) number for the censored cases.
censRand <- function(time, cens.t.5){  # cens.t.5 is the t 1/2 of censor process
  ctime <- rexp(n = length(time), rate = 1/cens.t.5)
  event <- (time <= ctime)
  t_obs <- pmin(time, ctime)
  return(data.frame(Times=t_obs, event=event))
}

time=rexp(1000, 4)
ctime <- censRand( time, 0.7)
plot( muhaz( ctime[ ,1], ctime[,2]) )


To get a further notion of the range of time over which this might be a "stable" estimate (if it were not already apparent from the excursions around the simulated parameter) you can run it multiple times:
png()
 plot( muhaz( ctime[ ,1], ctime[,2]) );
 for (i in 1:20) { time=rexp(1000, 4)
                    ctime <- censRand( time, 0.7)
                    lines( muhaz( ctime[ ,1], ctime[,2]) ) };
dev.off()


