Simulate with parameter uncertainty

5 messages 5 people Latest: Dec 17, 2022

Simulate with parameter uncertainty

From: Mark Sale Date: December 17, 2022 technical
Hi, I'm pretty sure this is possible, I think I even did it long ago, but I need to simulate a model with parameter uncertainty, i.e., sample mean and variance from prior distribution of typical value of CL, then sample individual Cls from that distribution of mean/variance. Can anyone help me with the code to do this? Thanks Mark Mark Sale M.D. Vice President Integrated Drug Development [email protected] Remote-Forestville CA Office Hours 9 AM - 5 PM Eastern Time +1 302-516-1684 www.certara.com This message (including any attachments) may contain confidential, proprietary, privileged and/or private information. The information is intended to be for the use of the individual or entity designated above. If you are not the intended recipient of this message, please notify the sender immediately, and delete the message and any attachments. Any disclosure, reproduction, distribution or other use of this message or any attachments by an individual or entity other than the intended recipient is prohibited.

Re: Simulate with parameter uncertainty

From: Leonid Gibiansky Date: December 17, 2022 technical
Is it is only CL (then you can just use SE and normal distribution) or you need predictions and use whole parameter matrix (then you need to use PRIORS): make sure to set TRUE=PRIOR on the simulation step). Leonid Roughly (See guide for IVAR value): $PRIOR TNPRI (PROBLEM 2) IVAR=2 PLEV=0.999 $MSFI ../.../FILE.MSF ONLYREAD $SUBROUTINES $PK ... $ERROR ... $PROBLEM XXX, simulations $INPUT $DATA .... REWIND IGNORE=C $THETA ... $OMEGA .. $SIGMA ... $SIMULATION (1334) (5778 UNIFORM) ONLYSIMULATION PARAFILE=ON RANMETHOD=P TRUE=PRIOR SUBPROBLEMS=3 $TAB FILE=...tab
Quoted reply history
On 12/17/2022 10:16 AM, Mark Sale wrote: > Hi, > I'm pretty sure this is possible, I think I even did it long ago, but I need > to simulate a model with parameter uncertainty, i.e., sample mean and variance > from prior distribution of typical value of CL, then sample individual Cls from > that distribution of mean/variance. Can anyone help me with the code to do this? > > Thanks > Mark > > Mark Sale M.D. > Vice President > Integrated Drug Development > [email protected] > Remote-Forestville CA > Office Hours 9 AM - 5 PM Eastern Time > +1 302-516-1684 > www.certara.com > > This message (including any attachments) may contain confidential, proprietary, > privileged and/or private information. The information is intended to be for > the use of the individual or entity designated above. If you are not the > intended recipient of this message, please notify the sender immediately, and > delete the message and any attachments. Any disclosure, reproduction, > distribution or other use of this message or any attachments by an individual > or entity other than the intended recipient is prohibited.

Re: Simulate with parameter uncertainty

