Survival analysis: basic terms, the exponential model, censoring, examples in R and JAGS

By | May 13, 2015

I have put together some basic material on survival analysis. It is available as:

  • .html document with highlighted syntax here.
  • Printer-ready .pdf document here.
  • GitHub repository with all the source files here.

Main motivation was that I wanted to learn the basics myself; also, it's tricky to find simple examples of survival models fitted in Bayesian setting and there are few materials that combine theory with examples.

The material contains:

  • Mathematical formulations of key concepts of survival analysis.
  • Illustration of the exponential model of failure density.
  • Example of the exponential model fitting in R.
  • Example of the same model fitting in JAGS.
  • More complex model with censoring in JAGS.
(Visited 2,775 times, 1 visits today)

10 thoughts on “Survival analysis: basic terms, the exponential model, censoring, examples in R and JAGS

    1. Petr Keil Post author

      Thanks Gregor for spotting this. I have updated the text so that J.G. Ibrahim is now acknowledged.

  1. Jonah Takalua


    In the second section, you say that Mean time to death (μ) for continuous S(t) is
    μ=∫∞0uf(u)du . This can also be written as μ=∫∞0S(u)du. Often times, this is easier to deal with. It isn't clear in here that this is the case, but I do believe this is important.

    It is pretty great other than that, thanks!

    1. Petr Keil Post author

      Thanks Jonah! I have added a note on that.

  2. Ben Weinstein

    Brilliant Petr, very cleanly done. I was looking for something like this. Thanks for your effort!

    My only question is why you chose an exponential function, and the biological interpretation of such a choice. Have you seen it done in other ways? I just needed one or two more lines under subheading 3.

  3. Joel Galang

    For the last example, I was able to get JAGS and survreg to agree by changing the data list passed to JAGS to: <- list( =,
    t.cen = t.cen,
    N = nrow(roaches),
    weight = roaches$weight,
    is.censored = is.censored) # added


Leave a Reply

Your email address will not be published. Required fields are marked *