This page contains a collection of worked examples using the

`merlin`

Stata package. Examples are loosely grouped into areas, and may appear in more than one area.Type

`help merlin`

to access the main help file, which documents all the available commands and options.If you have an example you’d like to contribute, then please get in touch.

$~$

## Tutorials

Each tutorial below is tagged to illustrate the level of completeness, as follows:

- [Tutorial] - a completed page, with code and full worked example
- [Draft] - still in draft, contains code but not fully documented
- [Code only] - example code only, minimal description
- [Sim] - example shows how to simulate data from the illustrated model
- [TBA] - to be added
- [EG] - indicates that the tutorial shows how to fit an example from the literature within the
`merlin`

framework

$~$

### Survival (time-to-event) analysis

- Using merlin with survival data [Tutorial, Sim]
- Parametric survival model with a frailty/random intercept [Draft]
- Parametric survival model with random coefficients [TBA]
- Three-level survival models - IPD meta-analysis of recurrent event data [Draft, Sim]
- Royston-Parmar multilevel survival models [TBA]
- User-defined hazard models - an example with fractional polynomials [Tutorial]
- Interval-censored survival analysis [Tutorial]
- Individual patient data network meta-analysis of survival data [TBA]

$~$

### Longitudinal (hierarchical) analysis

- Linear mixed effects model [TBA]
- Generalised linear mixed effects model [TBA]
- Mixed effects for the level 1 variance function [Tutorial, Sim, EG]
- Multivariate longitudinal model [TBA]
- Linear quantile mixed effects model [Tutorial, EG]

$~$

### Joint frailty models for recurrent and terminal events

- Joint frailty models for recurrent and terminal events [Tutorial, EG]
- General level joint frailty model [TBA]
- Joint frailty model with simple and complex time-dependent effects [TBA]

$~$

### Joint longitudinal-survival models

- Joint model with single continuous marker and survival [Draft]
- Joint longitudinal-survival model with time-dependent effects (non-proportional hazards) [Draft]
- Weighted cumulative joint longitudinal-survival model [Tutorial, EG]
- Multivariate longitudinal and survival model [Tutorial]
- Joint longitudinal and competing risks model [Tutorial, Sim]
- Generalised multivariate longitudinal and survival model [TBA]
- Generalised multivariate longitudinal and cause-specific competing risks model [TBA]
- Generalised multivariate longitudinal, recurrent event and a terminal event model [TBA]
- Generalised multivariate longitudinal and multi-state survival model [TBA]
- A trivariate model for joint longitudinal-survival data with an informative observation process [TBA, Sim, EG]

$~$

### Relative survival analysis

- An introduction to relative survival with
`merlin`

[Draft] - Relative survival model with a random intercept [TBA]
- Relative survival model with a random coefficients [TBA]
- General level relative survival model [TBA]
- General level relative survival model with time-dependent effects [TBA]

$~$

### Non-linear mixed effect models

- An exponential decay model [TBA]

$~$

### Meta-analysis

- Three-level survival models - IPD meta-analysis of recurrent event data [Draft, Sim]
- Individual patient data network meta-analysis of survival data [TBA, EG]

$~$

### Cost-effectiveness modelling

- A Gamma random effects model for costs [TBA]
- A two-part mixed effects model for costs [TBA, EG]
- A bivariate model for costs and utilities [TBA, EG]

$~$

### Miscellaneous

- A blog post on the importance of getting good starting values
- A blog post on modelling and prediction with non-linear effects

$~$

### External examples

$~$