kingaa / pomp

R package for statistical inference using partially observed Markov processes
https://kingaa.github.io/pomp
GNU General Public License v3.0
110 stars 26 forks source link

Minor change to simulate function with format = data.frame, and inclu… #165

Closed jeswheel closed 2 years ago

jeswheel commented 2 years ago

…de.data = TRUE. The change fixes a bug so that the covariates in the resulting simulation data.frame match the covariates in the actual data. Ed Ionides helped me snuff-out this minor bug.

The bug occurred because the simulations are ordered in the data.frame object by the time point rather than the simulation number, but the code assumes that the simulations are sorted by simulation number (see example below).

Let nsim = 2, and let simx-t represent the t-th time point of the x-th simulation. Similarly, let data-t be the covariate at the t-th time point. Then the suggested change is:

What was happening: sim1-1 = data-1 sim2-1 = data-2 sim1-2 = data-3 sim2-2 = data-4 sim1-3 = data-5 ...

What should happen: sim1-1 = data-1 sim2-1 = data-1 sim1-2 = data-2 sim2-2 = data-2 sim1-3 = data-3 ...

kingaa commented 2 years ago

Thanks for catching this, @jeswheel and @ionides! I will merge this with the master branch.

kingaa commented 2 years ago

This is in the new development release, 4.0.11.0.