From: Rob ter Heine Date: December 17, 2022 technical
Dear Mark, Another option to simulate with parameter uncertainty is to use the rawres output file from a bootstrap or SIR procedure you obtained with PsN. This can be done using the -rawres_input=… in combination with -no-estimate_simulation option for SSE. It will use the set of parameter values in the rawres file as input for simulation. Sincerely, Rob
Quoted reply history
> Op 17 dec. 2022 om 4:44 PM heeft Leonid Gibiansky <[email protected]> > het volgende geschreven: > > Is it is only CL (then you can just use SE and normal distribution) or you > need predictions and use whole parameter matrix (then you need to use > PRIORS): make sure to set TRUE=PRIOR on the simulation step). > Leonid > > Roughly (See guide for IVAR value): > > $PRIOR TNPRI (PROBLEM 2) IVAR=2 PLEV=0.999 > $MSFI ../.../FILE.MSF ONLYREAD > $SUBROUTINES > > $PK > ... > $ERROR > ... > > $PROBLEM XXX, simulations > $INPUT > $DATA .... REWIND IGNORE=C > > $THETA > ... > > $OMEGA > .. > > $SIGMA > ... > > $SIMULATION (1334) (5778 UNIFORM) ONLYSIMULATION PARAFILE=ON RANMETHOD=P > TRUE=PRIOR SUBPROBLEMS=3 > > $TAB FILE=...tab > > > >> On 12/17/2022 10:16 AM, Mark Sale wrote: >> Hi, >> I'm pretty sure this is possible, I think I even did it long ago, but I >> need to simulate a model with parameter uncertainty, i.e., sample mean and >> variance from prior distribution of typical value of CL, then sample >> individual Cls from that distribution of mean/variance. Can anyone help me >> with the code to do this? >> Thanks >> Mark >> Mark Sale M.D. >> Vice President >> Integrated Drug Development >> [email protected] >> Remote-Forestville CA >> Office Hours 9 AM - 5 PM Eastern Time >> +1 302-516-1684 >> www.certara.com%2F&data=05%7C01%7CR.terHeine%40radboudumc.nl%7C3215da0387984eb0d9f808dae0459810%7Cb208fe69471e48c48d87025e9b9a157f%7C1%7C0%7C638068886765196762%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=EDewq4VlY7vyp%2FiJP56rasJZFacCpwEpzM%2BXXVF4kiI%3D&reserved=0">https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.certara.com%2F&data=05%7C01%7CR.terHeine%40radboudumc.nl%7C3215da0387984eb0d9f808dae0459810%7Cb208fe69471e48c48d87025e9b9a157f%7C1%7C0%7C638068886765196762%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=EDewq4VlY7vyp%2FiJP56rasJZFacCpwEpzM%2BXXVF4kiI%3D&reserved=0 >> This message (including any attachments) may contain confidential, >> proprietary, privileged and/or private information. The information is >> intended to be for the use of the individual or entity designated above. If >> you are not the intended recipient of this message, please notify the sender >> immediately, and delete the message and any attachments. Any disclosure, >> reproduction, distribution or other use of this message or any attachments >> by an individual or entity other than the intended recipient is prohibited. > De informatie in dit bericht is uitsluitend bestemd voor de geadresseerde. Aan dit bericht en de bijlagen kunnen geen rechten worden ontleend. Heeft u deze e-mail onbedoeld ontvangen? Dan verzoeken wij u het te vernietigen en de afzender te informeren. Openbaar maken, kopiëren en verspreiden van deze e-mail of informatie uit deze e-mail is alleen toegestaan met voorafgaande schriftelijke toestemming van de afzender. Het Radboudumc staat geregistreerd bij de Kamer van Koophandel in het handelsregister onder nummer 80262783. The content of this message is intended solely for the addressee. No rights can be derived from this message or its attachments. If you are not the intended recipient, we kindly request you to delete the message and inform the sender. It is strictly prohibited to disclose, copy or distribute this email or the information inside it, without a written consent from the sender. Radboud university medical center is registered with the Dutch Chamber of Commerce trade register with number 80262783.

Re: Simulate with parameter uncertainty

