prebayesnecfit objects.R/expand_classes.R
expand_manec.RdExtracts a range of statistics from a list of prebayesnecfit
objects.
expand_manec(
object,
formula,
x_range = NA,
resolution = 1000,
sig_val = 0.01,
loo_controls
)A list of objects of class
prebayesnecfit.
Either a character string defining an
R formula or an actual formula object. See
bayesnecformula and check_formula. It could also
be a list of formulas if multiple objects are passed to
object.
A range of predictor values over which to consider extracting ECx.
The length of the predictor vector used for posterior predictions, and over which to extract ECx values. Large values will be slower but more precise.
Probability value to use as the lower quantile to test significance of the predicted posterior values against the control concentration, to estimate NEC as an interpolated NOEC value from smooth ECx curves.
A named list of up to five
elements. "fitting" and "weights" are each a named list
containing the desired arguments to be passed on to loo
(via "fitting") or to the weighting function (via "weights"). "weights"
names a method, "pseudobma" or "stacking", and the arguments of
pseudobma_weights (BB, BB_n and
alpha) or of stacking_weights
(optim_method and optim_control); any other argument is
refused. If no method is named, bayesnec uses "pseudobma",
whichever function assembles the model set. "leave_out" is "group" (the
default), "observation" or "kfold", and sets what is left out when the
score behind the weights is computed. Under "group", where each level of a
group-level term is observed at a single concentration, each level is left
out whole; otherwise, and always under "observation", each observation is
left out. "kfold" selects the exact K-fold scores that
kfold_weights stores with each equation. bnec() refuses
it, as do update() and an amend() that adds an equation,
because a new fit has no such score. "refit" is FALSE (the default)
or TRUE, and applies
under "group" only: where TRUE, each equation is refitted without
each level whose Pareto k is at or above 0.7. The "fitting" arguments
apply to the score computed by leaving out each observation.
"report_k" is TRUE (the default) or FALSE. For a model set,
it reports Pareto k at or above 0.7 for equations with at least 0.01 model
weight, using the LOO scores selected for weighting. Set it to FALSE
after assessing the diagnostic to silence the message. This does not change
the scores or weights. With fewer than about 2200 posterior draws, values
below 0.7 can exceed the draw-dependent reliability threshold used by
loo; these are reported separately and are not selected for refitting
by refit = TRUE. Every equation's observation-wise LOO criterion is
retained in
fit$mod_fits[[model]]$fit$criteria$loo; where groups were left out,
the selected criterion, including its Pareto k values, is in
fit$mod_fits[[model]]$fit$criteria$logo, even for equations with less
than 0.01 weight. Exact K-fold scores are stored in criteria$kfold.
See Details, under model averaging.
amend, update and pull_out operate on an
existing set. They keep the "fitting" arguments it was built with unless
the caller names "fitting", and the method it was weighted by unless the
caller names another. pull_out keeps the set's scores and
weights: it reports and ignores "weights", "leave_out" and "refit".
c and + take no loo_controls argument;
see c.bnecfit for how they decide the method. See
?pseudobma_weights for further info.
A list of model statistical output derived from
the input model list. This includes retained_data when compatible
retained columns were present on the input objects.
When recovered input objects contain retained_data, the
returned model set stores that data frame once if every available copy is
identical. Different retained frames are reported and omitted because one
frame cannot align observations for the whole set.
# \donttest{
library(bayesnec)
data(manec_example)
fits <- manec_example$mod_fits
formulas <- lapply(fits, function(f) f$bayesnecformula)
set_fit <- expand_manec(fits, formulas, resolution = 50)
#> Fitted models are: nec4param ecx4param
#> Warning:
#> 3 (3.0%) p_waic estimates greater than 0.4. We recommend trying loo instead.
#> Warning:
#> 4 (4.0%) p_waic estimates greater than 0.4. We recommend trying loo instead.
#> The leave-one-observation-out score has Pareto k at or above 0.7 for 2 of 100 observations in nec4param (weight 0.8); 2 of 100 observations in ecx4param (weight 0.2). The affected scores are approximate.
set_fit$mod_stats
#> model waic elpd wi dispersion_Estimate
#> nec4param nec4param 176.6074 -87.84436 0.8048 NA
#> ecx4param ecx4param 189.6968 -95.36972 0.1952 NA
#> dispersion_Q2.5 dispersion_Q97.5 dispersion_P_over_1
#> nec4param NA NA NA
#> ecx4param NA NA NA
# }