make_4pl_priors: Default weakly informative priors for the joint Bayesian 4PL

View source: R/priors.R

make_4pl_priorsR Documentation

Default weakly informative priors for the joint Bayesian 4PL

Description

Priors are weakly informative and do not adapt to the data (which would understate uncertainty). They are constructed to match make_4pl_formula()'s disjoint-bounds reparameterisation low = low_min + inv_logit(lowraw) * low_w and up = up_min + inv_logit(upraw) * up_w for the asymptote intervals derived from lower and upper by compute_4pl_bounds().

Usage

make_4pl_priors(
  data,
  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.

lower, upper

Response-scale bounds for the asymptotes. Default ⁠0, 1⁠ for proportion data. For sublethal data bounded above 0 (e.g. photosystem-II between 0.85 and 1), set lower accordingly.

random_effects

Optional character vector of grouping variables for random intercepts on mid. Adds one prior_random_sd row per group.

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 c(lower, upper) asymptote interval; supersedes lower/upper when supplied.

ctmax, z, up, low, k

One-sided formulas selecting the direct CTmax/z priors (matching make_4pl_formula()). Supplying ctmax/z switches to direct-mode priors: the same centred asymptote priors (per factor level for cell-means terms), coding-aware weakly-informative CTmaxdev/logz priors (the level prior lands on the Intercept or each factor level, while between-group contrasts and temperature slopes are centred on zero, so the per-group z/CTmax prior mean is invariant to cell-means vs treatment coding — this removes the log(3) shrinkage bias). The prior variance is not fully coding-invariant: under treatment coding a non-reference group's implied prior convolves the Intercept and contrast SDs (e.g. logz SD sqrt(0.7^2 + 0.7^2) ~ 0.99 vs 0.70 under cell-means), and normalize_cellmeans() only rewrites single-factor formulas. Prefer cell-means (0 + G) for multi-factor models to keep groups symmetric. Plus random-effect SD priors on CTmaxdev/logz only (never on the shape sub-parameters). up/low/k follow the same inheritance resolution as the formula.

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)⁠.

Details

Each of the four 4PL sub-parameters (lowraw, upraw, logk, mid) gets an Intercept-specific prior plus a general class = "b" prior covering the temp_c slope. Random-effect SDs on mid get one prior_random_sd row per grouping variable.

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_4pl_priors(d)

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