View source: R/predict_heat_injury.R
| predict_heat_injury | R Documentation |
Propagates the model's full posterior through an Eulerian damage- accumulation integration along the supplied temperature trace, returning the posterior median and 95% credible band of:
predict_heat_injury(
trace,
workflow,
target_surv = "relative",
T_c = NULL,
trace_unit = "hours",
ndraws = NULL,
repair = FALSE,
repair_pars = NULL,
repair_scales_with_survival = TRUE,
irreversible_mortality = TRUE,
save_draws = FALSE,
seed = NULL,
by = NULL,
shape = c("constant", "varying"),
varying_method = c("individual", "cumulative")
)
trace |
Tibble with columns |
workflow |
Fitted |
target_surv |
Threshold defining "1 dose". |
T_c |
Optional damage-accumulation threshold (°C). When
supplied, the damage rate is forced to zero at
|
trace_unit |
Time unit of the trace's |
ndraws |
Posterior draws to use; |
repair |
Logical. If |
repair_pars |
Required when |
repair_scales_with_survival |
Logical. If |
irreversible_mortality |
Logical. If |
save_draws |
Logical. If |
seed |
Optional integer seeding the posterior-draw subsample for
reproducibility. |
by |
Optional moderator column(s) for per-group injury. |
shape |
How the curve's shape enters the prediction.
|
varying_method |
For |
HI(t) — cumulative heat injury, in percent of an LT_target_surv dose.
When HI(t) = 100, the population has accumulated one full dose at the
chosen survival threshold (by default midway between the asymptotes,
(low + up)/2).
S(t) — predicted survival fraction. With shape = "constant" it is
read off the fitted dose-response curve (the log-logistic for
fit_4pl(), the log-normal or Weibull curve for fit_lognormal() /
fit_weibull()) at the cumulative dose; with shape = "varying" it
follows each individual's own heat injury (see the section "Varying
shape").
Optionally adds a temperature-dependent repair rate via
repair_rate_schoolfield().
A list with elements:
summary: tibble with time, temp, and posterior median + 95%
CrI for hi, survival, and mortality at each time step (plus the
moderator column(s) for a grouped fit).
draws: optional per-draw trajectories (when save_draws = TRUE); a
draw that gives no prediction is kept as rows of NA.
meta: list of inputs used. meta$ndraws is the number of posterior
draws that produced a prediction; a warning reports any that did not,
and they are left out of every summary column. For a grouped fit it is
the smallest such number in any group, and meta$ndraws_by_group
gives each group's count.
The fitted curves describe survival at constant temperatures. When their
shape (low, up, k) changes with temperature, survival under a
fluctuating trace depends on why it changes, which constant-temperature data
cannot reveal. varying_method chooses between two coherent methods. Both
reproduce the fitted curve at a constant temperature; both use the constant
shape's rule that, with irreversible mortality, injury that is repaired and
re-accrued kills no one until it passes its previous peak; and both equal the
constant shape exactly when low, up and k do not change with
temperature and the midpoint is linear in it (with an absolute target and a
very shallow curve, k below about 2, the starting values differ slightly:
the two shapes read their curves at a tiny dose measured in different
units). Otherwise they differ, and comparing them shows how much the unknown
mechanism matters.
"individual" (default): each individual is followed separately. The
individual of survival rank p is the one that dies, at a constant
temperature, when survival there falls to p, at that temperature's
threshold time for p. It accumulates heat injury additively (the time at
each temperature divided by its own threshold time there) and dies when
its injury reaches 1. This is exact if individuals have their own TDT lines
that fan out and keep their ranks. Without repair, once the trace has begun
to accrue injury, survival depends only on the time spent at each
temperature, not on their order or on where the trace starts; more time at
any temperature never raises it (a hotter trace can still end higher where
the fitted curves cross); and the heat injury of an absolute target reaches
100% exactly when survival falls to that target. Repair removes the same
fraction of every individual's injury.
"cumulative": cumulative exposure, with survival as the state. Over each
time step, survival continues along the current temperature's curve from
the point where that curve has the current survival. This is exact if
individuals share one injury process whose rate depends on the injury
already accrued, and differ only in their thresholds. It is the usual rule
in reliability for a shape that changes with stress (Nelson 1980) and the
one used by Rezende et al. (2020) and Bullard et al. (2026); given the same
curves it reproduces Bullard et al.'s code, except that their code reads
each step's curve at the step's end rather than its start (the difference
shrinks as the steps do). Temperature order matters. Because survival is
the state, deaths on exposure to a lower up (below) also advance the
survivors along later curves. A step injures only while survival is above
the floor of its curve; otherwise the state stays on the curve of the last
step that injured it (as ranks below low accrue no injury in the
per-individual method), as it does at or below T_c. With repair, a
shared injury falls by the repair amount on the dose scale of the curve the
state lies on, so the repair during a cool spell depends on the curve of
the last step that injured. The heat injury of an absolute target is the
per-individual method's and does not mark when survival under this method
reaches the target.
Each time step is held at the temperature at its start, as the dose is.
Survival starts at up of the first temperature at which the trace accrues
injury (above T_c); a trace that accrues none keeps the constant shape's
value, up at T_bar. Both
methods read a lower up at some temperature as individuals that die as
soon as they are exposed to it (a convention without published precedent),
so survival drops to that up once the trace spends time there above
T_c; those deaths are permanent even with
irreversible_mortality = FALSE, as the share 1 - up is in the constant
shape. If a temperature-dependent up reflects losses unrelated to heat, fit
up as a constant or set T_c; up(T) is extrapolated at trace
temperatures outside the assay range. Heat injury is the same under both
methods unless repair scales with survival, when each method's own survival
scales it. For a continuous response (the Beta family) the curve is a mean
response, so the reading in terms of individuals does not apply. With
irreversible_mortality = FALSE, survival rebounds as injury is repaired,
up to the lowest up met so far. The cost of the varying shape grows with
the number of distinct trace temperatures, so rounding the trace (for
example to 0.1 °C) speeds it up.
Bullard GW, Buckley LB, Kingsolver JG (2026). Incorporating variation in death times improves predictions of ectotherm responses to stressful temperatures. PLOS Biology 24(5): e3003623. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1371/journal.pbio.3003623")}
Nelson W (1980). Accelerated life testing - step-stress models and data analyses. IEEE Transactions on Reliability R-29(2): 103-108. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1109/TR.1980.5220742")}
Rezende EL, Bozinovic F, Szilagyi A, Santos M (2020). Predicting temperature mortality and selection in natural Drosophila populations. Science 369(6508): 1242-1245. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1126/science.aba9287")}
## Not run:
scens <- make_temperature_scenarios()
hi <- predict_heat_injury(scens$single_spike, wf)
hi$summary
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.