Defining censoring level in survival analysis I'm conducting a simulation analysis using the Exponential, Weibull and Gompertz distribution. To get the times I'm using the table from Austin 2012.

But how can I define the censoring level to be ~30%, ~40% and ~50%?
For the censored observations I'm using $Y_{i} \sim U(0,b)$. The problem is I'm selecting $b$ by trial and error. How can I select $b$ in a general way to give me the censoring levels needed?
Thanks in advance!
 A: If you only have a single combination of covariate values, then $\exp(\beta'x)$ is the same for all of your simulated values. It can thus be included in a single adjusted value of $\lambda$ for any of those distributions, if they are parameterized as above with respect to covariates $x$.
This Math Stack Exchange page shows the approach given the event probability distribution as a function of time, $f(t)$. If the censoring time $C\sim U(0,b)$ and event times are $T$, then the probability of censoring is:
$$P(C<T) = P(C<T \ \& \ T<b) + {P(T \ge b)}.$$
That is, all event times of $b$ or greater are censored, along with a fraction of those at earlier times. Given $f(t)$ you then solve for $b$ to get the desired $P(C<T)$.
The second term is:
$${P(T \ge b)} = \int_b^{\infty} f(t) dt.$$
The first term is:
$$P(C<T \ \& \ T<b) =\frac{1}{b}\int_0^b tf(t) dt.$$
For the exponential, the linked page shows
$$P(C<T)=\frac{1-e^{-\lambda b}}{\lambda b},$$
for the following curve of censoring probability versus $b/\lambda$:

In principle you can do this for any distribution of event times $f(t)$ and censoring based on a uniform distribution.
If you have already generated a set of $N$ (uncensored) event times $t_i$, you have an empirical distribution with $f(t_i)=1/N$ and 0 for other values of $t$. Plugging into the above general formula for censoring probability gives:
$$P(C<T) = \frac{\sum_{t_i <b} t_i+b\sum I(t_i\ge b)}{bN}, $$
which is pretty easy to solve for a desired value of $b$. With the empirical distribution it doesn't matter from which (if any) parametric distribution you drew, or whether you used a single set of covariate values or let them vary. Some simple R code:
censSolve <- function(b,t,cp) {abs(cp - (sum(t>=b) + sum(t[t<b])/b)/length(t))}
optimize(censSolve, interval=c(min(tvals),max(tvals)), t=tvals, cp=targetCensProb)$minimum

where tvals is your vector of uncensored event times and targetCensProb is your desired censoring probability should do the trick to return your desired value of $b$.
