Subsets model(s) from an existing object of class bayesmanecfit

pull_out(
  manec,
  model,
  loo_controls,
  x_range = NULL,
  resolution = NULL,
  sig_val = NULL,
  ...
)

Arguments

manec

An object of class bayesmanecfit as returned by bnec.

model

A character string indicating which model or suite of models to pull out.

loo_controls

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.

x_range, resolution, sig_val

As for bnec. Each is taken from manec unless supplied.

...

Not used. An argument supplied here is refused.

Value

If model is a string representing a single model, an object of class bayesnecfit; If model is instead a string depicting a suite of models, and object of class bayesmanecfit.

Details

Nothing is refitted, so the records of the set are kept. Each equation keeps its bnec_version record, the failed_models record is kept unchanged, and bnec_record lists each equation not kept as excluded, with the reason "not kept by pull_out()".

The estimates of the models kept are computed again with the x_range, resolution, sig_val and loo_controls "fitting" arguments manec was fitted with, unless they are supplied. The bnec defaults are used where manec records none, as an object fitted by an earlier version of bayesnec does not.

A bayesnecjointfit is refused. It fits one equation per level in one posterior, so no equation or level can be taken out of it without refitting.

Of loo_controls, only "fitting" and "report_k" are used. The models kept are scored and weighted as they were in manec, so "weights", "leave_out" and "refit" are ignored, with a message; use amend to change them.

See also

Examples

if (FALSE) { # \dontrun{
library(bayesnec)
data(manec_example)
nec4param <- pull_out(manec_example, model = "nec4param")
# use "ecx" to get all ECx-containing models
# (only one ["ecx4param"] in this minimal example)
ecx_models <- pull_out(manec_example, model = "ecx")
} # }