Extracts the percent effect associated with a predicted NSEC value from an object of class bayesnecfit or bayesmanecfit.

ecnsec(
  object,
  ...,
  resolution = 500,
  x_range = NA,
  type = "absolute",
  sig_val = 0.01,
  prob_vals = c(0.5, 0.025, 0.975),
  posterior = FALSE,
  pool = NULL,
  x_control = "own",
  extrapolate = FALSE
)

Arguments

object

An object of class bayesnecfit or bayesmanecfit returned by bnec.

...

Further arguments to pass to class specific methods. A method refuses any argument it does not use.

resolution

The number of unique x values over which the curve is predicted. It affects only type = "range", where the denominator is the lowest response the curve predicts over the grid. The default of 500 matches ecx and nsec. With an inline predictor transformation, their search grid is even on the fitted scale and each NSEC is returned through the inverse before its effect is reported.

x_range

A range of x values over which to predict the curve.

type

A character vector, taking values of "absolute" (the default), "relative" or "range". See Details.

sig_val

The control posterior quantile used as the NSEC reference. The default is 0.01, as in nsec.

prob_vals

A vector indicating the probability values over which to return the estimated ECNSEC value. Defaults to 0.5 (median) and 0.025 and 0.975 (95 percent credible intervals).

posterior

A logical value indicating if the full posterior sample of calculated ECNSEC values should be returned instead of just the median and 95 credible intervals.

pool

How observed group levels are combined. "none" returns per-level estimates. "mixture" gives each posterior draw to one level, in proportion to the levels' observation counts, and keeps it at its position, so that draw i of the mixture comes from posterior iteration i. Separate fits with different numbers of draws are instead each sampled over their full posterior. "mean_estimate" averages the levels' estimates at each draw, and "mean_curve" estimates from their weighted mean curve. A joint fit defaults to "none"; other fits with spanning group terms default to "mixture".

x_control

"own" reads each level's control recorded at fitting, or its lowest observed concentration for an older fit or one fitted without x_control. "shared" reads the lowest control across levels; a single finite number specifies the concentration directly. A control below a level's observations extrapolates its curve, and gives a warning unless it is the control recorded at fitting. Level controls are recorded in the result's x_control attribute.

extrapolate

FALSE, the default, uses the prediction range. A single finite number extends the upper end; two finite numbers may extend both ends. The original grid points are retained. Limits are on the recorded predictor scale. TRUE and narrowing limits are refused. For type = "range" the lowest response is taken over the prediction range before it is extended.

Value

A percentage summary or, with posterior = TRUE, one percentage per posterior draw. Grouped results follow nsec.

Details

Each posterior draw is evaluated at its own NSEC, where its curve reaches the sig_val quantile of the control posterior. The effect is the decline from that draw's control to the reference, divided by the distance from its control to the floor selected by type. The floor is zero for "absolute", the fitted asymptote for "relative", and the lowest predicted response over the original range for "range". A draw whose NSEC is the control concentration has zero effect. A draw whose control is below the reference and whose NSEC is a later crossing has a negative effect. With type = "range", a draw whose NSEC lies above the prediction range or whose effect exceeds its original response span is censored at 100 percent. Its posterior draw is Inf. The "absolute" values equal the ecnsec_relativeP attribute of nsec under matching options.

Use epx for the effect at a stated concentration.

The pool, x_control and extrapolate options use the same rules as nsec. type = "relative" is unavailable for a joint two-block hurdle curve.

See also

Examples

# \donttest{
library(bayesnec)
data(manec_example)
ecnsec(manec_example)
#>       50%      2.5%     97.5% 
#>  7.380699  1.127267 12.842312 
# }