How to remove the distributional part of a brms model with update()

  Kiến thức lập trình

I’m working with the brms package and fitting models using distributional formulas like this:

library(brms)
fml <- bf(mpg ~ hp, sigma ~ cyl)
mdl <- brm(fml, data = mtcars)

I want to programmatically remove the sigma part from this formula and refit the model using the update() function to avoid a full refit. Using update() is much faster because it avoids recompiling the Stan model.

I tried the following approach, but sigma is still part of the model:

fml_no_sigma <- fml$formula  # extracting main formula
mdl_no_sigma <- update(mdl, formula = fml_no_sigma)

However, the sigma part remains in the updated model.

Refitting the model with fml$formula does remove the sigma but is much slower than using updated:

brm(fml$formula, data = mtcars)

Is there a way to use update() to remove the sigma part without refitting the entire model from scratch?

6

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT