extract_tdt: Extract z, CTmax and (optionally) T_crit with bootstrap...

View source: R/extract_tdt.R

extract_tdtR Documentation

Extract z, CTmax and (optionally) T_crit with bootstrap confidence intervals

Description

The frequentist analogue of bayesTLS::extract_tdt(). Runs a parametric bootstrap (via the freqTLS engine), derives the thermal-death-time quantities on each replicate, and returns the same nested ⁠$z⁠ / ⁠$CTmax⁠ / ⁠$T_crit⁠ structure (each a list of draws + summary). Each row of a per-replicate table is a derived estimate from one parametric-bootstrap refit: it is a resampled frequentist estimate, not a posterior draw. ⁠*_median⁠ is the maximum-likelihood point estimate and ⁠*_lower⁠ / ⁠*_upper⁠ are bootstrap percentiles. Absolute-target bootstrap values are calculated or inverted for each refit. A draw whose target lies outside its refit's asymptotes, or has no unique crossing for a temperature-varying shape, is retained as NA with .valid = FALSE; counts by quantity and fitted group are returned in meta$inversion_counts. Absolute-target percentile limits are conditional on converged refits whose asymptotes bracket the target. For temperature-varying shapes, a usable draw must also have one detected crossing over the pooled fitted temperature range. Limits are withheld when fewer than 20 usable refits remain for a target and group. If no refit converges, extraction errors because there are no draws to return.

Usage

extract_tdt(
  object,
  target_surv = "relative",
  lethal = FALSE,
  TC_rate_range = c(0.1, 1),
  nboot = 1000L,
  level = 0.95,
  seed = NULL,
  by = NULL
)

Arguments

object

A freq_tls fit from fit_4pl() (or a profile_tls fit).

target_surv

"relative" (curve midpoint, default), "absolute" (50% survival), or a numeric survival level in ⁠(0, 1)⁠ for an LTx CTmax. An absolute target must lie strictly between the fitted low and up asymptotes. Temperature-varying shapes also require one crossing inside the observed temperature range for each fitted group. Constant or cell-mean shapes use the closed form; temperature-varying shapes use a bounded inverse. This target changes CTmax (and T_crit when requested); returned z remains the model's thermal-sensitivity coordinate at the relative curve midpoint.

lethal

If TRUE, also derive T_crit (the damage-rate-floor critical temperature, using a one-hour anchor for constant shapes and a bounded inverse at the equivalent duration for temperature-varying shapes. rate is log-uniform over TC_rate_range.

TC_rate_range

Two finite positive damage-rate floor endpoints (percent of lethal dose per hour) for T_crit, in non-decreasing order. Equal endpoints specify a fixed rate. Used only when lethal = TRUE; default c(0.1, 1).

nboot

Number of bootstrap replicates (default 1000; smaller is faster). Percentile limits require at least 20 usable refits per quantity and group. With fewer usable refits, limits are NA; converged draws and the requested/converged/failed counts remain available. The examples request 50 refits to allow some failures while still demonstrating finite limits.

level

Confidence level, one number strictly between zero and one (default 0.95).

seed

Optional RNG seed for reproducible replicates / rate draws.

by

Optional name or names of source-data grouping columns; defaults to the fit moderator. Crossed cell-means fits can report multiple columns.

Value

A list with ⁠$z⁠, ⁠$CTmax⁠, (⁠$T_crit⁠ when lethal), and ⁠$meta⁠. Each quantity is ⁠list(draws = <tibble>, summary = <tibble>)⁠. Column names follow bayesTLS: z_median/z_lower/z_upper for z; temp_median/temp_lower/ temp_upper for CTmax and T_crit; per-draw value columns are z / temp. ⁠$meta$tref⁠ records the reference time; ⁠$meta$duration_unit⁠ is retained when the input is a fit_4pl() workflow. ⁠$meta$z_definition⁠ clarifies that z remains the relative-midpoint model coordinate even when an absolute target was used. ⁠$meta$interval_counts⁠ records usable refits and the status of each percentile interval.

See Also

fit_4pl(), tls(), get_z_summary(), get_ctmax_summary()

Examples


raw <- simulate_tls(family = "binomial", times = c(30, 60, 120, 240, 480),
                    CTmax = 36, z = 4, tref = 60, seed = 1)
dat <- standardize_data(
  raw, temp = "temp", duration = "duration",
  n_total = "total", n_surv = "survived", duration_unit = "minutes"
)
fit <- fit_4pl(dat, family = "binomial", t_ref = 60, quiet = TRUE)
tdt <- extract_tdt(fit, nboot = 50, seed = 1)
tdt$CTmax$summary


freqTLS documentation built on Dec. 4, 2026, 5:11 p.m.