# Nonlinear multivariate multilevel models fitting problem in r brm

**URL:** <https://discourse.mc-stan.org/t/nonlinear-multivariate-multilevel-models-fitting-problem-in-r-brm/26298>\
**Category:** Modeling\
**Tags:** brms, rstan\
**Created:** [February 11, 2022, 6:01pm UTC](https://discourse.mc-stan.org/t/nonlinear-multivariate-multilevel-models-fitting-problem-in-r-brm/26298 "2022-02-11T18:01:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![justine](https://avatars.discourse-cdn.com/v4/letter/j/cab0a1/32.png) [@justine](https://discourse.mc-stan.org/u/justine)\
**Post date:** [February 11, 2022, 6:01pm UTC](https://discourse.mc-stan.org/t/nonlinear-multivariate-multilevel-models-fitting-problem-in-r-brm/26298/1 "2022-02-11T18:01:11Z")

</div>

Hi All,  
I am the beginner of using R brm to fit nonlinear mixed model.  
Now I have two longitudinal responses(y\_1,y\_2) with some covariates(Time, X1,X2) in my dataset and I plan to predicted the growth curve of these two responses simultaneously using multivariate nonlinear mixed effect model. I tried to fit a univariate nonlinear mixed model for a single response as follows:

X1: fixed effect;  
X2: random effect;  
y\_i: longitudinal response;  
time: time variable

prior1 = prior(normal(572, 48^2), nlpar = “Asym”) + prior(normal(1149, 67^2), nlpar = “xmid”) +  
prior(normal(194, 35^2), nlpar = “scal”) + prior(normal(44, 5), class=“sigma”) +  
prior(normal(48, 8), class=“sd”, nlpar=“Asym”) +prior(normal(67, 8), class=“sd”, nlpar=“xmid”)  
fit1 = brm(bf(y\_i ~ Asym/(1+exp((xmid - Time)/scal)), Asym ~ 1 + x1 + (1|Location),xmid ~ 1 + x1+ (1|x2), scal ~ 1 + x1 , nl = TRUE), data = data, prior = prior1, chains = 4)

It seems succeed. But I have no idea about how to combine these two univariate mixed models. I tried to follow the guideline of Paul Bürkner ( [Estimating Multivariate Models with brms](https://cran.r-project.org/web/packages/brms/vignettes/brms_multivariate.html)). However, it does not work.

So, if anyone has any suggestions or could point me towards useful resources that would be great. Thanks a lot
