Learn R Programming

bayesics (version 2.0.2)

predict.np_glm_b: Predict method for lm_b model fits

Description

Predict method for lm_b model fits

Usage

# S3 method for np_glm_b
predict(object, newdata, trials, CI_level = 0.95, ...)

Value

tibble with estimate, prediction intervals, and credible intervals for the mean.

Arguments

object

Object of class lm_b

newdata

An optional data.frame in which to look for variables with which to predict.

trials

Integer vector giving the number of trials for each observation if family = binomial().

CI_level

numeric. Credible interval level.

...

optional arguments.

Examples

Run this code
# \donttest{
# Generate some data
set.seed(2025)
N = 500
test_data = 
  data.frame(x1 = rnorm(N),
             x2 = rnorm(N),
             x3 = letters[1:5])
test_data$outcome = 
  rbinom(N,1,1.0 / (1.0 + exp(-(-2 + test_data$x1 + 2 * (test_data$x3 %in% c("d","e")) ))))

# Fit the GLM via the (non-parametric) loss-likelihood bootstrap.
fit1 <-
  np_glm_b(outcome ~ x1 + x2 + x3,
           data = test_data,
           family = binomial())
predict(fit1)
# }

Run the code above in your browser using DataLab