fbms: Fit a BGNLM model using Genetically Modified Mode Jumping...

fbmsR Documentation

Fit a BGNLM model using Genetically Modified Mode Jumping Markov Chain Monte Carlo (MCMC) sampling. Or Fit a BGLM model using Modified Mode Jumping Markov Chain Monte Carlo (MCMC) sampling.

Description

This function fits a model using the relevant MCMC sampling. The user can specify the formula, family, data, transforms, and other parameters to customize the model.

Usage

fbms(
  formula = NULL,
  family = "gaussian",
  beta_prior = list(type = "g-prior"),
  model_prior = NULL,
  extra_params = NULL,
  data = NULL,
  impute = FALSE,
  loglik.pi = NULL,
  method = "mjmcmc",
  verbose = TRUE,
  ...
)

Arguments

formula

A formula object specifying the model structure. Default is NULL.

family

The distribution family of the response variable. Currently supports "gaussian", "binomial", "poisson", "gamma", and "custom". Default is "gaussian".

beta_prior

Type of prior as a string (default: "g-prior" with a = max(n, p^2)). Possible values include: - "beta.prime": Beta-prime prior (GLM/Gaussian, no additional args) - "CH": Compound Hypergeometric prior (GLM/Gaussian, requires a, b, optionally s) - "EB-local": Empirical Bayes local prior (GLM/Gaussian, requires a for Gaussian) - "EB-global": Empirical Bayes local prior (Gaussian, requires a for Gaussian) - "g-prior": Zellner's g-prior (GLM/Gaussian, requires g) - "hyper-g": Hyper-g prior (GLM/Gaussian, requires a) - "hyper-g-n": Hyper-g/n prior (GLM/Gaussian, requires a) - "tCCH": Truncated Compound Hypergeometric prior (GLM/Gaussian, requires a, b, s, rho, v, k) - "intrinsic": Intrinsic prior (GLM/Gaussian, no additional args) - "TG": Truncated Gamma prior (GLM/Gamma, requires a, s) - "Jeffreys": Jeffreys prior (GLM/Gaussian, no additional args) - "uniform": Uniform prior (GLM/Gaussian, no additional args) - "benchmark": Benchmark prior (Gaussian/GLM, no additional args) - "ZS-adapted": Zellner-Siow adapted prior (Gaussian TCCH, no additional args) - "robust": Robust prior (Gaussian/GLM, no additional args) - "Jeffreys-BIC": Jeffreys prior with BIC approximation of marginal likelihood (Gaussian/GLM) - "ZS-null": Zellner-Siow null prior (Gaussian, requires a) - "ZS-full": Zellner-Siow full prior (Gaussian, requires a) - "hyper-g-laplace": Hyper-g Laplace prior (Gaussian, requires a) - "AIC": AIC prior from BAS (Gaussian, requires penalty a) - "BIC": BIC prior from BAS (Gaussian/GLM) - "JZS": Jeffreys-Zellner-Siow prior (Gaussian, requires a)

  • r: Model complexity penalty (default: 1/n)

  • g: Tuning parameter for g-prior (default: max(n, p^2))

  • a, b, s, v, rho, k: Hyperparameters for various priors

  • n: Sample size for some priors (default: length(y))

  • var: Variance assumption for Gaussian models ("known" or "unknown", default: "unknown")

  • laplace: Logical for Laplace approximation in GLM only (default: FALSE)

model_prior

a list with parameters of model priors, by default r should be provided

extra_params

extra parameters to be passed to the loglik.pi function

data

A data frame or matrix containing the data to be used for model fitting. If the outcome variable is in the first column of the data frame, the formula argument in fbms can be omitted, provided that all other columns are intended to serve as input covariates.

impute

TRUE means imputation combined with adding a dummy column with indicators of imputed values, FALSE (default) means only full data is used.

loglik.pi

Custom function to compute the logarithm of the posterior mode based on logarithm of marginal likelihood and logarithm of prior functions (needs specification only used if family = "custom")

method

Which fitting algorithm should be used, currently implemented options include "gmjmcmc", "gmjmcmc.parallel", "mjmcmc" and "mjmcmc.parallel" with "mjmcmc" being the default and 'mjmcmc' means that only linear models will be estimated

verbose

If TRUE, print detailed progress information during the fitting process. Default is TRUE.

...

Additional parameters to be passed to the underlying method.

Value

An object containing the results of the fitted model and MCMC sampling.

See Also

mjmcmc, gmjmcmc, gmjmcmc.parallel

Examples

# Fit a Gaussian multivariate time series model
fbms_result <- fbms(
 X1 ~ .,
 family = "gaussian",
 method = "gmjmcmc.parallel",
 data = data.frame(matrix(rnorm(600), 100)),
 transforms = c("sin","cos"),
 P = 10,
 runs = 1,
 cores = 1
)
summary(fbms_result)



FBMS documentation built on Sept. 13, 2025, 1:09 a.m.