From: Jakob Ribbing Date: December 17, 2022 technical
Hi Mark, I am assuming that you problem is a little more complex than only one theta, e.g. that you would like to simulate typical CL for a number of subgroups, where several covariate values (impactful on CL) are different across sub groups. In that case Leoid’s nonmem code would be a quick way to achieve this, and for each replicate simulation (subproblem) you would get a different set of population parameters, so you can for example calculate the mean for each subgroup, in each replicate, and then the distribution of means across replicates represents the uncertainty (in mean of the typical CL, for each subgroup). I noticed we discussed this on nmusers in 2016, so I include a reply I wrote at that point, regarding the use of TNPRI in simulations. I do not think I have used this way of simulating with uncertainty in population parameters, since then, so I just paste the text as is, without further comment. Wishing you all a nice weekend! Jakob > Hi Mark, > > Indeed there is: As an alternative to NWPRI, there is the TNPRI subroutine > that you can use with $PRIOR (frequentist prior). > This functionality is tripple normal, with regards to thetas, omegas and > sigma(s). > I will describe this more in detail than Mark would need (hopefully for the > benefit of others). > > I used to think that TNPRI was an appealing alternative when the standard > error of population parmeters were all modest. The implementation appears to > be appealing at a first glance (less error prone): Simply plug in the MSFO > file from a previous run (generating the prior), as a prior representing the > covariance matrix from that previous run. > In addition, if from that previous run one has reported SEs based on the > covariance matrix, it may be appealing to use the same distribution when > simulating with uncertainty in population parameters (what I call simulation > mode, below), or as a prior in the next analysis with a new analysis data set > (what I call estimation mode, below). > However, over the years I have been using it less and less due to various > limitations and “features”. > I am not sure if Marks question was with regards to estimation with support > of a prior (estimation mode), or simulation with uncertainty in population > parameters based on a prior distribution (simulation mode), but separate the > list of bugs/features/limitations we have come across, below. > Some of these features are documented, whereas others I believe are not. > > In estimation mode (using TNPRI) there are only a few limitations that comes > to my mind: > Any thetas that are fixed must appear as the last thetas in your model > (already when generating the prior) > When generating the prior, do not use the UNCONDITIONAL option for the > covariance step. Even in cases where the estimation is successful (so that > the UNCONDITIONAL option is not needed), the subsequent estimation with TNPRI > will fail (If I recall correctly, it will run forever). > If you use PsN: TNPRI is not supported by all programs, in particular, you > can not use scm. Some may raise their eyebrows, thinking that the prior does > not allow testing for (new) covariates, so I will adress that comment right > away. With a new patient population at hand, you may want to use scm to test > whether there is a significant difference in any of the population > parameters, as compared to the prior (prior not including the new patient > population). > > In simulation mode (using TNPRI) there are additional limitations that I > would tend to call bugs, and I will only mention a few: > From the TABLE output you can use IPRED (and the distribution of population > parameters), but other PRED defined variables can not be trusted, including > PRED itself: so any clever calculations you may do in your control stream > (e.g. change from baseline): Do not use it! The output may have been > generated based on the initial estimates (i.e. prior mode, despite > TRUE=PRIOR), rather than based on the simulations that include uncertainty in > population parameters > Limitations on which parameters needs to be fixed is even greater. If I > remember correctly, the whole model must be re-formulated in case you have > any terminal thetas: SIGMAs and OMEGAs must then also be fixed (to 1), and > magnitudes estimated as fixed effects (representing e.g. standard error of > IIV, or the covariance) - these additional thetas must then also appear > before the fixed thetas. But this is when generating the prior (in estimation > mode, before the subsequent simulation). Possibly, when using the prior in > simulation mode, then all previously fixed thetas must be unfixed again. > When generating the prior, do not use the UNCONDITIONAL option for the > covariance step. Even in cases where the estimation is successful (so that > the UNCONDITIONAL option is not needed), the subsequent simulation step will > fail (If I recall correctly, it will run forever). > > At Pharmetheus, we have not used TNPRI widely and tend to use it less and > less (favouring NWPRI), and we have never had the time to fully characterise > these bug/features: as soon as we have concluded it works for the task at > hand, we leave it without further exploring situations where TNPRI may > provide an unexpected/erroneous output. > Consequently, you may find my bug/feature description above a bit unclear. I > do not know exactly what situations trigger these bugs, and I could list > additional vague descriptions of bugs/features we have come across, if I look > back into previous projects. But I think if I do that it would raise more > questions than it answers... > However, this discussion is mainly on simulations, and maybe missess out > entirely on Marks question? Hopefully, someone will find it useful, still. > > Finally, back more towards Marks question, if SE is large in the sense that > the normal (uncertainty) distribution would go outside the boundaries (e.g. > OMEGA<0), for any population parameter (fixed and random), then there is > functionality to handle this. > I have never used TNPRI with any large SE:s, but Mats Karlsson once mentioned > to me that the functionality does not really handle this situation the way > you would expect: the tail of the distribution that goes outside the boundary > will be moved to the other end of the distribution. > Obviously, this is not what you want in case that tail constitutes a large > fraction, but if it is only a question of 1 out of 10 000 sample, this may be > harmless (in most cases). > > Maybe someone can complement with a fuller description on the limitations > with TNPRI than what I could provide? > Otherwise, I leave you with the following short summary, for when how to use > TNPRI: > In generating the prior > try to avoid fixing any theta (e.g. do not use a fixed theta to represent > allometric constants), and if the purpose of TNPRI is simulation try to avoid > fixing any omega as well > Do not use UNCONDITIONAL in the covariance step > In estimation with support of the TNPRI prior > Be aware you can not use PsN scm, for covariate selection (NWPRI works fine > with the new nonmem notation THETAP, etc. But you need to be aware of the > issues of testing covariates with suport of a prior that did not include that > covariate) > In simulation using TNPRI > From the TABLE output, you may use IPRED (and other variables that are not > simulated, like ID, trial-replicate nr, time and dose). THETAS, OMEGAS and > SIGMAS can be used to check the distribution across replicate simulations, > but pred-defined variables should not be used for anything! > > It used to be quite hairy and error prone to manually set up a complicated > nonmem control stream for using the NWPRI. > However, if you can use automatic functionality for adding the NWPRI > distribution in the control stream and just check it has been implemented > correctly, this is not a big hurdle. > For example, PsN has such a functionality as an option to the “update_inits” > program. > In addition, the new nonmem notation makes it easier for others to understand > the control stream (THETAP, etc). > Therefore, in most cases where I need to use a (frequentist) prior, NWPRI is > currently my first option. > (But I leave you with the cheery reservation that I do not mention much > around limitations/features with NWPRI, since that is clearly out of scope > for the topic in this tread :>) > > > Best regards > > Jakob > -- *This communication is confidential and is only intended for the use of the individual or entity to which it is directed. It may contain information that is privileged and exempt from disclosure under applicable law. If you are not the intended recipient please notify us immediately. Please do not copy it or disclose its contents to any other person.* *Any personal data will be processed in accordance with Pharmetheus' privacy notice, available here https://pharmetheus.com/privacy-policy/.** *

