threshold_x_by_draw: Per-draw threshold inversion of a posterior-prediction matrix

View source: R/predict_survival_curves.R

threshold_x_by_drawR Documentation

Per-draw threshold inversion of a posterior-prediction matrix

Description

Internal helper. For each row (draw) of pred_mat, finds the value of x at which the predicted probability crosses target, via linear interpolation. Returns one value per draw.

Usage

threshold_x_by_draw(pred_mat, x, target)

Arguments

pred_mat

Numeric matrix ⁠[ndraws × ngrid]⁠ of survival probabilities.

x

Numeric vector of grid values along which to invert (length = ncol(pred_mat)).

target

Numeric scalar: the probability value to invert at.

Details

stats::approx() requires its x argument (here, the survival values) to be monotonically increasing. Because the 4PL is monotonically decreasing in duration (and in temperature for a fixed duration), we sort by p ascending before calling approx().

Value

Numeric vector of length nrow(pred_mat).


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