bestmodel {BAMBI} | R Documentation |
Convenience function for extracting angmcmc object, and the value of the model selection criterion corresponding to the best fitted model in stepwise fits
Description
Convenience function for extracting angmcmc object, and the value of the model selection criterion corresponding to the best fitted model in stepwise fits
Usage
bestmodel(step_object)
bestcriterion(step_object)
Arguments
step_object |
stepwise fitted object obtained from fit_incremental_angmix. |
Details
These are convenience functions; the best fitted model and the corresponding value of model selection criterion
can also be directly obtained by
extracting the elements "fit.best"
and "crit.best"
from step_object
respectively.
Note that bestcriterion
returns:
(a) a scalar number (class = numeric
) if crit
used in original fit_incremental_angmix
call is 'AIC'
, 'BIC'
or 'DIC'
,
(b) an element of class bridge
from package bridgesampling
if crit
is
LOGML
, (c) an element of class c("waic", "loo")
if crit = 'WAIC'
, and (d) an element of
class c("psis_loo", "loo")
if crit = "LOOIC"
. See documentations of these model
selection criteria for more details.
Value
bestmodel
returns an angmcmc
object, and
bestcriterion
returns the corresponding value of model selection criterion for the best fitted model in step_object
.
Examples
# illustration only - more iterations needed for convergence
set.seed(1)
fit.vmsin.step.15 <- fit_incremental_angmix("vmsin", tim8, start_ncomp = 1,
max_ncomp = 3, n.iter = 15,
n.chains = 1,
crit = "WAIC")
fit.vmsin.best.15 <- bestmodel(fit.vmsin.step.15)
fit.vmsin.best.15
crit.best <- bestcriterion(fit.vmsin.step.15)
crit.best