ISoP ISoP on Twitter | ACoP ACoP on Twitter | PAGE | WCoP | PAGANZ | PAGJa

Performing Bayesian estimation on Shiny for improved dose prediction accuracy


Hi Guys,

I’m pretty new here but I’m trying to figure out a way to carry out Bayesian estimation of Vd and Cl following the acquisition of a serum drug concentration to get more accurate estimates of these PK parameters.

I’ve built a PopPK model in NONMEM and have implemented it in Shiny here:

I want to be able to update the predictions after acquiring 1 actual drug level.

Any leads would be most appreciated.

Thank you very much.



Hi Manee -

I recently built a Shiny app to do what you are talking about: the app uses a population model from NONMEM to get MAP Bayes estimates for new individuals when very sparse drug concentrations are entered (one or two observations + covariate information and dosing history). In our application, the MAP Bayes estimates were used to make predictions for candidate dosing regimens and select the regimen that will likely reach the target.

We published a vignette showing how to use mrgsolve to obtain the MAP Bayes estimates in R:

Hope this helps,


Hi Kyle,

Thank you very much for your kind response. This is most useful for me.

Thanks again.



No problem. I should say that you can get the R code to do this here:

Best wishes for your project.



Thank you. It looks like just what I needed.

Kind regards,


Hi DorajooSR, I´m interested in the same case. But now, many of the links in this page are broken. Can you help me?


Hi Kyle, I´m looking for the same R script! I´m very interesting on it. Can you help me? Many of the links of the page are inactive.


Hi -

I got your email. Just busy morning and haven’t been able to reply.

The content for the links has been moved to a different site. You can see how to generate MAP Bayes estimates here:

There is a plot at the end that is broken (actually, all the plots are broken). Hopefully have that fixed next week some time. But the steps you need for this are in the blog post.



Thanks kyleb,

I found this link after sent the mail this morning. At this time I´m reading it. But it´s so difficult to me. I´m new on mrgsolve and R and it seems complicated. My aim is to build a Shiny app where I introduce one concentration value and simulate concentrations for different doses. If you can help me with a simpler example I would appreciate it. Thanks in advance!


@jgonlop3 -

Please work through the example. It might look more complicated because I simulate the data for you first and then estimate the parameters. Work through the simulation and understand how it works. Then, work with that predict function … understand the inputs and the outputs. Then move to the estimation. By what you describe for your problem, the setup shouldn’t be too different.

You can get the raw code for the blog post here:

We have a TDM app up on here:

Otherwise, I know of a great group of M&S scientists based in Tariffville, CT who work every day to help people with this sort of thing.



Thank you Kyle. I´m working on the example you recommend me. I think I am understanding more. The TDM app is a good example of what I want to do. Do you know if it´s possible to have the shiny code? It will be a good base for my project.


Hi Kyle,

A quick question. I have seen this text on

  • Don’t use R + mrgsolve to fit PK models like this when you have an
    alternative (like NONMEM).

Why? I prefer mrgsolve!