derive_temperature_for_duration: Temperature at which survival equals a target after a fixed...

View source: R/derive_tdt.R

derive_temperature_for_durationR Documentation

Temperature at which survival equals a target after a fixed exposure

Description

The vertical read of the survival surface: fix an exposure duration, find the temperature at which the posterior survival reaches the chosen threshold. Returns one temperature per posterior draw.

Usage

derive_temperature_for_duration(
  workflow,
  exposure_duration,
  temp_grid = NULL,
  target_surv = "relative",
  ndraws = NULL,
  probs = c(0.025, 0.5, 0.975),
  seed = NULL,
  by = NULL
)

Arguments

workflow

Fitted bayes_tls.

exposure_duration

Numeric scalar — the fixed duration (model units).

temp_grid

Numeric vector of temperatures (°C) to search over when the curve bends; it is extended beyond each end by the data's temperature range (or its own width, if wider; a single temperature is extended at a fine step). Not needed for a straight curve, which is solved exactly. NULL (default): 11 points over the observed temperatures.

target_surv

Threshold mode. "relative" (default), "absolute", or a numeric in ⁠(0, 1)⁠.

ndraws

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

probs

Quantile probabilities. Default c(0.025, 0.5, 0.975).

seed

Optional integer seeding the draw subsample for reproducibility. NULL (default) leaves the RNG alone.

by

Optional moderator column(s) for per-group results. NULL (default) uses the fit's moderators; a single-condition fit returns one ungrouped result.

Details

Threshold modes (via target_surv) match derive_tdt_curve():

  • "relative" (default) → temperature at which mid(T) = log10(exposure_duration) per draw.

  • "absolute" (= 0.5) or numeric p in ⁠(0, 1)⁠ → temperature at which the LT at the literal survival probability p (the midpoint plus the model's closed-form offset) equals the exposure.

Each draw's temperature comes from the exact closed form whenever its log10(LT) is a straight line in temperature: every relative threshold of a fit whose midpoint is linear in temperature (midpoint and direct fits alike), and an absolute threshold when the asymptotes and steepness do not change with temperature. A curve that bends (temperature effects on the asymptotes or steepness, under an absolute threshold) is inverted on temp_grid, refined as in tls() (each interval split into equal steps of at most 0.05 degrees C, but into no more than 20, so an interval wider than 1 degree C is refined to a twentieth of its width), by linear interpolation between the refined points, taking the crossing where the LT shortens through the exposure as temperature rises; draws that do not cross on it are searched outward beyond each end, and draws left without a single crossing are reported in a warning. Where an absolute target lies outside the fitted asymptotes at a temperature, the LT there is treated as zero or infinite, so a crossing next to it is still found. tls() reads CTmax at t_ref the same way.

Value

A list with draws (per-draw threshold temperatures; target_surv column is a character label), summary (quantile summary), exposure_duration, target_surv (the label), target_mode, target_prob. A grouped fit adds the moderator column(s).

Examples

## Not run: 
wf <- fit_4pl(std)
# Temperature giving the relative midpoint threshold after a 60-unit exposure:
tt <- derive_temperature_for_duration(wf, exposure_duration = 60,
                                       temp_grid = seq(36, 44, by = 0.1))
tt$summary

## End(Not run)

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