Skip to contents

disappR is a Shiny workflow for diagnosing and modelling selective disappearance and selective appearance in longitudinal ageing data. If the individuals that leave a study early, or join it late, differ in the trait being measured, the population-level pattern stops reflecting how individuals age. disappR helps you check whether that is happening in your data and model it if it is.

The workflow follows the guide by Sanghvi, Ivimey-Cook, Bouwhuis, Sepil and van de Pol (2026, Methods in Ecology and Evolution): look for the signatures of selective disappearance and appearance in the data first, then choose the error family, random effects and ageing function, and only then compare the ten mixed models (Models 1–10) built to separate them.

Install

disappR is not on CRAN. Install it from GitHub:

install.packages("pak")
pak::pak("EIvimeyCook/disappR")

The packages below are optional. Without them the app still runs, with fewer analyses; the app’s Start here page lists any that are missing.

install.packages(c("glmmTMB", "lmerTest", "nlme", "DHARMa", "performance",
                   "see", "codetools", "callr", "mgcv", "gamm4"))

Run the app

The app has seven steps, each explained on screen:

  1. Data: simulated, bundled or your own data, and the column mapping.
  2. Visual diagnosis: does the trait differ between individuals that die or enter the study at different ages?
  3. Missingness and proxies: how complete the sampling is, and which lifespan proxy to use.
  4. Trajectories: the ageing function within individuals and in the population.
  5. Modelling: Models 1–10, with diagnostics and R code for each.
  6. Summary and report: everything saved along the way, as an HTML or text report.
  7. GAMMs (beta, optional): smooth ageing curves fitted with mgcv.

vignette("workflow", package = "disappR") describes each step and the data format in detail. There is also a video walkthrough.

A worked example in R

The models behind the app can also be run from a script. Here a population of 150 individuals is simulated with both age-independent and age-dependent selective disappearance:

library(disappR)

sim <- disappr_simulate(n_id = 150, seed = 1, sd_type = "both")
head(sim)
#>       ID age body_mass lifespan condition
#> 1 ID0001   1  39.77949       16    -1.521
#> 2 ID0001   2  43.97407       16    -1.521
#> 3 ID0001   3  45.54941       16    -1.521
#> 4 ID0001   4  44.82403       16    -1.521
#> 5 ID0001   5  48.70710       16    -1.521
#> 6 ID0001   6  47.28905       16    -1.521

Tell disappR which column plays which role, then check and prepare the data:

map <- disappr_mapping(id = "ID", age = "age", trait = "body_mass",
                       life = "lifespan")
x <- disappr_prepare(sim, map)

Fit three of the models and compare them. Model 1 has no term for selective disappearance (the negative control). Model 2 adds each individual’s age at last record (ALR), a proxy for lifespan, which captures age-independent selective disappearance. Model 4 also lets the ALR effect change with age (age-dependent selective disappearance):

fit <- disappr_fit(x, models = c("M1", "M2", "M4"))
disappr_compare(fit)
#>     Model      AIC df    logLik    N   Fit Eligible Delta_AIC Weight
#> 1 Model 4 12174.33  8 -6079.163 3019 Valid     TRUE     0.000      1
#> 2 Model 2 14597.91  6 -7292.954 3019 Valid     TRUE  2423.582      0
#> 3 Model 1 14827.46  5 -7408.728 3019 Valid     TRUE  2653.130      0

disappr_interpret() gives the same plain-language reading as the app, including what the result does and does not show:

disappr_interpret(fit)
#> [1] "Model 4 (with age-dependent terms) is favoured here while only random intercepts are fitted, although this might change if random slopes are fitted too. Individual differences in ageing rates can make interaction models fit better even in the absence of selective disappearance, through heterogeneity in ageing. The data support random slopes: refitting with a random slope may help to distinguish the two interpretations."

and disappr_predict() gives the fitted trajectory from a chosen model:

head(disappr_predict(fit, "M4"))
#>        age   fitted
#> 1 1.000000 42.05154
#> 2 1.333333 42.67614
#> 3 1.666667 43.28728
#> 4 2.000000 43.88495
#> 5 2.333333 44.46915
#> 6 2.666667 45.03987

disappr_code(fit, x) writes standalone R code that reproduces the fits without disappR. disappr_example() loads any of the bundled published datasets with the mapping and settings that match its paper, for example disappr_example("bouwhuis") for the great tit data.

Further documentation