plot_survival_curves: Plot posterior survival curves

View source: R/plotting.R

plot_survival_curvesR Documentation

Plot posterior survival curves

Description

Plots posterior median ± 95% CrI of survival as a function of duration, one coloured line per assay temperature. Optionally overlays observed survival proportions per replicate.

Usage

plot_survival_curves(
  pred,
  observed = NULL,
  log_time = FALSE,
  palette = "viridis",
  response_label = "Survival probability",
  clip_to_observed = TRUE,
  facet_scales = c("auto", "fixed", "free", "free_x", "free_y")
)

Arguments

pred

Output of predict_survival_curves().

observed

Optional standardised data tibble (from standardize_data()) to overlay as points (jittered, transparent).

log_time

Logical. If TRUE, the exposure-duration axis is log10. Default FALSE (linear).

palette

Character. Viridis option for the temperature colour scale. Default "viridis"; pass NULL to keep ggplot's default hue scale.

response_label

Character. y-axis label for the modelled response. Default "Survival probability"; set to e.g. "Retained PSII function" for a continuous-proportion (Beta) endpoint where the response is not survival.

clip_to_observed

Logical. If TRUE (the default) and observed is supplied, each temperature/group curve is capped at the longest exposure actually observed for that cell — shorter durations are still predicted (the curve there is well-behaved, rising to the upper asymptote), but the long tail is not extrapolated past the data (e.g. designs that test much shorter exposures at hotter temperatures). Prediction cells with no matching observed temperature/group combination are dropped. A no-op when observed is not supplied. Set FALSE for the full grid.

facet_scales

Facet scale behaviour for grouped fits. "auto" (default) frees the duration (x) axis per group when clip_to_observed = TRUE and observed is supplied, so each group fills its own tested range (survival stays shared at ⁠[0, 1]⁠); otherwise fixed. Or pass any facet_wrap() scale ("fixed", "free", "free_x", "free_y").

Details

Colour mapping uses the viridis palette by default (yellow at the highest temperature, dark purple at the lowest); the exposure-duration axis is linear by default, with the classical log-time TDT view available via log_time = TRUE.

Value

A ggplot object.

Examples

## Not run: 
pred <- predict_survival_curves(wf, temps = c(30, 32, 34, 36))
plot_survival_curves(pred, observed = wf$data)
plot_survival_curves(pred, log_time = TRUE)  # classical TDT view

## End(Not run)

bayesTLS documentation built on Nov. 29, 2026, 1:06 a.m.