-
-
Notifications
You must be signed in to change notification settings - Fork 199
Description
I've been running into a problem where I use brm_multiple and a spatial autocorrelation structure, where the matrix/array showing the spatial autocorrelation gets put into a list of lists in the data2 argument. That works just fine. However, if I run a brm_multiple and then follow it up with update(), where I use the pre-compiled model as the one to update, I get an error for data2:
Error: All elements of 'data2' must be named.
I'm putting in exactly the same code for data2 as I am for brm_multiple, but it doesn't pass the data2 validation mark. However, if I cut data2 down to just a single element in the list (i.e., data2=list(W=W)), it successfully passes the validation check and then fails the model run because the list of lists that brm_multiple requires isn't present. That leads me to suspect that there's a validation step present in update that isn't in brm_multiple, one that isn't expecting the list of list format that brm_multiple needs (or I'm messing up somewhere, which is equally as possible).
Here's the code I used. W is the spatial autocorrelation matrix.
brms_model_formula <- bf(
y~ s(x_variable) +
car(W, gr= ECODE_NAME)+
ar(time = YEAR, gr = series),
family = gaussian()
)
library(future)
compiled_model <- brm_multiple(
formula = brms_model_formula,
data = data_chunks[1:2],
chains = 0,
data2= list(list(W =W),
list(W =W))
)
print(paste0("Model has been compiled. Fitting model now"))
plan(multisession, workers = length(data_chunks))
multi_brms_model <- update(
object = compiled_model,
newdata = data_chunks,
iter = 4000,
warmup=2000,
chains = 4,
recompile = FALSE,
data2= list(list(W=W),
list(W=W),
list(W=W),
list(W=W)
)