ts_stage1: Stage 1 of the classical two-stage TDT pipeline

View source: R/two_stage.R

ts_stage1R Documentation

Stage 1 of the classical two-stage TDT pipeline

Description

Fits a separate logistic dose-response curve at each assay temperature and reads off log10(LT50) (the duration at 50% survival). The binomial family uses stats::glm; the beta-binomial family uses glmmTMB::glmmTMB with a betabinomial family (overdispersion at Stage 1).

Usage

ts_stage1(
  data,
  temp = "temp",
  duration = "duration",
  n_surv = "n_surv",
  n_total = "n_total",
  family = c("binomial", "betabinomial")
)

Arguments

data

Data frame with one row per (temperature, duration) replicate.

temp, duration, n_surv, n_total

Column names (strings) for assay temperature (°C), exposure duration, survivors, and trials.

family

"binomial" or "betabinomial".

Details

Two validity flags are returned so callers can choose their own success rule: finite_ok (finite coefficients, negative non-trivial slope) and bracket_ok (the fitted LT50 lies within the observed duration range, padded by 0.5 on the log10 scale). stage1_ok is their conjunction.

Value

A tibble with one row per temperature: temp, log10_lt50, se_log10_lt50, slope, phi (beta-binomial precision, else NA), finite_ok, bracket_ok, stage1_ok.

Examples

d <- simulate_tls(
  family = "binomial", temps = seq(30, 42, by = 2),
  times = c(0.01, 0.03, 0.1, 0.3, 1, 3, 10, 30, 100),
  reps = 4, n = 50, CTmax = 36, z = 4, seed = 42
)
ts_stage1(d, "temp", "duration", "survived", "total", family = "binomial")

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