View source: R/Modalregression.R
modal_regression | R Documentation |
Bayesian Modal Regression
modal_regression(formula, data, model, ...)
formula |
a formula. |
data |
a dataframe. |
model |
a description of the error distribution. Can be one of "FG", "DTP" and "TPSC". |
... |
Arguments passed to |
The Bayesian modal regression model based on the FG, DTP or TPSC distribution is defined as:
Y_{i} = \mathbf{X}_{i} \boldsymbol{\beta} + e_{i},
where e_{i}
follows the FG, DTP or TPSC distribution.
More details of the Bayesian modal regression model can be found at at Liu, Huang, and Bai (2024) https://arxiv.org/pdf/2211.10776.
A draw
object from the posterior package.
liu2022bayesianGUD
# Save current user's options.
old <- options()
# (Optional - Running Multiple Chains in Parallel)
options(mc.cores = 2)
if (require(MASS)) { # Need Boston housing data from MASS package.
# Fit the modal regression based on the FG distribution to the Boston housing data.
FG_model <- modal_regression(formula = medv ~ .,
data = Boston,
model = "FG",
chains = 2,
iter = 2000)
print(summary(FG_model), n = 17)
# Fit the modal regression based on the TPSC-Student-t distribution to the Boston housing data.
TPSC_model <- modal_regression(formula = medv ~ .,
data = Boston,
model = "TPSC",
chains = 2,
iter = 2000)
print(summary(TPSC_model), n = 17)
# Fit the modal regression based on the DTP-Student-t distribution to the Boston housing data.
DTP_model <- modal_regression(formula = medv ~ .,
data = Boston,
model = "DTP",
chains = 2,
iter = 2000)
print(summary(DTP_model), n = 17)
}
# reset (all) initial options
options(old)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.