predict_survival_curves: Posterior survival curves on a temperature × duration grid

View source: R/predict_survival_curves.R

predict_survival_curvesR Documentation

Posterior survival curves on a temperature × duration grid

Description

Predicts survival probability at every combination of temps × durations under a fitted 4PL, then returns the posterior median and 95% credible interval at each grid point. Random effects are marginalised out.

Usage

predict_survival_curves(
  workflow,
  temps = NULL,
  durations = NULL,
  ndraws = NULL,
  probs = c(0.025, 0.5, 0.975),
  by = NULL
)

Arguments

workflow

A fitted bayes_tls.

temps

Numeric vector of temperatures (°C). Default: unique assay temperatures in the training data.

durations

Numeric vector of durations. Default: 250 log-spaced values spanning 0.2× to 5× the observed range.

ndraws

Posterior draws to use; NULL (default) uses the full posterior. Pass an integer to subsample for speed.

probs

Numeric length-3 quantile probabilities (lower, median, upper). Default c(0.025, 0.5, 0.975).

by

Optional moderator column(s) for per-group curves. NULL (default) uses the fit's moderators; a single-condition fit returns the ungrouped curves, a grouped fit one block per group with the moderator column(s) prepended to summary.

Details

Use this for curves (a handful of temperatures, dense in duration). For a 2-D survival heatmap call derive_tdt_landscape() instead.

Value

A list with elements summary (tibble of temp, duration, survival_median, survival_lower, survival_upper; plus the moderator column(s) for a grouped fit), draws_matrix (the raw posterior matrix ⁠[ndraws x grid points]⁠ of survival probabilities), and grid (the prediction grid tibble from new_tdt_grid()). Use get_surv_draws() for the long-tibble form of the draws.

Examples

## Not run: 
wf <- fit_4pl(d, ...)
pred <- predict_survival_curves(wf, temps = c(30, 32, 34))

## End(Not run)

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