eval_replicate | R Documentation |
eval_replicate
is the default simuland
function applied to simulated bootstrap samples by likelihood-ratio testing functions (fixedLRT, LRT, anove.HLfit
). This documentation presents the requirements and possible features of this function and of possible user-defined alternatives.
An alternative function spaMM:::.eval_replicate2
is also provided. It is slower, as it refits the models compared with different initial values for random-effect parameters, which is useful in some difficult cases where initial values matter. The eval_replicate
function may also refit the “full” models with different initial values when the logLik of the refitted full model is substantially lower than that of the refitted null model. “Substantially” means that a tolerance of 1e-04
is applied to account for inaccuracies of numerical maximization.
eval_replicate(y)
y |
a response vector on which a previously fitted model may be refitted. |
likelihood-ratio testing functions have a debug.
argument whose effect depends on the simuland
function. The default behaviour is thus defined by eval_replicate
, as: if debug.=TRUE
, upon error in the fitting procedures, dump.frames
will be called, in which case a dump file will be written on disk; and a list with debugging information will be returned (so that, say, pbapply
will not return a matrix). This behaviour may change in later versions, so non-default debug.
values should not be used in reproducible code. In serial computation, debug.=2
may induce a stop
; this should not happen in parallel computation because the calling functions check against debug.==2
.
Essential information such as the originally fitted models is passed to the function not as arguments but through its environment, which is controlled by the calling functions (see the eval_replicate
source code to know which are these arguments). Users should thus not assume that they can control their own simuland
function's environment as this environment will be altered.
Advanced users can define their own simuland
function. The eval_replicate
source code provides a template showing how to use the function's environment. The Example below illustrates another approach augmenting eval_replicate
. A further example is provided in the file
tests/testthat/test-LRT-boot.R
, using ... to pass additional arguments beyond response values.
A vector of the form c(full=logLik(
<refitted full model>),null=logLik(
<refitted null model>)
; or possibly in debugging contexts, a list with the same elements each with some additional information provided as attribute.
Calling functions fixedLRT, LRT
.
## Not run:
# Simple wrapper enhancing the default 'simuland'
# with a call to some obscure option, and dealing with
# the need to pass the environment assigned to 'simuland'
eval_with_opt <- function(y) {
spaMM.options(some_obscure_option="some_obscure_value")
eval_rep <- spaMM:::.eval_replicate
environment(eval_rep) <- parent.env(environment()) # passing the environment
eval_rep(y)
}
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.