I am working on a project where I am trying to fit a nonlinear mixed effects model from a Bayesian perspective. The data set contains values
(the total lumens) and is measured for 40 samples (sample identifiers are contained in ids
) at multiple time points (measured in days
). Here is a snapshot of the data I have collected:
as well as a plot of the data I am working with
If we were to connect the data based on ids, you would see 40 lines in the plot (i.e., the data is longitudinal). From a physics point of view, I know that the relationship between my data and time should look something like an exponential decaying function. With that in mind, as a first pass, I would like to first try to fit a nonlinear model based on an exponentially decaying function. Something like (and I’m open to suggestions for a better model)
y_{ij} = a_i + \exp(-b_i\times \text{days}) + \varepsilon_{ij}
for i=1,...,40 and j is the day. However, where I am struggling is incorporating the longitudinal part. As I am unaware of how to do it, it would be useful to see how to write down the correct model. Ultimately I would like to be able to run the model in R
using the brms
package which I think proceeds as follows:
model <- brm(
bf(values ~ a * exp(-b * days),
a ~ 1 + (1|ids), b ~ 1 + (1|ids),
nl = TRUE),
data = dat, family = gaussian(),
prior = c(
prior(normal(0, 10), class = "b", nlpar = "a"),
prior(normal(0, 10), class = "b", nlpar = "b"),
prior(normal(0, 10), class = "sd", nlpar = "a"),
prior(normal(0, 10), class = "sd", nlpar = "b")
)
)
But I am not sure if that is the correct specification. Does the above model imply that each id gets it’s own estimate of a and b? I guess also I would like to run this model with non-informative priors as well.