Learn R Programming

FBMS (version 1.1)

get.best.model: Extract the Best Model from MJMCMC or GMJMCMC Results

Description

This function retrieves the best model from the results of MJMCMC, MJMCMC parallel, GMJMCMC, or GMJMCMC merged runs based on the maximum criterion value (crit). The returned list includes the model probability, selected features, criterion value, intercept parameter, and named coefficients.

Usage

get.best.model(result, labels = FALSE)

Value

A list containing the details of the best model:

prob

A numeric value representing the model's probability.

model

A logical vector indicating which features are included in the best model.

crit

The criterion value used for model selection (e.g., marginal likelihood or posterior probability).

alpha

The intercept parameter of the best model.

coefs

A named numeric vector of model coefficients, including the intercept and selected features.

Arguments

result

An object of class "mjmcmc", "mjmcmc_parallel", "gmjmcmc", or "gmjmcmc_merged", containing the results from the corresponding model search algorithms.

labels

Logical; if TRUE, uses labeled feature names when naming the model coefficients. Default is FALSE.

Details

The function identifies the best model by selecting the one with the highest crit value. Selection logic depends on the class of the result object:

"mjmcmc"

Selects the top model from a single MJMCMC run.

"mjmcmc_parallel"

Identifies the best chain, then selects the best model from that chain.

"gmjmcmc"

Selects the best population and model within that population.

"gmjmcmc_merged"

Finds the best chain and population before extracting the top model.

Examples

Run this code
result <- gmjmcmc(matrix(rnorm(600), 100), P = 2, gaussian.loglik, NULL, c("p0", "exp_dbl"))
get.best.model(result)

Run the code above in your browser using DataLab