bestmodel: Convenience function for extracting angmcmc object, and the...

View source: R/all_model_select.R

bestmodelR 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⁠bridgesamplingifcritisLOGML⁠, (c) an element of class ⁠c("waic", "loo")ifcrit = 'WAIC'⁠, and (d) an element of class ⁠c("psis_loo", "loo")ifcrit = "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


BAMBI documentation built on Oct. 25, 2024, 5:07 p.m.

Related to bestmodel in BAMBI...