Extracts the predicted ECx value as desired from an object of class
`bayesnecfit`

or `bayesnecfit`

.

```
ecx(
object,
ecx_val = 10,
resolution = 1000,
posterior = FALSE,
type = "absolute",
hormesis_def = "control",
x_range = NA,
xform = identity,
prob_vals = c(0.5, 0.025, 0.975)
)
```

- object
An object of class

`bayesnecfit`

or`bayesmanecfit`

returned by`bnec`

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

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

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

A vector containing the estimated ECx value, including upper and lower 95% credible interval bounds.

`type`

"relative" is calculated as the percentage decrease
from the maximum predicted value of the response (top) to the minimum
predicted value of the response. Type "absolute" (the default) is
calculated as the percentage decrease from the maximum value of the
response (top) to 0. Type "direct"
provides a direct estimate of the x value for a given y.
Note that for the current version, ECx for an "nechorme" (NEC Hormesis)
model is estimated at a percent decline from the control.

For `hormesis_def`

, if "max", then ECx values are calculated as a
decline from the maximum estimates (i.e. the peak at NEC);
if "control", then ECx values are calculated relative to the control, which
is assumed to be the lowest observed concentration.

Calls to functions `ecx`

and `nsec`

and
`compare_fitted`

do not require the same level of flexibility
in the context of allowing argument `newdata`

(from a `posterior_predict`

perspective) to
be supplied manually, as this is and should be handled within the function
itself. The argument `resolution`

controls how precisely the
`ecx`

or `nsec`

value is estimated, with
argument `x_range`

allowing estimation beyond the existing range of
the observed data (otherwise the default range) which can be useful in a
small number of cases. There is also no reasonable case where estimating
these from the raw data would be of value, because both functions would
simply return one of the treatment concentrations, making NOEC a better
metric in that case.

```
# \donttest{
library(brms)
library(bayesnec)
data(manec_example)
ecx(manec_example, ecx_val = 50)
#> Q50 Q2.5 Q97.5
#> 1.672709 1.610238 1.731829
#> attr(,"resolution")
#> [1] 1000
#> attr(,"ecx_val")
#> [1] 50
#> attr(,"toxicity_estimate")
#> [1] "ecx"
ecx(manec_example)
#> Q50 Q2.5 Q97.5
#> 1.4908009 0.9406099 1.5626864
#> attr(,"resolution")
#> [1] 1000
#> attr(,"ecx_val")
#> [1] 10
#> attr(,"toxicity_estimate")
#> [1] "ecx"
# }
```