Red Door Analytics

RDA pendragon

Multi-state and competing-risks survival models in R and Stata, built on the merlin engine and its Bayesian sibling morgana — transition probabilities, length of stay, and the health-economic outputs, with frequentist or Bayesian uncertainty. The successor to the multistate package.

Stata package · in developmentR package · in developmentBuilt on merlin & morgana

Coming

October 2026

Not yet released pendragon is in build for R and Stata.

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

Multi-state & competing risks · R + Stata · in development

What pendragon does

pendragon assembles transition-specific survival fits into multi-state and competing-risks models, then computes transition probabilities, length of stay, restricted mean time in state, and value-weighted occupancy — by exact Aalen-Johansen product integration or by simulation, with confidence or credible bands.

It comes in two implementations that share one design. The Stata package re-architects the prediction engine of the mature multistate package (predictms) on top of the current merlin engine — reusing multistate's battle-tested data-prep (msset, msaj, msboxes, graphms) verbatim, and rewriting only the predictor for grid-invariant, machine-exact results and a large speed-up. The R package, pendragon-r, is the parallel implementation the Stata one is built towards, feature for feature.

Like merlin, pendragon keeps the multi-state machinery out of the engine: merlin (or morgana) fits each transition; pendragon stitches the transitions into a state space. merlin builds each road; pendragon stitches the roads into a realm. A fitted transition is reduced to two operations — draw parameters, evaluate the hazard — so frequentist (merlin) confidence bands and Bayesian (morgana) credible bands flow through identical code, and engines can even be mixed within one transition matrix.

Capabilities

From transition fits to a state space — and a cost-effectiveness model

MULTI-STATE

Transition matrices

mstate-style transition matrices assembled from one merlin or morgana fit per transition, with clock-forward (Markov) and clock-reset (semi-Markov) semantics.

PROBABILITIES

Exact Aalen-Johansen

Transition probabilities via an exact matrix-exponential product integral — grid-invariant and machine-exact — or by microsimulation, alongside length of stay and restricted mean time in state.

UNCERTAINTY

Frequentist or Bayesian bands

Delta-method or draw-based (PSA) intervals, built once against a held merlin object and injected many times — merlin confidence bands or morgana credible bands through identical code, engines may even be mixed within one model.

Background-mortality anchoring

Additive or constrained relative-survival anchoring of the death transitions, with a life-table helper; delayed entry and left truncation via Chapman-Kolmogorov.

HTA

Health-economic layer

Discounted QALYs, life-years, and costs; ICERs, CEACs, and expected value of perfect information; partitioned-survival models; g-formula standardisation and covariate-pattern contrasts of any statistic.

VALIDATED

Against ground truth

Validated to machine / Monte-Carlo precision against analytic results; in Stata, a full certification suite passes against the current merlin engine.

Installation

Get started

pendragon is in active development in both R and Stata, and is not yet on SSC or CRAN. A public release is planned — get in touch if you'd like early access.

Rpendragon-r, the parallel R implementation, is in active development. Get in touch for early access to either implementation.

Examples

A first model

pendragon is in build, so both blocks show the intended interface rather than commands you can run today.

Planned syntax. The blocks marked planned show the interface being built, not a command you can run today. They may change before release.

Rplanned
library(pendragon)

# one merlin transition hazard per transition (illness-death)
models <- list(m1, m2, m3)

# transition probabilities, length of stay and RMST from state 1
p <- pendragon(
  models = models, transmatrix = tmat,
  from = 1, at = list(age = 55, chemo = 1),
  times = seq(0, 5, by = 0.1),
  los = TRUE, ci = TRUE
)
Stataplanned
* fit one merlin transition hazard per transition (illness-death model)
merlin (_stop age chemo, family(weibull, failure(_status)) timevar(_stop)) if _trans1==1
estimates store m1
// ... m2 and m3 fitted the same way for the other transitions ...

* transition probabilities, length of stay and RMST from state 1, with CIs
pendragon, transmatrix(tmat) models(m1 m2 m3) timevar(tt) ///
    at(age 55 chemo 1) from(1) los ci

* incremental QALYs, costs, the ICER and a CEAC between two strategies
pendragon_cea, transmatrix(tmat) models(m1 m2 m3) timevar(tt) ///
    at1(chemo 0) at2(chemo 1) value(1 0.7 0) wtp(0(5000)100000)
The merlin family

The multi-state layer of the family

pendragon is the multi-state layer of the merlin family. merlin (frequentist) and morgana (Bayesian) fit each transition; pendragon unifies them into a state space and a cost-effectiveness model. It is the successor to the Stata multistate package — re-architecting its prediction engine on the current merlin while reusing its data-prep tools.

Worked examples and tutorials for the family are in our Resources.

Try it in your browser: the multi-state & competing-risks explorer and the partitioned-survival explorer — interactive companions to pendragon's model class, with one-click export.

Cite

Citing pendragon

pendragon does not have a methods paper yet — cite the software itself. For the multi-state methodology it succeeds, the multistate paper below remains the reference.

@misc{pendragon2026,
  author = {Crowther, Michael J.},
  title  = {{pendragon: multi-state and competing-risks models on the merlin engine}},
  year   = {2026},
  url    = {https://reddooranalytics.se/software/pendragon/},
  note   = {Red Door Analytics}
}

The methods lineage: pendragon is the successor to multistate, whose paper describes the underlying approach.

@article{crowther2017,
  author  = {Crowther, M. J. and Lambert, P. C.},
  title   = {{Parametric multi-state survival models: flexible modelling allowing transition-specific distributions with application to estimating clinically useful measures of effect differences}},
  journal = {Statistics in Medicine},
  year    = {2017},
  volume  = {36},
  number  = {29},
  pages   = {4719--4742},
  doi     = {10.1002/sim.7448}
}

RIS and the full library are on the publications page.

Building a multi-state cost-effectiveness model?

pendragon takes you from transition-specific fits to transition probabilities, length of stay, and the health-economic outputs — with frequentist or Bayesian uncertainty, in Stata or R. Let's talk.

Get in touch Start a project