Closed ntorresd closed 2 months ago
Finding the error was kind of tricky. Comparing inst/stan/time_log_seroreversion.stan and inst/stan/time_log_no_seroreversion.stan I realized the indexation in the first case was being done like:
for(i in 1:age_max) {
int time_index = age_max - i + 1;
foi_expanded[time_index] = foi_vector[foi_index[i]];
}
time_index
also appears on other stan files, but it isn't being used:
for(i in 1:age_max) {
int time_index = age_max - i + 1;
foi_expanded[i] = foi_vector[foi_index[i]];
}
I corrected the indexation in the time-log-foi model with seroreversion and removed the unnecessary lines from the others. Now the example is working as expected.
Running some tests I realized the time indexation of the log-scale time-varying Stan model is incorrect. See the following example:
I'm simulating both surveys using the following FOI:
The difference between the two is that the one on the right is simulated using
seroreversion_rate = 0.1
(for the other is just 0). I implemented the time-varying models with and without seroreversion specifying the correct FOI indexation (to reproduce the input of the simulation):Note that the FOI on the right plot is indexed in the reversed order it should be.