Dear Mike,
Thanks for your reply and the video. Your approach is very interesting. However, you have many samples from the same population, but I have, for a given subject and at a given time, a single measure of the observed variables.
Anyway, inspired in your suggestion, what I am looking for is something like:
// Function for reduce_sum
real partial_sum_lpdf(...) {
// numerical integration
vector[2] y[n] = ode_rk45_tol(...);
// log-likelihood
return normal_lpdf(to_vector(obs[indices_1,1]) | pow(to_vector(y[start:end,2]),(1/3.0)) , sd_1)
+
normal_lpdf(to_vector(obs[indices_2,2]) | to_vector(y[start:end,2]) + to_vector(y[start:end,1]) , sd_2)
;
}
The final goal is to estimate the parameters of the derivatives (in the ode_rk45 function). This is a very simplified, non-functional code. I have removed all the arguments of the functions for sake of simplicity. The key is that indices_1 indicates the times for which I have observations of the first observed variable (obs[indices_1,1]).
The full code compiles but does not run:
Chain 1 Unrecoverable error evaluating the log probability at the initial value.
Chain 1 Exception: Exception: normal_lpdf: Random variable has size = 3, but Location parameter has size 7; and they must be the same size. (in ‘C:/Users/palmer/AppData/Local/Temp/RtmpYpXvVm/model-32204c3535d1.stan’, line 135, column 4 to line 138, column 14) (in ‘C:/Users/palmer/AppData/Local/Temp/RtmpYpXvVm/model-32204c3535d1.stan’, line 221, column 4 to line 227, column 26)
As expected, the length of the expected values (y, the output of ode_rk45) is larger than the length of the observed values.
The same code runs when the two variables are fully observed.
I guess that redece_sum selects some specific times (=the same times for all variables), thus the strategy above may be imposible.
But, at the same time, I would like to compute the integral only once because this step is very time consuming.
m