Red Door Analytics

RDA merlin

The multilevel mixed-effects survival-regression engine at the heart of the merlin family — in R and Stata.

R v0.1.1 · Stata on SSC GPL-3 · open source Stockholm · developed by Red Door Analytics

In build

R v2 · Stata v3

Due early October 2026

Available now R v0.1.1 from GitHub · Stata from SSC

One email, when it lands. Nothing else, and you can unsubscribe from it.

10 baseline families
across PH and AFT parameterisations
2 nested random-effect levels
with intercepts and slopes
3 integration methods
Laplace · GHQ · AGHQ
R + Stata one engine
in both ecosystems
The merlin family

merlin is the engine — here's the rest of the family

merlin fits the survival models. For Bayesian inference, multi-state and competing risks, data simulation, or validating a prediction model, reach for its siblings — all built on the same engine and syntax, except gawain, which takes predictions as data and depends on nothing. Joint and longitudinal models return to the R engine in v2.2+. The full catalogue, including the Stata predecessors multistate and survsim →

Coverage matrix

What merlin fits

Every baseline family, every integration method, with hand-derived analytic gradients in C++ across the matrix. Cure and relative survival compose with every PH family. This coverage describes the R engine; merlin for Stata already ships joint, multistate, competing-risks, and recurrent-event models.

Baseline family
No RE
+ Cure
+ RS
Royston-Parmar (log-cumH)
Royston-Parmar (log-h)
Exponential · Weibull · Gompertz
Log-normal · log-logistic · ggamma
Multivariate joint · multistate · CR
● Shipped ◐ Partial − Out of scope ○ v2.1+ (in development)
Featured case study · in preparation

Lifetime extrapolation, start to finish

The first of our HTA case studies: every step of a lifetime extrapolation on one simulated trial, with the code that produced each figure.

HTA case study · in preparation

Lifetime survival extrapolation for a simulated immuno-oncology trial, anchored to UK population mortality

A simulated trial like an immuno-oncology one, with a long-term-survivor fraction, taken start to finish: comparing the standard candidate models, fitting a non-mixture cure model on a Royston–Parmar baseline, anchoring the extrapolation to UK general-population mortality, and carrying parameter uncertainty through. Every figure will come from a recorded run of the code.

NICE DSU TSD 14 / 21 Simulated data Stata code
merlin for HTA →

For a real-world application, the same multilevel machinery powers fair, risk-adjusted comparisons of survival between hospitals and surgeons — see the published case study.

Examples

A first model

merlin fits the same model class from either language. Both of these are the packages' own documented examples.

R
library(merlin)
library(survival)
data("pbc.merlin", package = "merlin")

# a Weibull survival model
fit <- mlsurv(
  formula = Surv(stime, died) ~ trt,
  distribution = "weibull",
  data = pbc.merlin
)
summary(fit)
Stata
webuse brcancer, clear
stset rectime, failure(censrec) scale(365)

* a Royston-Parmar model with 3 df, fitted through the merlin engine
stmerlin hormon, distribution(rp) df(3)
Work with the team

The people who build merlin, on your project

merlin is free and open source — but when a submission, a non-standard analysis, or a deadline raises the stakes, the team that designed and maintains it works on contract: applied analysis, bespoke methods development and model review, with validated releases for regulated use in preparation. See how we work → or get in touch.

Built on

Methodology and references

merlin is published, cited, and aligned with the methodological standards HTA reviewers and methodologists actually use.

Framework paper
Crowther, MJ (2020)
merlin — a unified modelling framework for data analysis and methods development in Stata. Stata Journal 20(4):763–784. Read →
R software paper
merlin: Flexible and Fast Survival Analysis in R
In preparation for submission to the Journal of Statistical Software. arXiv preprint at launch.
HTA guidance alignment
NICE DSU TSD 14 · TSD 21
Standard reference frameworks for flexible parametric survival modelling and cure models in HTA submissions.

Considering merlin for a submission, methods project, or training need?

Our team designed merlin and continues to develop it. Get in touch — we'll point you to the right resource, or design something around what you need.

Get in touch