I’m getting the following error when I run my model (below): " Argument ‘autocor’ should be specified within the ‘formula’ argument." I looked this up, but it looks like the autocor argument was replaced with car, and I do have a car argument in the formula. I’m wondering if this is somehow related to the mo(DaysSinceLastExposed) and the prior(dirichlet(), class = “simo”, coef = “moDaysSinceLastExposed1”) aspect of the model because the error is present when I added in these aspects. Any idea what is wrong with the model here? I’m guessing it’s some syntax thing.
Thank you for your help!
# ran w error, Argument ‘autocor’ should be specified within the ‘formula’ argument
fit21<- brm_multiple(formula = chla_mg_m2 ~ temp+PAR_.5+I(PAR_.5^2)+THP+LakeSurfElev_m+mo(DaysSinceLastExposed)+(1+temp+PAR_.5+I(PAR_.5^2)+THP+LakeSurfElev_m+mo(DaysSinceLastExposed)+car(W, gr = site,"icar")|water_year*site),
data = imp, data2 = W_impute,
family = gaussian(),
prior = c(set_prior("normal(0,5)", class = "Intercept"),
set_prior("lognormal(0,1)", class = "sd")),
prior(dirichlet(), class = "simo", coef = "moDaysSinceLastExposed1"),
control = list(adapt_delta = 0.8),
warmup = 1000, iter = 2000, chains = 3,
cores = 3)
version R version 4.0.3 (2020-10-10)
os Windows 10 x64
system x86_64, mingw32:
Hi,
it is possible this is a bug. Does this work when you just fit a single model via brm? Could you try to find the simplest formula that still gives the issue and some toy data so that we can reproduce the issue on our computers? Do I understand correctly that if you remove the prior and the mo term that the error disappears?
When I moved the car() function out of the grouping term, as shown below, I still got the warning message "Argument ‘autocor’ should be specified within the ‘formula’ argument. "
Thoughts?
fit29<- brm_multiple(formula = chla_mg_m2 ~ temp+PAR_.5+I(PAR_.5^2)+THP+LakeSurfElev_m+car(W, gr = site,"icar")+mo(DaysSinceLastExposed)+(1+temp+PAR_.5+I(PAR_.5^2)+THP+LakeSurfElev_m+mo(DaysSinceLastExposed)|water_year*site),
data = imp, data2 = W_impute,
family = gaussian(),
prior = c(set_prior("normal(0,5)", class = "Intercept"),
set_prior("lognormal(0,1)", class = "sd")),
prior(dirichlet(), class = "simo", coef = "moDaysSinceLastExposed1"),
control = list(adapt_delta = 0.8),
warmup = 1000, iter = 2000, chains = 3,
cores = 3)
The error stopped when I fixed the priors as shown below.
However, now the model compiles and runs through all the iterations, but when all the chains get to 100%, the model starts back at 0% and keeps looping. When I finally stop this infinite cycle, the only error I get is the g++ not found message, which I read should be ignored. Thoughts?
fit31<- brm_multiple(formula = chla_mg_m2 ~ temp+PAR_.5+I(PAR_.5^2)+THP+LakeSurfElev_m+car(W, gr = site,"icar")+mo(DaysSinceLastExposed)+(1+temp+PAR_.5+I(PAR_.5^2)+THP+LakeSurfElev_m+mo(DaysSinceLastExposed)|water_year*site),
data = imp, data2 = W_impute,
family = gaussian(),
prior = set_prior("normal(0,5)", class = "Intercept")+
set_prior("lognormal(0,1)", class = "sd")+
set_prior("dirichlet(1,1,1,1)", class = "simo", coef = "moDaysSinceLastExposed1"),
control = list(adapt_delta = 0.8),
warmup = 100, iter = 200, chains = 3,
cores = 3)
You are running brm_multiple - this will fit the model separately for each imputed dataset. So if imp has 50 elements, it will fit 50 models. So this might be expected behaviour.
Also note that you can use triple backtics (```) to format code blocks neatly (I took the liberty to edit your previous posts to add this formatting)