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.
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,
...
)An object containing the results of the fitted model and MCMC sampling.
A formula object specifying the model structure. Default is NULL.
The distribution family of the response variable. Currently supports "gaussian", "binomial", "poisson", "gamma", and "custom". Default is "gaussian".
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)
a list with parameters of model priors, by default r should be provided
extra parameters to be passed to the loglik.pi function
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.
TRUE means imputation combined with adding a dummy column with indicators of imputed values, FALSE (default) means only full data is used.
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")
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
If TRUE, print detailed progress information during the fitting process. Default is TRUE.
Additional parameters to be passed to the underlying method.
mjmcmc, gmjmcmc, gmjmcmc.parallel
# 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)
Run the code above in your browser using DataLab