Extracts posterior predicted estimate values from a list of class bayesnecfit or bayesmanecfit model fits and calculates a geometric mean.

average_estimates(
  x,
  estimate = "nec",
  ecx_val = 10,
  posterior = FALSE,
  type = "absolute",
  hormesis_def = "control",
  sig_val = 0.01,
  resolution = 1000,
  x_range = NA,
  xform = identity,
  prob_vals = c(0.5, 0.025, 0.975)
)

Arguments

x

A named list of objects of class bayesnecfit or bayesmanecfit returned by bnec.

estimate

The type of estimate to use in the mean. Takes values "nec", "ecx" or "nsec".

ecx_val

The desired percentage effect value. This must be a value between 1 and 99 (for type = "relative" and "absolute"), defaults to 10.

posterior

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

type

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

hormesis_def

A character vector, taking values of "max" or "control". See Details.

sig_val

Probability value to use as the lower quantile to test significance of the predicted posterior values.

resolution

The number of unique x values over which to find ECx – large values will make the ECx estimate more precise.

x_range

A range of x values over which to consider extracting ECx.

xform

A function to apply to the returned estimated concentration values.

prob_vals

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

Value

The geometric mean of the estimates estimate values of the bayesnecfit or bayesmanecfit model fits contained in x. See Details.

Details

The geometric mean of values are simply the mean calculated on a log scale and back transformed through exp, although we have added the capacity to accommodate zero values. Note that the function assumes that x has been modelled on the natural scale. Often CR models are more stable on a log-transformed or sqrt scaling. If the input bayesnecfit or bayesmanecfit model fits are already based on a re-scaling of the x (concentration) axis, it is important to pass an appropriate xform argument to ensure these are back transformed before the the geometric mean calculation is applied.

See also

Examples

if (FALSE) { # \dontrun{
library(brms)
library(bayesnec)
data(manec_example)
nec4param <- pull_out(manec_example, model = "nec4param")
ecx4param <- pull_out(manec_example, model = "ecx4param")
average_estimates(list("nec" = ecx4param, "ecx" = nec4param), ecx_val = 50)
} # }