try/catching mrgsim errors #1120
Replies: 4 comments
-
Hi @efernandezbi - I don't believe there is ability to try and catch a problem with an individual subject from within the model. You could split the data and run one at a time and wrap that in sim <- try(
mod %>%
ev(amt=50e-6, ii=168, addl=7) %>%
idata_set(first_subject) %>%
mrgsim(end=endtime, atol = 1E-20)
) This will probably be slower; maybe batching this up by 10s would help? Not sure. I'm not sure what is the model structure, but I might look a little bit at why some parameters are failing. It looks like the dose is very small and you are having to increase Best regards, |
Beta Was this translation helpful? Give feedback.
-
Thank you, I will try this. Dose is small but parameters are scaled accordingly and the deterministic model runs fine. Indeed I could loop over the data set and run simulations one by one. An alternative solution to try is possibly() but I am unsure I can use it to wrap mrgsim(). |
Beta Was this translation helpful? Give feedback.
-
Hi @efernandezbi, CL <- rnorm(1000, 4.1, 75*4.1/100)
any(CL < 0)
#> [1] TRUE
CL <- 4.1 * exp(rnorm(1000, sd = 75/100))
any(CL < 0)
#> [1] FALSE In addition, if you have very large variability, assuming independent distributions might lead to the generation of unlikely combinations of, e.g., clearance and volume, hence increasing the risk of generating "hard to simulate" profiles and the solver to fail. Sampling from a multivariate distribution could help sometimes, see Best regards |
Beta Was this translation helpful? Give feedback.
-
Dear Félicien, Many thanks for your answer and advice. Indeed there is a large spread and possibility of generating negative values, but I was trying to reproduce the simulations from a published article, with same methods and variance. But you are right this would need to be addressed. |
Beta Was this translation helpful? Give feedback.
-
Hi,
Using mrgsim with idata is a great way to produce virtual patient populations. I use expand.idata to create parameter sets randomly distributed and produce VP, but there is always a risk that some sets lead to mrgsim/lsoda failing to converge. Example:
With 1000 patients, I sometimes get:
I have some workarounds like decreasing atol, however this sometimes work but this is not 100% failproof, and need to run the script a few times until it succeeds. Is there any possibility to catch mrgsim errors and ask it to drop those simulations that fail and skip to next patient? Thanks a lot for any advice.
Beta Was this translation helpful? Give feedback.
All reactions