View source: R/predict.lm_b_bma.R
| predict.lm_b_bma | R Documentation |
Predict method for bma model fits
## S3 method for class 'lm_b_bma'
predict(object, newdata, CI_level = 0.95, PI_level = 0.95, seed = 1, ...)
object |
Object of class bma |
newdata |
An optional data.frame in which to look for variables with which to predict. |
CI_level |
Posterior probability covered by credible interval |
PI_level |
Posterior probability covered by prediction interval |
seed |
integer. Always set your seed!!! |
... |
optional arguments. |
list.
newdata tibble with estimate, prediction intervals, and credible intervals for the mean.
posterior_draws
mean_of_ynew draws of E(y), marginalizing out the model
posterior draws of ynew
# Create data
set.seed(2025)
N = 500
test_data =
data.frame(x1 = rnorm(N),
x2 = rnorm(N),
x3 = letters[1:5],
x4 = rnorm(N),
x5 = rnorm(N),
x6 = rnorm(N),
x7 = rnorm(N),
x8 = rnorm(N),
x9 = rnorm(N),
x10 = rnorm(N))
test_data$outcome =
rnorm(N,-1 + test_data$x1 + 2 * (test_data$x3 %in% c("d","e")) )
# Fit linear model using Bayesian model averaging
fit <-
bma_inference(outcome ~ .,
test_data,
user.int = FALSE)
predict(fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.