predict_heat_injury: Predict cumulative heat injury under a temperature trace

View source: R/heat_injury.R

predict_heat_injuryR Documentation

Predict cumulative heat injury under a temperature trace

Description

predict_heat_injury() is the deterministic, maximum-likelihood prediction analogue of bayesTLS::predict_heat_injury(): given a fitted thermal-load- sensitivity curve and a temperature time-series (a "trace"), it accumulates thermal damage as a fraction of the lethal dose and reads survival back off the fitted survival curve. It does not fit an injury or repair model – fitting injury / repair dynamics remains a bayesTLS concern (the complementary boundary); predict_heat_injury() only predicts injury from the already-fitted survival curve. For a random-effects fit it uses the population curve and does not add a fitted group BLUP (best linear unbiased predictor; see ranef()).

Usage

predict_heat_injury(
  object,
  trace,
  group = NULL,
  target_surv = NULL,
  t_c = NULL,
  repair = NULL,
  irreversible = TRUE,
  T_c = NULL,
  trace_unit = NULL,
  irreversible_mortality = NULL,
  repair_pars = NULL
)

Arguments

object

A profile_tls fit from fit_tls(), or a freq_tls workflow from fit_4pl().

trace

A data frame with numeric columns time (strictly increasing, at least two rows) and temp (degrees C).

group

Optional single group level (grouped fits only; required when the fit is grouped).

target_surv

Optional absolute survival threshold defining one lethal dose: a single probability strictly between the fitted lower and upper asymptotes. NULL (default) uses the project-default relative threshold (the curve midpoint (low + up) / 2), matching derive_ctmax() and derive_lt(). For a bootstrap envelope the target must also be attainable in every converged bootstrap refit; otherwise the function aborts rather than clipping an invalid refit's threshold.

t_c

Optional damage-cutoff temperature (degrees C): at or below it the damage rate is zero. NULL (default) applies no cutoff.

repair

Optional named list of Sharpe-Schoolfield repair parameters (see Details); NULL (default) or FALSE means no repair. TRUE requires repair_pars.

irreversible

Logical; if TRUE (default) survival is monotone non-increasing (mortality does not reverse even if dose is repaired).

T_c, trace_unit, irreversible_mortality, repair_pars

Compatibility aliases for t_c, trace time units, irreversible, and repair. T_c and t_c cannot both be supplied. trace_unit accepts the same unit labels as standardize_data() and converts trace times to minutes when supplied. NULL (default) means the trace time is already in minutes. In ⁠repair = TRUE, repair_pars = ...⁠, the Bayesian r_ref is converted from doses per hour to doses per minute. irreversible_mortality sets the same behavior as irreversible. target_surv = "relative" selects the default relative midpoint and target_surv = "absolute" selects 0.5. repair_pars accepts either freqTLS parameter names or the uppercase names used by bayesTLS.

Details

Dose-accumulation model

One lethal dose is the thermal load that drives survival to a target set by target_surv. With the default target_surv = NULL the target is the project-default relative threshold – the curve midpoint (low + up) / 2. At temperature T the lethal time to the target is LT(T) = tref * 10^((CTmax - T) / z - q / k), where q is the negative inverse curve coordinate for the requested normalized survival fraction. Thus q = 0 at the common midpoint, and the value matches derive_lt(). The instantaneous damage rate is 1 / LT(T) (lethal doses per time unit). Cumulative dose is accumulated by forward Euler over the trace, using the actual per-step time increments:

D_j = \max\!\big(0,\; D_{j-1} + (\mathrm{dmg}(T_{j-1}) - \mathrm{rep}_{j-1})\,\Delta t_j\big),\quad D_1 = 0,

where \Delta t_j = t_j - t_{j-1}. Survival is read back from the selected curve by treating the accumulated dose as an equivalent log10-time: survival(D) evaluates the selected mean curve at k * log10(D) - q, so D = 1 (one lethal dose) reaches exactly target_surv – the relative midpoint (low + up) / 2 by default, or an absolute survival threshold when target_surv is supplied.

The trace time and the fit's duration / tref must share a time unit. Supported fits use minutes, so trace_unit = NULL means that trace time is already in minutes. Supply trace_unit to convert hours, seconds, or days to minutes. With irreversible = TRUE (default) survival is monotone non-increasing. A damage cutoff t_c (for example from derive_tcrit()) sets the damage rate to zero at or below t_c. low, up, and k formulas are evaluated at each trace temperature. Bootstrap confidence envelopes currently require constant or cell-mean shape designs.

This integrator is forward Euler (left-endpoint, per actual step), not the single-dt scheme some implementations use; irregular traces are integrated with their real increments.

Repair (optional, not identified by the data)

If repair is supplied, a Sharpe-Schoolfield repair rate is subtracted each step (scaled by the current survival fraction, so repair shrinks as the population dies). The repair parameters are a user-supplied scenario layer: they are not identified by the survival data the model was fitted to, so predict_heat_injury() warns when they are used. repair is a named list with r_ref, t_a, t_al, t_ah, t_l, t_h, t_ref, with the four reference temperatures in Kelvin. The freqTLS repair list expresses r_ref per fitted time unit. Compatibility repair_pars treats r_ref as doses per hour and converts it to the fitted minute scale.

Value

A data frame with columns time, temp, dose (cumulative, as a fraction of the lethal dose), injury (dose * 100, percent), and survival.

See Also

derive_lt() for the lethal time, derive_tcrit() for a damage cutoff temperature.

Examples

d <- simulate_tls(family = "binomial", times = c(30, 60, 120, 240, 480),
                  CTmax = 36, z = 4, tref = 60, seed = 1)
fit <- fit_tls(d, y = survived, n = total, time = duration, temp = temp,
               family = "binomial", tref = 60)
trace <- data.frame(time = seq(0, 2, by = 0.05),
                    temp = 34 + 6 * sin(seq(0, 2, by = 0.05)))
head(predict_heat_injury(fit, trace))

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