Hello, I am trying to fit an ODE model to a series of longitudinal data for different patients so I am interested in a multilevel model with between subject variability for parameter values. I have used a sample example of brms and adjusted it to my model and and when it runs I get the following message:
Chain 1: Rejecting initial value:
Chain 1: Error evaluating the log probability at the initial value.
Chain 1: Exception: Exception: integrate_ode_rk45: initial time is 0, but must be less than 0
Any idea as to what this generally refers to? as I do not understand the initial time being less than 0. My code is the following:
myFuns <- "
real[] ode_expon(real t, real[] y, real[] theta,
data real[] x_r, data int[] x_i){
real dV_dt = theta[1] * y[1];
return {dV_dt};
}
real expon(real t, real V0, real K){
real y0[1];
real y[1,1];
real theta[1];
theta[1] = K;
y0[1] = V0;
y = integrate_ode_rk45(ode_expon,y0, 0, rep_array(t,1), theta,
rep_array(0.0, 0), rep_array(0, 0),0.001, 0.001, 100);
return y[1,1];
}
"
library(brms)
rstan_options(auto_write = TRUE)
options(mc.cores = parallel::detectCores())
b4 <- brm(
bf(Volume ~ expon(TIME, V0, K),
K ~ 1 + (1 | Model),
sigma ~ 0,
nl = TRUE),
stanvars = stanvar(scode = myFuns, block = "functions"),
data = dat,
family = brmsfamily("gaussian", link_sigma = "identity"),
prior = c(prior(normal(0.5, 0.5), nlpar = "K", lb=0)),
seed = 1275, iter = 30,chains = 1)