rbayesiannon-linear-regressionbrms

mean in Bayesian formula for non-linear modeling with brms


I am trying to fit non-linear models with brms. My model is:

y = intercept + b1 * (x1 * mean(x2^b2))

where:

A colleague of mine coded it in rjags this way:

y1[i] <- x1[i]*(mean(x2_matrix[1:no_per_site[i],i]^b2))
y2[i] <- intercept + y1[i]*b1

Where i is the site index, x2_matrix has one row per individual mass (x2) values and one column per site, and where no_per_site is the number of x2 measured in each site.

Is there a way to fit this model in brms? How do I manage the x2 matrix?

Here is the structure of the data:

'data.frame':   31 obs. of  3 variables:
 $ population: chr  "p1" "p2" "p3" "p4" ...`
 $ y2        : num  592 551 1720 5135 3710 ...
 $ x1        : int  145 145 72 3173 3173 1262 1262 504 504 777 ...
 $ no_per_site: num 104 55 187 102 ...

and the x2 matrix:

num [1:187, 1:31] 530 600 460 510 325 420 490 430 450 350 ...

Thank you!


Solution

  • The solution I fond is to use taylor expansions for the first moment of functions of random variables. The details can be found here: vignette_taylor_series