Computes the posterior probability that a no-effect or effect-concentration estimate lies above a threshold concentration, such as a guideline or trigger value. Posterior draws that lie beyond the prediction range are counted from the censoring record rather than deleted.

exceedance(
  object,
  threshold,
  estimate = c("nec", "nsec", "ecx"),
  ecx_val = 10,
  xform = NULL,
  x_scale = c("recorded", "fitted"),
  ...
)

Arguments

object

An object of class bayesnecfit, bayesmanecfit, bayesnechurdlefit, bayesnecgroupfit or bayesnecjointfit.

threshold

A single finite number, the concentration the estimate is compared with. It is read on the scale the estimate is returned on; see Details.

estimate

The estimate to compare: "nec" (the default), "nsec" or "ecx", read by nec, nsec or ecx respectively.

ecx_val

The effect level of the ECx, as in ecx. Used only where estimate = "ecx", and refused for the other two.

xform

NULL or identity leaves the estimate on x_scale. Any other function is applied on the fitted scale and requires x_scale = "recorded" for a predictor with an inline transformation; see nec.

x_scale

"recorded" (the default) reads threshold on the recorded predictor scale. "fitted" reads it on the scale fitted by crf().

...

Further arguments passed to nec, nsec or ecx, such as x_range, resolution, type, sig_val or extrapolate, which for a bayesnechurdlefit, and no_effect for a bayesnecjointfit. posterior is not accepted: the full posterior is always read.

Value

A data.frame with one row, and for a bayesnecgroupfit or a bayesnecjointfit one row per level preceded by a column level. The columns are:

threshold

The threshold supplied.

prob

The posterior probability that the estimate exceeds threshold, or NA where the censoring record leaves it between prob_lower and prob_upper.

prob_lower, prob_upper

The lowest and highest values of that probability consistent with the censoring record. They are equal wherever the record decides every draw.

n_above, n_below

The number of draws censored above the upper bound and below the lower bound of the prediction range, on the scale the threshold is read on.

n_draws

The number of draws the probabilities are taken over.

Details

The probability is the share of the posterior draws of the estimate that lie above threshold. The draws are those the estimator returns with posterior = TRUE, so the estimate compared is the one nec, nsec or ecx reports for the same object and arguments. For a bayesmanecfit that is the model-averaged posterior, which under "nec" mixes NEC and NSEC draws where the model set contains smooth or hormesis threshold equations. For a bayesnechurdlefit it is the combined endpoint unless which names a component; under "nec" that is the combined no-effect concentration described in nec.bayesnechurdlefit. For a bayesnecgroupfit each level is compared in turn. For a bayesnecjointfit each level is compared in turn as well, on the draws the estimator returns for that level of the joint refit. Under "nec" a level whose equation has no nec parameter has only NA draws, as nec reports for it, so its probabilities are NA and its n_draws is 0. Where every level lacks a nec parameter, exceedance stops. For a bayesnecjointfit, passing no_effect = TRUE compares the NSEC of that level's fitted curve instead, as nec(x, no_effect = TRUE) reports it.

threshold and the estimate are compared on one scale, the scale the estimator returns the estimate on. Without xform that is the scale the predictor was recorded on, so under crf(log(concentration)) the threshold is a concentration. With x_scale = "fitted" it is a log concentration, the scale the model was fitted on. A decreasing xform reverses the order of the scale. A draw then exceeds the threshold on the transformed scale where it lies below the corresponding value on the fitted scale, and the censoring record is remapped with the draws, so that a draw beyond the top of the fitted range is counted at the foot of the transformed one.

Censored draws

A draw beyond an end of the prediction range is not given a value. That includes a threshold equation's sampled nec draw beyond the range, which nec reports only as a bound. The censoring record states such a draw as lying at or above the upper bound of the range, or at or below its lower bound, and the draw is counted from that statement.

Inside the prediction range the record decides every draw. A draw censored above lies above any threshold below the upper bound, and a draw censored below does not lie above any threshold at or above the lower bound. The probability is then exact: prob_lower and prob_upper are equal and prob is that value.

Beyond an end the record does not decide the draws censored at that end, because it does not say on which side of the threshold they lie. For a threshold at or above the upper bound, prob_lower counts every draw censored above as not exceeding it and prob_upper counts each as exceeding it, so the two are the share of identified draws above the threshold and that share plus the share censored above. A threshold below the lower bound is treated in the same way with the draws censored below. prob is NA in both cases, because the posterior does not identify a single probability. Widening the prediction range decides more of those draws, at the price of reading the curve where there are no data: x_range widens it for ecx and nsec, and extrapolate for nec and nsec.

A threshold equal to the upper bound is also reported as an interval. A sampled nec draw is marked censored where it is at or above the bound, so a censored draw may lie on the bound itself, and a draw equal to the threshold does not exceed it. A threshold equal to the lower bound is decided, because a draw at or below it does not exceed it. Where the bound is itself back-transformed, as for "nec" on a fit to crf(log(concentration)) without xform or with xform = exp, it can differ in the last digits from the concentration it was computed from: exp(log(100)) is slightly above 100. A threshold given as that concentration then falls just inside or just outside the range, and the rounding decides whether its probability is exact or reported as an interval.

A draw that is NA without the record accounting for it could not be computed at all, and is left out of both probabilities and of n_draws. An object whose no-effect posterior carries no censoring record, as one built by an earlier version of the package does, has every nec draw compared by its value.

The comparison is strict: a draw equal to threshold does not exceed it. The result is a probability only, and is not converted to an evidence ratio.

Examples

library(bayesnec)
data(manec_example)
exceedance(manec_example, threshold = 1.5)
#> This bayesmanecfit combines sampled NEC and curve-read NSEC draws, so the returned estimate is the model-averaged N(S)EC. See ?nec and summary(), which labels it.
#>   threshold       prob prob_lower prob_upper n_above n_below n_draws
#> 1       1.5 0.09583333 0.09583333 0.09583333       0       0    2400
# \donttest{
exceedance(manec_example, threshold = 1.5, estimate = "ecx", ecx_val = 50)
#>   threshold prob prob_lower prob_upper n_above n_below n_draws
#> 1       1.5    1          1          1       0       0    2400
# }