In a new version of brms I now have a new warning message which makes me think this could be related to the splines initialization.
Missing init values for the following parameters:
- chain 1: Intercept_sigma, bs_sigma, zs_sigma_1_1, sds_sigma_1_1, zs_sigma_2_1, sds_sigma_2_1, zs_sigma_3_1, sds_sigma_3_1, nu
- chain 2: Intercept_sigma, bs_sigma, zs_sigma_1_1, sds_sigma_1_1, zs_sigma_2_1, sds_sigma_2_1, zs_sigma_3_1, sds_sigma_3_1, nu
- chain 3: Intercept_sigma, bs_sigma, zs_sigma_1_1, sds_sigma_1_1, zs_sigma_2_1, sds_sigma_2_1, zs_sigma_3_1, sds_sigma_3_1, nu
- chain 4: Intercept_sigma, bs_sigma, zs_sigma_1_1, sds_sigma_1_1, zs_sigma_2_1, sds_sigma_2_1, zs_sigma_3_1, sds_sigma_3_1, nu
So I tried setting the inits for those variables explicitly with the list below but that did not change anything.
init = function(){list(b_a=rgamma(2,1),b_b=rgamma(2,1),b_c=rgamma(2,1),
Intercept_sigma=runif(2,1,3), bs_sigma=runif(2,1,3),
zs_sigma_1_1=runif(2,1,3),sds_sigma_1_1=runif(2,1,3),
zs_sigma_2_1=runif(2,1,3), sds_sigma_2_1=runif(2,1,3), nu=runif(2,1,3))}
I also stumbled into a comment on a post about change-point/piecewise models suggesting recoding categorical variables as dummy variables (although that was in response to a different error than I have had), I gave that a shot with a subset of the data and did not see any improvements.
dummyCompleteDf<-completeDf%>%
mutate(sample2=sample, treatment2=treatment)%>%
pivot_wider(names_from = treatment2, values_from=sample2, names_prefix = "trt_")%>%
mutate(across(.cols = contains("trt_"), .fns = ~ifelse(is.na(.x),0,1)))
dummyData.fit <- brm(bf(y ~ a*exp(-b*exp(-c*time)),
sigma~s(time,by=treatment),
a + b + c ~ 0+trt_a+trt_b+trt_c,
autocor = ~arma(~time|sample:(treatment),1,1),
nl = TRUE),
family = student, prior = prior1, data = dummyCompleteDf%>%filter(treatment %in% c("a", "b", "c")), iter = 1000, # I started by trying with just a few groups
cores = 4, chains = 4, backend = "cmdstanr",
control = list(adapt_delta = 0.999,max_treedepth = 20),
init = 0) # tried with variety of inits