RDA merlin
The multilevel mixed-effects survival-regression engine at the heart of the merlin family — in R and Stata.
In build
R v2 · Stata v3
Due early October 2026
Available now R v0.1.1 from GitHub · Stata from SSC
Registered
We will email you once, when the next merlin release lands.
One email, when it lands. Nothing else, and you can unsubscribe from it.
A confirmation is on its way to your inbox.
across PH and AFT parameterisations
with intercepts and slopes
Laplace · GHQ · AGHQ
in both ecosystems
Find what matters to you
merlin serves four distinct audiences. Pick the entry point that matches what you're trying to do.
merlin for R →
The R implementation — a ground-up rewrite: modular, extensible, with analytic gradients in C++ across every family.
Exploremerlin for Stata →
The original implementation, installable from SSC — the widest model coverage of the family, with the stmerlin / stmixed wrappers. v3 brings a rebuilt analytic-gradient engine, 2–4× faster than v2.4.7 on random-effects, time-dependent, and numerically-integrated fits.
Exploremerlin for HTA →
Worked case studies and methods guidance — partitioned survival, multistate CE, cure, relative survival.
Exploremerlin in research →
The published applied work merlin was built for — registry and real-world-evidence studies, methods papers, and simulation, in R and Stata.
Exploremerlin 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 →
morgana →
Bayesian flexible parametric survival — built for HTA extrapolation. Available in Stata now (a bayesmh prefix to stmerlin); the R implementation, with posterior inference via the No-U-Turn Sampler, is in development.
pendragon →
Multi-state and competing-risks models on top of merlin and morgana — transition probabilities, length of stay, RMST, and the health-economic outputs. The successor to multistate, in development in R and Stata.
Exploreavalon →
Survival-data simulation — standard, flexible parametric, fitted-model and user-defined hazards, with competing risks and multi-state structures. The successor to survsim, in development in R and Stata.
Exploregawain →
Discrimination, calibration and decision curves for a survival prediction model. It takes predictions as data, so it depends on no other package in the family — enforced by a test in each implementation. In development.
ExploreWhat 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.
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.
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.
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.
In R and Stata
merlin is available as open-source implementations in R and Stata, both freshly advanced and under active development. The Stata implementation has the widest model coverage and the next release in build; the R implementation is a parallel ground-up rewrite.
merlin for R
v0.1.1 is on GitHub today. v2 is the 2026 ground-up rewrite of the engine's survival core, on an in-house C++ kernel layer with analytic gradients across every family and integration method.
Explore the R implementation → v3 in buildmerlin for Stata
The original implementation, introduced in Crowther (2020) and installable from SSC: the broadest model class of the family — joint models, multistate, competing risks, recurrent events. The rebuilt analytic-gradient engine, 2–4× faster than v2.4.7 on random-effects, time-dependent, and numerically-integrated fits, arrives with v3.
Explore the Stata implementation →A first model
merlin fits the same model class from either language. Both of these are the packages' own documented examples.
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)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)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.
Methodology and references
merlin is published, cited, and aligned with the methodological standards HTA reviewers and methodologists actually use.