Case 2: cereal-aphid thermal tolerance

knitr::opts_chunk$set(collapse = TRUE, comment = "#>", fig.width = 7,
                      fig.height = 4.5, dpi = 96)

This article follows the cereal-aphid case in the bayesTLS supplement: the heat branch, 6-day-old aphids for the main analysis, then the all-age heat extension.

library(freqTLS)
data(aphid_tdt)

Main analysis: heat branch at age 6

aphid6 <- droplevels(subset(aphid_tdt, branch == "heat" & age == "6"))
aphid6$species <- factor(
  aphid6$species,
  levels = c("M_dirhodum", "R_padi", "S_avenae"),
  labels = c("Metopolophium dirhodum", "Rhopalosiphum padi",
             "Sitobion avenae")
)
aphid6_std <- standardize_data(
  aphid6, temp = "temp", duration = "duration_min",
  n_total = "n_total", n_surv = "n_surv", duration_unit = "minutes"
)

The beta-binomial model gives each species a direct CTmax and z, lets steepness vary with centred assay temperature, and shares low and up. t_ref = 60 is one hour because the standardized duration unit is minutes.

aphid6_fit <- fit_4pl(
  aphid6_std,
  ctmax = ~ 0 + species,
  z = ~ 0 + species,
  low = ~ 1,
  up = ~ 1,
  k = ~ temp_c,
  family = "beta_binomial",
  t_ref = 60,
  method = "wald",
  quiet = TRUE
)
diagnose_tdt_fit(aphid6_fit)
aphid6_tls <- tls(aphid6_fit, by = "species", lethal = FALSE, method = "wald")
aphid6_table <- aphid6_tls$summary
names(aphid6_table)[names(aphid6_table) == "median"] <- "estimate"
aphid6_table

This experimental freqTLS page reports CTmax and z only. The pinned bayesTLS case additionally extracts Tcrit; users needing that Bayesian derived quantity should use the supplement rather than interpret its omission here as a zero biological effect.

plot_tdt_curve(aphid6_fit)

The table reports Wald confidence intervals. The TDT figure shows fitted point curves, not uncertainty intervals. Check convergence, Hessian status, gradient, and data-adequacy warnings before ranking species.

All-age heat extension

The supplement next uses all heat-branch ages and the direct fixed structure species * age on both headline coordinates. This is an experimental larger fixed-effect model in freqTLS; it is not a substitute empirical case.

aphid_all <- droplevels(subset(aphid_tdt, branch == "heat"))
aphid_all$species <- factor(
  aphid_all$species,
  levels = c("M_dirhodum", "R_padi", "S_avenae"),
  labels = c("Metopolophium dirhodum", "Rhopalosiphum padi",
             "Sitobion avenae")
)
aphid_all_std <- standardize_data(
  aphid_all, temp = "temp", duration = "duration_min",
  n_total = "n_total", n_surv = "n_surv", duration_unit = "minutes"
)
aphid_all_fit <- fit_4pl(
  aphid_all_std,
  ctmax = ~ 1 + species * age,
  z = ~ 1 + species * age,
  low = ~ 1,
  up = ~ 1,
  k = ~ temp_c,
  family = "beta_binomial",
  t_ref = 60,
  method = "wald",
  quiet = TRUE
)
diagnose_tdt_fit(aphid_all_fit)

The interacted formula coefficients are not themselves species-by-age values. The parameter prediction below evaluates the fitted direct coordinates for all nine biological cells at the observed mean assay temperature.

aphid_cells <- expand.grid(
  species = levels(aphid_all$species),
  age = levels(aphid_all$age),
  temp = mean(aphid_all_std$temp),
  KEEP.OUT.ATTRS = FALSE
)
aphid_cell_pars <- predict(aphid_all_fit, aphid_cells, type = "parameters")
cbind(aphid_cells[c("species", "age")],
      aphid_cell_pars[c("CTmax", "z")])
aphid_tdt_grid <- merge(
  expand.grid(
    temp = seq(min(aphid_all_std$temp), max(aphid_all_std$temp), length.out = 60),
    KEEP.OUT.ATTRS = FALSE
  ),
  aphid_cells[c("species", "age")]
)
aphid_tdt_pars <- predict(aphid_all_fit, aphid_tdt_grid, type = "parameters")
aphid_tdt_grid$duration_50 <- 10^(
  log10(60) - (aphid_tdt_grid$temp - aphid_tdt_pars$CTmax) / aphid_tdt_pars$z
)
ggplot2::ggplot(
  aphid_tdt_grid,
  ggplot2::aes(temp, duration_50, colour = species)
) +
  ggplot2::geom_line(linewidth = 0.8) +
  ggplot2::scale_y_log10() +
  ggplot2::facet_wrap(~ age) +
  ggplot2::labs(
    x = "Temperature (°C)",
    y = "Duration to 50% relative survival (minutes, log scale)",
    colour = "Species"
  ) +
  ggplot2::theme_minimal()

Projection boundary

The Wuhan field-temperature projection is not run here. Its environmental trace remains outside the installed package until the full redistribution chain is recorded in the licence ledger. predict_heat_injury() can evaluate a temperature trace, but any repair kernel supplied to current freqTLS is illustrative and unfitted. The fitted Bayesian projection remains available in bayesTLS.



Try the freqTLS package in your browser

Any scripts or data that you put into this service are public.

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