# Growth models with many groups

**URL:** <https://discourse.mc-stan.org/t/growth-models-with-many-groups/26972>\
**Category:** Modeling\
**Tags:** fitting-issues, specification, brms, cmdstanr\
**Created:** [March 30, 2022, 2:29pm UTC](https://discourse.mc-stan.org/t/growth-models-with-many-groups/26972 "2022-03-30T14:29:01Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![jsumner](https://avatars.discourse-cdn.com/v4/letter/j/3e96dc/32.png) [@jsumner](https://discourse.mc-stan.org/u/jsumner)\
**Post date:** [May 9, 2022, 5:43pm UTC](https://discourse.mc-stan.org/t/growth-models-with-many-groups/26972/4 "2022-05-09T17:43:09Z")

</div>

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.

```nohighlight
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.

```nohighlight
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](https://discourse.mc-stan.org/t/piecewise-linear-mixed-models-with-a-random-change-point/5306/13) 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.

```nohighlight
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

```

---

_[View the full topic](https://discourse.mc-stan.org/t/growth-models-with-many-groups/26972)._
