make_tdt_priors: Default priors for a joint Bayesian four-parameter...

View source: R/priors.R

make_tdt_priorsR Documentation

Default priors for a joint Bayesian four-parameter dose-response model

Description

Model-generic twin of make_4pl_priors(). The only prior that depends on model is the Intercept prior mean of logk: it is shifted by log(0.25 / slope_factor) so that the implied prior on the slope of the curve at its midpoint, -k (up - low) * slope_factor, is the same for every model (slope_factor = 0.25 log-logistic, 0.399 log-normal, 0.347 both Weibull types). make_4pl_priors() is make_tdt_priors(model = "log-logistic").

Usage

make_tdt_priors(
  data,
  model = "log-logistic",
  lower = 0,
  upper = 1,
  random_effects = NULL,
  prior_random_sd = "exponential(2)",
  prior_phi = "gamma(2, 0.1)",
  bounds = NULL,
  ctmax = NULL,
  z = NULL,
  up = NULL,
  low = NULL,
  k = NULL,
  fix_asymptotes = NULL
)

Arguments

data

Output of standardize_data(). Only logd is used, to centre the midpoint Intercept prior.

model

Dose-response curve: "log-logistic" (the 4PL), "log-normal" (probit), "weibull1" (Weibull type 1, the Gompertz-shaped curve on log time) or "weibull2" (Weibull type 2). Every model is written in its midpoint form, so mid, the TDT line, z and CTmax mean the same thing for all of them; only the shape of the curve and the absolute-threshold correction differ.

lower, upper

Response-scale bounds for the asymptotes. Default ⁠0, 1⁠ for proportion data; set narrower for sublethal data whose response sits well above 0.

random_effects

Optional character vector of grouping variables for random intercepts on mid.

prior_random_sd

Stan prior string for random-effect SDs. Default "exponential(2)".

prior_phi

Stan prior string for the beta-binomial precision parameter phi. Default "gamma(2, 0.1)". Pass NULL to omit the phi prior — needed when fitting with family = binomial() (no overdispersion).

bounds

Length-2 numeric c(lower, upper) giving the response-scale asymptote interval. Defaults to c(lower, upper). Preferred over the separate lower/upper (which it supersedes — see those).

ctmax, z

One-sided formulas for the direct parameterisation. Supplying either switches make_4pl_formula() to fit CTmax (as CTmaxdev = CTmax - mean(temp)) and z (as logz) directly as nonlinear parameters, with mid reconstructed from them. Carry the fixed and random effects for tolerance and sensitivity, e.g. ~ life_stage + (1 | Date). Omit z for a single pooled z (logz ~ 1).

up, low, k

Optional one-sided formulas for the asymptote and steepness sub-parameters. In direct mode, when omitted they inherit the ctmax/z fixed effects crossed with temp_c (random effects are not inherited); intercept-only ctmax/z gives ~ temp_c. In midpoint mode they default to the temp_effects structure (or by, see below); an explicit formula always overrides.

fix_asymptotes

Pin one or both asymptotes instead of estimating them (default NULL: both estimated). TRUE fixes low and up at the response bounds (lower, upper; 0 and 1 for proportions); c("up") fixes only the named asymptote at its bound; a named numeric vector such as c(low = 0.02) or c(low = 0, up = 1) fixes the named ones at those values. A fixed asymptote gets a brms constant() prior on its Intercept and no slope prior (its formula is ~ 1). Values at the response bounds are pinned at the edge of the padded window (0.001 / 0.999 with the defaults, see compute_4pl_bounds()) because the identity-link likelihood needs probabilities strictly inside ⁠(lower, upper)⁠.

Value

A brmsprior object ready to pass to fit_4pl().

Examples

raw <- data.frame(
  temperature_C = rep(c(30, 32, 34), each = 4),
  exposure_h    = rep(c(1, 2, 4, 8), times = 3),
  n             = 30L,
  alive         = c(29, 28, 25, 5, 30, 27, 18, 2, 28, 22, 10, 1)
)
d <- standardize_data(raw, temp = "temperature_C", duration = "exposure_h",
                      n_total = "n", n_surv = "alive")
make_tdt_priors(d, model = "weibull1")

bayesTLS documentation built on Nov. 29, 2026, 1:06 a.m.