I’m wondering what is happening behind the scenes when I use brms::update to fit a model to new data. Do posteriors from the original model influence the updated model?
I’ve been searching the web and brms/stan documentation, but I’m coming up short on answers.
Here’s a reproducible example
library(brms) set.seed(1 ) data1 <- data.frame(x = rnorm(1000)) # data for species 1 data1$y = data1$x + rnorm(1000, 0, .01) data2 <- data.frame(x = rnorm(10)) # data for species 2 data2$y = data2$x + rnorm(10, 0, 2) plot(y~x, data1, col = "red") points(y~x, data2, col = "blue") prior <- prior(normal(0, 5), nlpar = "a") + prior(normal(0, 5), nlpar = "b") m1 <- brm( bf( y ~ x * a + b, a + b ~ 1, nl = TRUE), data = data1, prior = prior, sample_prior = T) m2 <- brm( bf( y ~ x * a + b, a + b ~ 1, nl = TRUE), data = data2, prior = prior, sample_prior = T) m3 <- update(m1, newdata = data2) # is there a difference between how m2 and m3 were fit or are they functionally the same procedure?