Re: Simulate with parameter uncertainty

From: Mahmoud Tareq Abdelwahab Date: December 17, 2022 technical
Hello Mark, In addition to the above suggestions, PsN sse script takes any rawres file given that it follows naming conventions (details are mentioned in sse user manual) or one could read the Covariance matrix into mrgsolve or RxODE and simulate with uncertainty as well. Best Regards Mahmoud.Abdelwahab
Quoted reply history
On Sat, Dec 17, 2022, 7:30 PM Mark Sale <[email protected]> wrote: > Thanks Rob, > I need to do this programmatically (in R), for an automated method. > Computational load is an issue for using SIR or bootstrap. I did see that > you can do simulation only in SSE, and thought I could programmatically > write a rawres output file, in R, just sampling from the $COV output > parameters SEEs and use that. Using SSE with no-estimate_simulation is my > back up plan if I can't get NWPRI working. > Specifically, this works (I need the output tables for diagnostics, so > need the -keep_tables): > sse run1.mod -samples=5 -rawres_input=raw_results_run1.csv > -no-estimate_simulation -keep_tables > > I'm thinking that may be easier than trying to use NWPRI. > > thanks > > > Mark Sale M.D. > Vice President > Integrated Drug Development > [email protected] > Remote-Forestville CA > Office Hours 9 AM – 5 PM Eastern Time > +1 302-516-1684 > www.certara.com > > > -----Original Message----- > From: Heine, Rob ter <[email protected]> > Sent: Saturday, December 17, 2022 7:51 AM > To: Leonid Gibiansky <[email protected]> > Cc: Mark Sale <[email protected]>; [email protected] > Subject: Re: [NMusers] Simulate with parameter uncertainty > > [You don't often get email from [email protected]. Learn why this > is important at https://aka.ms/LearnAboutSenderIdentification ] > > Dear Mark, > > Another option to simulate with parameter uncertainty is to use the rawres > output file from a bootstrap or SIR procedure you obtained with PsN. This > can be done using the -rawres_input=… in combination with > -no-estimate_simulation option for SSE. It will use the set of parameter > values in the rawres file as input for simulation. > > Sincerely, > Rob > > > Op 17 dec. 2022 om 4:44 PM heeft Leonid Gibiansky < > [email protected]> het volgende geschreven: > > > > Is it is only CL (then you can just use SE and normal distribution) or > you need predictions and use whole parameter matrix (then you need to use > PRIORS): make sure to set TRUE=PRIOR on the simulation step). > > Leonid > > > > Roughly (See guide for IVAR value): > > > > $PRIOR TNPRI (PROBLEM 2) IVAR=2 PLEV=0.999 $MSFI ../.../FILE.MSF > > ONLYREAD $SUBROUTINES > > > > $PK > > ... > > $ERROR > > ... > > > > $PROBLEM XXX, simulations > > $INPUT > > $DATA .... REWIND IGNORE=C > > > > $THETA > > ... > > > > $OMEGA > > .. > > > > $SIGMA > > ... > > > > $SIMULATION (1334) (5778 UNIFORM) ONLYSIMULATION PARAFILE=ON > > RANMETHOD=P TRUE=PRIOR SUBPROBLEMS=3 > > > > $TAB FILE=...tab > > > > > > > >> On 12/17/2022 10:16 AM, Mark Sale wrote: > >> Hi, > >> I'm pretty sure this is possible, I think I even did it long ago, but > I need to simulate a model with parameter uncertainty, i.e., sample mean > and variance from prior distribution of typical value of CL, then sample > individual Cls from that distribution of mean/variance. Can anyone help me > with the code to do this? > >> Thanks > >> Mark > >> Mark Sale M.D. > >> Vice President > >> Integrated Drug Development > >> [email protected] > >> Remote-Forestville CA > >> Office Hours 9 AM - 5 PM Eastern Time > >> +1 302-516-1684 > >> https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww. > >> certara.com%2F&data=05%7C01%7Cmark.sale%40certara.com%7Caf45e1bf43604 > >> fb3f63508dae0467790%7C7287abd30220456e98514352bae208c9%7C1%7C0%7C6380 > >> 68890546783907%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2 > >> luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000%7C%7C%7C&sdata=l2TeAtlq2N > >> ltv%2FEC5Z9mZD7lk0r7tLz42hkiWYFfDgY%3D&reserved=0 > >> This message (including any attachments) may contain confidential, > proprietary, privileged and/or private information. The information is > intended to be for the use of the individual or entity designated above. If > you are not the intended recipient of this message, please notify the > sender immediately, and delete the message and any attachments. Any > disclosure, reproduction, distribution or other use of this message or any > attachments by an individual or entity other than the intended recipient is > prohibited. > > > De informatie in dit bericht is uitsluitend bestemd voor de geadresseerde. > Aan dit bericht en de bijlagen kunnen geen rechten worden ontleend. Heeft u > deze e-mail onbedoeld ontvangen? Dan verzoeken wij u het te vernietigen en > de afzender te informeren. Openbaar maken, kopiëren en verspreiden van deze > e-mail of informatie uit deze e-mail is alleen toegestaan met voorafgaande > schriftelijke toestemming van de afzender. Het Radboudumc staat > geregistreerd bij de Kamer van Koophandel in het handelsregister onder > nummer 80262783. > > The content of this message is intended solely for the addressee. No > rights can be derived from this message or its attachments. If you are not > the intended recipient, we kindly request you to delete the message and > inform the sender. It is strictly prohibited to disclose, copy or > distribute this email or the information inside it, without a written > consent from the sender. Radboud university medical center is registered > with the Dutch Chamber of Commerce trade register with number 80262783. > > > > This message (including any attachments) may contain confidential, > proprietary, privileged and/or private information. The information is > intended to be for the use of the individual or entity designated above. If > you are not the intended recipient of this message, please notify the > sender immediately, and delete the message and any attachments. Any > disclosure, reproduction, distribution or other use of this message or any > attachments by an individual or entity other than the intended recipient is > prohibited. > > >