Learn R Programming

hbsaems (version 0.1.1)

update_hbm: update_hbm : Update a Hierarchical Bayesian Model (hbm) object

Description

This function updates an existing hbmfit object generated by hbm(), hbm_beta(), hbm_logitnormal(), and hbm_lognormal(). It allows updating the formula, data, and other arguments, following the behavior of brms::update().

Usage

update_hbm(
  model,
  newdata = NULL,
  iter = NULL,
  warmup = NULL,
  chains = NULL,
  cores = NULL,
  control = NULL,
  ...
)

Value

An updated hbmfit object

Arguments

model

A brmsfit/hbmfit object

newdata

(optional) A new dataset with the same structure as the original

iter

(optional) Number of MCMC iterations

warmup

(optional) Number of warmup iterations

chains

(optional) Number of MCMC chains

cores

(optional) Number of cores to use for sampling

control

(optional) A named list of control parameters passed to Stan

...

Other arguments passed to update.brmsfit, except those modifying model structure

Details

Update a Hierarchical Bayesian Model (hbm) object

Examples

Run this code
# \donttest{
library(hbsaems)
# Load example data
data("data_fhnorm")
# Fit initial model
model <- hbm(
formula = bf(y ~ x1 + x2 + x3),
hb_sampling = "gaussian",
hb_link = "identity",
data = data_fhnorm,
chains = 2,
iter = 10000,
warmup = 2000,
cores = 2
 )
# Update number of  iterations and warmup
updated_model <- update_hbm(
model,
newdata = data_fhnorm,
iter = 10000,
warmup = 2000,
 chains = 2,
 cores = 2
 )
# Check updated model summary
summary(updated_model)
  # }

Run the code above in your browser using DataLab