diff --git a/docs/404.html b/docs/404.html deleted file mode 100644 index c9fabb48..00000000 --- a/docs/404.html +++ /dev/null @@ -1,138 +0,0 @@ - - -
- - - - -GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007
-Copyright (C) 2007 Free Software Foundation, Inc. http://fsf.org/ Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
-This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.
-As used herein, “this License” refers to version 3 of the GNU Lesser General Public License, and the “GNU GPL” refers to version 3 of the GNU General Public License.
-“The Library” refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.
-An “Application” is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.
-A “Combined Work” is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the “Linked Version”.
-The “Minimal Corresponding Source” for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.
-The “Corresponding Application Code” for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.
-You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.
-If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:
-under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or
under the GNU GPL, with none of the additional permissions of this License applicable to that copy.
The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:
-Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.
Accompany the object code with a copy of the GNU GPL and this license document.
You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:
-Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.
Accompany the Combined Work with a copy of the GNU GPL and this license document.
For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.
Do one of the following:
-Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user’s computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version.
Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)
You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:
-Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.
Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
-Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation.
-If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy’s public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.
- - -vignettes/PopED.Rmd
- PopED.Rmd
PopED computes optimal experimental designs for both population and individual studies based on nonlinear mixed-effect models. Often this is based on a computation of the Fisher Information Matrix (FIM).
-To get started you need to define
-There are a number of functions to help you with these tasks. See ?poped
for more information.
Below is an example to introduce the package. The code in the below example, and several other examples, are available as r-scripts in the “examples” folder in the PopED installation directory located at:
- -You can view a list of the example files using the commands:
- -You can then open one of the examples (for example, ex.1.a.PK.1.comp.oral.md.intro.R
, the code found in this vignette) using the following code
file_name <- "ex.1.a.PK.1.comp.oral.md.intro.R"
-ex_file <- system.file("examples",file_name,package="PopED")
-file.copy(ex_file,tempdir(),overwrite = T)
-file.edit(file.path(tempdir(),file_name))
In addition, there is another vignette called “Examples” that explores the new features in each example.
-Here we define a one-compartment pharmacokinetic model with linear absorption using an analytical solution. In this case the solution is applicable for both multiple and single dosing. Note that this function is also predefined in PopED as ff.PK.1.comp.oral.md.CL
.
ff <- function(model_switch,xt,parameters,poped.db){
- with(as.list(parameters),{
- N = floor(xt/TAU)+1
- y=(DOSE*Favail/V)*(KA/(KA - CL/V)) *
- (exp(-CL/V * (xt - (N - 1) * TAU)) * (1 - exp(-N * CL/V * TAU))/(1 - exp(-CL/V * TAU)) -
- exp(-KA * (xt - (N - 1) * TAU)) * (1 - exp(-N * KA * TAU))/(1 - exp(-KA * TAU)))
- return(list( y=y,poped.db=poped.db))
- })
-}
Next we define the parameters of this function, in this case log-normal distributions around the parameters (except for Favail
). DOSE
and TAU
are defined as covariates (in vector a
) so that we can optimize their values later.
sfg <- function(x,a,bpop,b,bocc){
- parameters=c( V=bpop[1]*exp(b[1]),
- KA=bpop[2]*exp(b[2]),
- CL=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1],
- TAU=a[2])
-}
Now we define the residual unexplained variability (RUV) function, in this case the RUV has both an additive and proportional component.
-feps <- function(model_switch,xt,parameters,epsi,poped.db){
- returnArgs <- ff(model_switch,xt,parameters,poped.db)
- y <- returnArgs[[1]]
- poped.db <- returnArgs[[2]]
-
- y = y*(1+epsi[,1])+epsi[,2]
-
- return(list(y=y,poped.db=poped.db))
-}
We have now defined all aspects of the model.
-Now we define the model parameter values, the initial design and design space for optimization.
-In this example, the parameter values are defined for the fixed effects (bpop
), the between-subject variability variances (d
) and the residual variability variances (sigma
). We also fix the parameter Favail
using notfixed_bpop
, since we have only oral dosing and the parameter is not identifiable.
Fixing a parameter means that we assume the parameter will not be estimated (and is know without uncertainty). In addition, we fix the small additive RUV term, as this term is reflecting the higher error expected at low concentration measurements (limit of quantification measurements) and would typically be calculated from analytical assay methods (for example, the standard deviation of the parameter might be 20% of the limit of quantification).
-For the initial design, we define two groups (m=2
) of 20 individuals (groupsize=20
), with doses of 20 mg or 40 mg every 24 hours (a
). The initial design has 5 sample times per individual (xt
).
For the design space, which can be searched during optimization, we define a potential dose range of between 0 and 200 mg (mina
and maxa
), and a range of potential sample times between 0 and 10 hours for the first three samples and between 240 and 248 hours for the last two samples (minxt
and maxxt
).
Finally, we fix the two groups of subjects to have the same sample times (bUseGrouped_xt=TRUE
).
poped.db <- create.poped.database(ff_fun=ff,
- fg_fun=sfg,
- fError_fun=feps,
- bpop=c(V=72.8,KA=0.25,CL=3.75,Favail=0.9),
- notfixed_bpop=c(1,1,1,0),
- d=c(V=0.09,KA=0.09,CL=0.25^2),
- sigma=c(0.04,5e-6),
- notfixed_sigma=c(1,0),
- m=2,
- groupsize=20,
- a=list(c(DOSE=20,TAU=24),c(DOSE=40, TAU=24)),
- maxa=c(DOSE=200,TAU=24),
- mina=c(DOSE=0,TAU=24),
- xt=c( 1,2,8,240,245),
- minxt=c(0,0,0,240,240),
- maxxt=c(10,10,10,248,248),
- bUseGrouped_xt=TRUE)
First it may make sense to check your model and design to make sure you get what you expect when simulating data. Here we plot the model typical values:
- - -Next, we plot the model typical values prediction intervals taking into account the between-subject variability (you can even investigate the effects of the residual, unexplained, variability with the DV=TRUE
argument) but without sampling times:
We can get these predictions numerically as well:
-dat <- model_prediction(poped.db,DV=TRUE)
-head(dat,n=5);tail(dat,n=5)
-#> ID Time DV IPRED PRED Group Model DOSE TAU
-#> 1 1 1 0.04422501 0.05747039 0.05325024 1 1 20 24
-#> 2 1 2 0.08522768 0.09828859 0.09204804 1 1 20 24
-#> 3 1 8 0.11048943 0.17340393 0.16409609 1 1 20 24
-#> 4 1 240 0.17322493 0.22959440 0.12671376 1 1 20 24
-#> 5 1 245 0.46941713 0.35619950 0.24980320 1 1 20 24
-#> ID Time DV IPRED PRED Group Model DOSE TAU
-#> 196 40 1 0.1500322 0.1613167 0.1065005 2 1 40 24
-#> 197 40 2 0.2746268 0.2762786 0.1840961 2 1 40 24
-#> 198 40 8 0.4568408 0.4497718 0.3281922 2 1 40 24
-#> 199 40 240 0.2097838 0.1769645 0.2534275 2 1 40 24
-#> 200 40 245 0.6648005 0.5527004 0.4996064 2 1 40 24
Next, we evaluate the initial design
-evaluate_design(poped.db)
-#> $ofv
-#> [1] 39.309
-#>
-#> $fim
-#> V KA CL om_V om_KA
-#> V 0.05336692 -8.683963 -0.05863412 0.000000 0.000000
-#> KA -8.68396266 2999.851007 -14.43058560 0.000000 0.000000
-#> CL -0.05863412 -14.430586 37.15243290 0.000000 0.000000
-#> om_V 0.00000000 0.000000 0.00000000 999.953587 312.240246
-#> om_KA 0.00000000 0.000000 0.00000000 312.240246 439.412556
-#> om_CL 0.00000000 0.000000 0.00000000 3.202847 2.287838
-#> SIGMA[1,1] 0.00000000 0.000000 0.00000000 575.347261 638.581909
-#> om_CL SIGMA[1,1]
-#> V 0.000000 0.0000
-#> KA 0.000000 0.0000
-#> CL 0.000000 0.0000
-#> om_V 3.202847 575.3473
-#> om_KA 2.287838 638.5819
-#> om_CL 3412.005199 1182.3255
-#> SIGMA[1,1] 1182.325475 33864.3226
-#>
-#> $rse
-#> V KA CL om_V om_KA om_CL
-#> 8.215338 10.090955 4.400304 39.844763 60.655110 27.562541
-#> SIGMA[1,1]
-#> 13.865357
We see that the fixed-effect and residual variability parameters are relatively well estimated with this design, but the between-subject variability parameters are less well estimated.
-We can compare the initial design to a similar design with sparse sampling, i.e. having only 3 time points: xt = c(1,2,245).
-poped.db.new <- create.poped.database(ff_fun=ff,
- fg_fun=sfg,
- fError_fun=feps,
- bpop=c(V=72.8,KA=0.25,CL=3.75,Favail=0.9),
- notfixed_bpop=c(1,1,1,0),
- d=c(V=0.09,KA=0.09,CL=0.25^2),
- sigma=c(0.04,5e-6),
- notfixed_sigma=c(1,0),
- m=2,
- groupsize=20,
- a=list(c(DOSE=20,TAU=24),c(DOSE=40, TAU=24)),
- maxa=c(DOSE=200,TAU=24),
- mina=c(DOSE=0,TAU=24),
- xt=c( 1,2,245),
- minxt=c(0,0,240),
- maxxt=c(10,10,248),
- bUseGrouped_xt=TRUE)
evaluate_design(poped.db.new)
-#> $ofv
-#> [1] 29.66484
-#>
-#> $fim
-#> V KA CL om_V om_KA
-#> V 0.04243232 -10.51432 0.05782431 0.000000 0.000000
-#> KA -10.51432135 2666.25466 -14.66678102 0.000000 0.000000
-#> CL 0.05782431 -14.66678 21.59743298 0.000000 0.000000
-#> om_V 0.00000000 0.00000 0.00000000 632.163776 457.737062
-#> om_KA 0.00000000 0.00000 0.00000000 457.737062 347.115999
-#> om_CL 0.00000000 0.00000 0.00000000 3.115099 2.363458
-#> SIGMA[1,1] 0.00000000 0.00000 0.00000000 348.477101 262.369792
-#> om_CL SIGMA[1,1]
-#> V 0.000000 0.0000
-#> KA 0.000000 0.0000
-#> CL 0.000000 0.0000
-#> om_V 3.115099 348.4771
-#> om_KA 2.363458 262.3698
-#> om_CL 1153.026981 1979.2314
-#> SIGMA[1,1] 1979.231386 15617.8185
-#>
-#> $rse
-#> V KA CL om_V om_KA om_CL
-#> 44.120338 51.256239 5.748842 207.941540 280.689945 53.350716
-#> SIGMA[1,1]
-#> 22.795275
The precision on CL (bpop[3]) is similar with the alternative design but the other parameters are less well estimated with the alternative design.
-It is possible to compare the objective function value (ofv) and see that for this dummy example the alternative design (less samples per subject) the ofv is smaller (=worse). This value can also be used to optimize sampling times, doses, and other design features.
-Now we can optimize the sample times of the design1.
- -summary(output)
-#> ===============================================================================
-#> FINAL RESULTS
-#> Optimized Sampling Schedule
-#> Group 1: 0.4574 10 10 240 240.9
-#> Group 2: 0.4574 10 10 240 240.9
-#>
-#> OFV = 40.5277
-#>
-#> Efficiency:
-#> ((exp(ofv_final) / exp(ofv_init))^(1/n_parameters)) = 1.1902
-#>
-#> Expected relative standard error
-#> (%RSE, rounded to nearest integer):
-#> Parameter Values RSE_0 RSE
-#> V 72.8 8 6
-#> KA 0.25 10 8
-#> CL 3.75 4 4
-#> om_V 0.09 40 33
-#> om_KA 0.09 61 50
-#> om_CL 0.0625 28 26
-#> SIGMA[1,1] 0.04 14 15
-#>
-#> Total running time: 16.393 seconds
-plot_model_prediction(output$poped.db)
We see that there are four distinct sample times for this design. This means that for this model, with these exact parameter values, that the most information from the study to inform the parameter estimation is with these sample times.
-Of course, this means that there are multiple samples at some of these time points. We can explore a more practical design by looking at the loss of efficiency if we spread out sample times in a uniform distribution around these optimal points (\(\pm 30\) minutes).
- - -Here we see the efficiency (\((|FIM_{optimized}|/|FIM_{initial}|)^{1/npar}\)) drops below 80% in some cases, which is mostly caused by an increase in the D[2,2] parameter uncertainty (BSV on absorption). Smaller windows or different windowing on different samples might be needed. To investigate see ?plot_efficiency_of_windows
.
In the previous example we optimized over a continuous design space (sample times could be optimized to be any value between a lower and an upper limit). We could also limit the search to only “allowed” values, for example, only samples taken on the hour are allowed.
-poped.db.discrete <- create.poped.database(poped.db,discrete_xt = list(c(0:10,240:248)))
-
-output_discrete <- poped_optim(poped.db.discrete, opt_xt=TRUE)
summary(output_discrete)
-#> ===============================================================================
-#> FINAL RESULTS
-#> Optimized Sampling Schedule
-#> Group 1: 1 10 10 240 241
-#> Group 2: 1 10 10 240 241
-#>
-#> OFV = 40.3782
-#>
-#> Efficiency:
-#> ((exp(ofv_final) / exp(ofv_init))^(1/n_parameters)) = 1.165
-#>
-#> Expected relative standard error
-#> (%RSE, rounded to nearest integer):
-#> Parameter Values RSE_0 RSE
-#> V 72.8 8 6
-#> KA 0.25 10 8
-#> CL 3.75 4 4
-#> om_V 0.09 40 32
-#> om_KA 0.09 61 53
-#> om_CL 0.0625 28 27
-#> SIGMA[1,1] 0.04 14 15
-#>
-#> Total running time: 7.912 seconds
-plot_model_prediction(output_discrete$poped.db)
Here we see that the optimization ran somewhat quicker, but gave a less efficient design.
-One could also optimize over dose, to see if a different dose could help in parameter estimation .
- -In this case the results are predictable … higher doses give observations with somewhat lower absolute residual variability leading to both groups at the highest allowed dose levels (200 mg in this case).
-Optimizing the dose of a study just to have better model parameter estimates may be somewhat implausible. Instead, let’s use a cost function to optimize dose based on some sort of target concentration … perhaps typical population trough concentrations of 0.2 and 0.35 for the two groups of patients at 240 hours.
-First we define the criteria we use to optimize the doses, here a least squares minimization.
-crit_fcn <- function(poped.db,...){
- pred_df <- model_prediction(poped.db)
- sum((pred_df[pred_df["Time"]==240,"PRED"] - c(0.2,0.35))^2)
-}
-crit_fcn(output$poped.db)
-#> [1] 0.01469712
Now we minimize the cost function
-output_cost <- poped_optim(poped.db, opt_a = TRUE, opt_xt = FALSE,
- ofv_fun=crit_fcn,
- maximize = FALSE)
summary(output_cost)
-#> ===============================================================================
-#> FINAL RESULTS
-#>
-#> Optimized Covariates:
-#> Group 1: 31.5672 : 24
-#> Group 2: 55.2426 : 24
-#>
-#> OFV = 6.58259e-15
-#>
-#> Efficiency:
-#> (ofv_final / ofv_init) = 4.4788e-13
-#>
-#> Expected relative standard error
-#> (%RSE, rounded to nearest integer):
-#> Parameter Values RSE_0 RSE
-#> V 72.8 8 8
-#> KA 0.25 10 10
-#> CL 3.75 4 4
-#> om_V 0.09 40 40
-#> om_KA 0.09 61 60
-#> om_CL 0.0625 28 28
-#> SIGMA[1,1] 0.04 14 14
-#>
-#> Total running time: 3.435 seconds
-get_rse(output_cost$FIM, output_cost$poped.db)
-#> V KA CL om_V om_KA om_CL
-#> 8.207404 10.070674 4.399378 39.808012 60.478363 27.549531
-#> SIGMA[1,1]
-#> 13.800551
-plot_model_prediction(output_cost$poped.db)
Tip: to make the optimization run faster use the option parallel = TRUE
in the poped_optim
command.↩
vignettes/examples.Rmd
- examples.Rmd
In this vignette, we try to highlight PopED features that may be -useful. Only code related to specific features we would like to -highlight is described here in this vignette. These features (and more) -are presented as r-scripts in the “examples” folder in the PopED -installation directory. You can view a list of these example files using -the commands:
-
-ex_dir <- system.file("examples", package="PopED")
-list.files(ex_dir)
-#> [1] "ex.1.a.PK.1.comp.oral.md.intro.R"
-#> [2] "ex.1.b.PK.1.comp.oral.md.re-parameterize.R"
-#> [3] "ex.1.c.PK.1.comp.oral.md.ODE.compiled.R"
-#> [4] "ex.10.PKPD.HCV.compiled.R"
-#> [5] "ex.11.PK.prior.R"
-#> [6] "ex.12.covariate.distributions.R"
-#> [7] "ex.13.shrinkage.R"
-#> [8] "ex.14.PK.IOV.R"
-#> [9] "ex.15.full.covariance.matrix.R"
-#> [10] "ex.2.a.warfarin.evaluate.R"
-#> [11] "ex.2.b.warfarin.optimize.R"
-#> [12] "ex.2.c.warfarin.ODE.compiled.R"
-#> [13] "ex.2.d.warfarin.ED.R"
-#> [14] "ex.2.e.warfarin.Ds.R"
-#> [15] "ex.3.a.PKPD.1.comp.oral.md.imax.D-opt.R"
-#> [16] "ex.3.b.PKPD.1.comp.oral.md.imax.ED-opt.R"
-#> [17] "ex.4.PKPD.1.comp.emax.R"
-#> [18] "ex.5.PD.emax.hill.R"
-#> [19] "ex.6.PK.1.comp.oral.sd.R"
-#> [20] "ex.7.PK.1.comp.maturation.R"
-#> [21] "ex.8.tmdd_qss_one_target_compiled.R"
-#> [22] "ex.9.PK.2.comp.oral.md.ode.compiled.R"
-#> [23] "HCV_ode.c"
-#> [24] "HCV_ode.o"
-#> [25] "HCV_ode.so"
-#> [26] "one_comp_oral_CL.c"
-#> [27] "one_comp_oral_CL.o"
-#> [28] "one_comp_oral_CL.so"
-#> [29] "tmdd_qss_one_target.c"
-#> [30] "tmdd_qss_one_target.o"
-#> [31] "tmdd_qss_one_target.so"
-#> [32] "two_comp_oral_CL.c"
-#> [33] "two_comp_oral_CL.o"
-#> [34] "two_comp_oral_CL.so"
You can then open one of the examples (for example,
-ex.1.a.PK.1.comp.oral.md.intro.R
) using the following
-code
-file_name <- "ex.1.a.PK.1.comp.oral.md.intro.R"
-
-ex_file <- system.file("examples",file_name,package="PopED")
-file.copy(ex_file,tempdir(),overwrite = T)
-file.edit(file.path(tempdir(),file_name))
The table below provides a check list of features for each of the 15 -available examples.
-Features | -Ex1 | -Ex2 | -Ex3 | -Ex4 | -Ex5 | -Ex6 | -Ex7 | -Ex8 | -Ex9 | -Ex10 | -Ex11 | -Ex12 | -Ex13 | -Ex14 | -Ex15 | -
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Analytic model | -X | -X | -X | -X | -X | -X | -X | -- | -- | -- | -X | -X | -X | -X | -X | -
ODE model | -X | -X | -- | -- | -- | -X | -- | -X | -X | -X | -- | -- | -- | -- | -- | -
Irregular dosing | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -
Full cov matrix W | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -X | -
Inter-occ variability | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -X | -- | -
Discrete covariates | -- | -- | -- | -- | -- | -- | -X | -- | -- | -- | -X | -- | -- | -- | -- | -
Continuous covariates | -X | -X | -X | -X | -- | -X | -X | -X | -X | -X | -X | -X | -X | -X | -X | -
Multiple arms | -X | -- | -X | -X | -- | -- | -X | -X | -- | -- | -X | -X | -- | -X | -- | -
Multi response models | -- | -- | -X | -X | -- | -- | -- | -X | -- | -X | -- | -- | -- | -- | -- | -
Designs differ across responses |
-- | -- | -- | -X | -- | -- | -- | -X | -- | -- | -- | -- | -- | -- | -- | -
Calculate precision of derived parameters |
-- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -
Power calculation | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -X | -- | -- | -- | -- | -
Include previous FIM | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -X | -- | -- | -- | -- | -
Shrinkage/Bayesian FIM | -X | -X | -X | -X | -- | -- | -X | -- | -- | -X | -- | -- | -X | -- | -- | -
Discrete optimization | -X | -X | -X | -- | -- | -X | -- | -X | -- | -- | -- | -- | -- | -X | -- | -
Optimization of multi-group designs (same response) |
-X | -- | -X | -X | -- | -- | -X | -X | -- | -- | -- | -- | -- | -X | -- | -
Different optimal sampling times between groups |
-- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -
Optimization with constraining sampling times |
-X | -- | -X | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -X | -- | -
Optimization of subjects per group |
-- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -
Note: All features are available in PopED but some are not -demonstrated in the supplied examples.
-The full code for this example is available in
-ex.4.PKPD.1.comp.emax.R
.
Here we define a PKPD mode using analytical equations. The PK is a
-one compartment model with intravenous bolus administration and linear
-elimination. The PD is an ordinary Emax model driven by the PK
-concentrations. The expected output of each measurement (PK or PD) is
-given in the vector model_switch
(see below for
-details).
-library(PopED)
-f_pkpdmodel <- function(model_switch,xt,parameters,poped.db){
- with(as.list(parameters),{
- y=xt
- MS <- model_switch
-
- # PK model
- CONC = DOSE/V*exp(-CL/V*xt)
-
- # PD model
- EFF = E0 + CONC*EMAX/(EC50 + CONC)
-
- y[MS==1] = CONC[MS==1]
- y[MS==2] = EFF[MS==2]
-
- return(list( y= y,poped.db=poped.db))
- })
-}
The error model also has to accommodate both response models.
-
-## -- Residual Error function
-## -- Proportional PK + additive PD
-f_Err <- function(model_switch,xt,parameters,epsi,poped.db){
- returnArgs <- do.call(poped.db$model$ff_pointer,list(model_switch,xt,parameters,poped.db))
- y <- returnArgs[[1]]
- poped.db <- returnArgs[[2]]
-
- MS <- model_switch
-
- prop.err <- y*(1+epsi[,1])
- add.err <- y+epsi[,2]
-
- y[MS==1] = prop.err[MS==1]
- y[MS==2] = add.err[MS==2]
-
- return(list( y= y,poped.db =poped.db ))
-}
In the poped.db
object the vector we specify
-model_switch
in order to assign the sampling times defined
-in the vector xt
to the PK (=1) or PD (=2) model.
-poped.db <- create.poped.database(
-
- # Model
- ff_fun=f_pkpdmodel,
- fError_fun=f_Err,
- fg_fun=f_etaToParam,
- sigma=diag(c(0.15,0.015)),
- bpop=c(CL=0.5,V=0.2,E0=1,EMAX=1,EC50=1),
- d=c(CL=0.09,V=0.09,E0=0.04,EC50=0.09),
-
- # Design
- groupsize=20,
- m=3,
- xt = c(0.33,0.66,0.9,5,0.1,1,2,5),
- model_switch=c(1,1,1,1,2,2,2,2),
- a=list(c(DOSE=0),c(DOSE=1),c(DOSE=2)),
-
- # Design space
- minxt=0,
- maxxt=5,
- bUseGrouped_xt=1,
- maxa=c(DOSE=10),
- mina=c(DOSE=0))
The model predictions below show typical PK and PD profiles for three
-dose groups and the expected 95% prediction interval of the data. The
-initial design, as shown in the poped.db
object, consists
-of 3 arms with doses of 0, 1, and 2 mg; PK sampling times are 0.33,
-0.66, 0.9, and 5 hours/days; PD sampling times are 0.1, 1, 2, and 5
-hours/days. With model.names=c("PK","PD")
one can name the
-outputs in the graph.
-plot_model_prediction(
- poped.db,PI=TRUE,
- facet_scales="free",
- separate.groups=TRUE,
- model.names=c("PK","PD"))
The full code for this example is available in
-ex.9.PK.2.comp.oral.md.ode.compiled.R
.
In this example, the deSolve
library needs to be
-installed for computing solutions to a system of differential equations.
-For faster solutions one can use pre-compiled code using the
-Rcpp
library (see below).
Here we define the two compartment model in R using deSolve -notation
-
-PK.2.comp.oral.ode <- function(Time, State, Pars){
- with(as.list(c(State, Pars)), {
- dA1 <- -KA*A1
- dA2 <- KA*A1 + A3* Q/V2 -A2*(CL/V1+Q/V1)
- dA3 <- A2* Q/V1-A3* Q/V2
- return(list(c(dA1, dA2, dA3)))
- })
-}
Now we define the initial conditions of the ODE system
-A_ini
with a named vector, in this case all compartments
-are initialized to zero c(A1=0,A2=0,A3=0)
. The dosing input
-is defined as a data.frame dose_dat
referring to the named
-compartment var = c("A1")
, the specified
-dose_times
and value=c(DOSE*Favail)
dose
-amounts. Note that the covariates DOSE
and the regimen
-TAU
can differ by arm and be optimized (as shown in
-ex.1.a.PK.1.comp.oral.md.intro.R
). For more information see
-the help pages for ?deSolve::ode
and
-?deSolve::events
.
-ff.PK.2.comp.oral.md.ode <- function(model_switch, xt, parameters, poped.db){
- with(as.list(parameters),{
-
- # initial conditions of ODE system
- A_ini <- c(A1=0, A2=0, A3=0)
-
- #Set up time points to get ODE solutions
- times_xt <- drop(xt) # sample times
- times_start <- c(0) # add extra time for start of study
- times_dose = seq(from=0,to=max(times_xt),by=TAU) # dose times
- times <- unique(sort(c(times_start,times_xt,times_dose))) # combine it all
-
- # Dosing
- dose_dat <- data.frame(
- var = c("A1"),
- time = times_dose,
- value = c(DOSE*Favail),
- method = c("add")
- )
-
- out <- ode(A_ini, times, PK.2.comp.oral.ode, parameters,
- events = list(data = dose_dat))#atol=1e-13,rtol=1e-13)
- y = out[, "A2"]/V1
- y=y[match(times_xt,out[,"time"])]
- y=cbind(y)
- return(list(y=y,poped.db=poped.db))
- })
-}
When creating a PopED database. ff_fun
should point to
-the function providing the solution to the ODE. Further, the names in
-the parameter definition (fg
) function should match the
-parameters used in the above two functions.
-poped.db <- create.poped.database(
-
- # Model
- ff_fun="ff.PK.2.comp.oral.md.ode",
- fError_fun="feps.add.prop",
- fg_fun="fg",
- sigma=c(prop=0.1^2,add=0.05^2),
- bpop=c(CL=10,V1=100,KA=1,Q= 3.0, V2= 40.0, Favail=1),
- d=c(CL=0.15^2,KA=0.25^2),
- notfixed_bpop=c(1,1,1,1,1,0),
-
- # Design
- groupsize=20,
- m=1, #number of groups
- xt=c( 48,50,55,65,70,85,90,120),
-
- # Design space
- minxt=0,
- maxxt=144,
- discrete_xt = list(0:144),
- a=c(DOSE=100,TAU=24),
- discrete_a = list(DOSE=seq(0,1000,by=100),TAU=8:24))
We plot the population prediction of the model for the initial -design
-
-plot_model_prediction(poped.db,model_num_points = 500)
Faster computations with Rcpp: We could also define
-the system using Rcpp, which will produce compiled code that should run
-faster (further examples in
-ex.2.c.warfarin.ODE.compiled.R
). First we redefine the ODE
-system using Rcpp.
-library(Rcpp)
-cppFunction(
- 'List two_comp_oral_ode_Rcpp(double Time, NumericVector A, NumericVector Pars) {
- int n = A.size();
- NumericVector dA(n);
-
- double CL = Pars[0];
- double V1 = Pars[1];
- double KA = Pars[2];
- double Q = Pars[3];
- double V2 = Pars[4];
-
- dA[0] = -KA*A[0];
- dA[1] = KA*A[0] - (CL/V1)*A[1] - Q/V1*A[1] + Q/V2*A[2];
- dA[2] = Q/V1*A[1] - Q/V2*A[2];
- return List::create(dA);
- }')
Next we add the compiled function
-(two_comp_oral_ode_Rcpp
) in the ODE solver.
-ff.PK.2.comp.oral.md.ode.Rcpp <- function(model_switch, xt, parameters, poped.db){
- with(as.list(parameters),{
-
- # initial conditions of ODE system
- A_ini <- c(A1=0, A2=0, A3=0)
-
- #Set up time points to get ODE solutions
- times_xt <- drop(xt) # sample times
- times_start <- c(0) # add extra time for start of study
- times_dose = seq(from=0,to=max(times_xt),by=TAU) # dose times
- times <- unique(sort(c(times_start,times_xt,times_dose))) # combine it all
-
- # Dosing
- dose_dat <- data.frame(
- var = c("A1"),
- time = times_dose,
- value = c(DOSE*Favail),
- method = c("add")
- )
-
- # Here "two_comp_oral_ode_Rcpp" is equivalent
- # to the non-compiled version "PK.2.comp.oral.ode".
- out <- ode(A_ini, times, two_comp_oral_ode_Rcpp, parameters,
- events = list(data = dose_dat))#atol=1e-13,rtol=1e-13)
- y = out[, "A2"]/V1
- y=y[match(times_xt,out[,"time"])]
- y=cbind(y)
- return(list(y=y,poped.db=poped.db))
- })
-}
Finally we create a poped database to use these functions by updating -the previously created database.
-
-poped.db.Rcpp <- create.poped.database(
- poped.db,
- ff_fun="ff.PK.2.comp.oral.md.ode.Rcpp")
We can compare the time for design evaluation with these two methods -of describing the same model.
-
-tic(); eval <- evaluate_design(poped.db); toc()
-#> Elapsed time: 1.593 seconds.
-tic(); eval <- evaluate_design(poped.db.Rcpp); toc()
-#> Elapsed time: 0.816 seconds.
The difference is noticeable and gets larger for more complex ODE -models.
-The full code for this example is available in
-ex.8.tmdd_qss_one_target_compiled.R
.
In the function that defines the dosing and derives the ODE solution,
-the discrete covariate SC_FLAG
is used to give the dose
-either into A1
or A2
, the sub-cutaneous or the
-IV compartment.
-tmdd_qss_one_target_model_compiled <- function(model_switch,xt,parameters,poped.db){
- with(as.list(parameters),{
- y=xt
-
- #The initialization vector for the compartment
- A_ini <- c(A1=DOSE*SC_FLAG,
- A2=DOSE*(1-SC_FLAG),
- A3=0,
- A4=R0)
-
- #Set up time points for the ODE
- times_xt <- drop(xt)
- times <- sort(times_xt)
- times <- c(0,times) ## add extra time for start of integration
-
- # solve the ODE
- out <- ode(A_ini, times, tmdd_qss_one_target_model_ode, parameters)#,atol=1e-13,rtol=1e-13)
-
-
- # extract the time points of the observations
- out = out[match(times_xt,out[,"time"]),]
-
- # Match ODE output to measurements
- RTOT = out[,"A4"]
- CTOT = out[,"A2"]/V1
- CFREE = 0.5*((CTOT-RTOT-KSSS)+sqrt((CTOT-RTOT-KSSS)^2+4*KSSS*CTOT))
- COMPLEX=((RTOT*CFREE)/(KSSS+CFREE))
- RFREE= RTOT-COMPLEX
-
- y[model_switch==1]= RTOT[model_switch==1]
- y[model_switch==2] =CFREE[model_switch==2]
- #y[model_switch==3]=RFREE[model_switch==3]
-
- return(list( y=y,poped.db=poped.db))
- })
-}
Two different sub-studies are defined, with different sampling times
-per arm - in terms of total number of samples and the actual times1. Due to
-this difference in numbers and the relatively complicated study design
-we define the sample times (xt
), what each sample time will
-measure (model_switch
) and which samples should be taken at
-the same study time (G_xt
) as matrices. Here three
-variables xt
, model_switch
, and
-G_xt
are matrices with each row representing one arm, and
-the number of columns is the maximum number of samples (for all
-endpoints) in any of the arms (i.e., max(ni)
). To be clear
-about which elements in the matrices should be considered we specify the
-number of samples per arm by defining the vector ni
in the
-create.poped.database
function.
-xt <- zeros(6,30)
-study_1_xt <- matrix(rep(c(0.0417,0.25,0.5,1,3,7,14,21,28,35,42,49,56),8),nrow=4,byrow=TRUE)
-study_2_xt <- matrix(rep(c(0.0417,1,1,7,14,21,28,56,63,70,77,84,91,98,105),4),nrow=2,byrow=TRUE)
-xt[1:4,1:26] <- study_1_xt
-xt[5:6,] <- study_2_xt
-
-model_switch <- zeros(6,30)
-model_switch[1:4,1:13] <- 1
-model_switch[1:4,14:26] <- 2
-model_switch[5:6,1:15] <- 1
-model_switch[5:6,16:30] <- 2
-
-G_xt <- zeros(6,30)
-study_1_G_xt <- matrix(rep(c(1:13),8),nrow=4,byrow=TRUE)
-study_2_G_xt <- matrix(rep(c(14:28),4),nrow=2,byrow=TRUE)
-G_xt[1:4,1:26] <- study_1_G_xt
-G_xt[5:6,] <- study_2_G_xt
These can then be plugged into the normal poped.db
-setup.
-poped.db.2 <- create.poped.database(
-
- # Model
- ff_fun=tmdd_qss_one_target_model_compiled,
- fError_fun=tmdd_qss_one_target_model_ruv,
- fg_fun=sfg,
- sigma=c(rtot_add=0.04,cfree_add=0.0225),
- bpop=c(CL=0.3,V1=3,Q=0.2,V2=3,FAVAIL=0.7,KA=0.5,VMAX=0,
- KMSS=0,R0=0.1,KSSS=0.015,KDEG=10,KINT=0.05),
- d=c(CL=0.09,V1=0.09,Q=0.04,V2=0.04,FAVAIL=0.04,
- KA=0.16,VMAX=0,KMSS=0,R0=0.09,KSSS=0.09,KDEG=0.04,
- KINT=0.04),
- notfixed_bpop=c( 1,1,1,1,1,1,0,0,1,1,1,1),
- notfixed_d=c( 1,1,1,1,1,1,0,0,1,1,1,1),
-
- # Design
- groupsize=rbind(6,6,6,6,100,100),
- m=6, #number of groups
- xt=xt,
- model_switch=model_switch,
- ni=rbind(26,26,26,26,30,30),
- a=list(c(DOSE=100, SC_FLAG=0),
- c(DOSE=300, SC_FLAG=0),
- c(DOSE=600, SC_FLAG=0),
- c(DOSE=1000, SC_FLAG=1),
- c(DOSE=600, SC_FLAG=0),
- c(DOSE=1000, SC_FLAG=1)),
-
- # Design space
- bUseGrouped_xt=1,
- G_xt=G_xt,
- discrete_a = list(DOSE=seq(100,1000,by=100),
- SC_FLAG=c(0,1)))
Now we can plot population predictions for each group and evaluate -the design.
-
-plot_model_prediction(poped.db.2,facet_scales="free")
-eval_2 <- evaluate_design(poped.db.2)
-round(eval_2$rse) # in percent
- | RSE in % | -
---|---|
CL | -2 | -
V1 | -2 | -
Q | -2 | -
V2 | -3 | -
FAVAIL | -3 | -
KA | -5 | -
R0 | -3 | -
KSSS | -3 | -
KDEG | -3 | -
KINT | -2 | -
d_CL | -11 | -
d_V1 | -12 | -
d_Q | -22 | -
d_V2 | -20 | -
d_FAVAIL | -24 | -
d_KA | -19 | -
d_R0 | -12 | -
d_KSSS | -13 | -
d_KDEG | -20 | -
d_KINT | -18 | -
sig_rtot_add | -3 | -
sig_cfree_add | -3 | -
The R code for this example is available in
-ex.12.covariate_distributions.R
.
Let’s assume that we have a model with a covariate included in the -model description. Here we define a one-compartment PK model that uses -allometric scaling with a weight effect on both clearance and volume of -distribution.
-
-mod_1 <- function(model_switch,xt,parameters,poped.db){
- with(as.list(parameters),{
- y=xt
-
- CL=CL*(WT/70)^(WT_CL)
- V=V*(WT/70)^(WT_V)
- DOSE=1000*(WT/70)
- y = DOSE/V*exp(-CL/V*xt)
-
- return(list( y= y,poped.db=poped.db))
- })
-}
-
-par_1 <- function(x,a,bpop,b,bocc){
- parameters=c( CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- WT_CL=bpop[3],
- WT_V=bpop[4],
- WT=a[1])
- return( parameters )
-}
Now we define a design. In this case one group of individuals, where
-we define the individuals’ typical weight as 70 kg
-(a=c(WT=70)
).
-poped_db <-
- create.poped.database(
- ff_fun=mod_1,
- fg_fun=par_1,
- fError_fun=feps.add.prop,
- groupsize=50,
- m=1,
- sigma=c(prop=0.015,add=0.0015),
- notfixed_sigma = c(1,0),
- bpop=c(CL=3.8,V=20,WT_CL=0.75,WT_V=1),
- d=c(CL=0.05,V=0.05),
- xt=c( 1,2,4,6,8,24),
- minxt=0,
- maxxt=24,
- bUseGrouped_xt=1,
- a=c(WT=70)
- )
We can create a plot of the model prediction for the typical -individual
-
-plot_model_prediction(poped_db)
And evaluate the initial design
-
-evaluate_design(poped_db)
-#> Problems inverting the matrix. Results could be misleading.
-#> Warning: The following parameters are not estimable:
-#> WT_CL, WT_V
-#> Is the design adequate to estimate all parameters?
-#> $ofv
-#> [1] -Inf
-#>
-#> $fim
-#> CL V WT_CL WT_V d_CL d_V sig_prop
-#> CL 65.8889583 -0.7145374 0 0 0.00000 0.00000 0.000
-#> V -0.7145374 2.2798156 0 0 0.00000 0.00000 0.000
-#> WT_CL 0.0000000 0.0000000 0 0 0.00000 0.00000 0.000
-#> WT_V 0.0000000 0.0000000 0 0 0.00000 0.00000 0.000
-#> d_CL 0.0000000 0.0000000 0 0 9052.31524 29.49016 1424.255
-#> d_V 0.0000000 0.0000000 0 0 29.49016 8316.09464 2483.900
-#> sig_prop 0.0000000 0.0000000 0 0 1424.25450 2483.90024 440009.144
-#>
-#> $rse
-#> CL V WT_CL WT_V d_CL d_V sig_prop
-#> 3.247502 3.317107 NA NA 21.026264 21.950179 10.061292
From the output produced we see that the covariate parameters can not
-be estimated according to this design calculation (RSE of WT_CL and WT_V
-are NA
). Why is that? Well, the calculation being done is
-assuming that every individual in the group has the same covariate (to
-speed up the calculation). This is clearly a poor assumption in this
-case!
Distribution of covariates: We can improve the
-computation by assuming a distribution of the covariate (WT) in the
-individuals in the study. We set groupsize=1
, the number of
-groups to be 50 (m=50
) and assume that WT is sampled from a
-normal distribution with mean=70 and sd=10
-(a=as.list(rnorm(50, mean = 70, sd = 10)
).
-poped_db_2 <-
- create.poped.database(
- ff_fun=mod_1,
- fg_fun=par_1,
- fError_fun=feps.add.prop,
- groupsize=1,
- m=50,
- sigma=c(prop=0.015,add=0.0015),
- notfixed_sigma = c(prop=1,add=0),
- bpop=c(CL=3.8,V=20,WT_CL=0.75,WT_V=1),
- d=c(CL=0.05,V=0.05),
- xt=c(1,2,4,6,8,24),
- minxt=0,
- maxxt=24,
- bUseGrouped_xt=1,
- a=as.list(rnorm(50, mean = 70, sd = 10))
- )
-ev <- evaluate_design(poped_db_2)
-round(ev$ofv,1)
-#> [1] 42.4
-round(ev$rse)
- | RSE in % | -
---|---|
CL | -3 | -
V | -3 | -
WT_CL | -28 | -
WT_V | -21 | -
d_CL | -21 | -
d_V | -22 | -
sig_prop | -10 | -
Here we see that, given this distribution of weights, the covariate
-effect parameters (WT_CL
and WT_V
) would be
-well estimated.
However, we are only looking at one sample of 50 individuals. Maybe a -better approach is to look at the distribution of RSEs over a number of -experiments given the expected weight distribution.
-
-nsim <- 30
-rse_list <- c()
-for(i in 1:nsim){
- poped_db_tmp <-
- create.poped.database(
- ff_fun=mod_1,
- fg_fun=par_1,
- fError_fun=feps.add.prop,
- groupsize=1,
- m=50,
- sigma=c(prop=0.015,add=0.0015),
- notfixed_sigma = c(1,0),
- bpop=c(CL=3.8,V=20,WT_CL=0.75,WT_V=1),
- d=c(CL=0.05,V=0.05),
- xt=c( 1,2,4,6,8,24),
- minxt=0,
- maxxt=24,
- bUseGrouped_xt=1,
- a=as.list(rnorm(50,mean = 70,sd=10)))
- rse_tmp <- evaluate_design(poped_db_tmp)$rse
- rse_list <- rbind(rse_list,rse_tmp)
-}
-(rse_quant <- apply(rse_list,2,quantile))
- | CL | -V | -WT_CL | -WT_V | -d_CL | -d_V | -sig_prop | -
---|---|---|---|---|---|---|---|
0% | -3.25 | -3.32 | -23.74 | -18.19 | -21.03 | -21.95 | -10.06 | -
25% | -3.25 | -3.32 | -27.11 | -20.79 | -21.03 | -21.95 | -10.07 | -
50% | -3.26 | -3.33 | -29.96 | -22.96 | -21.03 | -21.96 | -10.07 | -
75% | -3.29 | -3.36 | -32.92 | -25.23 | -21.03 | -21.96 | -10.07 | -
100% | -3.42 | -3.49 | -36.95 | -28.31 | -21.03 | -21.96 | -10.08 | -
Note, that the variance of the RSE of the covariate effect is in this -case strongly correlated with the variance of the weight distribution -(not shown).
-See ex.11.PK.prior.R
. This has the covariate
-isPediatric
to distinguish between adults and pediatrics.
-Alternatively, DOSE
and TAU
in the first
-example can be considered as discrete covariates.
The full code for this example is available in
-ex.14.PK.IOV.R
.
The IOV is introduced with bocc[x,y]
in the parameter
-definition function as a matrix with the first argument x
-indicating the index for the IOV variances, and the second argument
-y
denoting the occasion. This is used in the example to
-derive to different clearance values, i.e., CL_OCC_1
and
-CL_OCC_2
.
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c( CL_OCC_1=bpop[1]*exp(b[1]+bocc[1,1]),
- CL_OCC_2=bpop[1]*exp(b[1]+bocc[1,2]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- DOSE=a[1],
- TAU=a[2])
- return( parameters )
-}
These parameters can now be used in the model function to define the -change in parameters between the occasions (here the change occurs with -the 7th dose in a one-compartment model with first order -absorption).
-
-cppFunction(
- 'List one_comp_oral_ode(double Time, NumericVector A, NumericVector Pars) {
- int n = A.size();
- NumericVector dA(n);
-
- double CL_OCC_1 = Pars[0];
- double CL_OCC_2 = Pars[1];
- double V = Pars[2];
- double KA = Pars[3];
- double TAU = Pars[4];
- double N,CL;
-
- N = floor(Time/TAU)+1;
- CL = CL_OCC_1;
- if(N>6) CL = CL_OCC_2;
-
- dA[0] = -KA*A[0];
- dA[1] = KA*A[0] - (CL/V)*A[1];
- return List::create(dA);
- }'
-)
-
-ff.ode.rcpp <- function(model_switch, xt, parameters, poped.db){
- with(as.list(parameters),{
- A_ini <- c(A1=0, A2=0)
- times_xt <- drop(xt) #xt[,,drop=T]
- dose_times = seq(from=0,to=max(times_xt),by=TAU)
- eventdat <- data.frame(var = c("A1"),
- time = dose_times,
- value = c(DOSE), method = c("add"))
- times <- sort(c(times_xt,dose_times))
- out <- ode(A_ini, times, one_comp_oral_ode, c(CL_OCC_1,CL_OCC_2,V,KA,TAU),
- events = list(data = eventdat))#atol=1e-13,rtol=1e-13)
- y = out[, "A2"]/(V)
- y=y[match(times_xt,out[,"time"])]
- y=cbind(y)
- return(list(y=y,poped.db=poped.db))
- })
-}
The within-subject variability variances (docc
) are
-defined in the poped database as a 3-column matrix with one row per
-IOV-parameter, and the middle column giving the variance values.
-poped.db <-
- create.poped.database(
- ff_fun=ff.ode.rcpp,
- fError_fun=feps.add.prop,
- fg_fun=sfg,
- bpop=c(CL=3.75,V=72.8,KA=0.25),
- d=c(CL=0.25^2,V=0.09,KA=0.09),
- sigma=c(prop=0.04,add=5e-6),
- notfixed_sigma=c(0,0),
- docc = matrix(c(0,0.09,0),nrow = 1),
- m=2,
- groupsize=20,
- xt=c( 1,2,8,240,245),
- minxt=c(0,0,0,240,240),
- maxxt=c(10,10,10,248,248),
- bUseGrouped_xt=1,
- a=list(c(DOSE=20,TAU=24),c(DOSE=40, TAU=24)),
- maxa=c(DOSE=200,TAU=24),
- mina=c(DOSE=0,TAU=24)
- )
We can visualize the IOV by looking at an example individual. We see -the PK profile changes at the 7th dose (red line) due to the change in -clearance.
-
-library(ggplot2)
-set.seed(123)
-plot_model_prediction(
- poped.db,
- PRED=F,IPRED=F,
- separate.groups=T,
- model_num_points = 300,
- groupsize_sim = 1,
- IPRED.lines = T,
- alpha.IPRED.lines=0.6,
- sample.times = F
-) + geom_vline(xintercept = 24*6,color="red")
We can also see that the design is relatively poor for estimating the -IOV parameter:
-
-ev <- evaluate_design(poped.db)
-round(ev$rse)
- | RSE in % | -
---|---|
CL | -6 | -
V | -9 | -
KA | -11 | -
d_CL | -106 | -
d_V | -43 | -
d_KA | -63 | -
D.occ[1,1] | -79 | -
The full code for this example is available in
-ex.15.full.covariance.matrix.R
.
The covd
object is used for defining the covariances of
-the between subject variances (off-diagonal elements of the full
-variance-covariance matrix for the between subject variability).
-poped.db_with <-
- create.poped.database(
- ff_file="ff",
- fg_file="sfg",
- fError_file="feps",
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- covd = c(.03,.1,.09),
- sigma=c(prop=0.01),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0,
- maxxt=120,
- a=70
- )
What do the covariances mean?
-
-(IIV <- poped.db_with$parameters$param.pt.val$d)
-#> [,1] [,2] [,3]
-#> [1,] 0.07 0.03 0.10
-#> [2,] 0.03 0.02 0.09
-#> [3,] 0.10 0.09 0.60
-cov2cor(IIV)
-#> [,1] [,2] [,3]
-#> [1,] 1.0000000 0.8017837 0.4879500
-#> [2,] 0.8017837 1.0000000 0.8215838
-#> [3,] 0.4879500 0.8215838 1.0000000
They indicate a correlation of the inter-individual variabilities, -here of ca. 0.8 between clearance and volume, as well as between volume -and absorption rate.
-We can clearly see a difference in the variance of the model -predictions.
-
-library(ggplot2)
-p1 <- plot_model_prediction(poped.db, PI=TRUE)+ylim(-0.5,12)
-p2 <- plot_model_prediction(poped.db_with,PI=TRUE) +ylim(-0.5,12)
-gridExtra::grid.arrange(p1+ ggtitle("No covariance in BSV"), p2+ ggtitle("Covariance in BSV"), nrow = 1)
Evaluating the designs with and without the covariances:
-
-ev1 <- evaluate_design(poped.db)
-ev2 <- evaluate_design(poped.db_with)
- | Diagonal BSV | -Covariance in BSV | -
---|---|---|
CL | -5 | -5 | -
V | -3 | -3 | -
KA | -14 | -14 | -
d_CL | -26 | -26 | -
d_V | -30 | -30 | -
d_KA | -26 | -26 | -
sig_prop | -11 | -11 | -
D[2,1] | -NA | -31 | -
D[3,1] | -NA | -41 | -
D[3,2] | -NA | -31 | -
Note, that the precision of all other parameters is barely affected -by including the full covariance matrix. This is likely to be different -in practice with more ill-conditioned numerical problems.
-Evaluate the same designs with full FIM (instead of -reduced)
-
-ev1 <- evaluate_design(poped.db, fim.calc.type=0)
-ev2 <-evaluate_design(poped.db_with, fim.calc.type=0)
-
-round(ev1$rse,1)
-round(ev2$rse,1)
- | Diagonal BSV | -Covariance in BSV | -
---|---|---|
CL | -4 | -4 | -
V | -3 | -2 | -
KA | -5 | -5 | -
d_CL | -26 | -27 | -
d_V | -31 | -31 | -
d_KA | -27 | -26 | -
sig_prop | -12 | -12 | -
D[2,1] | -NA | -31 | -
D[3,1] | -NA | -42 | -
D[3,2] | -NA | -31 | -
In this example we incorporate prior knowledge into a current study
-design calculation. First the expected FIM obtained from an experiment
-in adults is computed. Then this FIM is added to the current experiment
-in children. One could also use the observed FIM when using estimation
-software to fit one realization of a design (from the $COVARIANCE step
-in NONMEM for example). The full code for this example is available in
-ex.11.PK.prior.R
.
Note that we define the parameters for a one-compartment first-order
-absorption model using a covariate called isPediatric
to
-switch between adult and pediatric models, and
-bpop[5]=pedCL
is the factor to multiply the adult clearance
-bpop[3]
to obtain the pediatric one.
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(
- V=bpop[1]*exp(b[1]),
- KA=bpop[2]*exp(b[2]),
- CL=bpop[3]*exp(b[3])*bpop[5]^a[3], # add covariate for pediatrics
- Favail=bpop[4],
- isPediatric = a[3],
- DOSE=a[1],
- TAU=a[2])
- return( parameters )
-}
The design and design space for adults is defined below (Two arms, 5
-sample time points per arm, doses of 20 and 40 mg,
-isPediatric = 0
). As we want to pool the results (i.e. add
-the FIMs together), we also have to provide the pedCL
-parameter so that both the adult and children FIMs have the same
-dimensions.
-poped.db <-
- create.poped.database(
- ff_fun=ff.PK.1.comp.oral.md.CL,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- bpop=c(V=72.8,KA=0.25,CL=3.75,Favail=0.9,pedCL=0.8),
- notfixed_bpop=c(1,1,1,0,1),
- d=c(V=0.09,KA=0.09,CL=0.25^2),
- sigma=c(0.04,5e-6),
- notfixed_sigma=c(0,0),
- m=2,
- groupsize=20,
- xt=c( 1,8,10,240,245),
- bUseGrouped_xt=1,
- a=list(c(DOSE=20,TAU=24,isPediatric = 0),
- c(DOSE=40, TAU=24,isPediatric = 0))
- )
Create plot of model without variability
-
-plot_model_prediction(poped.db, model_num_points = 300)
To store the FIM from the adult design we evaluate this design
-
-(outAdult = evaluate_design(poped.db))
-#> Problems inverting the matrix. Results could be misleading.
-#> Warning: The following parameters are not estimable:
-#> pedCL
-#> Is the design adequate to estimate all parameters?
-#> $ofv
-#> [1] -Inf
-#>
-#> $fim
-#> V KA CL pedCL d_V d_KA
-#> V 0.05854391 -6.815269 -0.01531146 0 0.0000000 0.00000000
-#> KA -6.81526942 2963.426688 -1.32113719 0 0.0000000 0.00000000
-#> CL -0.01531146 -1.321137 37.50597895 0 0.0000000 0.00000000
-#> pedCL 0.00000000 0.000000 0.00000000 0 0.0000000 0.00000000
-#> d_V 0.00000000 0.000000 0.00000000 0 1203.3695137 192.31775149
-#> d_KA 0.00000000 0.000000 0.00000000 0 192.3177515 428.81459138
-#> d_CL 0.00000000 0.000000 0.00000000 0 0.2184104 0.01919009
-#> d_CL
-#> V 0.000000e+00
-#> KA 0.000000e+00
-#> CL 0.000000e+00
-#> pedCL 0.000000e+00
-#> d_V 2.184104e-01
-#> d_KA 1.919009e-02
-#> d_CL 3.477252e+03
-#>
-#> $rse
-#> V KA CL pedCL d_V d_KA d_CL
-#> 6.634931 8.587203 4.354792 NA 33.243601 55.689432 27.133255
It is obvious that we cannot estimate the pediatric covariate from
-adult data only; hence the warning message. You can also note the zeros
-in the 4th column and 4th row of the FIM indicating that
-pedCL
cannot be estimated from the adult data.
We can evaluate the adult design without warning, by setting the
-pedCL
parameter to be fixed (i.e., not estimated):
-evaluate_design(create.poped.database(poped.db, notfixed_bpop=c(1,1,1,0,0)))
-#> $ofv
-#> [1] 29.70233
-#>
-#> $fim
-#> V KA CL d_V d_KA d_CL
-#> V 0.05854391 -6.815269 -0.01531146 0.0000000 0.00000000 0.000000e+00
-#> KA -6.81526942 2963.426688 -1.32113719 0.0000000 0.00000000 0.000000e+00
-#> CL -0.01531146 -1.321137 37.50597895 0.0000000 0.00000000 0.000000e+00
-#> d_V 0.00000000 0.000000 0.00000000 1203.3695137 192.31775149 2.184104e-01
-#> d_KA 0.00000000 0.000000 0.00000000 192.3177515 428.81459138 1.919009e-02
-#> d_CL 0.00000000 0.000000 0.00000000 0.2184104 0.01919009 3.477252e+03
-#>
-#> $rse
-#> V KA CL d_V d_KA d_CL
-#> 6.634931 8.587203 4.354792 33.243601 55.689432 27.133255
One obtains good estimates for all parameters for adults (<60% RSE -for all).
-For pediatrics the covariate isPediatric = 1
. We define
-one arm, 4 sample-time points.
-poped.db.ped <-
- create.poped.database(
- ff_fun=ff.PK.1.comp.oral.md.CL,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- bpop=c(V=72.8,KA=0.25,CL=3.75,Favail=0.9,pedCL=0.8),
- notfixed_bpop=c(1,1,1,0,1),
- d=c(V=0.09,KA=0.09,CL=0.25^2),
- sigma=c(0.04,5e-6),
- notfixed_sigma=c(0,0),
- m=1,
- groupsize=6,
- xt=c( 1,2,6,240),
- bUseGrouped_xt=1,
- a=list(c(DOSE=40,TAU=24,isPediatric = 1))
- )
We can create a plot of the pediatric model without variability
-
-plot_model_prediction(poped.db.ped, model_num_points = 300)
Evaluate the design of the pediatrics study alone.
-
-evaluate_design(poped.db.ped)
-#> Problems inverting the matrix. Results could be misleading.
-#> $ofv
-#> [1] -Inf
-#>
-#> $fim
-#> V KA CL pedCL d_V d_KA
-#> V 0.007766643 -1.395981 -0.01126202 -0.05279073 0.0000000 0.0000000
-#> KA -1.395980934 422.458209 -2.14666933 -10.06251250 0.0000000 0.0000000
-#> CL -0.011262023 -2.146669 5.09936874 23.90329099 0.0000000 0.0000000
-#> pedCL -0.052790734 -10.062512 23.90329099 112.04667652 0.0000000 0.0000000
-#> d_V 0.000000000 0.000000 0.00000000 0.00000000 141.1922923 53.7923483
-#> d_KA 0.000000000 0.000000 0.00000000 0.00000000 53.7923483 58.0960085
-#> d_CL 0.000000000 0.000000 0.00000000 0.00000000 0.7877291 0.3375139
-#> d_CL
-#> V 0.0000000
-#> KA 0.0000000
-#> CL 0.0000000
-#> pedCL 0.0000000
-#> d_V 0.7877291
-#> d_KA 0.3375139
-#> d_CL 428.5254900
-#>
-#> $rse
-#> V KA CL pedCL d_V d_KA
-#> 24.7208804 30.8495322 0.5200823 11.4275854 116.2309452 181.1977846
-#> d_CL
-#> 77.2918849
Clearly the design has problems on its own.
-We can add the prior information from the adult study and evaluate -that design (i.e., pooling adult and pediatric data).
-
-poped.db.all <- create.poped.database(
- poped.db.ped,
- prior_fim = outAdult$fim
-)
-
-(out.all <- evaluate_design(poped.db.all))
-#> $ofv
-#> [1] 34.96368
-#>
-#> $fim
-#> V KA CL pedCL d_V d_KA
-#> V 0.007766643 -1.395981 -0.01126202 -0.05279073 0.0000000 0.0000000
-#> KA -1.395980934 422.458209 -2.14666933 -10.06251250 0.0000000 0.0000000
-#> CL -0.011262023 -2.146669 5.09936874 23.90329099 0.0000000 0.0000000
-#> pedCL -0.052790734 -10.062512 23.90329099 112.04667652 0.0000000 0.0000000
-#> d_V 0.000000000 0.000000 0.00000000 0.00000000 141.1922923 53.7923483
-#> d_KA 0.000000000 0.000000 0.00000000 0.00000000 53.7923483 58.0960085
-#> d_CL 0.000000000 0.000000 0.00000000 0.00000000 0.7877291 0.3375139
-#> d_CL
-#> V 0.0000000
-#> KA 0.0000000
-#> CL 0.0000000
-#> pedCL 0.0000000
-#> d_V 0.7877291
-#> d_KA 0.3375139
-#> d_CL 428.5254900
-#>
-#> $rse
-#> V KA CL pedCL d_V d_KA d_CL
-#> 6.381388 8.222819 4.354761 12.591940 31.808871 52.858399 25.601551
The pooled data leads to much higher precision in parameter estimates -compared to either study separately.
-One can also obtain the power for estimating the pediatric difference -in clearance (power in estimating bpop[5] as different from 1).
-
-evaluate_power(poped.db.all, bpop_idx=5, h0=1, out=out.all)
-#> $ofv
-#> [1] 34.96368
-#>
-#> $fim
-#> V KA CL pedCL d_V d_KA
-#> V 0.007766643 -1.395981 -0.01126202 -0.05279073 0.0000000 0.0000000
-#> KA -1.395980934 422.458209 -2.14666933 -10.06251250 0.0000000 0.0000000
-#> CL -0.011262023 -2.146669 5.09936874 23.90329099 0.0000000 0.0000000
-#> pedCL -0.052790734 -10.062512 23.90329099 112.04667652 0.0000000 0.0000000
-#> d_V 0.000000000 0.000000 0.00000000 0.00000000 141.1922923 53.7923483
-#> d_KA 0.000000000 0.000000 0.00000000 0.00000000 53.7923483 58.0960085
-#> d_CL 0.000000000 0.000000 0.00000000 0.00000000 0.7877291 0.3375139
-#> d_CL
-#> V 0.0000000
-#> KA 0.0000000
-#> CL 0.0000000
-#> pedCL 0.0000000
-#> d_V 0.7877291
-#> d_KA 0.3375139
-#> d_CL 428.5254900
-#>
-#> $rse
-#> V KA CL pedCL d_V d_KA d_CL
-#> 6.381388 8.222819 4.354761 12.591940 31.808871 52.858399 25.601551
-#>
-#> $power
-#> Value RSE power_pred power_want need_rse min_N_tot
-#> pedCL 0.8 12.59194 51.01851 80 8.923519 14
We see that to clearly distinguish this parameter one would need 14 -children in the pediatric study (for 80% power at \(\alpha=0.05\)).
-In this example the aim is to evaluate a design incorporating
-uncertainty around parameter values in the model. The full code for this
-example is available in ex.2.d.warfarin.ED.R
. This
-illustration is one of the Warfarin examples from software comparison
-in: Nyberg et al.2.
We define the fixed effects in the model and add a 10% uncertainty to
-all but Favail. To do this we use a
-Matrix defining the fixed effects, per row (row number =
-parameter_number) we should have:
Here we define a log-normal distribution
-
-bpop_vals <- c(CL=0.15, V=8, KA=1.0, Favail=1)
-bpop_vals_ed <-
- cbind(ones(length(bpop_vals),1)*4, # log-normal distribution
- bpop_vals,
- ones(length(bpop_vals),1)*(bpop_vals*0.1)^2) # 10% of bpop value
-bpop_vals_ed["Favail",] <- c(0,1,0)
-bpop_vals_ed
-#> bpop_vals
-#> CL 4 0.15 0.000225
-#> V 4 8.00 0.640000
-#> KA 4 1.00 0.010000
-#> Favail 0 1.00 0.000000
With this model and parameter set we define the initial design and
-design space. Specifically note the bpop=bpop_vals_ed
and
-the ED_samp_size=20
arguments. ED_samp_size=20
-indicates the number of samples used in evaluating the E-family
-objective functions.
-poped.db <-
- create.poped.database(
- ff_fun=ff,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- bpop=bpop_vals_ed,
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(0.01,0.25),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0,
- maxxt=120,
- a=70,
- mina=0,
- maxa=100,
- ED_samp_size=20)
You can also provide ED_samp_size
argument to the design
-evaluation or optimization arguments:
-tic();evaluate_design(poped.db,d_switch=FALSE,ED_samp_size=20); toc()
-#> $ofv
-#> [1] 55.41311
-#>
-#> $fim
-#> CL V KA d_CL d_V d_KA
-#> CL 17590.84071 21.130793 10.320177 0.000000e+00 0.00000 0.00000000
-#> V 21.13079 17.817120 -3.529007 0.000000e+00 0.00000 0.00000000
-#> KA 10.32018 -3.529007 51.622520 0.000000e+00 0.00000 0.00000000
-#> d_CL 0.00000 0.000000 0.000000 2.319890e+03 10.62595 0.03827253
-#> d_V 0.00000 0.000000 0.000000 1.062595e+01 19005.72029 11.80346662
-#> d_KA 0.00000 0.000000 0.000000 3.827253e-02 11.80347 38.83793850
-#> SIGMA[1,1] 0.00000 0.000000 0.000000 7.336186e+02 9690.93156 64.79341332
-#> SIGMA[2,2] 0.00000 0.000000 0.000000 9.057819e+01 265.70389 2.95284399
-#> SIGMA[1,1] SIGMA[2,2]
-#> CL 0.00000 0.000000
-#> V 0.00000 0.000000
-#> KA 0.00000 0.000000
-#> d_CL 733.61860 90.578191
-#> d_V 9690.93156 265.703890
-#> d_KA 64.79341 2.952844
-#> SIGMA[1,1] 193719.81023 6622.636801
-#> SIGMA[2,2] 6622.63680 477.649386
-#>
-#> $rse
-#> CL V KA d_CL d_V d_KA SIGMA[1,1]
-#> 5.030673 2.983917 14.014958 29.787587 36.758952 26.753311 31.645011
-#> SIGMA[2,2]
-#> 25.341368
-#> Elapsed time: 0.101 seconds.
We can see that the result, based on MC sampling, is somewhat -variable with so few samples.
-
-tic();evaluate_design(poped.db,d_switch=FALSE,ED_samp_size=20); toc()
-#> $ofv
-#> [1] 55.42045
-#>
-#> $fim
-#> CL V KA d_CL d_V d_KA
-#> CL 17652.97859 20.900077 10.206898 0.000000e+00 0.00000 0.00000000
-#> V 20.90008 17.846603 -3.482767 0.000000e+00 0.00000 0.00000000
-#> KA 10.20690 -3.482767 51.214965 0.000000e+00 0.00000 0.00000000
-#> d_CL 0.00000 0.000000 0.000000 2.323385e+03 10.26722 0.03682497
-#> d_V 0.00000 0.000000 0.000000 1.026722e+01 19067.54099 11.76757081
-#> d_KA 0.00000 0.000000 0.000000 3.682497e-02 11.76757 38.83554961
-#> SIGMA[1,1] 0.00000 0.000000 0.000000 7.287665e+02 9671.83881 65.02022679
-#> SIGMA[2,2] 0.00000 0.000000 0.000000 9.042351e+01 265.46887 2.94967457
-#> SIGMA[1,1] SIGMA[2,2]
-#> CL 0.00000 0.000000
-#> V 0.00000 0.000000
-#> KA 0.00000 0.000000
-#> d_CL 728.76653 90.423509
-#> d_V 9671.83881 265.468868
-#> d_KA 65.02023 2.949675
-#> SIGMA[1,1] 194823.12196 6613.513007
-#> SIGMA[2,2] 6613.51301 476.316709
-#>
-#> $rse
-#> CL V KA d_CL d_V d_KA SIGMA[1,1]
-#> 5.021700 2.980981 14.068646 29.765030 36.691675 26.754137 31.469425
-#> SIGMA[2,2]
-#> 25.311870
-#> Elapsed time: 0.104 seconds.
Ds-optimality is a criterion that can be used if one is interested in
-estimating a subset “s” of the model parameters as precisely as
-possible. The full code for this example is available in
-ex.2.e.warfarin.Ds.R
. First we define initial design and
-design space:
For Ds optimality we add the ds_index
option to the
-create.poped.database
function to indicate whether a
-parameter is interesting (=0) or not (=1). Moreover, we set the
-ofv_calc_type=6
for computing the Ds optimality criterion
-(it is set to 4 by default, for computing the log of the determinant of
-the FIM). More details are available by running the command
-?create.poped.database
.
-poped.db <-
- create.poped.database(
- ff_fun=ff,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(0.01,0.25),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0,
- maxxt=120,
- a=70,
- mina=0,
- maxa=100,
- ds_index=c(0,0,0,1,1,1,1,1), # size is number_of_non_fixed_parameters
- ofv_calc_type=6) # Ds OFV calculation
Design evaluation:
-
-evaluate_design(poped.db)
-#> $ofv
-#> [1] 16.49204
-#>
-#> $fim
-#> CL V KA d_CL d_V
-#> CL 17141.83891 20.838375 10.011000 0.000000e+00 0.000000
-#> V 20.83837 17.268051 -3.423641 0.000000e+00 0.000000
-#> KA 10.01100 -3.423641 49.864697 0.000000e+00 0.000000
-#> d_CL 0.00000 0.000000 0.000000 2.324341e+03 9.770352
-#> d_V 0.00000 0.000000 0.000000 9.770352e+00 19083.877564
-#> d_KA 0.00000 0.000000 0.000000 3.523364e-02 11.721317
-#> SIGMA[1,1] 0.00000 0.000000 0.000000 7.268410e+02 9656.158553
-#> SIGMA[2,2] 0.00000 0.000000 0.000000 9.062739e+01 266.487127
-#> d_KA SIGMA[1,1] SIGMA[2,2]
-#> CL 0.00000000 0.00000 0.000000
-#> V 0.00000000 0.00000 0.000000
-#> KA 0.00000000 0.00000 0.000000
-#> d_CL 0.03523364 726.84097 90.627386
-#> d_V 11.72131703 9656.15855 266.487127
-#> d_KA 38.85137516 64.78096 2.947285
-#> SIGMA[1,1] 64.78095548 192840.20092 6659.569867
-#> SIGMA[2,2] 2.94728469 6659.56987 475.500111
-#>
-#> $rse
-#> CL V KA d_CL d_V d_KA SIGMA[1,1]
-#> 5.096246 3.031164 14.260384 29.761226 36.681388 26.748640 32.011719
-#> SIGMA[2,2]
-#> 25.637971
The full code for this example is available in -“ex.13.shrinkage.R”.
- -To evaluate the estimation quality of the individual random effects
-in the model (the b’s) we use the function shrinkage()
.
-shrinkage(poped.db)
-#> # A tibble: 3 × 5
-#> d_KA d_V `D[3,3]` type group
-#> <dbl> <dbl> <dbl> <chr> <chr>
-#> 1 0.504 0.367 0.424 shrink_var grp_1
-#> 2 0.295 0.205 0.241 shrink_sd grp_1
-#> 3 0.710 0.303 0.206 se grp_1
The output shows us the expected shrinkage on the variance scale -(\(shrink_{var}=1-var(b_j)/D(j,j)\)) -and on the standard deviation scale (\(shrink_{sd}=1-sd(b_j)/sqrt(D(j,j))\)), as -well as the standard errors of the \(b_j\) estimates.
-Available in PopED, but not shown in examples:
-To be implemented:
-Study 1 and 2 from table 2 in: Gibiansky, L., Gibiansky, -E., & Bauer, R. (2012). Comparison of Nonmem 7.2 estimation methods -and parallel processing efficiency on a target-mediated drug disposition -model. Journal of Pharmacokinetics and Pharmacodynamics, 39(1), 17–35. -https://doi.org/10.1007/s10928-011-9228-y↩︎
Nyberg, J., Bazzoli, C., Ogungbenro, K., Aliev, A., -Leonov, S., Duffull, S., Hooker, A.C. and Mentré, F. (2014). Methods and -software tools for design evaluation for population -pharmacokinetics-pharmacodynamics studies. British Journal of Clinical -Pharmacology, 79(1), 1–32. https://doi.org/10.1111/bcp.12352↩︎
vignettes/handling_LOQ.Rmd
- handling_LOQ.Rmd
-library(PopED)
-packageVersion("PopED")
-#> [1] '0.6.0.9002'
Here we define, as an example, a one-compartment pharmacokinetic -model with linear absorption (analytic solution) in PopED (Nyberg et al. -2012).
-
-ff <- function(model_switch,xt,parameters,poped.db){
- with(as.list(parameters),{
- y=xt
- y=(DOSE*KA/(V*(KA-CL/V)))*(exp(-CL/V*xt)-exp(-KA*xt))
- return(list(y=y,poped.db=poped.db))
- })}
Next we define the parameters of this function. DOSE
is
-defined as a covariate (in vector a
) so that we can
-optimize the value later.
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c( CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- DOSE=a[1])
-}
We will use an additive and proportional residual unexplained
-variability (RUV) model, predefined in PopED as the function
-feps.add.prop
.
Now we define the model parameter values, the initial design and -design space for optimization.
-We define model parameters similar to the Warfarin example from the -software comparison in Nyberg et al. (2015) and an arbitrary design of two -groups of 20 individuals.
-
-poped_db <-
- create.poped.database(
- ff_fun=ff,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- bpop=c(CL=0.15, V=8, KA=1.0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(prop=0.01,add=0.25),
- groupsize=32,
- xt=c( 0.5,3,50,120),
- discrete_xt = list(c(0.5,1:120)),
- minxt=0,
- maxxt=120,
- a=70,
- mina=0,
- maxa=100)
-
First it may make sense to check your model and design to make sure -you get what you expect when simulating data. Here we plot the model -typical values for the two groups:
-
-plot_model_prediction(poped_db, model_num_points = 500,facet_scales = "free",PI=T)
Next, we evaluate the initial design. We see that the relative -standard error of the parameters (in percent) are relatively well -estimated with this design except for the proportional RUV.
-
-eval_full <- evaluate_design(poped_db)
- | --RSE - | -
---|---|
-CL - | --5 - | -
-V - | --4 - | -
-KA - | --15 - | -
-d_CL - | --34 - | -
-d_V - | --70 - | -
-d_KA - | --28 - | -
-sig_prop - | --89 - | -
-sig_add - | --36 - | -
We assume that the LOQ level is at 2 concentration units.
-
-library(ggplot2)
-plot_model_prediction(poped_db, model_num_points = 500,facet_scales = "free",PI=T) +
- geom_hline(yintercept = 2,color="red",linetype="dotted")
We use optimization criteria based on the D6
-(loq_method=1
which is the default) and D2
-(loq_method=2
) methods from Vong et
-al. (2012). For the D6 method, which
-has been shown to be a better method in comparison to SSE studies, we
-have updated the method to only investigate points where the 95% PI
-overlaps LOQ, otherwise we set the design point to either no information
-or full information. Further we filter out situations with very low
-probabilities (loq_prob_limit = 0.001
). Both the CI% and
-the low probability limit can be specified in the calculation (default
-values are loq_PI_conf_level = 0.95
and
-loq_prob_limit = 0.001
). In this way we can get the D6
-method to compute in reasonable time-frames even for larger number of
-design samples.
Here we can evaluate the design with both methods and test the speed -of computation. We see that D6 is significantly slower than D2 (but D6 -should be a more accurate representation of the RSE expected using M3 -estimation methods).
-
-set.seed(1234)
-e_time_D6 <- system.time(
- eval_D6 <- evaluate_design(poped_db,loq=2)
-)
-
-e_time_D2 <- system.time(
- eval_D2 <- evaluate_design(poped_db,loq=2, loq_method=2)
-)
-
-cat("D6 evaluation time: ",e_time_D6[1],"\n" )
-cat("D2 evaluation time: ",e_time_D2[1],"\n" )
-#> D6 evaluation time: 0.174
-#> D2 evaluation time: 0.06
The D2 nmethod is the same as removing the last data point
-
-poped_db_2 <- create.poped.database(
- ff_fun=ff,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- bpop=c(CL=0.15, V=8, KA=1.0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(prop=0.01,add=0.25),
- groupsize=32,
- xt=c( 0.5,3,50),
- discrete_xt = list(c(0.5,1:120)),
- minxt=0,
- maxxt=120,
- a=70,
- mina=0,
- maxa=100)
-eval_red <- evaluate_design(poped_db_2)
-testthat::expect_equal(eval_red$ofv,eval_D2$ofv)
-testthat::expect_equal(eval_red$rse,eval_D2$rse)
Predicted parameter uncertainty for the three methods is shown below. -We see that the uncertainty is generally higher with the LOQ evaluations -(as expected). We also see that because the D2 method ignores data that -is below LOQ (the last observation in the design), then the predictions -of uncertainty are significantly larger.
--Parameter - | --No LOQ - | --D6 - | --D2 - | -
---|---|---|---|
-CL - | --5 - | --6 - | --6 - | -
-V - | --4 - | --4 - | --4 - | -
-KA - | --15 - | --17 - | --15 - | -
-d_CL - | --34 - | --50 - | --498 - | -
-d_V - | --70 - | --109 - | --428 - | -
-d_KA - | --28 - | --33 - | --113 - | -
-sig_prop - | --89 - | --161 - | --1444 - | -
-sig_add - | --36 - | --118 - | --2127 - | -
If needed we can also handle upper limits of quantification. Lets -assume we have an ULOQ at 7 units in addition to the LLOQ of 2 -units:
-
-library(ggplot2)
-plot_model_prediction(poped_db, model_num_points = 500,facet_scales = "free",
- PI=T, PI_alpha = 0.1) +
- geom_hline(yintercept = 2,color="red",linetype="dotted") +
- geom_hline(yintercept = 7,color="blue",linetype="dotted")
-eval_ul_D6 <-evaluate_design(poped_db,
- loq=2,
- uloq=7)
-
-eval_ul_D2 <- evaluate_design(poped_db,
- loq=2,
- loq_method=2,
- uloq=7,
- uloq_method=2)
-#> Problems inverting the matrix. Results could be misleading.
-Parameter - | --No LOQ - | --D6 (only LLOQ) - | --D2 (only LLOQ) - | --D6 (ULOQ and LLOQ) - | --D2 (ULOQ and LLOQ) - | -
---|---|---|---|---|---|
-CL - | --5 - | --6 - | --6 - | --6 - | --6 - | -
-V - | --4 - | --4 - | --4 - | --8 - | --0 - | -
-KA - | --15 - | --17 - | --15 - | --21 - | --14 - | -
-d_CL - | --34 - | --50 - | --498 - | --59 - | --276 - | -
-d_V - | --70 - | --109 - | --428 - | --203 - | --1743 - | -
-d_KA - | --28 - | --33 - | --113 - | --35 - | --55 - | -
-sig_prop - | --89 - | --161 - | --1444 - | --297 - | --1645 - | -
-sig_add - | --36 - | --118 - | --2127 - | --122 - | --6 - | -
We can then optimize the design using the different methods of -computing the FIM. Here we optimize only using lower LOQ.
-
-optim_D6 <- poped_optim(poped_db, opt_xt = TRUE,
- parallel=T,
- loq=2)
-
-optim_D2 <- poped_optim(poped_db, opt_xt = TRUE,
- parallel=T,
- loq=2,
- loq_method=2)
-
-optim_full <- poped_optim(poped_db, opt_xt = TRUE,
- parallel=T)
Predictions using the D6 method from each of the optimizations shows -the expected %RSE of the parameters if each design is used and the LOQ -is at 2 concentration units. We see that D2 may be a reasonable strategy -to optimize designs that are “good enough” if the D6 method is too slow -for optimization.
-
-optim_full_D6<- with(optim_full,
- evaluate_design(poped.db,
- loq=2))
-
-optim_D2_D6<- with(optim_D2,
- evaluate_design(poped.db,
- loq=2))
-
-optim_D6_D6<- with(optim_D6,
- evaluate_design(poped.db,
- loq=2))
-Parameter - | --No LOQ - | --D6 - | --D2 - | -
---|---|---|---|
-CL - | --7 - | --5 - | --6 - | -
-V - | --4 - | --3 - | --3 - | -
-KA - | --16 - | --17 - | --16 - | -
-d_CL - | --67 - | --34 - | --43 - | -
-d_V - | --58 - | --54 - | --52 - | -
-d_KA - | --30 - | --39 - | --30 - | -
-sig_prop - | --114 - | --96 - | --93 - | -
-sig_add - | --152 - | --60 - | --92 - | -
-sessionInfo()
-#> R version 4.3.2 (2023-10-31)
-#> Platform: aarch64-apple-darwin20 (64-bit)
-#> Running under: macOS Ventura 13.6.1
-#>
-#> Matrix products: default
-#> BLAS: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib
-#> LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0
-#>
-#> locale:
-#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
-#>
-#> time zone: Europe/Stockholm
-#> tzcode source: internal
-#>
-#> attached base packages:
-#> [1] stats graphics grDevices utils datasets methods base
-#>
-#> other attached packages:
-#> [1] kableExtra_1.3.4 knitr_1.45 ggplot2_3.4.4 PopED_0.6.0.9002
-#> [5] testthat_3.2.0
-#>
-#> loaded via a namespace (and not attached):
-#> [1] gtable_0.3.4 xfun_0.41 bslib_0.5.1 htmlwidgets_1.6.2
-#> [5] devtools_2.4.5 remotes_2.4.2.1 processx_3.8.2 callr_3.7.3
-#> [9] vctrs_0.6.4 tools_4.3.2 ps_1.7.5 generics_0.1.3
-#> [13] tibble_3.2.1 fansi_1.0.5 highr_0.10 pkgconfig_2.0.3
-#> [17] desc_1.4.2 webshot_0.5.5 lifecycle_1.0.3 farver_2.1.1
-#> [21] compiler_4.3.2 stringr_1.5.0 brio_1.1.3 textshaping_0.3.7
-#> [25] munsell_0.5.0 codetools_0.2-19 httpuv_1.6.12 htmltools_0.5.7
-#> [29] usethis_2.2.2 sass_0.4.7 yaml_2.3.7 later_1.3.1
-#> [33] pkgdown_2.0.7 pillar_1.9.0 crayon_1.5.2 jquerylib_0.1.4
-#> [37] urlchecker_1.0.1 MASS_7.3-60 ellipsis_0.3.2 cachem_1.0.8
-#> [41] sessioninfo_1.2.2 boot_1.3-28.1 mime_0.12 gtools_3.9.4
-#> [45] rvest_1.0.3 tidyselect_1.2.0 digest_0.6.33 mvtnorm_1.2-3
-#> [49] stringi_1.7.12 dplyr_1.1.3 purrr_1.0.2 bookdown_0.36
-#> [53] labeling_0.4.3 rprojroot_2.0.3 fastmap_1.1.1 grid_4.3.2
-#> [57] colorspace_2.1-0 cli_3.6.1 magrittr_2.0.3 pkgbuild_1.4.2
-#> [61] utf8_1.2.4 withr_2.5.2 prettyunits_1.2.0 scales_1.2.1
-#> [65] promises_1.2.1 httr_1.4.7 rmarkdown_2.25 ragg_1.2.6
-#> [69] memoise_2.0.1 shiny_1.7.5.1 evaluate_0.23 viridisLite_0.4.2
-#> [73] miniUI_0.1.1.1 profvis_0.3.8 rlang_1.1.1 Rcpp_1.0.11
-#> [77] xtable_1.8-4 glue_1.6.2 xml2_1.3.5 pkgload_1.3.3
-#> [81] svglite_2.1.2 rstudioapi_0.15.0 jsonlite_1.8.7 R6_2.5.1
-#> [85] systemfonts_1.0.5 fs_1.6.3
vignettes/intro-poped.Rmd
- intro-poped.Rmd
PopED computes optimal experimental designs for both population and -individual studies based on nonlinear mixed-effect models. Often this is -based on a computation of the Fisher Information Matrix (FIM).
-To get started you need to define
-There are a number of functions to help you with these tasks. See
-?poped
for more information.
Below is an example to introduce the package. Several other examples -are available as r-scripts in the “examples” folder in the PopED -installation directory located at:
-
-system.file("examples", package="PopED")
You can view a list of the example files using the commands:
-
-ex_dir <- system.file("examples", package="PopED")
-list.files(ex_dir)
You can then open one of the examples (for example,
-ex.1.a.PK.1.comp.oral.md.intro.R
, is very similar to the
-code found in this vignette) using the following code
-file_name <- "ex.1.a.PK.1.comp.oral.md.intro.R"
-ex_file <- system.file("examples",file_name,package="PopED")
-file.copy(ex_file,tempdir(),overwrite = T)
-file.edit(file.path(tempdir(),file_name))
In addition, there is another vignette called “Examples” that -explores the new features in each example.
-Here we define a one-compartment pharmacokinetic model with linear
-absorption using an analytical solution. In this case the solution is
-applicable for both multiple and single dosing. Note that this function
-is also predefined in PopED as ff.PK.1.comp.oral.md.CL
(see
-?ff.PK.1.comp.oral.md.CL
for more information).
-library(PopED)
-packageVersion("PopED")
-#> [1] '0.6.0.9002'
-ff <- function(model_switch,xt,parameters,poped.db){
- with(as.list(parameters),{
- N = floor(xt/TAU)+1
- y=(DOSE*Favail/V)*(KA/(KA - CL/V)) *
- (exp(-CL/V * (xt - (N - 1) * TAU)) * (1 - exp(-N * CL/V * TAU))/(1 - exp(-CL/V * TAU)) -
- exp(-KA * (xt - (N - 1) * TAU)) * (1 - exp(-N * KA * TAU))/(1 - exp(-KA * TAU)))
- return(list( y=y,poped.db=poped.db))
- })
-}
Next we define the parameters of this function, in this case the
-between-subject variability (BSV) for each parameter is log-normally
-distributed (parameter Favail
is assumed not to have BSV).
-DOSE
and TAU
are defined as covariates (in
-vector a
) so that we can optimize their values later.
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c( V=bpop[1]*exp(b[1]),
- KA=bpop[2]*exp(b[2]),
- CL=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1],
- TAU=a[2])
-}
Now we define the residual unexplained variability (RUV) function, in -this case the RUV has both an additive and proportional component.
- -We create a poped database to link the model defined above with a set -of model parameters, the initial design and design space for -optimization.
-In this example, the parameter values are defined for the fixed
-effects (bpop
), the between-subject variability variances
-(d
) and the residual variability variances
-(sigma
). We also fix the parameter Favail
-using notfixed_bpop
, since we have only oral dosing and the
-parameter is not identifiable. Fixing a parameter means that we assume
-the parameter will not be estimated (and is know without uncertainty).
-In addition, we fix the small additive RUV term, as this term is
-reflecting the higher error expected at low concentration measurements
-(limit of quantification measurements) and would typically be calculated
-from analytical assay methods (for example, the standard deviation of
-the parameter might be 20% of the limit of quantification).
For the initial design, we define two groups (m=2
) of 20
-individuals (groupsize=20
), with doses of 20 mg or 40 mg
-every 24 hours (a
). The initial design has 5 sample times
-per individual (xt
).
For the design space, which can be searched during optimization, we
-define a potential dose range of between 0 and 200 mg (mina
-and maxa
), and a range of potential sample times between 0
-and 10 hours for the first three samples and between 240 and 248 hours
-for the last two samples (minxt
and maxxt
).
-Finally, we fix the two groups of subjects to have the same sample times
-(bUseGrouped_xt=TRUE
).
-poped.db <- create.poped.database(
- # Model
- ff_fun=ff,
- fg_fun=sfg,
- fError_fun=feps,
- bpop=c(V=72.8,KA=0.25,CL=3.75,Favail=0.9),
- notfixed_bpop=c(1,1,1,0),
- d=c(V=0.09,KA=0.09,CL=0.25^2),
- sigma=c(prop=0.04,add=5e-6),
- notfixed_sigma=c(1,0),
-
- # Design
- m=2,
- groupsize=20,
- a=list(c(DOSE=20,TAU=24),c(DOSE=40, TAU=24)),
- maxa=c(DOSE=200,TAU=24),
- mina=c(DOSE=0,TAU=24),
- xt=c( 1,2,8,240,245),
-
- # Design space
- minxt=c(0,0,0,240,240),
- maxxt=c(10,10,10,248,248),
- bUseGrouped_xt=TRUE)
First it may make sense to check your model and design to make sure -you get what you expect when simulating data. Here we plot the model -typical values:
-
-plot_model_prediction(poped.db, model_num_points = 300)
Next, we plot the expected prediction interval (by default a 95% PI)
-of the data taking into account the BSV and RUV using the option
-PI=TRUE
. This option makes predictions based on first-order
-approximations to the model variance and a normality assumption of that
-variance. Better (and slower) computations are possible with the
-DV=T
, IPRED=T
and
-groupsize_sim = some large number
options.
-plot_model_prediction(poped.db,
- PI=TRUE,
- separate.groups=T,
- model_num_points = 300,
- sample.times = FALSE)
We can get these predictions numerically as well:
-
-dat <- model_prediction(poped.db,DV=TRUE)
-head(dat,n=5);tail(dat,n=5)
-#> ID Time DV IPRED PRED Group Model DOSE TAU
-#> 1 1 1 0.09659927 0.08034839 0.05325024 1 1 20 24
-#> 2 1 2 0.13172074 0.13415072 0.09204804 1 1 20 24
-#> 3 1 8 0.19502544 0.19134279 0.16409609 1 1 20 24
-#> 4 1 240 0.04847782 0.05881203 0.12671376 1 1 20 24
-#> 5 1 245 0.29770447 0.23457544 0.24980320 1 1 20 24
-#> ID Time DV IPRED PRED Group Model DOSE TAU
-#> 196 40 1 0.04411438 0.0583122 0.1065005 2 1 40 24
-#> 197 40 2 0.10599655 0.1039377 0.1840961 2 1 40 24
-#> 198 40 8 0.20262746 0.2206604 0.3281922 2 1 40 24
-#> 199 40 240 0.17506051 0.3788561 0.2534275 2 1 40 24
-#> 200 40 245 0.56558539 0.5183551 0.4996064 2 1 40 24
Next, we evaluate the initial design
-
-(ds1 <- evaluate_design(poped.db))
-#> $ofv
-#> [1] 39.309
-#>
-#> $fim
-#> V KA CL d_V d_KA d_CL
-#> V 0.05336692 -8.683963 -0.05863412 0.000000 0.000000 0.000000
-#> KA -8.68396266 2999.851007 -14.43058560 0.000000 0.000000 0.000000
-#> CL -0.05863412 -14.430586 37.15243290 0.000000 0.000000 0.000000
-#> d_V 0.00000000 0.000000 0.00000000 999.953587 312.240246 3.202847
-#> d_KA 0.00000000 0.000000 0.00000000 312.240246 439.412556 2.287838
-#> d_CL 0.00000000 0.000000 0.00000000 3.202847 2.287838 3412.005199
-#> sig_prop 0.00000000 0.000000 0.00000000 575.347261 638.581909 1182.325475
-#> sig_prop
-#> V 0.0000
-#> KA 0.0000
-#> CL 0.0000
-#> d_V 575.3473
-#> d_KA 638.5819
-#> d_CL 1182.3255
-#> sig_prop 33864.3226
-#>
-#> $rse
-#> V KA CL d_V d_KA d_CL sig_prop
-#> 8.215338 10.090955 4.400304 39.844763 60.655110 27.562541 13.865357
We see that the fixed-effect and residual variability parameters are -relatively well estimated with this design, but the between-subject -variability parameters are less well estimated.
-What about an alternative design with sparse sampling? For example, -what if each individual only has 3 time points at 1, 2 and 245 -hours:
-
-poped.db.new <- create.poped.database(
- # Model
- ff_fun=ff,
- fg_fun=sfg,
- fError_fun=feps,
- bpop=c(V=72.8,KA=0.25,CL=3.75,Favail=0.9),
- notfixed_bpop=c(1,1,1,0),
- d=c(V=0.09,KA=0.09,CL=0.25^2),
- sigma=c(prop=0.04,add=5e-6),
- notfixed_sigma=c(1,0),
-
- # Design
- m=2,
- groupsize=20,
- a=list(c(DOSE=20,TAU=24),c(DOSE=40, TAU=24)),
- maxa=c(DOSE=200,TAU=24),
- mina=c(DOSE=0,TAU=24),
- xt=c( 1,2,245),
-
- # Design space
- minxt=c(0,0,240),
- maxxt=c(10,10,248),
- bUseGrouped_xt=TRUE)
-(ds2 <- evaluate_design(poped.db.new))
-#> $ofv
-#> [1] 29.66484
-#>
-#> $fim
-#> V KA CL d_V d_KA d_CL
-#> V 0.04243232 -10.51432 0.05782431 0.000000 0.000000 0.000000
-#> KA -10.51432135 2666.25466 -14.66678102 0.000000 0.000000 0.000000
-#> CL 0.05782431 -14.66678 21.59743298 0.000000 0.000000 0.000000
-#> d_V 0.00000000 0.00000 0.00000000 632.163776 457.737062 3.115099
-#> d_KA 0.00000000 0.00000 0.00000000 457.737062 347.115999 2.363458
-#> d_CL 0.00000000 0.00000 0.00000000 3.115099 2.363458 1153.026981
-#> sig_prop 0.00000000 0.00000 0.00000000 348.477101 262.369792 1979.231386
-#> sig_prop
-#> V 0.0000
-#> KA 0.0000
-#> CL 0.0000
-#> d_V 348.4771
-#> d_KA 262.3698
-#> d_CL 1979.2314
-#> sig_prop 15617.8185
-#>
-#> $rse
-#> V KA CL d_V d_KA d_CL sig_prop
-#> 44.120338 51.256239 5.748842 207.941540 280.689945 53.350716 22.795275
The precision on CL is similar with the alternative design but the -other parameters are less well estimated.
-
-(design_eval <- round(data.frame("Design 1"=ds1$rse,"Design 2"=ds2$rse)))
- | Design.1 | -Design.2 | -
---|---|---|
V | -8 | -44 | -
KA | -10 | -51 | -
CL | -4 | -6 | -
d_V | -40 | -208 | -
d_KA | -61 | -281 | -
d_CL | -28 | -53 | -
sig_prop | -14 | -23 | -
Comparing the objective function value (OFV), we see that the -alternative design (less samples per subject) has a smaller OFV -(=worse). We can compare the two OFVs using efficiency, which tells us -the proportion extra individuals that are needed in the alternative -design to have the same information content as the original design -(around 4 times more individuals than are currently in the design).
-
-efficiency(ds2$ofv,ds1$ofv,poped.db)
-#> [1] 3.965919
-#> attr(,"description")
-#> [1] "(exp(ofv_final) / exp(ofv_init))^(1/n_parameters)"
Now we can optimize the sample times of the original design by -maximizing the OFV1.
-
-output <- poped_optim(poped.db, opt_xt=TRUE)
-summary(output)
-#> ===============================================================================
-#> FINAL RESULTS
-#> Optimized Sampling Schedule
-#> Group 1: 0.4574 10 10 240 240.9
-#> Group 2: 0.4574 10 10 240 240.9
-#>
-#> OFV = 40.5277
-#>
-#> Efficiency:
-#> ((exp(ofv_final) / exp(ofv_init))^(1/n_parameters)) = 1.1902
-#>
-#> Expected relative standard error
-#> (%RSE, rounded to nearest integer):
-#> Parameter Values RSE_0 RSE
-#> V 72.8 8 6
-#> KA 0.25 10 8
-#> CL 3.75 4 4
-#> d_V 0.09 40 33
-#> d_KA 0.09 61 50
-#> d_CL 0.0625 28 26
-#> sig_prop 0.04 14 15
-#>
-#> Total running time: 11.41 seconds
-plot_model_prediction(output$poped.db)
We see that there are four distinct sample times for this design. -This means that for this model, with these exact parameter values, that -the most information from the study to inform the parameter estimation -is with these sample times.
-Of course, this means that there are multiple samples at some of -these time points. We can explore a more practical design by looking at -the loss of efficiency if we spread out sample times in a uniform -distribution around these optimal points (\(\pm 30\) minutes).
-
-plot_efficiency_of_windows(output$poped.db,xt_windows=0.5)
Here we see the efficiency (\((|FIM_{optimized}|/|FIM_{initial}|)^{1/npar}\))
-drops below 80% in some cases, which is mostly caused by an increase in
-the parameter uncertainty of the BSV parameter on absorption (om_KA).
-Smaller windows or different windowing on different samples might be
-needed. To investigate see ?plot_efficiency_of_windows
.
In the previous example we optimized over a continuous design space -(sample times could be optimized to be any value between a lower and an -upper limit). We could also limit the search to only “allowed” values, -for example, only samples taken on the hour are allowed.
-
-poped.db.discrete <- create.poped.database(poped.db,discrete_xt = list(c(0:10,240:248)))
-
-output_discrete <- poped_optim(poped.db.discrete, opt_xt=TRUE)
-summary(output_discrete)
-#> ===============================================================================
-#> FINAL RESULTS
-#> Optimized Sampling Schedule
-#> Group 1: 1 10 10 240 241
-#> Group 2: 1 10 10 240 241
-#>
-#> OFV = 40.3782
-#>
-#> Efficiency:
-#> ((exp(ofv_final) / exp(ofv_init))^(1/n_parameters)) = 1.165
-#>
-#> Expected relative standard error
-#> (%RSE, rounded to nearest integer):
-#> Parameter Values RSE_0 RSE
-#> V 72.8 8 6
-#> KA 0.25 10 8
-#> CL 3.75 4 4
-#> d_V 0.09 40 32
-#> d_KA 0.09 61 53
-#> d_CL 0.0625 28 27
-#> sig_prop 0.04 14 15
-#>
-#> Total running time: 5.389 seconds
-plot_model_prediction(output_discrete$poped.db, model_num_points = 300)
Here we see that the optimization ran somewhat quicker, but gave a -less efficient design.
-One could also optimize over dose, to see if a different dose could -help in parameter estimation .
-
-output_dose_opt <- poped_optim(output$poped.db, opt_xt=TRUE, opt_a=TRUE)
In this case the results are predictable … higher doses give -observations with somewhat lower absolute residual variability leading -to both groups at the highest allowed dose levels (200 mg in this -case).
-Optimizing the dose of a study just to have better model parameter -estimates may be somewhat implausible. Instead, let’s use a cost -function to optimize dose based on some sort of target concentration … -perhaps typical population trough concentrations of 0.2 and 0.35 for the -two groups of patients at 240 hours.
-First we define the criteria we use to optimize the doses, here a -least squares minimization.
-
-crit_fcn <- function(poped.db,...){
- pred_df <- model_prediction(poped.db)
- sum((pred_df[pred_df["Time"]==240,"PRED"] - c(0.2,0.35))^2)
-}
-crit_fcn(output$poped.db)
-#> [1] 0.01469712
Now we minimize the cost function
-
-output_cost <- poped_optim(poped.db, opt_a = TRUE, opt_xt = FALSE,
- ofv_fun=crit_fcn,
- maximize = FALSE)
-summary(output_cost)
-#> ===============================================================================
-#> FINAL RESULTS
-#>
-#> Optimized Covariates:
-#> Group 1: 31.5672 : 24
-#> Group 2: 55.2426 : 24
-#>
-#> OFV = 6.09293e-15
-#>
-#> Efficiency:
-#> (ofv_final / ofv_init) = 4.1457e-13
-#>
-#> Expected relative standard error
-#> (%RSE, rounded to nearest integer):
-#> Parameter Values RSE_0 RSE
-#> V 72.8 8 8
-#> KA 0.25 10 10
-#> CL 3.75 4 4
-#> d_V 0.09 40 40
-#> d_KA 0.09 61 60
-#> d_CL 0.0625 28 28
-#> sig_prop 0.04 14 14
-#>
-#> Total running time: 1.702 seconds
We see that the optimal doses are 31.6 and 55.2 for the two groups. -This leads to population trough concentrations of 0.2 and 0.35 for the -two groups of patients at 240 hours:
-
-library(ggplot2)
-plot_model_prediction(output_cost$poped.db, model_num_points = 300)+
- coord_cartesian(xlim=c(230,250))
Tip: to make the optimization run faster use the option
-parallel = TRUE
in the poped_optim
command.↩︎
vignettes/model_def_other_pkgs.Rmd
- model_def_other_pkgs.Rmd
This is a simple example on how to couple PopED with external R based -PKPD simulation tools. Typically, these tools might be R packages that -can simulate from ordinary differential equation (ODE) based models. In -this document you will see how to couple PopED to models, defined with -ODEs, implemented using:
-We will use a one-compartment with linear absorption population -pharmacokinetic (PK) model as an example (see below).
- - - - - -This model can be described with the following set of ODEs:
-\[ - \begin{split} - \frac{dA_{0}}{dt} &= - k_{a} \cdot A_{0}\\ - \frac{dA_{1}}{dt} &=-(CL/V_1)\cdot A_1 + k_{a} \cdot A_{0} \\ - f(t) &= A_1/V_1 - \end{split} -\]
-All compartment amounts are assumed to be zero at time zero (\(\boldsymbol{A}[t=0]=0\)). Inputs to the -system come in tablet form and are added to the amount in \(A_{0}\) according to
-\[ - \text{Input}(t,D,t_D) = - \begin{cases} - D, &\text{if} \quad t = t_D \\ - 0, &\text{otherwise} - \end{cases} -\]
-Parameter values are defined as:
-\[ - \begin{split} - k_a &= \theta_{k_a} \cdot e^{\eta_{k_a}} \\ - CL &= \theta_{CL} \cdot e^{\eta_{CL}} \\ - V_1 &= \theta_{V_1} \cdot e^{\eta_{V_1}} \\ - \end{split} -\] where elements of the between subject variability (BSV), \(\eta_{j}\), vary across individuals and -come from normal distributions with means of zero and variances of \(\omega^2_{j}\).
-The residual unexplained variability (RUV) model has a proportional -and additive component
-\[ - y = f(t) \cdot (1+\varepsilon_{prop}) + \varepsilon_{add} -\]
-elements of \(\boldsymbol{\varepsilon}_{j}\) vary accross -observations and come from normal distributions with means of zero and -variances of \(\sigma^2_{j}\).
-Parameter values are assumed to be the following: - --Parameter - | --Value - | -
---|---|
-\(k_a\) - | --0.2500 - | -
-CL - | --3.7500 - | -
-\(V_1\) - | --72.8000 - | -
-\(\omega^2_{k_a}\) - | --0.0900 - | -
-\(\omega^2_{CL}\) - | --0.0625 - | -
-\(\omega^2_{V_1}\) - | --0.0900 - | -
-\(\sigma^2_{prop}\) - | --0.0400 - | -
-\(\sigma^2_{add}\) - | --0.0025 - | -
Below we implement this model using a number of different methods.
-For the ODE solvers, if possible, we set the tuning parameters to be the
-same values (atol
, rtol
, etc.).
First we implement an analytic solution to the model in a function
-that could be used in PopED
. Here we assume a single dose
-or multiple dosing with a dose interval of TAU
time units.
-The named vector parameters
defines the values of
-KA
, CL
, V
, DOSE
and
-TAU
used to compute the value of f
(\(f(t)\) in at each time point in the vector
-xt
.
-ff_analytic <- function(model_switch,xt,parameters,poped.db){
- with(as.list(parameters),{
- y=xt
- N = floor(xt/TAU)+1
- f=(DOSE/V)*(KA/(KA - CL/V)) *
- (exp(-CL/V * (xt - (N - 1) * TAU)) * (1 - exp(-N * CL/V * TAU))/(1 - exp(-CL/V * TAU)) -
- exp(-KA * (xt - (N - 1) * TAU)) * (1 - exp(-N * KA * TAU))/(1 - exp(-KA * TAU)))
- return(list( f=f,poped.db=poped.db))
- })
-}
The same model can be implemented using ODEs. Here the ODEs are -defined in deSolve:
-
-PK_1_comp_oral_ode <- function(Time, State, Pars){
- with(as.list(c(State, Pars)), {
- dA1 <- -KA*A1
- dA2 <- KA*A1 - (CL/V)*A2
- return(list(c(dA1, dA2)))
- })
-}
Then, just as in the analytic solution, the named vector
-parameters
defines the values of KA
,
-CL
, V
, DOSE
and TAU
-used to compute the value of \(f(t)\)
-at each time point in the vector xt
. The inputs to the
-system dosing times need to be added as an input to the ODE system
-(called events
).
-ff_ode_desolve <- function(model_switch, xt, parameters, poped.db){
- with(as.list(parameters),{
- A_ini <- c(A1=0, A2=0)
-
- #Set up time points for the ODE
- times_xt <- drop(xt)
- times <- c(0,times_xt) ## add extra time for start of the experiment
- dose_times = seq(from=0,to=max(times_xt),by=TAU)
- times <- c(times,dose_times)
- times <- sort(times)
- times <- unique(times) # remove duplicates
-
- eventdat <- data.frame(var = c("A1"),
- time = dose_times,
- value = c(DOSE), method = c("add"))
-
- out <- ode(A_ini, times, PK_1_comp_oral_ode, parameters,
- events = list(data = eventdat),
- atol=1e-8, rtol=1e-8,maxsteps=5000)
-
- # grab timepoint values
- out = out[match(times_xt,out[,"time"]),]
-
- f = out[,"A2"]/V
-
- f=cbind(f) # must be a column matrix
- return(list(f=f,poped.db=poped.db))
- })
-}
We can use compiled C code with deSolve to speed up computing -solutions to the ODEs. The C code is that need to be compiled looks like -this:
-/* file one_comp_oral_CL.c */
-#include <R.h>
-static double parms[3];
-#define CL parms[0]
-#define V parms[1]
-#define KA parms[2]
-
-/* initializer */
-void initmod(void (* odeparms)(int *, double *))
-{
- int N=3;
- odeparms(&N, parms);
-}
-
-/* Derivatives and 1 output variable */
-void derivs (int *neq, double *t, double *y, double *ydot,
- double *yout, int *ip)
-{
-
- if (ip[0] <1) error("nout should be at least 1");
-
- ydot[0] = -KA*y[0];
- ydot[1] = KA*y[0] - CL/V*y[1];
- yout[0] = y[0]+y[1];
-}
-
-/* END file one_comp_oral_CL.c */
-This code is available as a file in the PopED distribution, and is -compiled with the following commands:
-
-file.copy(system.file("examples/one_comp_oral_CL.c", package="PopED"),"./one_comp_oral_CL.c")
-#> [1] FALSE
-system('R CMD SHLIB one_comp_oral_CL.c')
-dyn.load(paste("one_comp_oral_CL", .Platform$dynlib.ext, sep = ""))
Again, just as in the analytic solution, the named vector
-parameters
defines the values of KA
,
-CL
, V
, DOSE
and TAU
-used to compute the value of \(f(t)\)
-at each time point in the vector xt
.
-ff_ode_desolve_c <- function(model_switch, xt, parameters, poped.db){
- with(as.list(parameters),{
- A_ini <- c(A1=0, A2=0)
-
- #Set up time points for the ODE
- times_xt <- drop(xt)
- times <- c(0,times_xt) ## add extra time for the start of the experiment
- dose_times = seq(from=0,to=max(times_xt),by=TAU)
- times <- c(times,dose_times)
- times <- sort(times)
- times <- unique(times) # remove duplicates
-
- eventdat <- data.frame(var = c("A1"),
- time = dose_times,
- value = c(DOSE), method = c("add"))
-
- out <- ode(A_ini, times, func = "derivs",
- parms = c(CL,V,KA),
- dllname = "one_comp_oral_CL",
- initfunc = "initmod", nout = 1,
- outnames = "Sum",
- events = list(data = eventdat),
- atol=1e-8, rtol=1e-8,maxsteps=5000)
-
- # grab timepoint values
- out = out[match(times_xt,out[,"time"]),]
-
- y = out[, "A2"]/V
-
- y=cbind(y) # must be a column matrix
- return(list(y=y,poped.db=poped.db))
- })
-}
Here we define the ODE system using inline C++ code via Rcpp
-
-cppFunction('List one_comp_oral_rcpp(double Time, NumericVector A, NumericVector Pars) {
-int n = A.size();
-NumericVector dA(n);
-
-double CL = Pars[0];
-double V = Pars[1];
-double KA = Pars[2];
-
-dA[0] = -KA*A[0];
-dA[1] = KA*A[0] - (CL/V)*A[1];
-return List::create(dA);
-}')
-ff_ode_desolve_rcpp <- function(model_switch, xt, p, poped.db){
- A_ini <- c(A1=0, A2=0)
-
- #Set up time points for the ODE
- times_xt <- drop(xt)
- times <- c(0,times_xt) ## add extra time for start of integration
- dose_times = seq(from=0,to=max(times_xt),by=p[["TAU"]])
- times <- c(times,dose_times)
- times <- sort(times)
- times <- unique(times) # remove duplicates
-
- eventdat <- data.frame(var = c("A1"),
- time = dose_times,
- value = c(p[["DOSE"]]), method = c("add"))
-
- out <- ode(A_ini, times,
- one_comp_oral_rcpp,
- c(CL=p[["CL"]],V=p[["V"]], KA=p[["KA"]]),
- events = list(data = eventdat),
- atol=1e-8, rtol=1e-8,maxsteps=5000)
-
-
- # grab timepoint values for central comp
- y = out[match(times_xt,out[,"time"]),"A2",drop=F]/p[["V"]]
-
- return(list(y=y,poped.db=poped.db))
-}
The same model written as a set of ODEs using PKPDsim:
-
-pk1cmtoral <- PKPDsim::new_ode_model("pk_1cmt_oral") # take from library
-ff_ode_pkpdsim <- function(model_switch, xt, p, poped.db){
- #Set up time points for the ODE
- times_xt <- drop(xt)
- dose_times <- seq(from=0,to=max(times_xt),by=p[["TAU"]])
- times <- sort(unique(c(0,times_xt,dose_times)))
-
- N = length(dose_times)
- regimen = PKPDsim::new_regimen(amt=p[["DOSE"]],n=N,interval=p[["TAU"]])
- design <- PKPDsim::sim(
- ode = pk1cmtoral,
- parameters = c(CL=p[["CL"]],V=p[["V"]],KA=p[["KA"]]),
- regimen = regimen,
- only_obs = TRUE,
- t_obs = times,
- checks = FALSE,
- return_design = TRUE)
- tmp <- PKPDsim::sim_core(sim_object = design, ode = pk1cmtoral)
- y <- tmp$y
- m_tmp <- match(round(times_xt,digits = 6),tmp[,"t"])
- if(any(is.na(m_tmp))){
- stop("can't find time points in solution\n",
- "try changing the digits argument in the match function")
- }
-
- y <- y[m_tmp]
- return(list(y = y, poped.db = poped.db))
-}
The same model written as a set of ODEs using mrgsolve:
-
-code <- '
-$PARAM CL=3.75, V=72.8, KA=0.25
-$CMT DEPOT CENT
-$ODE
-dxdt_DEPOT = -KA*DEPOT;
-dxdt_CENT = KA*DEPOT - (CL/V)*CENT;
-$TABLE double CP = CENT/V;
-$CAPTURE CP
-'
Compile and load the model with mcode
-moda <- mcode("optim", code, atol=1e-8, rtol=1e-8,maxsteps=5000)
-#> Building optim ... done.
-ff_ode_mrg <- function(model_switch, xt, p, poped.db){
- times_xt <- drop(xt)
- dose_times <- seq(from=0,to=max(times_xt),by=p[["TAU"]])
- time <- sort(unique(c(0,times_xt,dose_times)))
- is.dose <- time %in% dose_times
-
- data <-
- tibble::tibble(ID = 1,
- time = time,
- amt = ifelse(is.dose,p[["DOSE"]], 0),
- cmt = ifelse(is.dose, 1, 0),
- evid = cmt,
- CL = p[["CL"]], V = p[["V"]], KA = p[["KA"]])
-
- out <- mrgsim_q(moda, data=data)
-
- y <- out$CP
-
- y <- y[match(times_xt,out$time)]
-
- return(list(y=matrix(y,ncol=1),poped.db=poped.db))
-
-}
The model written for RxODE:
-
-modrx <- rxode2({
- d/dt(DEPOT) = -KA*DEPOT;
- d/dt(CENT) = KA*DEPOT - (CL/V)*CENT;
- CP=CENT/V;
-})
-ff_ode_rx <- function(model_switch, xt, p, poped.db){
- times_xt <- drop(xt)
- et(0,amt=p[["DOSE"]], ii=p[["TAU"]], until=max(times_xt)) %>%
- et(times_xt) -> data
-
- out <- rxSolve(modrx, p, data, atol=1e-8, rtol=1e-8,maxsteps=5000,
- returnType="data.frame")
-
- y <- out$CP[match(times_xt,out$time)]
-
- return(list(y=matrix(y,ncol=1),poped.db=poped.db))
-
-}
Other functions are used to define BSV and RUV.
-
-
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(
- KA=bpop[1]*exp(b[1]),
- CL=bpop[2]*exp(b[2]),
- V=bpop[3]*exp(b[3]),
- DOSE=a[1],
- TAU=a[2])
- return( parameters )
-}
-
-feps <- function(model_switch,xt,parameters,epsi,poped.db){
- f <- do.call(poped.db$model$ff_pointer,list(model_switch,xt,parameters,poped.db))[[1]]
- y = f*(1+epsi[,1])+epsi[,2]
- return(list(y=y,poped.db=poped.db))
-}
Next we define the model to use, the parameters of those models, the -intial design design and design space for any design calculation. Here -we create a number of databases that correspond to different model -implementations.
-The initial design is a 2 group design, with doses of 20 mg or 40 mg -every 24 hours. Each group has the same sampling schedule, with 3 -samples in the first day of the study and 2 on the 10th day of the -study.
-
-poped_db_analytic <- create.poped.database(ff_fun =ff_analytic,
- fg_fun =sfg,
- fError_fun=feps,
- bpop=c(KA=0.25,CL=3.75,V=72.8),
- d=c(KA=0.09,CL=0.25^2,V=0.09),
- sigma=c(prop=0.04,add=0.0025),
- m=2,
- groupsize=20,
- xt=c( 1,2,8,240,245),
- minxt=c(0,0,0,240,240),
- maxxt=c(10,10,10,248,248),
- bUseGrouped_xt=1,
- a=cbind(DOSE=c(20,40),TAU=c(24,24)),
- maxa=c(DOSE=200,TAU=24),
- mina=c(DOSE=0,TAU=24))
-
-
-poped_db_ode_desolve <- create.poped.database(poped_db_analytic,ff_fun = ff_ode_desolve)
-poped_db_ode_desolve_c <- create.poped.database(poped_db_analytic,ff_fun = ff_ode_desolve_c)
-poped_db_ode_desolve_rcpp <- create.poped.database(poped_db_analytic,ff_fun = ff_ode_desolve_rcpp)
-poped_db_ode_pkpdsim <- create.poped.database(poped_db_analytic,ff_fun = ff_ode_pkpdsim)
-poped_db_ode_mrg <- create.poped.database(poped_db_analytic,ff_fun = ff_ode_mrg)
-poped_db_ode_rx <- create.poped.database(poped_db_analytic,ff_fun = ff_ode_rx)
So are there difference in the model predictions between the -different implementations?
-Here is a visual representation of the model predictions for this -study design, based on the analytic solution:
-
-plot_model_prediction(poped_db_analytic,model_num_points = 500,PI=T,separate.groups = T)
We can compare the different predictions in this plot accross model -implementations. Here we see that the accuracy of the different methods -are within machine precision (or very small).
-
-pred_std <- model_prediction(poped_db_analytic,model_num_points = 500,include_sample_times = TRUE,PI = TRUE)
-
-pred_ode_desolve <- model_prediction(poped_db_ode_desolve,
- model_num_points = 500,
- include_sample_times = TRUE,
- PI = TRUE)
-all.equal(pred_std,pred_ode_desolve)
-#> [1] TRUE
-
-pred_ode_desolve_c <- model_prediction(poped_db_ode_desolve_c,
- model_num_points = 500,
- include_sample_times = TRUE,
- PI = TRUE)
-all.equal(pred_std,pred_ode_desolve_c)
-#> [1] TRUE
-
-pred_ode_desolve_rcpp <- model_prediction(poped_db_ode_desolve_rcpp,
- model_num_points = 500,
- include_sample_times = TRUE,
- PI = TRUE)
-all.equal(pred_std,pred_ode_desolve_rcpp)
-#> [1] TRUE
-
-pred_ode_pkpdsim <- model_prediction(poped_db_ode_pkpdsim,
- model_num_points = 500,
- include_sample_times = TRUE,
- PI = TRUE)
-all.equal(pred_std,pred_ode_pkpdsim)
-#> [1] "Component \"PI_l\": Mean relative difference: 1.998475e-08"
-
-pred_ode_mrg <- model_prediction(poped_db_ode_mrg,
- model_num_points = 500,
- include_sample_times = TRUE,
- PI = TRUE)
-all.equal(pred_std,pred_ode_mrg)
-#> [1] TRUE
-
-pred_ode_rx <- model_prediction(poped_db_ode_rx,
- model_num_points = 500,
- include_sample_times = TRUE,
- PI = TRUE)
-all.equal(pred_std,pred_ode_rx)
-#> [1] TRUE
Here we compare the computation of the Fisher Information Matrix -(FIM). By comparing the \(ln(det(FIM))\) (the lnD-objective function -value, or ofv).
-
-(eval_std <- evaluate_design(poped_db_analytic))
-#> $ofv
-#> [1] 48.98804
-#>
-#> $fim
-#> KA CL V d_KA d_CL d_V
-#> KA 1695.742314 -11.73537527 -6.75450789 0.00000 0.00000 0.00000
-#> CL -11.735375 29.99735715 -0.03288331 0.00000 0.00000 0.00000
-#> V -6.754508 -0.03288331 0.04213359 0.00000 0.00000 0.00000
-#> d_KA 0.000000 0.00000000 0.00000000 147.24270 1.52226 192.23403
-#> d_CL 0.000000 0.00000000 0.00000000 1.52226 2254.55188 1.21987
-#> d_V 0.000000 0.00000000 0.00000000 192.23403 1.21987 634.42055
-#> sig_prop 0.000000 0.00000000 0.00000000 148.86724 844.57325 387.53816
-#> sig_add 0.000000 0.00000000 0.00000000 6555.68433 14391.88132 8669.58391
-#> sig_prop sig_add
-#> KA 0.0000 0.000
-#> CL 0.0000 0.000
-#> V 0.0000 0.000
-#> d_KA 148.8672 6555.684
-#> d_CL 844.5733 14391.881
-#> d_V 387.5382 8669.584
-#> sig_prop 7759.5374 110702.705
-#> sig_add 110702.7045 4436323.946
-#>
-#> $rse
-#> KA CL V d_KA d_CL d_V sig_prop
-#> 16.285678 4.909749 11.209270 120.825798 34.448477 57.300408 36.104027
-#> sig_add
-#> 24.339781
All the computations give very similar results:
-
-eval_ode_desolve <- evaluate_design(poped_db_ode_desolve)
-all.equal(eval_std$ofv,eval_ode_desolve$ofv)
-#> [1] "Mean relative difference: 5.044611e-08"
-
-eval_ode_desolve_c <- evaluate_design(poped_db_ode_desolve_c)
-all.equal(eval_std$ofv,eval_ode_desolve_c$ofv)
-#> [1] "Mean relative difference: 5.112116e-08"
-
-eval_ode_desolve_rccp <- evaluate_design(poped_db_ode_desolve_rcpp)
-all.equal(eval_std$ofv,eval_ode_desolve_rccp$ofv)
-#> [1] "Mean relative difference: 5.112116e-08"
-
-eval_ode_pkpdsim <- evaluate_design(poped_db_ode_pkpdsim)
-all.equal(eval_std$ofv,eval_ode_pkpdsim$ofv)
-#> [1] TRUE
-
-eval_ode_mrg <- evaluate_design(poped_db_ode_mrg)
-all.equal(eval_std$ofv,eval_ode_mrg$ofv)
-#> [1] "Mean relative difference: 2.388152e-08"
We can compare the speed of the computations. Analytic solutions are -fast, as expected, in this case more than 20 times faster than any of -the ODE methods. mrgsolve is the fastest of the ODE solvers in this -example. Note that much of the speed difference between mrgsolve, RxODE -and PKPDsim has been found to be due to the overhead from pre- and -post-processing of the simulation from ODE systems. Other ways of -handling the pre- and post-processing may speed up these -computations.
-
-library(microbenchmark)
-library(ggplot2)
-
-compare <- microbenchmark(
- evaluate_design(poped_db_analytic),
- evaluate_design(poped_db_ode_desolve),
- evaluate_design(poped_db_ode_desolve_c),
- evaluate_design(poped_db_ode_desolve_rcpp),
- evaluate_design(poped_db_ode_pkpdsim),
- evaluate_design(poped_db_ode_mrg),
- evaluate_design(poped_db_ode_rx),
- times = 100L)
-
-autoplot(compare)
-devtools::session_info()
-#> ─ Session info ───────────────────────────────────────────────────────────────
-#> setting value
-#> version R version 4.3.2 (2023-10-31)
-#> os macOS Ventura 13.6.2
-#> system aarch64, darwin20
-#> ui X11
-#> language en
-#> collate en_US.UTF-8
-#> ctype en_US.UTF-8
-#> tz Europe/Stockholm
-#> date 2023-11-09
-#> pandoc 3.1.1 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/ (via rmarkdown)
-#>
-#> ─ Packages ───────────────────────────────────────────────────────────────────
-#> ! package * version date (UTC) lib source
-#> backports 1.4.1 2021-12-13 [1] CRAN (R 4.3.0)
-#> bookdown 0.36 2023-10-16 [1] CRAN (R 4.3.1)
-#> boot 1.3-28.1 2022-11-22 [1] CRAN (R 4.3.2)
-#> brio 1.1.3 2021-11-30 [1] CRAN (R 4.3.0)
-#> bslib 0.5.1 2023-08-11 [1] CRAN (R 4.3.0)
-#> cachem 1.0.8 2023-05-01 [1] CRAN (R 4.3.0)
-#> callr 3.7.3 2022-11-02 [1] CRAN (R 4.3.0)
-#> checkmate 2.3.0 2023-10-25 [1] CRAN (R 4.3.1)
-#> cli 3.6.1 2023-03-23 [1] CRAN (R 4.3.0)
-#> codetools 0.2-19 2023-02-01 [1] CRAN (R 4.3.2)
-#> colorspace 2.1-0 2023-01-23 [1] CRAN (R 4.3.0)
-#> crayon 1.5.2 2022-09-29 [1] CRAN (R 4.3.0)
-#> data.table 1.14.8 2023-02-17 [1] CRAN (R 4.3.0)
-#> desc 1.4.2 2022-09-08 [1] CRAN (R 4.3.0)
-#> deSolve * 1.38 2023-09-05 [1] CRAN (R 4.3.0)
-#> devtools 2.4.5 2022-10-11 [1] CRAN (R 4.3.0)
-#> digest 0.6.33 2023-07-07 [1] CRAN (R 4.3.0)
-#> dparser 1.3.1-10 2023-03-16 [1] CRAN (R 4.3.0)
-#> dplyr 1.1.3 2023-09-03 [1] CRAN (R 4.3.0)
-#> ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.3.0)
-#> evaluate 0.23 2023-11-01 [1] CRAN (R 4.3.1)
-#> fansi 1.0.5 2023-10-08 [1] CRAN (R 4.3.1)
-#> fastmap 1.1.1 2023-02-24 [1] CRAN (R 4.3.0)
-#> fs 1.6.3 2023-07-20 [1] CRAN (R 4.3.0)
-#> generics 0.1.3 2022-07-05 [1] CRAN (R 4.3.0)
-#> ggplot2 3.4.4 2023-10-12 [1] CRAN (R 4.3.1)
-#> glue 1.6.2 2022-02-24 [1] CRAN (R 4.3.0)
-#> gtable 0.3.4 2023-08-21 [1] CRAN (R 4.3.0)
-#> gtools 3.9.4 2022-11-27 [1] CRAN (R 4.3.0)
-#> htmltools 0.5.7 2023-11-03 [1] CRAN (R 4.3.1)
-#> htmlwidgets 1.6.2 2023-03-17 [1] CRAN (R 4.3.0)
-#> httpuv 1.6.12 2023-10-23 [1] CRAN (R 4.3.1)
-#> httr 1.4.7 2023-08-15 [1] CRAN (R 4.3.0)
-#> jquerylib 0.1.4 2021-04-26 [1] CRAN (R 4.3.0)
-#> jsonlite 1.8.7 2023-06-29 [1] CRAN (R 4.3.0)
-#> kableExtra * 1.3.4 2021-02-20 [1] CRAN (R 4.3.0)
-#> knitr * 1.45 2023-10-30 [1] CRAN (R 4.3.1)
-#> later 1.3.1 2023-05-02 [1] CRAN (R 4.3.0)
-#> lattice 0.22-5 2023-10-24 [1] CRAN (R 4.3.1)
-#> lifecycle 1.0.3 2022-10-07 [1] CRAN (R 4.3.0)
-#> lotri 0.4.3 2023-03-20 [1] CRAN (R 4.3.0)
-#> magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.3.0)
-#> MASS 7.3-60 2023-05-04 [1] CRAN (R 4.3.2)
-#> memoise 2.0.1 2021-11-26 [1] CRAN (R 4.3.0)
-#> mime 0.12 2021-09-28 [1] CRAN (R 4.3.0)
-#> miniUI 0.1.1.1 2018-05-18 [1] CRAN (R 4.3.0)
-#> mrgsolve * 1.1.1 2023-08-16 [1] CRAN (R 4.3.0)
-#> munsell 0.5.0 2018-06-12 [1] CRAN (R 4.3.0)
-#> mvtnorm 1.2-3 2023-08-25 [1] CRAN (R 4.3.0)
-#> nlme 3.1-163 2023-08-09 [1] CRAN (R 4.3.2)
-#> pillar 1.9.0 2023-03-22 [1] CRAN (R 4.3.0)
-#> pkgbuild 1.4.2 2023-06-26 [1] CRAN (R 4.3.0)
-#> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.3.0)
-#> pkgdown 2.0.7 2022-12-14 [1] CRAN (R 4.3.0)
-#> pkgload 1.3.3 2023-09-22 [1] CRAN (R 4.3.1)
-#> PKPDsim * 1.3.0 2023-03-02 [1] CRAN (R 4.3.0)
-#> P PopED * 0.6.0.9002 2023-11-08 [?] load_all()
-#> PreciseSums 0.6 2023-04-22 [1] CRAN (R 4.3.0)
-#> prettyunits 1.2.0 2023-09-24 [1] CRAN (R 4.3.1)
-#> processx 3.8.2 2023-06-30 [1] CRAN (R 4.3.0)
-#> profvis 0.3.8 2023-05-02 [1] CRAN (R 4.3.0)
-#> promises 1.2.1 2023-08-10 [1] CRAN (R 4.3.0)
-#> ps 1.7.5 2023-04-18 [1] CRAN (R 4.3.0)
-#> purrr 1.0.2 2023-08-10 [1] CRAN (R 4.3.0)
-#> qs 0.25.5 2023-02-22 [1] CRAN (R 4.3.0)
-#> R6 2.5.1 2021-08-19 [1] CRAN (R 4.3.0)
-#> ragg 1.2.6 2023-10-10 [1] CRAN (R 4.3.1)
-#> RApiSerialize 0.1.2 2022-08-25 [1] CRAN (R 4.3.0)
-#> Rcpp * 1.0.11 2023-07-06 [1] CRAN (R 4.3.0)
-#> RcppParallel 5.1.7 2023-02-27 [1] CRAN (R 4.3.0)
-#> remotes 2.4.2.1 2023-07-18 [1] CRAN (R 4.3.0)
-#> rlang 1.1.1 2023-04-28 [1] CRAN (R 4.3.0)
-#> rmarkdown 2.25 2023-09-18 [1] CRAN (R 4.3.1)
-#> rprojroot 2.0.3 2022-04-02 [1] CRAN (R 4.3.0)
-#> rstudioapi 0.15.0 2023-07-07 [1] CRAN (R 4.3.0)
-#> rvest 1.0.3 2022-08-19 [1] CRAN (R 4.3.0)
-#> rxode2 * 2.0.14 2023-10-07 [1] CRAN (R 4.3.1)
-#> rxode2et 2.0.10 2023-03-17 [1] CRAN (R 4.3.0)
-#> rxode2parse 2.0.16 2023-03-28 [1] CRAN (R 4.3.0)
-#> rxode2random 2.0.11 2023-03-28 [1] CRAN (R 4.3.0)
-#> sass 0.4.7 2023-07-15 [1] CRAN (R 4.3.0)
-#> scales 1.2.1 2022-08-20 [1] CRAN (R 4.3.0)
-#> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.3.0)
-#> shiny 1.7.5.1 2023-10-14 [1] CRAN (R 4.3.1)
-#> stringfish 0.15.8 2023-05-30 [1] CRAN (R 4.3.0)
-#> stringi 1.7.12 2023-01-11 [1] CRAN (R 4.3.0)
-#> stringr 1.5.0 2022-12-02 [1] CRAN (R 4.3.0)
-#> svglite 2.1.2 2023-10-11 [1] CRAN (R 4.3.1)
-#> sys 3.4.2 2023-05-23 [1] CRAN (R 4.3.0)
-#> systemfonts 1.0.5 2023-10-09 [1] CRAN (R 4.3.1)
-#> testthat * 3.2.0 2023-10-06 [1] CRAN (R 4.3.1)
-#> textshaping 0.3.7 2023-10-09 [1] CRAN (R 4.3.1)
-#> tibble 3.2.1 2023-03-20 [1] CRAN (R 4.3.0)
-#> tidyselect 1.2.0 2022-10-10 [1] CRAN (R 4.3.0)
-#> urlchecker 1.0.1 2021-11-30 [1] CRAN (R 4.3.0)
-#> usethis 2.2.2 2023-07-06 [1] CRAN (R 4.3.0)
-#> utf8 1.2.4 2023-10-22 [1] CRAN (R 4.3.1)
-#> vctrs 0.6.4 2023-10-12 [1] CRAN (R 4.3.1)
-#> viridisLite 0.4.2 2023-05-02 [1] CRAN (R 4.3.0)
-#> webshot 0.5.5 2023-06-26 [1] CRAN (R 4.3.0)
-#> withr 2.5.2 2023-10-30 [1] CRAN (R 4.3.1)
-#> xfun 0.41 2023-11-01 [1] CRAN (R 4.3.1)
-#> xml2 1.3.5 2023-07-06 [1] CRAN (R 4.3.0)
-#> xtable 1.8-4 2019-04-21 [1] CRAN (R 4.3.0)
-#> yaml 2.3.7 2023-01-23 [1] CRAN (R 4.3.0)
-#>
-#> [1] /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library
-#>
-#> P ── Loaded and on-disk path mismatch.
-#>
-#> ──────────────────────────────────────────────────────────────────────────────
-#sessionInfo()
GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007
-Copyright (C) 2007 Free Software Foundation, Inc. http://fsf.org/ Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
-This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.
-As used herein, “this License” refers to version 3 of the GNU Lesser General Public License, and the “GNU GPL” refers to version 3 of the GNU General Public License.
-“The Library” refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.
-An “Application” is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.
-A “Combined Work” is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the “Linked Version”.
-The “Minimal Corresponding Source” for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.
-The “Corresponding Application Code” for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.
-You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.
-If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:
-a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or
-b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.
-The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:
-a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.
-b) Accompany the object code with a copy of the GNU GPL and this license document.
-You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:
-a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.
-b) Accompany the Combined Work with a copy of the GNU GPL and this license document.
-c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.
-d) Do one of the following:
- 0) Convey the Minimal Corresponding Source under the terms of this
- License, and the Corresponding Application Code in a form
- suitable for, and under terms that permit, the user to
- recombine or relink the Application with a modified version of
- the Linked Version to produce a modified Combined Work, in the
- manner specified by section 6 of the GNU GPL for conveying
- Corresponding Source.
-
- 1) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (a) uses at run time
- a copy of the Library already present on the user's computer
- system, and (b) will operate properly with a modified version
- of the Library that is interface-compatible with the Linked
- Version.
e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)
-You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:
-a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.
-b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
-The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
-Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation.
-If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy’s public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.
- - -PopED computes optimal experimental designs for both population and individual studies based on nonlinear mixed-effect models. Often this is based on a computation of the Fisher Information Matrix (FIM).
-You need to have R installed. Download the latest version of R from www.r-project.org. You can install the released version of PopED from CRAN with:
- -And the development version from GitHub with:
- -To get started you need to define
-Learn more in this introduction to PopED
-You are welcome to:
-PopED computes optimal experimental designs for both population and individual studies based on nonlinear mixed-effect models. Often this is based on a computation of the Fisher Information Matrix (FIM).
-You need to have R installed. Download the latest version of R from www.r-project.org. You can install the released version of PopED from CRAN with:
-
-install.packages("PopED")
And the development version from GitHub with:
-
-# install.packages("devtools")
-devtools::install_github("andrewhooker/PopED")
To get started you need to define
-Learn more in this introduction to PopED
-You are welcome to:
-NEWS.md
- Added the options allow_replicates=TRUE/FALSE
, allow_replicates_xt=TRUE/FALSE
and allow_replicates_a=TRUE/FALSE
to poped_optim
. This allows the optimization algorithm to avoid replicates (or not) in the design components. Currently only works for discrete variable optimization. Future versions will also handle continuous optimization.
Exported a function for the computation of the Bayesian Fisher information matrix for individual parameters of a population model based on Maximum A Posteriori (MAP) estimation of the empirical Bayes estimates (EBEs) in a population model. See ?evaluate_fim_map
for more details.
Allowing for no covariates in the function that automatically builds a PopED parameter function from a model function (?build_sfg
).
Updates to documentation and package testing.
Minor bug fixes.
Added the ability to incorporate limit of quantification information into FIM calculations (both upper and lower limits). See the new vignette on the webpage https://andrewhooker.github.io/PopED/articles/handling_loq.html
Adding functionality to optimize groupsize and total size of the study. See ?optimize_groupsize
, `?optimize_n_eff
and ?optimize_n_rse
. This is also implemented in poped_optim
through the opt_inds=T
argument.
Updating Vignettes, including a new one about using other tools to use as simulators for design computations. See https://andrewhooker.github.io/PopED/articles/model_def_other_pkgs.html
Simplify RxODE syntax in the above vingette (#47, @mattfidler).
Added the ability to predict and plot model prediction intervals by computing the expected variance (using an FO approximation) and then computing a prediction interval based on an assumption of normality. See ?model_prediciton
and ?plot_model_prediction
. The computation is faster but less accurate compared to using DV=TRUE
(and groupsize_sim = 500
) in the two functions.
Named parameters are now passed to all calculations so that the FIM and RSE output is more readable with parameter names instead of default names.
Allow for parallel computation in plot_efficiency_of_windows
(#50).
Make parallelization work with mrgsolve on windows (#37, #45, #46, #51, @Vincent-AC).
Updated the function for automatic building of parameter model function (see build_sfg
).
Simplify derivative calculations (#34, @martin-gmx).
Allow for only simulating model_switch > 1 models.
Change the defult Ds calculation to be on log scale.
Updated the website at https://andrewhooker.github.io/PopED
Remove options for discontinued dplyr commands rbind_all
and rbind_list
.
Minor bug fixes in shrinkage calculations (#44, #39, @martin-gmx).
New and improved vignettes (#30, @giulialestini)!
Added power evaluation script to test the power of a design to identify a parameter different than an assumed value. The function also calculates the number of individuals needed in a design to have a specific power. See ?evaluate_power
for more information (#26, @martin-gmx).
Added function to compute expected shrinkage of a design. See ?shrinkage
for more information.
Updated and added new example scripts in system.file("examples", package="PopED")
(). This includes an example describing how to handle covariate distributions in optimal design, an example on how to incorporate IOV, an example on how to handle shrinkage, an example with a full covariance matrix and an example with a prior FIM (#30, @giulialestini and @martin-gmx).
Major overhaul in optimization methods used in poped_optim()
so that generic optimization routines like optim()
can be easily used in optimizing PopED designs.
Update speed of FIM calculations (#20, @martin-gmx).
Update RSE calculations so that prior FIM is handled correctly (#22, @martin-gmx).
Simplified code and removed duplicated code (#21, #24 and #32, @martin-gmx).
New ways of handling inverting matricies, should be faster and work better when the matricies are ill-conditioned. See ?inv
for more information (#19, @martin-gmx).
Updated functionality of IOV calculations.
Updates to optim_ARS()
for when to stop search.
Extended functionality of plot.model.prediction()
(#23, @martin-gmx).
Bug fixing. See https://github.com/andrewhooker/PopED/commits/master for more information.
Exported the summary
method for the results of poped_optim
in the PopED NAMESPACE, so that the method can actually be used! Just use summary(output)
.
Fixed some old bugs that used return
as a varible in functions, a la MATLAB.
Added a vignette to introduce PopED!
Improved optimization with poped_optim
, plus all example scripts now running with poped_optim
.
Update to more easily allow discrete optimization of xt and a variables. See the example scripts.
Added a summary method for the results of poped_optim
. Just use summary(output)
.
changed handling of seed numbers in optimizations.
more robust handling of non-population models
more natural handling of NA values in design vectors
NAMESPACE: removed ggplot2 from “Depends” and added to “Imports”
Added mean line to efficiency plots.
Update to computation and error handling for Laplace approximation to ED objective function.
Added more intuitive cost function input. See examples in ?poped_optim
Various small changes and bug fixes.
Added new optimization methods and tools, see ?poped_optim()
. This function incorporates the new optimization routines optim_ARS()
and optim_LS
which are optimized versions of previous optimization algorithms used in PopED. Both can be run with parallelization. poped_optim()
also incorporates the genetic algorithm from GA::ga()
, which can also be run with parallelization, and the “L-BFGS-B” method from stats::optim()
. poped_optim()
should be more efficient and faster than poped_optimize()
.
Changed the default objective function to be the log of the determinant of the FIM. create.poped.database(ofv_calc_type=4)
Various small changes and bug fixes.
Fixed plot_efficiency_of_windows()
bug that had wrong headers on each subplot.
Fixed bug in plot_model_prediction()
that did not plot the optimized design, but instead the initial design
Reorganized the database created from create.poped.database()
. The output from this function is now a list with 5 sub-lists: design, design_space, model, parameters and settings. Also removed duplicate entries in the database for easier manipulation. This will cause some back compatibility issues when referring to elements in a database.
Added example 10 describing a PKPD design of hepatitis C virus (HCV) kinetics to the system.file("examples",package="PopED")
directory of the PopED installation.
Updated model_prediction() to allow for creation of NONMEM datasets.
-Useful for testing of optimized designs via PsN’s (http://psn.sf.net) SSE tool, for example.
Two new functions create_design() and create_design_space() that allow for design and design space creation without the need for a model or parameter values.
Updated the create.poped.database() function to use create_design() and create_design_space()
Added examples for evaluation and optimization of a one-target quasi-steady-state target mediated drug disposition model (TMDD) to the system.file(“examples”,package=“PopED”) directory of the PopED installation.
Added a 2-compartment, oral absorption, multiple dose example to the system.file(“examples”, package=“PopED”) directory of the PopED installation.
Updated plot_efficiency_of_windows() to allow for the plotting of the RSE of each parameter on the y-axis.
Updated error handing for the Laplace approximation of the ED OFV.
Fixed bug when computing FIM with only one BSV term present in model (calculation gave an error).
Fixed a bug in plot_model_predictions where an error was returned if not all time values in the xt matrix were to be used for the design calculation (ni is different from size(xt,2), see ?create_poped_database).
Various small bug fixes.
Updated package author list
New functionality to compute the ED OFV using the Laplace approximation. This can be orders of magnitude faster than the standard MC integration approach. See ‘?ed_laplace_ofv’ and ‘?evaluate.e.ofv.fim’
Added a general function to compute the FIM and OFV(FIM) for all available methods in PopED. See ‘?calc_ofv_and_fim’.
Added a general optimization algorithm ‘RS_opt_gen()’ that works for both D-family and E-family optimization.
Added optimization of E-family designs to ‘poped_optimize()’.
Changed distribution tests for package building
Fixed bug where correlations between BSV (between subject variability) terms in the model gave an error when creating a PopED database
Fixed a bug where get_rse failed when a parameter had a value of 3.
Optimize the objective function. There are 4 different optimization -algorithms used in this function
Adaptive random search.
-See RS_opt
.
Stochastic gradient.
A Broyden Fletcher -Goldfarb Shanno (BFGS) method for nonlinear minimization with box -constraints.
A line search. See a_line_search
.
The
-optimization algorithms run in series, taking as input the output from the
-previous method. The stopping rule used is to test if the line search
-algorithm fids a better optimum then its initial value. If so, then the chain
-of algorithms is run again. If line search is not used then the argument
-iter_tot
defines the number of times the chain of algorithms is run.
-This function takes information from the PopED database supplied as an
-argument. The PopED database supplies information about the the model,
-parameters, design and methods to use. Some of the arguments coming from the
-PopED database can be overwritten; if they are supplied then they are used
-instead of the arguments from the PopED database.
Doptim(
- poped.db,
- ni,
- xt,
- model_switch,
- x,
- a,
- bpopdescr,
- ddescr,
- maxxt,
- minxt,
- maxa,
- mina,
- fmf = 0,
- dmf = 0,
- trflag = TRUE,
- bUseRandomSearch = poped.db$settings$bUseRandomSearch,
- bUseStochasticGradient = poped.db$settings$bUseStochasticGradient,
- bUseBFGSMinimizer = poped.db$settings$bUseBFGSMinimizer,
- bUseLineSearch = poped.db$settings$bUseLineSearch,
- sgit = poped.db$settings$sgit,
- ls_step_size = poped.db$settings$ls_step_size,
- BFGSConvergenceCriteriaMinStep = poped.db$settings$BFGSConvergenceCriteriaMinStep,
- BFGSProjectedGradientTol = poped.db$settings$BFGSProjectedGradientTol,
- BFGSTolerancef = poped.db$settings$BFGSTolerancef,
- BFGSToleranceg = poped.db$settings$BFGSToleranceg,
- BFGSTolerancex = poped.db$settings$BFGSTolerancex,
- iter_tot = poped.db$settings$iNumSearchIterationsIfNotLineSearch,
- iter_max = 10,
- ...
-)
A PopED database.
A vector of the number of samples in each group.
A matrix of sample times. Each row is a vector of sample times for a group.
A matrix that is the same size as xt, specifying which model each sample belongs to.
A matrix for the discrete design variables. Each row is a group.
A matrix of covariates. Each row is a group.
Matrix defining the fixed effects, per row (row number = -parameter_number) we should have:
column 1 the type of the -distribution for E-family designs (0 = Fixed, 1 = Normal, 2 = Uniform, 3 = -User Defined Distribution, 4 = lognormal and 5 = truncated normal)
column 2 defines the mean.
column 3 defines the variance of the -distribution (or length of uniform distribution).
Matrix defining the diagonals of the IIV (same logic as for
-the bpopdescr
).
Matrix or single value defining the maximum value for each xt sample. If a single value is -supplied then all xt values are given the same maximum value.
Matrix or single value defining the minimum value for each xt sample. If a single value is -supplied then all xt values are given the same minimum value
Vector defining the max value for each covariate. If a single value is supplied then -all a values are given the same max value
Vector defining the min value for each covariate. If a single value is supplied then -all a values are given the same max value
The initial value of the FIM. If set to zero then it is computed.
The initial OFV. If set to zero then it is computed.
Should the optimization be output to the screen and to a file?
******START OF Optimization algorithm SPECIFICATION OPTIONS**********
Use random search (1=TRUE, 0=FALSE)
Use Stochastic Gradient search (1=TRUE, 0=FALSE)
Use BFGS Minimizer (1=TRUE, 0=FALSE)
Use Line search (1=TRUE, 0=FALSE)
Number of stochastic gradient iterations
Number of grid points in the line search.
BFGS Minimizer Convergence Criteria Minimum Step
BFGS Minimizer Convergence Criteria Normalized Projected Gradient Tolerance
BFGS Minimizer Line Search Tolerance f
BFGS Minimizer Line Search Tolerance g
BFGS Minimizer Line Search Tolerance x
Number of iterations to use if line search is not used. Must
-be less than iter_max
to be used.
If line search is used then the algorithm tests if line
-search (always run at the end of the optimization iteration) changes the
-design in any way. If not, the algorithm stops. If yes, then a new
-iteration is run unless iter_max
iterations have already been run.
arguments passed to evaluate.fim
and ofv_fim
.
M. Foracchia, A.C. Hooker, P. Vicini and A. - Ruggeri, "PopED, a software for optimal experimental design in population - kinetics", Computer Methods and Programs in Biomedicine, 74, 2004.
J. - Nyberg, S. Ueckert, E.A. Stroemberg, S. Hennig, M.O. Karlsson and A.C. - Hooker, "PopED: An extended, parallelized, nonlinear mixed effects models - optimal design tool", Computer Methods and Programs in Biomedicine, 108, - 2012.
Other Optimize:
-LEDoptim()
,
-RS_opt()
,
-a_line_search()
,
-bfgsb_min()
,
-calc_autofocus()
,
-calc_ofv_and_grad()
,
-mfea()
,
-optim_ARS()
,
-optim_LS()
,
-poped_optim_1()
,
-poped_optim_2()
,
-poped_optim_3()
,
-poped_optimize()
,
-poped_optim()
library(PopED)
-
-############# START #################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## Optimization using an additive + proportional reidual error
-## to avoid sample times at very low concentrations (time 0 or very late samples).
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(prop=0.01,add=0.25),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0.01,
- maxxt=120,
- a=c(DOSE=70),
- mina=c(DOSE=0.01),
- maxa=c(DOSE=100))
-
-############# END ###################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-
-if (FALSE) {
-
- ##############
- # typically one will use poped_optimize
- # This then calls Doptim for continuous optimization problems
- ##############
-
-
- # RS+SG+LS optimization of sample times
- # optimization with just a few iterations
- # only to check that things are working
- output <- poped_optimize(poped.db,opt_xt=T,
- rsit=5,sgit=5,ls_step_size=5)
-
- # RS+SG+LS optimization of sample times
- # (longer run time than above but more likely to reach a maximum)
- output <- poped_optimize(poped.db,opt_xt=T)
- get_rse(output$fmf,output$poped.db)
- plot_model_prediction(output$poped.db)
-
-
- # Random search (just a few samples here)
- rs.output <- poped_optimize(poped.db,opt_xt=1,opt_a=1,rsit=20,
- bUseRandomSearch= 1,
- bUseStochasticGradient = 0,
- bUseBFGSMinimizer = 0,
- bUseLineSearch = 0)
-
- # line search, DOSE and sample time optimization
- ls.output <- poped_optimize(poped.db,opt_xt=1,opt_a=1,
- bUseRandomSearch= 0,
- bUseStochasticGradient = 0,
- bUseBFGSMinimizer = 0,
- bUseLineSearch = 1,
- ls_step_size=10)
-
- # Stochastic gradient search, DOSE and sample time optimization
- sg.output <- poped_optimize(poped.db,opt_xt=1,opt_a=1,
- bUseRandomSearch= 0,
- bUseStochasticGradient = 1,
- bUseBFGSMinimizer = 0,
- bUseLineSearch = 0,
- sgit=20)
-
- # BFGS search, DOSE and sample time optimization
- bfgs.output <- poped_optimize(poped.db,opt_xt=1,opt_a=1,
- bUseRandomSearch= 0,
- bUseStochasticGradient = 0,
- bUseBFGSMinimizer = 1,
- bUseLineSearch = 0)
-
- ##############
- # If you really want to you can use Doptim dirtectly
- ##############
- dsl <- downsizing_general_design(poped.db)
- poped.db$settings$optsw[2] <- 1 # sample time optimization
- output <- Doptim(poped.db,dsl$ni, dsl$xt, dsl$model_switch, dsl$x, dsl$a,
- dsl$bpop, dsl$d, dsl$maxxt, dsl$minxt,dsl$maxa,dsl$mina)
-
-}
-
-
-
A helper function for writing output to the screen and files when optimizing.
-Dtrace(
- fn,
- it,
- ni,
- xtopt,
- xopt,
- aopt,
- gxt,
- ga,
- dmf,
- diff,
- ixt,
- ia,
- itvector,
- dmfvector,
- poped.db,
- opt_xt = poped.db$settings$optsw[2],
- opt_a = poped.db$settings$optsw[4],
- opt_x = poped.db$settings$optsw[3],
- opt_samps = poped.db$settings$optsw[1],
- opt_inds = poped.db$settings$optsw[5],
- rsit = poped.db$settings$rsit,
- convergence_eps = poped.db$settings$convergence_eps
-)
A file to output information to. Can also be the screen if ''
.
the iteration number.
A vector of the number of samples in each group.
The matrix defining current best sampling schedule.
The cell structure defining the current best discrete design variables.
The matrix defining the current best continuous design variables.
The matrix defining the current gradient of the xt vector.
The matrix defining the current gradient for the continuous design variables.
The current OFV.
The difference from the previous iteration.
If xt Gradient Inversion occurred or not.
If a Gradient Inversion occurred or not.
The iteration vector. Not currently used.
The dmf vector. Not currently used.
A PopED database.
Should the sample times be optimized?
Should the continuous design variables be optimized?
Should the discrete design variables be optimized?
Are the number of sample times per group being optimized?
Are the number of individuals per group being optimized?
Number of Random search iterations
Stochastic Gradient convergence value, -(difference in OFV for D-optimal, difference in gradient for ED-optimal)
library(PopED)
-
-############# START #################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## Optimization using an additive + proportional reidual error
-## to avoid sample times at very low concentrations (time 0 or very late samples).
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(prop=0.01,add=0.25),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0.01,
- maxxt=120,
- a=c(DOSE=70),
- mina=c(DOSE=0.01),
- maxa=c(DOSE=100))
-
-############# END ###################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-
-FIM <- evaluate.fim(poped.db)
-dmf <- det(FIM)
-
-Dtrace(fn="",
- it=1,
- ni=poped.db$design$ni,
- xtopt=poped.db$design$xt,
- xopt=poped.db$design$x,
- aopt=poped.db$design$a,
- gxt=0,ga=0,
- dmf=dmf,diff=3,
- ixt=FALSE,
- ia=FALSE,
- itvector=NULL,
- dmfvector=NULL,
- poped.db,
- opt_xt=poped.db$settings$optsw[2],
- opt_a=poped.db$settings$optsw[4],opt_x=poped.db$settings$optsw[3],
- opt_samps=poped.db$settings$optsw[1],opt_inds=poped.db$settings$optsw[5],
- rsit=200)
-#> RS - It. : 1 OFV : 1.14386e+24
-
-Dtrace(fn="",
- it=1,
- ni=poped.db$design$ni,
- xtopt=poped.db$design$xt,
- xopt=poped.db$design$x,
- aopt=poped.db$design$a,
- gxt=0,ga=0,
- dmf=dmf,diff=3,
- ixt=FALSE,
- ia=FALSE,
- itvector=NULL,
- dmfvector=NULL,
- poped.db,
- opt_xt=poped.db$settings$optsw[2],
- opt_a=poped.db$settings$optsw[4],opt_x=poped.db$settings$optsw[3],
- opt_samps=poped.db$settings$optsw[1],opt_inds=poped.db$settings$optsw[5],
- rsit=0)
-#> SG - It. : 1 OFV : 1.144e+24 Diff. : 3
-
-Dtrace(fn="",
- it=1,
- ni=poped.db$design$ni,
- xtopt=poped.db$design$xt,
- xopt=poped.db$design$x,
- aopt=poped.db$design$a,
- gxt=0,ga=0,
- dmf=dmf,diff=3,
- ixt=FALSE,
- ia=FALSE,
- itvector=NULL,
- dmfvector=NULL,
- poped.db,
- opt_xt=poped.db$settings$optsw[2],
- opt_a=poped.db$settings$optsw[4],opt_x=poped.db$settings$optsw[3],
- opt_samps=poped.db$settings$optsw[1],opt_inds=poped.db$settings$optsw[5],
- rsit=1)
-#> RS - It. : 1 OFV : 1.14386e+24
-#>
-#> *******************************
-#> RS Results
-#> OFV(mf) = 1.14386e+24
-#>
-#> *********************************
-#>
-
-Dtrace(fn="",
- it=1,
- ni=poped.db$design$ni,
- xtopt=poped.db$design$xt,
- xopt=poped.db$design$x,
- aopt=poped.db$design$a,
- gxt=0,ga=0,
- dmf=dmf,
- diff=0,
- ixt=FALSE,
- ia=FALSE,
- itvector=NULL,
- dmfvector=NULL,
- poped.db,
- opt_xt=poped.db$settings$optsw[2],
- opt_a=poped.db$settings$optsw[4],opt_x=poped.db$settings$optsw[3],
- opt_samps=poped.db$settings$optsw[1],opt_inds=poped.db$settings$optsw[5],
- rsit=1)
-#> RS - It. : 1 OFV : 1.14386e+24
-#>
-#> *******************************
-#> RS Results
-#> OFV(mf) = 1.14386e+24
-#>
-#> *********************************
-#>
-
-Dtrace(fn="",
- it=5,
- ni=poped.db$design$ni,
- xtopt=poped.db$design$xt,
- xopt=poped.db$design$x,
- aopt=poped.db$design$a,
- gxt=0,ga=0,
- dmf=dmf,
- diff=0,
- ixt=FALSE,
- ia=FALSE,
- itvector=NULL,
- dmfvector=NULL,
- poped.db,
- opt_xt=poped.db$settings$optsw[2],
- opt_a=poped.db$settings$optsw[4],opt_x=poped.db$settings$optsw[3],
- opt_samps=poped.db$settings$optsw[1],opt_inds=poped.db$settings$optsw[5],
- rsit=1)
-#> SG - It. : 4 OFV : 1.144e+24 Diff. : 0
-#>
-#> SG - Iteration 4 --------- FINAL -------------------------
-#> OFV(mf) : 1.14386e+24
-#> diff : 0
-#> *************************************************************
-
-
R/LEDoptim.R
- LEDoptim.Rd
Optimize the objective function for D-family, E-family and Laplace approximated ED designs. -Right now there is only one optimization algorithm used in this -function
Adaptive random search. See RS_opt
.
This function takes information from the PopED database supplied as an argument. -The PopED database supplies information about the the model, parameters, design and methods to use. -Some of the arguments coming from the PopED database can be overwritten; -if they are supplied then they are used instead of the arguments from the PopED database.
-LEDoptim(
- poped.db,
- model_switch = NULL,
- ni = NULL,
- xt = NULL,
- x = NULL,
- a = NULL,
- bpopdescr = NULL,
- ddescr = NULL,
- maxxt = NULL,
- minxt = NULL,
- maxa = NULL,
- mina = NULL,
- ofv_init = 0,
- fim_init = 0,
- trflag = TRUE,
- header_flag = TRUE,
- footer_flag = TRUE,
- opt_xt = poped.db$settings$optsw[2],
- opt_a = poped.db$settings$optsw[4],
- opt_x = poped.db$settings$optsw[3],
- out_file = NULL,
- d_switch = FALSE,
- use_laplace = T,
- laplace.fim = FALSE,
- use_RS = poped.db$settings$bUseRandomSearch,
- ...
-)
A PopED database.
A matrix that is the same size as xt, specifying which model each sample belongs to.
A vector of the number of samples in each group.
A matrix of sample times. Each row is a vector of sample times for a group.
A matrix for the discrete design variables. Each row is a group.
A matrix of covariates. Each row is a group.
Matrix defining the fixed effects, per row (row number = -parameter_number) we should have:
column 1 the type of the -distribution for E-family designs (0 = Fixed, 1 = Normal, 2 = Uniform, 3 = -User Defined Distribution, 4 = lognormal and 5 = truncated normal)
column 2 defines the mean.
column 3 defines the variance of the -distribution (or length of uniform distribution).
Matrix defining the diagonals of the IIV (same logic as for
-the bpopdescr
).
Matrix or single value defining the maximum value for each xt sample. If a single value is -supplied then all xt values are given the same maximum value.
Matrix or single value defining the minimum value for each xt sample. If a single value is -supplied then all xt values are given the same minimum value
Vector defining the max value for each covariate. If a single value is supplied then -all a values are given the same max value
Vector defining the min value for each covariate. If a single value is supplied then -all a values are given the same max value
The initial OFV. If set to zero then it is computed.
The initial value of the FIM. If set to zero then it is computed.
Should the optimization be output to the screen and to a file?
Should the header text be printed out?
Should the footer text be printed out?
Should the sample times be optimized?
Should the continuous design variables be optimized?
Should the discrete design variables be optimized?
Which file should the output be directed to? A string, a file handle using
-file
or ""
will output to the screen.
******START OF CRITERION SPECIFICATION OPTIONS**********
D-family design (1) or ED-family design (0) (with or without parameter uncertainty)
Should the Laplace method be used in calculating the expectation of the OFV?
Should an E(FIM) be calculated when computing the Laplace approximated E(OFV). Typically -the FIM does not need to be computed and, if desired, this calculation -is done using the standard MC integration technique, so can be slow.
should the function use a random search algorithm?
arguments passed to evaluate.fim
and ofv_fim
.
Other Optimize:
-Doptim()
,
-RS_opt()
,
-a_line_search()
,
-bfgsb_min()
,
-calc_autofocus()
,
-calc_ofv_and_grad()
,
-mfea()
,
-optim_ARS()
,
-optim_LS()
,
-poped_optim_1()
,
-poped_optim_2()
,
-poped_optim_3()
,
-poped_optimize()
,
-poped_optim()
library(PopED)
-
-############# START #################
-## Create PopED database
-## (warfarin model for optimization
-## with parameter uncertainty)
-#####################################
-
-## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## Optimization using an additive + proportional reidual error
-## to avoid sample times at very low concentrations (time 0 or very late samoples).
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-# Adding 10% log-normal Uncertainty to fixed effects (not Favail)
-bpop_vals <- c(CL=0.15, V=8, KA=1.0, Favail=1)
-bpop_vals_ed_ln <- cbind(ones(length(bpop_vals),1)*4, # log-normal distribution
- bpop_vals,
- ones(length(bpop_vals),1)*(bpop_vals*0.1)^2) # 10% of bpop value
-bpop_vals_ed_ln["Favail",] <- c(0,1,0)
-bpop_vals_ed_ln
-#> bpop_vals
-#> CL 4 0.15 0.000225
-#> V 4 8.00 0.640000
-#> KA 4 1.00 0.010000
-#> Favail 0 1.00 0.000000
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- bpop=bpop_vals_ed_ln,
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(0.01,0.25),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0,
- maxxt=120,
- a=70,
- mina=0,
- maxa=100)
-
-############# END ###################
-## Create PopED database
-## (warfarin model for optimization
-## with parameter uncertainty)
-#####################################
-
-# warfarin ed model
-
-if (FALSE) {
-
- LEDoptim(poped.db)
-
- LEDoptim(poped.db,opt_xt=T,rsit=10)
-
- LEDoptim(poped.db,opt_xt=T,rsit=10,d_switch=TRUE)
-
- LEDoptim(poped.db,opt_xt=T,rsit=10,laplace.fim=TRUE)
-
- LEDoptim(poped.db,opt_xt=T,rsit=10,use_laplace=FALSE)
-
- ## testing header and footer
- LEDoptim(poped.db,opt_xt=T,rsit=10,d_switch=TRUE,
- out_file="foobar.txt")
-
- ff <- LEDoptim(poped.db,opt_xt=T,rsit=10,d_switch=TRUE,
- trflag=FALSE)
-
- LEDoptim(poped.db,opt_xt=T,rsit=10,d_switch=TRUE,
- header_flag=FALSE)
-
- LEDoptim(poped.db,opt_xt=T,rsit=10,d_switch=TRUE,
- out_file="")
-
- LEDoptim(poped.db,opt_xt=T,rsit=10,d_switch=TRUE,
- footer_flag=FALSE)
-
- LEDoptim(poped.db,opt_xt=T,rsit=10,d_switch=TRUE,
- footer_flag=FALSE, header_flag=FALSE)
-
- LEDoptim(poped.db,opt_xt=T,rsit=10,d_switch=TRUE,
- footer_flag=FALSE, header_flag=FALSE,out_file="foobar.txt")
-
- LEDoptim(poped.db,opt_xt=T,rsit=10,d_switch=TRUE,
- footer_flag=FALSE, header_flag=FALSE,out_file="")
-
-}
-
The function performs a linearization of the model with respect to the residual variability. -Derivative of model w.r.t. eps evaluated at eps=0
-LinMatrixH(model_switch, xt_ind, x, a, bpop, b_ind, bocc_ind, poped.db)
A matrix that is the same size as xt, specifying which model each sample belongs to.
A vector of the individual/group sample times
A matrix for the discrete design variables. Each row is a group.
A matrix of covariates. Each row is a group.
The fixed effects parameter values. Supplied as a vector.
vector of individual realization of the BSV terms b
Vector of individual realizations of the BOV terms bocc
A PopED database.
A matrix of size (samples per individual x number of epsilons)
-Other FIM:
-LinMatrixLH()
,
-LinMatrixL_occ()
,
-calc_ofv_and_fim()
,
-ed_laplace_ofv()
,
-ed_mftot()
,
-efficiency()
,
-evaluate.e.ofv.fim()
,
-evaluate.fim()
,
-gradf_eps()
,
-mf3()
,
-mf7()
,
-mftot()
,
-ofv_criterion()
,
-ofv_fim()
Function computes the derivative of the model with respect to the between subject variability -terms in the model (b's and bocc's) evaluated at -a defined point -(b_ind and bocc_ind).
-LinMatrixL(model_switch, xt_ind, x, a, bpop, b_ind, bocc_ind, poped.db)
A vector that is the same size as xt, specifying which model each sample belongs to.
A vector for the discrete design variables.
A vector of covariates.
The fixed effects parameter values. Supplied as a vector.
The point at which to evaluate the derivative
The point at which to evaluate the derivative
A PopED database.
As a list:
-A matrix of size (samples per individual x number of random effects)
A PopED database
library(PopED)
-
-############# START #################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## Optimization using an additive + proportional reidual error
-## to avoid sample times at very low concentrations (time 0 or very late samples).
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(prop=0.01,add=0.25),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0.01,
- maxxt=120,
- a=c(DOSE=70),
- mina=c(DOSE=0.01),
- maxa=c(DOSE=100))
-
-############# END ###################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-
-#for the FO approximation
-ind=1
-LinMatrixL(model_switch=t(poped.db$design$model_switch[ind,,drop=FALSE]),
- xt_ind=t(poped.db$design$xt[ind,,drop=FALSE]),
- x=zeros(0,1),
- a=t(poped.db$design$a[ind,,drop=FALSE]),
- bpop=poped.db$parameters$bpop[,2,drop=FALSE],
- b_ind=zeros(poped.db$parameters$NumRanEff,1),
- bocc_ind=zeros(poped.db$parameters$NumDocc,1),
- poped.db)["y"]
-#> $y
-#> [,1] [,2] [,3]
-#> [1,] -0.01736446 -3.4080713 2.63882264
-#> [2,] -0.05954832 -5.4115558 3.17591023
-#> [3,] -0.18102648 -7.2011569 2.27256206
-#> [4,] -0.74460344 -7.2016770 -0.01921862
-#> [5,] -2.44998833 -3.2358678 -0.10864692
-#> [6,] -2.97791129 -1.5623370 -0.08675634
-#> [7,] -3.07661786 0.7649213 -0.04417255
-#> [8,] -2.09673861 1.1568729 -0.01795922
-#>
-
-
The function performs a linearization of the model with respect to the residual variability and -then the between subject variability. -Derivative of model w.r.t. eps then eta, evaluated at eps=0 and b=b_ind.
-LinMatrixLH(
- model_switch,
- xt_ind,
- x,
- a,
- bpop,
- b_ind,
- bocc_ind,
- NumEPS,
- poped.db
-)
A matrix that is the same size as xt, specifying which model each sample belongs to.
A vector of the individual/group sample times
A matrix for the discrete design variables. Each row is a group.
A matrix of covariates. Each row is a group.
The fixed effects parameter values. Supplied as a vector.
vector of individual realization of the BSV terms b
Vector of individual realizations of the BOV terms bocc
The number of eps() terms in the model.
A PopED database.
A matrix of size (samples per individual x (number of sigma x number of omega))
-Other FIM:
-LinMatrixH()
,
-LinMatrixL_occ()
,
-calc_ofv_and_fim()
,
-ed_laplace_ofv()
,
-ed_mftot()
,
-efficiency()
,
-evaluate.e.ofv.fim()
,
-evaluate.fim()
,
-gradf_eps()
,
-mf3()
,
-mf7()
,
-mftot()
,
-ofv_criterion()
,
-ofv_fim()
library(PopED)
-
-############# START #################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## Optimization using an additive + proportional reidual error
-## to avoid sample times at very low concentrations (time 0 or very late samples).
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(prop=0.01,add=0.25),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0.01,
- maxxt=120,
- a=c(DOSE=70),
- mina=c(DOSE=0.01),
- maxa=c(DOSE=100))
-
-############# END ###################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-
-#for the FOI approximation
-ind=1
-poped.db$settings$iApproximationMethod=3 # FOI approximation method
-
-LinMatrixLH(model_switch=t(poped.db$design$model_switch[ind,,drop=FALSE]),
- xt_ind=t(poped.db$design$xt[ind,,drop=FALSE]),
- x=zeros(0,1),
- a=t(poped.db$design$a[ind,,drop=FALSE]),
- bpop=poped.db$parameters$bpop[,2,drop=FALSE],
- b_ind=zeros(poped.db$parameters$NumRanEff,1),
- bocc_ind=zeros(poped.db$parameters$NumDocc,1),
- NumEPS=size(poped.db$parameters$sigma,1),
- poped.db)["y"]
-#> $y
-#> [,1] [,2] [,3] [,4] [,5] [,6]
-#> [1,] -0.01736389 0 -3.4080716 0 2.63882249 0
-#> [2,] -0.05954792 0 -5.4115556 0 3.17591065 0
-#> [3,] -0.18102853 0 -7.2011552 0 2.27256214 0
-#> [4,] -0.74460438 0 -7.2016748 0 -0.01922018 0
-#> [5,] -2.44998688 0 -3.2358671 0 -0.10864643 0
-#> [6,] -2.97791125 0 -1.5623369 0 -0.08675727 0
-#> [7,] -3.07661785 0 0.7649203 0 -0.04417244 0
-#> [8,] -2.09673889 0 1.1568727 0 -0.01795897 0
-#>
-
-
-
R/LinMatrixL_occ.R
- LinMatrixL_occ.Rd
The function performs a linearization of the model with respect to the occasion variability parameter.. -Derivative of model w.r.t. eta_occ, evaluated bocc_ind.
-LinMatrixL_occ(
- model_switch,
- xt_ind,
- x,
- a,
- bpop,
- b_ind,
- bocc_ind,
- iCurrentOcc,
- poped.db
-)
A matrix that is the same size as xt, specifying which model each sample belongs to.
A vector of the individual/group sample times
A matrix for the discrete design variables. Each row is a group.
A matrix of covariates. Each row is a group.
The fixed effects parameter values. Supplied as a vector.
vector of individual realization of the BSV terms b
Vector of individual realizations of the BOV terms bocc
The current occasion.
A PopED database.
A matrix of size (samples per individual x number of iovs)
-Other FIM:
-LinMatrixH()
,
-LinMatrixLH()
,
-calc_ofv_and_fim()
,
-ed_laplace_ofv()
,
-ed_mftot()
,
-efficiency()
,
-evaluate.e.ofv.fim()
,
-evaluate.fim()
,
-gradf_eps()
,
-mf3()
,
-mf7()
,
-mftot()
,
-ofv_criterion()
,
-ofv_fim()
library(PopED)
-
-############# START #################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## Optimization using an additive + proportional reidual error
-## to avoid sample times at very low concentrations (time 0 or very late samples).
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(prop=0.01,add=0.25),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0.01,
- maxxt=120,
- a=c(DOSE=70),
- mina=c(DOSE=0.01),
- maxa=c(DOSE=100))
-
-############# END ###################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-
-#for the FO approximation
-ind=1
-
-# no occasion defined in this example, so result is zero
-LinMatrixL_occ(model_switch=t(poped.db$design$model_switch[ind,,drop=FALSE]),
- xt_ind=t(poped.db$design$xt[ind,,drop=FALSE]),
- x=zeros(0,1),
- a=t(poped.db$design$a[ind,,drop=FALSE]),
- bpop=poped.db$parameters$bpop[,2,drop=FALSE],
- b_ind=zeros(poped.db$parameters$NumRanEff,1),
- bocc_ind=zeros(poped.db$parameters$NumDocc,1),
- iCurrentOcc=1,
- poped.db)["y"]
-#> $y
-#> [1] 0
-#>
-
-
PopED computes optimal experimental designs for both -population and individual studies based on nonlinear mixed-effect models. -Often this is based on a computation of the Fisher Information Matrix (FIM).
-To get started you need to define
A model.
An initial design (and design space if you want to optimize).
The tasks to perform.
There are a number of functions to help you with these tasks. The user-level functions defined below are -meant to be run with a minimum of arguments (for beginners to advanced users). Many of the other functions in the package -(and not listed here) are called by these user-level functions -and are often not as user -friendly (developer level or advanced user functions).
-Define a structural model:
-ff.PK.1.comp.oral.md.CL
,
- ff.PK.1.comp.oral.md.KE
,
- ff.PK.1.comp.oral.sd.CL
,
- ff.PK.1.comp.oral.sd.KE
,
- ff.PKPD.1.comp.oral.md.CL.imax
,
- ff.PKPD.1.comp.sd.CL.emax
.
Define a residual unexplained variability model (residual error model):
-feps.add.prop
,
-feps.add
,
-feps.prop
.
Create an initial study design (and design space):
-create.poped.database
.
Evaluate the model and/or design through simulation and graphics:
-plot_model_prediction
,
-model_prediction
,
-plot_efficiency_of_windows
.
Evaluate the design using the FIM:
-evaluate_design
,
-evaluate.fim
,
-evaluate.e.ofv.fim
,
-ofv_fim
,
-get_rse
.
Optimize the design (evaluate afterwards using the above functions):
-poped_optim
,
See the "Examples" section below for a short introduction to using the above functions. -There are several other examples, as r-scripts, in the "examples" folder in the -PopED installation directory located at (run at the R command line):
-system.file("examples", package="PopED")
.
J. Nyberg, S. Ueckert, E.A. Stroemberg, S. Hennig, M.O. Karlsson and A.C. Hooker, "PopED: An extended, -parallelized, nonlinear mixed effects models optimal design tool", -Computer Methods and Programs in Biomedicine, 108, 2012.
M. Foracchia, A.C. Hooker, P. Vicini and A. Ruggeri, "PopED, a software for optimal -experimental design in population kinetics", Computer Methods and Programs in Biomedicine, 74, 2004.
-library(PopED)
-
-##-- Model: One comp first order absorption
-## -- Analytic solution for both mutiple and single dosing
-ff <- function(model_switch,xt,parameters,poped.db){
- with(as.list(parameters),{
- y=xt
- N = floor(xt/TAU)+1
- y=(DOSE*Favail/V)*(KA/(KA - CL/V)) *
- (exp(-CL/V * (xt - (N - 1) * TAU)) * (1 - exp(-N * CL/V * TAU))/(1 - exp(-CL/V * TAU)) -
- exp(-KA * (xt - (N - 1) * TAU)) * (1 - exp(-N * KA * TAU))/(1 - exp(-KA * TAU)))
- return(list( y=y,poped.db=poped.db))
- })
-}
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c( V=bpop[1]*exp(b[1]),
- KA=bpop[2]*exp(b[2]),
- CL=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1],
- TAU=a[2])
- return( parameters )
-}
-
-## -- Residual unexplained variablity (RUV) function
-## -- Additive + Proportional
-feps <- function(model_switch,xt,parameters,epsi,poped.db){
- returnArgs <- do.call(poped.db$model$ff_pointer,list(model_switch,xt,parameters,poped.db))
- y <- returnArgs[[1]]
- poped.db <- returnArgs[[2]]
-
- y = y*(1+epsi[,1])+epsi[,2]
-
- return(list( y= y,poped.db =poped.db ))
-}
-
-## -- Define design and design space
-poped.db <- create.poped.database(ff_fun=ff,
- fg_fun=sfg,
- fError_fun=feps,
- bpop=c(V=72.8,KA=0.25,CL=3.75,Favail=0.9),
- notfixed_bpop=c(1,1,1,0),
- d=c(V=0.09,KA=0.09,CL=0.25^2),
- sigma=c(0.04,5e-6),
- notfixed_sigma=c(0,0),
- m=2,
- groupsize=20,
- xt=c( 1,2,8,240,245),
- minxt=c(0,0,0,240,240),
- maxxt=c(10,10,10,248,248),
- bUseGrouped_xt=1,
- a=list(c(DOSE=20,TAU=24),c(DOSE=40, TAU=24)),
- maxa=c(DOSE=200,TAU=24),
- mina=c(DOSE=0,TAU=24))
-
-## create plot of model without variability
-plot_model_prediction(poped.db, model_num_points = 300)
-
-
-
-if (FALSE) {
-
- ## create plot of model with variability
- plot_model_prediction(poped.db, IPRED=T, DV=T, separate.groups=T, model_num_points = 300)
-
-}
-
-## evaluate initial design
-evaluate_design(poped.db)
-#> $ofv
-#> [1] 28.9197
-#>
-#> $fim
-#> V KA CL d_V d_KA d_CL
-#> V 0.05336692 -8.683963 -0.05863412 0.000000 0.000000 0.000000
-#> KA -8.68396266 2999.851007 -14.43058560 0.000000 0.000000 0.000000
-#> CL -0.05863412 -14.430586 37.15243290 0.000000 0.000000 0.000000
-#> d_V 0.00000000 0.000000 0.00000000 999.953587 312.240246 3.202847
-#> d_KA 0.00000000 0.000000 0.00000000 312.240246 439.412556 2.287838
-#> d_CL 0.00000000 0.000000 0.00000000 3.202847 2.287838 3412.005199
-#>
-#> $rse
-#> V KA CL d_V d_KA d_CL
-#> 8.215338 10.090955 4.400304 39.833230 60.089601 27.391518
-#>
-
-if (FALSE) {
-
- # Optimization of sample times
- output <- poped_optim(poped.db, opt_xt=TRUE, parallel = TRUE)
- summary(output)
- get_rse(output$FIM, output$poped.db)
- plot_model_prediction(output$poped.db)
-
- # Optimization of sample times and doses
- output_2 <- poped_optim(poped.db, opt_xt=TRUE, opt_a=TRUE, parallel = TRUE)
- summary(output_2)
- get_rse(output_2$FIM,output_2$poped.db)
- plot_model_prediction(output_2$poped.db)
-
- # Optimization of sample times with only integer time points in design space
- # faster than continuous optimization in this case
- poped.db.discrete <- create.poped.database(ff_fun=ff,
- fg_fun=sfg,
- fError_fun=feps,
- bpop=c(V=72.8,KA=0.25,CL=3.75,Favail=0.9),
- notfixed_bpop=c(1,1,1,0),
- d=c(V=0.09,KA=0.09,CL=0.25^2),
- sigma=c(0.04,5e-6),
- notfixed_sigma=c(0,0),
- m=2,
- groupsize=20,
- xt=c( 1,2,8,240,245),
- minxt=c(0,0,0,240,240),
- maxxt=c(10,10,10,248,248),
- discrete_xt = list(0:248),
- bUseGrouped_xt=1,
- a=list(c(DOSE=20,TAU=24),c(DOSE=40, TAU=24)),
- maxa=c(DOSE=200,TAU=24),
- mina=c(DOSE=0,TAU=24),
- ourzero = 0)
-
- output_discrete <- poped_optim(poped.db.discrete, opt_xt=T, parallel = TRUE)
-
-
- summary(output_discrete)
- get_rse(output_discrete$FIM,output_discrete$poped.db)
- plot_model_prediction(output_discrete$poped.db)
-
- # Efficiency of sampling windows
- plot_efficiency_of_windows(output_discrete$poped.db,xt_windows=0.5)
- plot_efficiency_of_windows(output_discrete$poped.db,xt_windows=1)
-
-}
-
R/RS_opt.R
- RS_opt.Rd
Optimize the objective function using an adaptive random search algorithm.
-Optimization can be performed for both D-family and E-family designs.
-The function works for both discrete and continuous optimization variables.
-This function takes information from the PopED database supplied as an argument.
-The PopED database supplies information about the the model, parameters, design and methods to use.
-Some of the arguments coming from the PopED database can be overwritten;
-by default these arguments are NULL
in the
-function, if they are supplied then they are used instead of the arguments from the PopED database.
RS_opt(
- poped.db,
- ni = NULL,
- xt = NULL,
- model_switch = NULL,
- x = NULL,
- a = NULL,
- bpopdescr = NULL,
- ddescr = NULL,
- maxxt = NULL,
- minxt = NULL,
- maxa = NULL,
- mina = NULL,
- fmf = 0,
- dmf = 0,
- trflag = TRUE,
- opt_xt = poped.db$settings$optsw[2],
- opt_a = poped.db$settings$optsw[4],
- opt_x = poped.db$settings$optsw[3],
- cfaxt = poped.db$settings$cfaxt,
- cfaa = poped.db$settings$cfaa,
- rsit = poped.db$settings$rsit,
- rsit_output = poped.db$settings$rsit_output,
- fim.calc.type = poped.db$settings$iFIMCalculationType,
- approx_type = poped.db$settings$iApproximationMethod,
- iter = NULL,
- d_switch = poped.db$settings$d_switch,
- use_laplace = poped.db$settings$iEDCalculationType,
- laplace.fim = FALSE,
- header_flag = TRUE,
- footer_flag = TRUE,
- out_file = NULL,
- compute_inv = TRUE,
- ...
-)
A PopED database.
A vector of the number of samples in each group.
A matrix of sample times. Each row is a vector of sample times for a group.
A matrix that is the same size as xt, specifying which model each sample belongs to.
A matrix for the discrete design variables. Each row is a group.
A matrix of covariates. Each row is a group.
Matrix defining the fixed effects, per row (row number = -parameter_number) we should have:
column 1 the type of the -distribution for E-family designs (0 = Fixed, 1 = Normal, 2 = Uniform, 3 = -User Defined Distribution, 4 = lognormal and 5 = truncated normal)
column 2 defines the mean.
column 3 defines the variance of the -distribution (or length of uniform distribution).
Matrix defining the diagonals of the IIV (same logic as for
-the bpopdescr
).
Matrix or single value defining the maximum value for each xt sample. If a single value is -supplied then all xt values are given the same maximum value.
Matrix or single value defining the minimum value for each xt sample. If a single value is -supplied then all xt values are given the same minimum value
Vector defining the max value for each covariate. If a single value is supplied then -all a values are given the same max value
Vector defining the min value for each covariate. If a single value is supplied then -all a values are given the same max value
The initial value of the FIM. If set to zero then it is computed.
The initial OFV. If set to zero then it is computed.
Should the optimization be output to the screen and to a file?
Should the sample times be optimized?
Should the continuous design variables be optimized?
Should the discrete design variables be optimized?
First step factor for sample times
Stochastic Gradient search first step factor for covariates
Number of Random search iterations
Number of iterations in random search between screen output
The method used for calculating the FIM. Potential values:
0 = Full FIM. No assumption that fixed and random effects are uncorrelated.
1 = Reduced FIM. Assume that there is no correlation in the FIM between the fixed and random effects, and set these elements in -the FIM to zero.
2 = weighted models (placeholder).
3 = Not currently used.
4 = Reduced FIM and computing all derivatives with respect to the standard deviation of the residual unexplained variation (sqrt(SIGMA) in NONMEM). -This matches what is done in PFIM, and assumes that the standard deviation of the residual unexplained variation is the estimated parameter -(NOTE: NONMEM estimates the variance of the residual unexplained variation by default).
5 = Full FIM parameterized with A,B,C matrices & derivative of variance.
6 = Calculate one model switch at a time, good for large matrices.
7 = Reduced FIM parameterized with A,B,C matrices & derivative of variance.
Approximation method for model, 0=FO, 1=FOCE, 2=FOCEI, 3=FOI.
The number of iterations entered into the blockheader_2
function.
******START OF CRITERION SPECIFICATION OPTIONS**********
D-family design (1) or ED-family design (0) (with or without parameter uncertainty)
Should the Laplace method be used in calculating the expectation of the OFV?
Should an E(FIM) be calculated when computing the Laplace approximated E(OFV). Typically -the FIM does not need to be computed and, if desired, this calculation -is done using the standard MC integration technique, so can be slow.
Should the header text be printed out?
Should the footer text be printed out?
Which file should the output be directed to? A string, a file handle using
-file
or ""
will output to the screen.
should the inverse of the FIM be used to compute expected RSE values? Often not needed -except for diagnostic purposes.
arguments passed to evaluate.fim
and ofv_fim
.
M. Foracchia, A.C. Hooker, P. Vicini and A. Ruggeri, "PopED, a software fir optimal -experimental design in population kinetics", Computer Methods and Programs in Biomedicine, 74, 2004.
J. Nyberg, S. Ueckert, E.A. Stroemberg, S. Hennig, M.O. Karlsson and A.C. Hooker, "PopED: An extended, -parallelized, nonlinear mixed effects models optimal design tool", -Computer Methods and Programs in Biomedicine, 108, 2012.
Other Optimize:
-Doptim()
,
-LEDoptim()
,
-a_line_search()
,
-bfgsb_min()
,
-calc_autofocus()
,
-calc_ofv_and_grad()
,
-mfea()
,
-optim_ARS()
,
-optim_LS()
,
-poped_optim_1()
,
-poped_optim_2()
,
-poped_optim_3()
,
-poped_optimize()
,
-poped_optim()
library(PopED)
-
-############# START #################
-## Create PopED database
-## (warfarin model for optimization
-## with parameter uncertainty)
-#####################################
-
-## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## Optimization using an additive + proportional reidual error
-## to avoid sample times at very low concentrations (time 0 or very late samoples).
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-# Adding 10% log-normal Uncertainty to fixed effects (not Favail)
-bpop_vals <- c(CL=0.15, V=8, KA=1.0, Favail=1)
-bpop_vals_ed_ln <- cbind(ones(length(bpop_vals),1)*4, # log-normal distribution
- bpop_vals,
- ones(length(bpop_vals),1)*(bpop_vals*0.1)^2) # 10% of bpop value
-bpop_vals_ed_ln["Favail",] <- c(0,1,0)
-bpop_vals_ed_ln
-#> bpop_vals
-#> CL 4 0.15 0.000225
-#> V 4 8.00 0.640000
-#> KA 4 1.00 0.010000
-#> Favail 0 1.00 0.000000
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- bpop=bpop_vals_ed_ln,
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(0.01,0.25),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0,
- maxxt=120,
- a=70,
- mina=0,
- maxa=100)
-
-############# END ###################
-## Create PopED database
-## (warfarin model for optimization
-## with parameter uncertainty)
-#####################################
-
-
-# Just a few iterations, optimize on DOSE and sample times using the full FIM
-out_1 <- RS_opt(poped.db,opt_xt=1,opt_a=1,rsit=3,fim.calc.type=0, out_file = "")
-#> ===============================================================================
-#> Initial design evaluation
-#>
-#> Initial OFV = 57.0828
-#>
-#> Initial design
-#> expected relative standard error
-#> (%RSE, rounded to nearest integer)
-#> Parameter Values RSE_0
-#> CL 0.15 5
-#> V 8 3
-#> KA 1 7
-#> d_CL 0.07 30
-#> d_V 0.02 37
-#> d_KA 0.6 28
-#> SIGMA[1,1] 0.01 33
-#> SIGMA[2,2] 0.25 26
-#>
-#> ==============================================================================
-#> Optimization of design parameters
-#>
-#> * Optimize Sampling Schedule
-#> * Optimize Covariates
-#>
-#> *******************************
-#> Initial Value
-#> OFV(mf) = 57.0828
-#> *******************************
-#>
-#> RS - It. : 3 OFV : 57.0828
-#>
-#> *******************************
-#> RS Results
-#> OFV(mf) = 57.0828
-#>
-#> Optimized Sampling Schedule
-#> Group 1: 0.5 1 2 6 24 36 72 120
-#>
-#> Optimized Covariates:
-#> Group 1: 70
-#>
-#> *********************************
-#>
-#> ===============================================================================
-#> FINAL RESULTS
-#> Optimized Sampling Schedule
-#> Group 1: 0.5 1 2 6 24 36 72 120
-#>
-#> Optimized Covariates:
-#> Group 1: 70
-#>
-#> OFV = 57.0828
-#>
-#> Efficiency:
-#> ((exp(ofv_final) / exp(ofv_init))^(1/n_parameters)) = 1
-#>
-#> Expected relative standard error
-#> (%RSE, rounded to nearest integer):
-#> Parameter Values RSE_0 RSE
-#> CL 0.15 5 5
-#> V 8 3 3
-#> KA 1 7 7
-#> d_CL 0.07 0 0
-#> d_V 0.02 37 37
-#> d_KA 0.6 0 0
-#> SIGMA[1,1] 0.01 33 33
-#> SIGMA[2,2] 0.25 26 26
-#>
-#> Total running time: 0.017 seconds
-
-if (FALSE) {
-
- RS_opt(poped.db)
-
- RS_opt(poped.db,opt_xt=TRUE,rsit=100,compute_inv=F)
- RS_opt(poped.db,opt_xt=TRUE,rsit=20,d_switch=0)
- RS_opt(poped.db,opt_xt=TRUE,rsit=10,d_switch=0,use_laplace=T)
- RS_opt(poped.db,opt_xt=TRUE,rsit=10,d_switch=0,use_laplace=T,laplace.fim=T)
-
- ## Different headers and footers of output
- RS_opt(poped.db,opt_xt=TRUE,rsit=10,out_file="foo.txt")
- output <- RS_opt(poped.db,opt_xt=TRUE,rsit=100,trflag=FALSE)
- RS_opt(poped.db,opt_xt=TRUE,rsit=10,out_file="")
- RS_opt(poped.db,opt_xt=TRUE,rsit=10,header_flag=FALSE)
- RS_opt(poped.db,opt_xt=TRUE,rsit=10,footer_flag=FALSE)
- RS_opt(poped.db,opt_xt=TRUE,rsit=10,header_flag=FALSE,footer_flag=FALSE)
- RS_opt(poped.db,opt_xt=TRUE,rsit=10,header_flag=FALSE,footer_flag=FALSE,out_file="foo.txt")
- RS_opt(poped.db,opt_xt=TRUE,rsit=10,header_flag=FALSE,footer_flag=FALSE,out_file="")
-
-}
-
RS_opt_gen.Rd
Optimize the objective function using an adaptive random search algorithm.
-Optimization can be performed for both D-family and E-family designs.
-The function works for both discrete and continuous optimization variables.
-This function takes information from the PopED database supplied as an argument.
-The PopED database supplies information about the the model, parameters, design and methods to use.
-Some of the arguments coming from the PopED database can be overwritten;
-by default these arguments are NULL
in the
-function, if they are supplied then they are used instead of the arguments from the PopED database.
RS_opt_gen(poped.db, ni = NULL, xt = NULL, model_switch = NULL, - x = NULL, a = NULL, bpopdescr = NULL, ddescr = NULL, maxxt = NULL, - minxt = NULL, maxa = NULL, mina = NULL, fmf = 0, dmf = 0, - trflag = TRUE, opt_xt = poped.db$settings$optsw[2], - opt_a = poped.db$settings$optsw[4], opt_x = poped.db$settings$optsw[3], - cfaxt = poped.db$settings$cfaxt, cfaa = poped.db$settings$cfaa, - rsit = poped.db$settings$rsit, - rsit_output = poped.db$settings$rsit_output, - fim.calc.type = poped.db$settings$iFIMCalculationType, - approx_type = poped.db$settings$iApproximationMethod, iter = NULL, - d_switch = poped.db$settings$d_switch, - use_laplace = poped.db$settings$iEDCalculationType, laplace.fim = FALSE, - header_flag = TRUE, footer_flag = TRUE, out_file = NULL, - compute_inv = TRUE, ...)- -
poped.db | -A PopED database. |
-
---|---|
ni | -A vector of the number of samples in each group. |
-
xt | -A matrix of sample times. Each row is a vector of sample times for a group. |
-
model_switch | -A matrix that is the same size as xt, specifying which model each sample belongs to. |
-
x | -A matrix for the discrete design variables. Each row is a group. |
-
a | -A matrix of covariates. Each row is a group. |
-
bpopdescr | -Matrix defining the fixed effects, per row (row number = -parameter_number) we should have:
|
-
ddescr | -Matrix defining the diagnonals of the IIV (same logic as for
-the |
-
maxxt | -Matrix or single value defining the maximum value for each xt sample. If a single value is -supplied then all xt values are given the same maximum value. |
-
minxt | -Matrix or single value defining the minimum value for each xt sample. If a single value is -supplied then all xt values are given the same minimum value |
-
maxa | -Vector defining the max value for each covariate. If a single value is supplied then -all a values are given the same max value |
-
mina | -Vector defining the min value for each covariate. If a single value is supplied then -all a values are given the same max value |
-
fmf | -The initial value of the FIM. If set to zero then it is computed. |
-
dmf | -The inital OFV. If set to zero then it is computed. |
-
trflag | -Should the optimization be output to the screen and to a file? |
-
opt_xt | -Should the sample times be optimized? |
-
opt_a | -Should the continuous design variables be optimized? |
-
opt_x | -Should the discrete design variables be optimized? |
-
cfaxt | -First step factor for sample times |
-
cfaa | -Stochastic Gradient search first step factor for covariates |
-
rsit | -Number of Random search iterations |
-
rsit_output | -Number of iterations in random search between screen output |
-
fim.calc.type | -The method used for calculating the FIM. Potential values:
|
-
approx_type | -Approximation method for model, 0=FO, 1=FOCE, 2=FOCEI, 3=FOI. |
-
iter | -The number of iterations entered into the |
-
d_switch | -
D-family design (1) or ED-familty design (0) (with or without parameter uncertainty) |
-
use_laplace | -Should the Laplace method be used in calculating the expectation of the OFV? |
-
laplace.fim | -Should an E(FIM) be calculated when computing the Laplace approximated E(OFV). Typically -the FIM does not need to be computed and, if desired, this calculation -is done usng the standard MC integration technique, so can be slow. |
-
header_flag | -Should the header text be printed out? |
-
footer_flag | -Should the footer text be printed out? |
-
out_file | -Which file should the output be directed to? A string, a file handle using
- |
-
compute_inv | -should the inverse of the FIM be used to compute expected RSE values? Often not needed -except for diagnostic purposes. |
-
... | -arguments passed to |
-
M. Foracchia, A.C. Hooker, P. Vicini and A. Ruggeri, "PopED, a software fir optimal -experimental design in population kinetics", Computer Methods and Programs in Biomedicine, 74, 2004.
J. Nyberg, S. Ueckert, E.A. Stroemberg, S. Hennig, M.O. Karlsson and A.C. Hooker, "PopED: An extended, -parallelized, nonlinear mixed effects models optimal design tool", -Computer Methods and Programs in Biomedicine, 108, 2012.
Other Optimize: Doptim
,
- LEDoptim
, RS_opt
,
- a_line_search
, bfgsb_min
,
- calc_autofocus
,
- calc_ofv_and_grad
, mfea
,
- optim_ARS
, optim_LS
,
- poped_optim_1
, poped_optim_2
,
- poped_optim_3
,
- poped_optimize
, poped_optim
-library(PopED) - -############# START ################# -## Create PopED database -## (warfarin model for optimization -## with parameter uncertainty) -##################################### - -## Warfarin example from software comparison in: -## Nyberg et al., "Methods and software tools for design evaluation -## for population pharmacokinetics-pharmacodynamics studies", -## Br. J. Clin. Pharm., 2014. - -## Optimization using an additive + proportional reidual error -## to avoid sample times at very low concentrations (time 0 or very late samoples). - -## find the parameters that are needed to define from the structural model -ff.PK.1.comp.oral.sd.CL#> function(model_switch,xt,parameters,poped.db){ -#> ##-- Model: One comp first order absorption -#> with(as.list(parameters),{ -#> y=xt -#> y=(DOSE*Favail*KA/(V*(KA-CL/V)))*(exp(-CL/V*xt)-exp(-KA*xt)) -#> return(list( y= y,poped.db=poped.db)) -#> }) -#> } -#> <environment: namespace:PopED>-## -- parameter definition function -## -- names match parameters in function ff -sfg <- function(x,a,bpop,b,bocc){ - parameters=c(CL=bpop[1]*exp(b[1]), - V=bpop[2]*exp(b[2]), - KA=bpop[3]*exp(b[3]), - Favail=bpop[4], - DOSE=a[1]) - return(parameters) -} - -# Adding 10% log-normal Uncertainty to fixed effects (not Favail) -bpop_vals <- c(CL=0.15, V=8, KA=1.0, Favail=1) -bpop_vals_ed_ln <- cbind(ones(length(bpop_vals),1)*4, # log-normal distribution - bpop_vals, - ones(length(bpop_vals),1)*(bpop_vals*0.1)^2) # 10% of bpop value -bpop_vals_ed_ln["Favail",] <- c(0,1,0) -bpop_vals_ed_ln#> bpop_vals -#> CL 4 0.15 0.000225 -#> V 4 8.00 0.640000 -#> KA 4 1.00 0.010000 -#> Favail 0 1.00 0.000000-## -- Define initial design and design space -poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL, - fg_fun=sfg, - fError_fun=feps.add.prop, - bpop=bpop_vals_ed_ln, - notfixed_bpop=c(1,1,1,0), - d=c(CL=0.07, V=0.02, KA=0.6), - sigma=c(0.01,0.25), - groupsize=32, - xt=c( 0.5,1,2,6,24,36,72,120), - minxt=0, - maxxt=120, - a=70, - mina=0, - maxa=100) - -############# END ################### -## Create PopED database -## (warfarin model for optimization -## with parameter uncertainty) -##################################### - - -# Just a few iterations, optimize on DOSE and sample times using the full FIM -out_1 <- RS_opt_gen(poped.db,opt_xt=1,opt_a=1,rsit=3,fim.calc.type=0)#> =============================================================================== -#> Initial design evaluation -#> -#> Initial OFV = 57.0828 -#> -#> Efficiency criterion [usually defined as OFV^(1/npar)] = 1255.57 -#> -#> Initial design expected parameter -#> relative standard error (%RSE) -#> Parameter Values RSE_0 -#> bpop[1] 0.15 4.84 -#> bpop[2] 8.00 2.96 -#> bpop[3] 1.00 6.59 -#> D[1,1] 0.07 30.20 -#> D[2,2] 0.02 37.10 -#> D[3,3] 0.60 27.62 -#> SIGMA[1,1] 0.01 32.87 -#> SIGMA[2,2] 0.25 26.03 -#> -#> RS - It. : 3 OFV : 57.0828 -#> =============================================================================== -#> FINAL RESULTS -#> -#> Optimized Sampling Schedule -#> Group 1: 0.5 1 2 6 24 36 72 120 -#> -#> Optimized Covariates: -#> Group 1: 70 -#> -#> OFV = 57.0828 -#> -#> Efficiency: -#> ((exp(ofv_final) / exp(ofv_init))^(1/n_parameters)) = 1 -#> -#> Expected parameter -#> relative standard error (%RSE): -#> Parameter Values RSE_0 RSE -#> bpop[1] 0.15 4.84 4.84 -#> bpop[2] 8.00 2.96 2.96 -#> bpop[3] 1.00 6.59 6.59 -#> D[1,1] 0.07 30.20 30.20 -#> D[2,2] 0.02 37.10 37.10 -#> D[3,3] 0.60 27.62 27.62 -#> SIGMA[1,1] 0.01 32.87 32.87 -#> SIGMA[2,2] 0.25 26.03 26.03 -#> -#> Total running time: 0.205 seconds-# NOT RUN { - - RS_opt_gen(poped.db) - - RS_opt_gen(poped.db,opt_xt=TRUE,rsit=100,compute_inv=F) - RS_opt_gen(poped.db,opt_xt=TRUE,rsit=20,d_switch=0) - RS_opt_gen(poped.db,opt_xt=TRUE,rsit=10,d_switch=0,use_laplace=T) - RS_opt_gen(poped.db,opt_xt=TRUE,rsit=10,d_switch=0,use_laplace=T,laplace.fim=T) - - ## Different headers and footers of output - RS_opt_gen(poped.db,opt_xt=TRUE,rsit=10,out_file="foo.txt") - output <- RS_opt_gen(poped.db,opt_xt=TRUE,rsit=100,trflag=FALSE) - RS_opt_gen(poped.db,opt_xt=TRUE,rsit=10,out_file="") - RS_opt_gen(poped.db,opt_xt=TRUE,rsit=10,header_flag=FALSE) - RS_opt_gen(poped.db,opt_xt=TRUE,rsit=10,footer_flag=FALSE) - RS_opt_gen(poped.db,opt_xt=TRUE,rsit=10,header_flag=FALSE,footer_flag=FALSE) - RS_opt_gen(poped.db,opt_xt=TRUE,rsit=10,header_flag=FALSE,footer_flag=FALSE,out_file="foo.txt") - RS_opt_gen(poped.db,opt_xt=TRUE,rsit=10,header_flag=FALSE,footer_flag=FALSE,out_file="") - -# }
The function performs a grid search sequentially along -design variables. The grid is defined by ls_step_size.
-a_line_search(
- poped.db,
- out_file = "",
- bED = FALSE,
- diff = 0,
- fmf_initial = 0,
- dmf_initial = 0,
- opt_xt = poped.db$settings$optsw[2],
- opt_a = poped.db$settings$optsw[4],
- opt_x = poped.db$settings$optsw[3],
- opt_samps = poped.db$settings$optsw[1],
- opt_inds = poped.db$settings$optsw[5],
- ls_step_size = poped.db$settings$ls_step_size
-)
A PopED database.
The output file to write to.
If the algorithm should use E-family methods. Logical.
The OFV difference that is deemed significant for changing a design. If,
-by changing a design variable the difference between the new and old OFV is less than diff
-the change is not made.
The initial value of the FIM. If 0
then the FIM is calculated from poped.db.
The initial value of the objective function value (OFV).
-If 0
then the OFV is calculated from poped.db.
Should the sample times be optimized?
Should the continuous design variables be optimized?
Should the discrete design variables be optimized?
Are the number of sample times per group being optimized?
Are the number of individuals per group being optimized?
Number of grid points in the line search.
A list containing:
-The FIM.
The final value of the objective function value.
If the algorithm has found a better design than the starting design.
A matrix of sample times. Each row is a vector of sample times for a group.
A matrix for the discrete design variables. Each row is a group.
A matrix of covariates. Each row is a group.
A PopED database.
Other Optimize:
-Doptim()
,
-LEDoptim()
,
-RS_opt()
,
-bfgsb_min()
,
-calc_autofocus()
,
-calc_ofv_and_grad()
,
-mfea()
,
-optim_ARS()
,
-optim_LS()
,
-poped_optim_1()
,
-poped_optim_2()
,
-poped_optim_3()
,
-poped_optimize()
,
-poped_optim()
library(PopED)
-
-############# START #################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## Optimization using an additive + proportional reidual error
-## to avoid sample times at very low concentrations (time 0 or very late samples).
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(prop=0.01,add=0.25),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0.01,
- maxxt=120,
- a=c(DOSE=70),
- mina=c(DOSE=0.01),
- maxa=c(DOSE=100))
-
-############# END ###################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-
-# very sparse grid to evaluate (4 points for each design valiable)
-output <- a_line_search(poped.db, opt_xt=TRUE, opt_a=TRUE, ls_step_size=4)
-#> *****************************
-#> Line Search
-#>
-#> Searching xt5 on group 1
-#> group 1 -- xt[5] changed from 24 to 0.01
-#> OFV(MF) changed from 55.3964 to 55.545
-#> group 1 -- xt[5] changed from 0.01 to 120
-#> OFV(MF) changed from 55.545 to 55.5979
-#> Searching xt1 on group 1
-#> group 1 -- xt[1] changed from 0.5 to 0.01
-#> OFV(MF) changed from 55.5979 to 55.6096
-#> group 1 -- xt[1] changed from 0.01 to 30.0075
-#> OFV(MF) changed from 55.6096 to 55.6818
-#> Searching xt3 on group 1
-#> Searching xt4 on group 1
-#> Searching xt8 on group 1
-#> Searching xt7 on group 1
-#> group 1 -- xt[7] changed from 72 to 90.0025
-#> OFV(MF) changed from 55.6818 to 55.7642
-#> group 1 -- xt[7] changed from 90.0025 to 120
-#> OFV(MF) changed from 55.7642 to 55.7932
-#> Searching xt2 on group 1
-#> Searching xt6 on group 1
-#> group 1 -- xt[6] changed from 36 to 30.0075
-#> OFV(MF) changed from 55.7932 to 55.857
-#> OFV(MF): 55.857
-#>
-#> Best value for OFV(MF) = 55.857
-#>
-#> Best value for xt:
-#> Group 1: 1 2 6 30.01 30.01 120 120 120
-#>
-#> Searching a1 on individual/group 1
-#> group 1 -- a[1] changed from 70 to 75.0025
-#> OFV(MF) changed from 55.857 to 56.0566
-#> group 1 -- a[1] changed from 75.0025 to 100
-#> OFV(MF) changed from 56.0566 to 56.6925
-#> OFV(MF): 56.6925
-#> Best value for OFV(MF) = 56.6925
-#>
-#> Best value for a:
-#> Group 1: 100 [0.01,100]
-#>
-#>
-#> Line search run time: 0.161 seconds
-#> ***************************
-#>
-
-if (FALSE) {
-
- # longer run time
- output <- a_line_search(poped.db,opt_xt=TRUE)
-
- # output to a text file
- output <- a_line_search(poped.db,opt_xt=TRUE,out_file="tmp.txt")
-
-}
-
-
This is the implementation of a Broyden Fletcher Goldfarb Shanno (BFGS) -method for nonlinear minimization with box constraints.
-bfgsb_min(f_name, f_options, x0, l, u, options = list())
A function name (as a text string) that returns an objective function and the gradient of that objective function, in that order.
-See calc_ofv_and_grad
as used in Doptim
.
Options for the f_name argument.
the initial values to optimize
the lower bounds
the upper bounds
a list of additional settings arguments
A list containing:
-The objective function.
The gradient.
The hessian.
Other Optimize:
-Doptim()
,
-LEDoptim()
,
-RS_opt()
,
-a_line_search()
,
-calc_autofocus()
,
-calc_ofv_and_grad()
,
-mfea()
,
-optim_ARS()
,
-optim_LS()
,
-poped_optim_1()
,
-poped_optim_2()
,
-poped_optim_3()
,
-poped_optimize()
,
-poped_optim()
library(PopED)
-
-############# START #################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## Optimization using an additive + proportional reidual error
-## to avoid sample times at very low concentrations (time 0 or very late samples).
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(prop=0.01,add=0.25),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0.01,
- maxxt=120,
- a=c(DOSE=70),
- mina=c(DOSE=0.01),
- maxa=c(DOSE=100))
-
-############# END ###################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-
-if (FALSE) {
-
- # BFGS search, DOSE and sample time optimization
- bfgs.output <- poped_optimize(poped.db,opt_xt=1,opt_a=0,
- bUseRandomSearch= 0,
- bUseStochasticGradient = 0,
- bUseBFGSMinimizer = 1,
- bUseLineSearch = 0)
-
- f_name <- 'calc_ofv_and_grad'
- gen_des <- downsizing_general_design(poped.db)
-
- aa <- 0*poped.db$settings$cfaa*matrix(1,poped.db$design$m,size(poped.db$design$a,2))
- axt=1*poped.db$settings$cfaxt*matrix(1,poped.db$design$m,max(poped.db$design_space$maxni))
-
- f_options_1 <- list(gen_des$x,1, 0, gen_des$model_switch,
- aa=aa,axt=axt,poped.db$design$groupsize,
- gen_des$ni,
- gen_des$xt,gen_des$x,gen_des$a,gen_des$bpop[,2,drop=F],
- getfulld(gen_des$d[,2,drop=F],poped.db$parameters$covd),
- poped.db$parameters$sigma,
- getfulld(poped.db$parameters$docc[,2,drop=F],
- poped.db$parameters$covdocc),poped.db)
-
- options=list('factr'=poped.db$settings$BFGSConvergenceCriteriaMinStep,
- #'factr'=0.01,
- 'pgtol'=poped.db$settings$BFGSProjectedGradientTol,
- 'ftol'=poped.db$settings$BFGSTolerancef,
- 'gtol'=poped.db$settings$BFGSToleranceg,
- 'xtol'=poped.db$settings$BFGSTolerancex)
-
- x_k=t(gen_des$xt)
- lb=t(gen_des$minxt)
- ub=t(gen_des$maxxt)
-
- output <- bfgsb_min(f_name,f_options, x_k,lb,ub,options)
-
-}
-
-
Create some output to the screen and a text file that summarizes the initial design and the design space -you will use to optimize.
-blockexp(
- fn,
- poped.db,
- e_flag = FALSE,
- opt_xt = poped.db$settings$optsw[2],
- opt_a = poped.db$settings$optsw[4],
- opt_x = poped.db$settings$optsw[4],
- opt_samps = poped.db$settings$optsw[1],
- opt_inds = poped.db$settings$optsw[5]
-)
The file handle to write to.
A PopED database.
Should output be with uncertainty around parameters?
Should the sample times be optimized?
Should the continuous design variables be optimized?
Should the discrete design variables be optimized?
Are the number of sample times per group being optimized?
Are the number of individuals per group being optimized?
Other Helper:
-blockfinal()
,
-blockheader()
,
-blockopt()
library(PopED)
-
-############# START #################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## Optimization using an additive + proportional reidual error
-## to avoid sample times at very low concentrations (time 0 or very late samples).
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(prop=0.01,add=0.25),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0.01,
- maxxt=120,
- a=c(DOSE=70),
- mina=c(DOSE=0.01),
- maxa=c(DOSE=100))
-
-############# END ###################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-
-blockexp("",poped.db, opt_xt=TRUE)
-#> ==============================================================================
-#> Model description : PopED model
-#>
-#> Model Sizes :
-#> Number of individual model parameters g[j] : Ng = 5
-#> Number of population model fixed parameters bpop[j] : Nbpop = 4
-#> Number of population model random effects parameters b[j] : Nb = 3
-#>
-#> Typical Population Parameters:
-#> Warning: 5 arguments not used by format '%s[%g%s]: %5.4g %s
-#> '
-#> bpop[1]: 0.15
-#> Warning: 5 arguments not used by format '%s[%g%s]: %5.4g %s
-#> '
-#> bpop[2]: 8
-#> Warning: 5 arguments not used by format '%s[%g%s]: %5.4g %s
-#> '
-#> bpop[3]: 1
-#> Warning: 5 arguments not used by format '%s[%g%s]: %5.4g %s
-#> '
-#> bpop[4]: 1
-#>
-#> Between Subject Variability matrix D (variance units)
-#> 0.07 0.00 0.00
-#> 0.00 0.02 0.00
-#> 0.00 0.00 0.60
-#>
-#> Diagonal Elements of D [sqrt(param)]:
-#> Warning: 5 arguments not used by format '%s[%g%s]: %5.4g %s
-#> '
-#> D[1,1]: 0.07 [0.2646]
-#> Warning: 5 arguments not used by format '%s[%g%s]: %5.4g %s
-#> '
-#> D[2,2]: 0.02 [0.1414]
-#> Warning: 5 arguments not used by format '%s[%g%s]: %5.4g %s
-#> '
-#> D[3,3]: 0.6 [0.7746]
-#>
-#> Residual Unexplained Variability matrix SIGMA (variance units) :
-#> 0.01 0.00
-#> 0.00 0.25
-#>
-#> Diagonal Elements of SIGMA [sqrt(param)]:
-#> Warning: 5 arguments not used by format '%s[%g%s]: %5.4g %s
-#> '
-#> SIGMA[1,1]: 0.01 [ 0.1]
-#> Warning: 5 arguments not used by format '%s[%g%s]: %5.4g %s
-#> '
-#> SIGMA[2,2]: 0.25 [ 0.5]
-#>
-#> ==============================================================================
-#> Experiment description (design and design space)
-#>
-#> Warning: 2 arguments not used by format 'Number of individuals: %g
-#> '
-#> Number of individuals: 32
-#> Number of groups (individuals with same design): 1
-#> Number of individuals per group:
-#>
-#> Warning: 2 arguments not used by format ' Group %g: %g
-#> '
-#> Group 1: 32
-#> Number of samples per group:
-#> Number of discrete experimental variables: 0
-#> Number of model covariates: 1
-#>
-#> Initial Sampling Schedule
-#> Group 1: 0.5 1 2 6 24 36 72 120
-#>
-#> Minimum allowed sampling values
-#> Group 1: 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01
-#>
-#> Maximum allowed sampling values
-#> Group 1: 120 120 120 120 120 120 120 120
-#>
-#> Covariates:
-#> Group 1:
-#> Warning: 2 arguments not used by format '%g'
-#> 70
-#>
-#> NULL
-
-
Create some output to the screen and a text file that summarizes the problem you solved.
-blockfinal(
- fn,
- fmf,
- dmf,
- groupsize,
- ni,
- xt,
- x,
- a,
- model_switch,
- bpop,
- d,
- docc,
- sigma,
- poped.db,
- opt_xt = poped.db$settings$optsw[2],
- opt_a = poped.db$settings$optsw[4],
- opt_x = poped.db$settings$optsw[3],
- opt_inds = poped.db$settings$optsw[5],
- fmf_init = NULL,
- dmf_init = NULL,
- param_cvs_init = NULL,
- compute_inv = TRUE,
- out_file = NULL,
- trflag = TRUE,
- footer_flag = TRUE,
- run_time = NULL,
- ...
-)
The file handle to write to.
The initial value of the FIM. If set to zero then it is computed.
The initial OFV. If set to zero then it is computed.
A vector of the number of individuals in each group.
A vector of the number of samples in each group.
A matrix of sample times. Each row is a vector of sample times for a group.
A matrix for the discrete design variables. Each row is a group.
A matrix of covariates. Each row is a group.
A matrix that is the same size as xt, specifying which model each sample belongs to.
Matrix defining the fixed effects, per row (row number = parameter_number) we should have:
column 1 the type of the distribution for E-family designs (0 = Fixed, 1 = Normal, 2 = Uniform, - 3 = User Defined Distribution, 4 = lognormal and 5 = truncated normal)
column 2 defines the mean.
column 3 defines the variance of the distribution (or length of uniform distribution).
Can also just supply the parameter values as a vector c()
if no uncertainty around the
-parameter value is to be used. The parameter order of 'bpop' is defined in the 'fg_fun' or 'fg_file'. If you use named
-arguments in 'bpop' then the order will be worked out automatically.
Matrix defining the diagonals of the IIV (same logic as for the fixed effects
-matrix bpop to define uncertainty). One can also just supply the parameter values as a c()
.
-The parameter order of 'd' is defined in the 'fg_fun' or 'fg_file'. If you use named
-arguments in 'd' then the order will be worked out automatically.
Matrix defining the IOV, the IOV variances and the IOV distribution as for d and bpop.
Matrix defining the variances can covariances of the residual variability terms of the model.
-can also just supply the diagonal parameter values (variances) as a c()
.
A PopED database.
Should the sample times be optimized?
Should the continuous design variables be optimized?
Should the discrete design variables be optimized?
Are the number of individuals per group being optimized?
Initial FIM.
Initial OFV.
The initial design parameter RSE values in percent.
should the inverse of the FIM be used to compute expected RSE values? Often not needed -except for diagnostic purposes.
Which file should the output be directed to? A string, a file handle using
-file
or ""
will output to the screen.
Should the optimization be output to the screen and to a file?
Should the footer text be printed out?
arguments passed to evaluate.fim
and ofv_fim
.
Other Helper:
-blockexp()
,
-blockheader()
,
-blockopt()
library(PopED)
-
-############# START #################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## Optimization using an additive + proportional reidual error
-## to avoid sample times at very low concentrations (time 0 or very late samples).
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(prop=0.01,add=0.25),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0.01,
- maxxt=120,
- a=c(DOSE=70),
- mina=c(DOSE=0.01),
- maxa=c(DOSE=100))
-
-############# END ###################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-
-FIM <- evaluate.fim(poped.db)
-dmf <- det(FIM)
-
-
-blockfinal(fn="",fmf=FIM,
- dmf=dmf,
- groupsize=poped.db$design$groupsize,
- ni=poped.db$design$ni,
- xt=poped.db$design$xt,
- x=poped.db$design$x,a=poped.db$design$a,
- model_switch=poped.db$design$model_switch,
- poped.db$parameters$param.pt.val$bpop,
- poped.db$parameters$param.pt.val$d,
- poped.db$parameters$docc,
- poped.db$parameters$param.pt.val$sigma,
- poped.db,
- opt_xt=TRUE,
- fmf_init=FIM,
- dmf_init=dmf,
- param_cvs_init=get_rse(FIM,poped.db))
-#> ===============================================================================
-#> FINAL RESULTS
-#> Optimized Sampling Schedule
-#> Group 1: 0.5 1 2 6 24 36 72 120
-#>
-#> OFV = 1.14386e+24
-#>
-#> Efficiency:
-#> ((exp(ofv_final) / exp(ofv_init))^(1/n_parameters)) = NaN
-#>
-#> Expected relative standard error
-#> (%RSE, rounded to nearest integer):
-#> Parameter Values RSE_0 RSE
-#> CL 0.15 5 5
-#> V 8 3 3
-#> KA 1 14 14
-#> d_CL 0.07 30 30
-#> d_V 0.02 37 37
-#> d_KA 0.6 27 27
-#> sig_prop 0.01 32 32
-#> sig_add 0.25 26 26
-#>
-#> Total running time: 1.25 seconds
-
-
-
Create some output to the screen and a text file that summarizes the problem you are tying to solve.
-blockheader(
- poped.db,
- name = "Default",
- iter = NULL,
- e_flag = !(poped.db$settings$d_switch),
- opt_xt = poped.db$settings$optsw[2],
- opt_a = poped.db$settings$optsw[4],
- opt_x = poped.db$settings$optsw[3],
- opt_samps = poped.db$settings$optsw[1],
- opt_inds = poped.db$settings$optsw[5],
- fmf = 0,
- dmf = 0,
- bpop = NULL,
- d = NULL,
- docc = NULL,
- sigma = NULL,
- name_header = poped.db$settings$strOutputFileName,
- file_path = poped.db$settings$strOutputFilePath,
- out_file = NULL,
- compute_inv = TRUE,
- trflag = TRUE,
- header_flag = TRUE,
- ...
-)
A PopED database.
The name used for the output file. Combined with name_header
and iter
.
-If ""
then output is to the screen.
The last number in the name printed to the output file, combined with name
.
Should output be with uncertainty around parameters?
Should the sample times be optimized?
Should the continuous design variables be optimized?
Should the discrete design variables be optimized?
Are the number of sample times per group being optimized?
Are the number of individuals per group being optimized?
The initial value of the FIM. If set to zero then it is computed.
The initial OFV. If set to zero then it is computed.
Matrix defining the fixed effects, per row (row number = parameter_number) we should have:
column 1 the type of the distribution for E-family designs (0 = Fixed, 1 = Normal, 2 = Uniform, - 3 = User Defined Distribution, 4 = lognormal and 5 = truncated normal)
column 2 defines the mean.
column 3 defines the variance of the distribution (or length of uniform distribution).
Can also just supply the parameter values as a vector c()
if no uncertainty around the
-parameter value is to be used. The parameter order of 'bpop' is defined in the 'fg_fun' or 'fg_file'. If you use named
-arguments in 'bpop' then the order will be worked out automatically.
Matrix defining the diagonals of the IIV (same logic as for the fixed effects
-matrix bpop to define uncertainty). One can also just supply the parameter values as a c()
.
-The parameter order of 'd' is defined in the 'fg_fun' or 'fg_file'. If you use named
-arguments in 'd' then the order will be worked out automatically.
Matrix defining the IOV, the IOV variances and the IOV distribution as for d and bpop.
Matrix defining the variances can covariances of the residual variability terms of the model.
-can also just supply the diagonal parameter values (variances) as a c()
.
The initial portion of the file name.
The path to where the file should be created.
Which file should the output be directed to? A string, a file handle using
-file
or ""
will output to the screen.
should the inverse of the FIM be used to compute expected RSE values? Often not needed -except for diagnostic purposes.
Should the optimization be output to the screen and to a file?
Should the header text be printed out?
Additional arguments passed to further functions.
fn A file handle (or ''
if name=''
)
Other Helper:
-blockexp()
,
-blockfinal()
,
-blockopt()
library(PopED)
-
-############# START #################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## Optimization using an additive + proportional reidual error
-## to avoid sample times at very low concentrations (time 0 or very late samples).
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(prop=0.01,add=0.25),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0.01,
- maxxt=120,
- a=c(DOSE=70),
- mina=c(DOSE=0.01),
- maxa=c(DOSE=100))
-
-############# END ###################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-
-FIM <- evaluate.fim(poped.db)
-dmf <- det(FIM)
-
-blockheader(poped.db,name="")
-#> ==============================================================================
-#> Optimization of design parameters
-#>
-#>
-#> [1] ""
-
-blockheader(name="",iter=1,poped.db)
-#> ==============================================================================
-#> Optimization of design parameters
-#>
-#>
-#> [1] ""
-
-
-blockheader(name='',
- iter=1,
- poped.db,
- e_flag=FALSE,
- opt_xt=TRUE,
- opt_a=TRUE,opt_x=poped.db$settings$optsw[4],
- opt_samps=poped.db$settings$optsw[1],opt_inds=poped.db$settings$optsw[5],
- fmf=FIM,dmf=dmf,
- bpop=poped.db$parameters$param.pt.val$bpop,
- d=poped.db$parameters$param.pt.val$d,
- docc=poped.db$parameters$docc,sigma=poped.db$parameters$param.pt.val$sigma)
-#> ===============================================================================
-#> Initial design evaluation
-#>
-#> Initial OFV = 1.14386e+24
-#>
-#> Initial design
-#> expected relative standard error
-#> (%RSE, rounded to nearest integer)
-#> Parameter Values RSE_0
-#> CL 0.15 5
-#> V 8 3
-#> KA 1 14
-#> d_CL 0.07 30
-#> d_V 0.02 37
-#> d_KA 0.6 27
-#> sig_prop 0.01 32
-#> sig_add 0.25 26
-#>
-#> ==============================================================================
-#> Optimization of design parameters
-#>
-#> * Optimize Sampling Schedule
-#> * Optimize Covariates
-#>
-#> [1] ""
-
-
-
-blockheader(name='',
- iter=1,
- poped.db,
- e_flag=TRUE,
- opt_xt=TRUE,
- opt_a=TRUE,opt_x=poped.db$settings$optsw[4],
- opt_samps=poped.db$settings$optsw[1],opt_inds=poped.db$settings$optsw[5],
- fmf=FIM,dmf=dmf,
- bpop=poped.db$parameters$param.pt.val$bpop,
- d=poped.db$parameters$param.pt.val$d,
- docc=poped.db$parameters$docc,sigma=poped.db$parameters$param.pt.val$sigma)
-#> ===============================================================================
-#> Initial design evaluation
-#>
-#> Initial OFV = 1.14386e+24
-#>
-#> Initial design
-#> expected relative standard error
-#> (%RSE, rounded to nearest integer)
-#> Parameter Values RSE_0
-#> CL 0.15 5
-#> V 8 3
-#> KA 1 14
-#> d_CL 0.07 30
-#> d_V 0.02 37
-#> d_KA 0.6 27
-#> sig_prop 0.01 32
-#> sig_add 0.25 26
-#>
-#> ==============================================================================
-#> Optimization of design parameters
-#>
-#> * Optimize Sampling Schedule
-#> * Optimize Covariates
-#>
-#> [1] ""
-
-
-poped.db.1 <- create.poped.database(ff_file="ff.PK.1.comp.oral.sd.CL",
- fg_file="sfg",
- fError_file="feps.add.prop",
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(0.01,0.25),
- groupsize=32,
- xt=rbind(c( 0.5,1,2,6,24,36,72,120),
- c( 0.5,1.1,2,6,24,36,72,120)),
- minxt=rbind(c(0,1,1.5,3,20,30,70,118),
- c(0.1,1.1,1.6,3.1,20.1,30.1,70.1,118.1)),
- maxxt=c(12,13,14,15,26,44,78,120),
- a=70,
- mina=0,
- maxa=100)
-#> Warning: cannot open file 'sfg': No such file or directory
-#> Error in file(filename, "r", encoding = encoding): cannot open the connection
-
-
-blockheader(poped.db.1,name="",trflag=2,opt_xt=TRUE)
-#> ==============================================================================
-#> Error in eval(expr, envir, enclos): object 'poped.db.1' not found
-
-
-
R/blockopt.R
- blockopt.Rd
Create some output to the screen and a text file that summarizes the optimization settings -you will use to optimize.
-blockopt(fn, poped.db, opt_method = "")
The file handle to write to.
A PopED database.
If "RS" (random search), "SG" (stochastic gradient) or "DO" (discrete optimization) then specific output is produced.
Other Helper:
-blockexp()
,
-blockfinal()
,
-blockheader()
library(PopED)
-
-############# START #################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## Optimization using an additive + proportional reidual error
-## to avoid sample times at very low concentrations (time 0 or very late samples).
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(prop=0.01,add=0.25),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0.01,
- maxxt=120,
- a=c(DOSE=70),
- mina=c(DOSE=0.01),
- maxa=c(DOSE=100))
-
-############# END ###################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-
-blockopt(fn="",poped.db,opt_method="SG")
-#> ==============================================================================
-#> Optimization Settings
-#>
-#> Stochastic Gradient :
-#> Maximum number of cycles : 150
-#> Epsilon for termination : 1e-08
-#> First step factor for xt: 0.001
-#> First step factor for a: 0.001
-#> RS m0it: 50
-#>
-#> NULL
-blockopt(fn="",poped.db,opt_method="RS")
-#> ==============================================================================
-#> Optimization Settings
-#>
-#> Random Search :
-#> Number of cycles : 300
-#> Locality factor for xt : 10
-#> Locality factor for a : 10
-#>
-#> NULL
-blockopt(fn="",poped.db,opt_method="DO")
-#> ==============================================================================
-#> Optimization Settings
-#>
-#> Discrete Optimization :
-#> RS int it: 250
-#> SG int it: 50
-#>
-#> NULL
-
Build PopED parameter function from a model function
-build_sfg(
- model = "ff.PK.1.comp.oral.sd.CL",
- covariates = c("dose", "tau"),
- par_names = NULL,
- etas = "exp",
- no_etas = c("F", "Favail"),
- env = parent.frame()
-)
A string of text describing the model function name
A list of covariate names to be filtered out of the model
A list of parameter names in the model file. If not supplied then -all undefined variables in the model file are extracted and the covariate names are -filtered out of that list.
Can be "exp", "prop", "add" or "none". Either one value for all parameters or -a list defining the model per parameter.
Parameters that should not have etas associated with them.
The environment to create the function in.
A parameter model function to be used as input to PopED calculations.
-build_sfg(model="ff.PK.1.comp.oral.md.CL")
-#> function (x, a, bpop, b, bocc)
-#> parameters = c(CL = bpop[1] * exp(b[1]), Favail = bpop[2], KA = bpop[3] *
-#> exp(b[2]), V = bpop[4] * exp(b[3]), DOSE = a[1], TAU = a[2])
-#> <environment: 0x11047b668>
-
-etas <- c(Favail="exp",KA="exp",V="add",CL="exp")
-build_sfg(model="ff.PK.1.comp.oral.md.CL",etas = etas)
-#> function (x, a, bpop, b, bocc)
-#> parameters = c(CL = bpop[1] * exp(b[1]), Favail = bpop[2] * exp(b[2]),
-#> KA = bpop[3] * exp(b[3]), V = bpop[4] + b[4], DOSE = a[1],
-#> TAU = a[2])
-#> <environment: 0x11047b668>
-
R/Doptim.R
- calc_autofocus.Rd
Compute the autofocus portion of the stochastic gradient routine
-calc_autofocus(
- m,
- ni_var,
- dmf,
- varopt,
- varopto,
- maxvar,
- minvar,
- gradvar,
- normgvar,
- avar,
- model_switch,
- groupsize,
- xtopt,
- xopt,
- aopt,
- ni,
- bpop,
- d,
- sigma,
- docc,
- poped.db
-)
Number of groups in the study. Each individual in a group will have the same design.
The ni_var.
The initial OFV. If set to zero then it is computed.
The varopt.
The varopto.
The maxvar.
The minvar.
The gradvar.
The normgvar.
The avar.
A matrix that is the same size as xt, specifying which model each sample belongs to.
A vector of the number of individuals in each group.
The optimal sampling times matrix.
The optimal discrete design variables matrix.
The optimal continuous design variables matrix.
A vector of the number of samples in each group.
Matrix defining the fixed effects, per row (row number = parameter_number) we should have:
column 1 the type of the distribution for E-family designs (0 = Fixed, 1 = Normal, 2 = Uniform, - 3 = User Defined Distribution, 4 = lognormal and 5 = truncated normal)
column 2 defines the mean.
column 3 defines the variance of the distribution (or length of uniform distribution).
Can also just supply the parameter values as a vector c()
if no uncertainty around the
-parameter value is to be used. The parameter order of 'bpop' is defined in the 'fg_fun' or 'fg_file'. If you use named
-arguments in 'bpop' then the order will be worked out automatically.
Matrix defining the diagonals of the IIV (same logic as for the fixed effects
-matrix bpop to define uncertainty). One can also just supply the parameter values as a c()
.
-The parameter order of 'd' is defined in the 'fg_fun' or 'fg_file'. If you use named
-arguments in 'd' then the order will be worked out automatically.
Matrix defining the variances can covariances of the residual variability terms of the model.
-can also just supply the diagonal parameter values (variances) as a c()
.
Matrix defining the IOV, the IOV variances and the IOV distribution as for d and bpop.
A PopED database.
A list containing:
-The autofocus parameter.
PopED database.
Other Optimize:
-Doptim()
,
-LEDoptim()
,
-RS_opt()
,
-a_line_search()
,
-bfgsb_min()
,
-calc_ofv_and_grad()
,
-mfea()
,
-optim_ARS()
,
-optim_LS()
,
-poped_optim_1()
,
-poped_optim_2()
,
-poped_optim_3()
,
-poped_optimize()
,
-poped_optim()
library(PopED)
-
-############# START #################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## Optimization using an additive + proportional reidual error
-## to avoid sample times at very low concentrations (time 0 or very late samples).
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(prop=0.01,add=0.25),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0.01,
- maxxt=120,
- a=c(DOSE=70),
- mina=c(DOSE=0.01),
- maxa=c(DOSE=100))
-
-############# END ###################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-
-if (FALSE) {
-
-# Stochastic gradient search, DOSE and sample time optimization
-sg.output <- poped_optimize(poped.db,opt_xt=1,opt_a=1,
- bUseRandomSearch= 0,
- bUseStochasticGradient = 1,
- bUseBFGSMinimizer = 0,
- bUseLineSearch = 0,
- sgit=20)
-
-}
-
R/calc_ofv_and_fim.R
- calc_ofv_and_fim.Rd
This function computes the expectation of the FIM and OFV(FIM) for either point values of parameter estimates -or parameter distributions given the model, parameters, -distributions of parameter uncertainty, design and methods defined in the -PopED database.
-calc_ofv_and_fim(
- poped.db,
- ofv = 0,
- fim = 0,
- d_switch = poped.db$settings$d_switch,
- bpopdescr = poped.db$parameters$bpop,
- ddescr = poped.db$parameters$d,
- bpop = bpopdescr[, 2, drop = F],
- d = getfulld(ddescr[, 2, drop = F], poped.db$parameters$covd),
- docc_full = getfulld(poped.db$parameters$docc[, 2, drop = F],
- poped.db$parameters$covdocc),
- model_switch = poped.db$design$model_switch,
- ni = poped.db$design$ni,
- xt = poped.db$design$xt,
- x = poped.db$design$x,
- a = poped.db$design$a,
- fim.calc.type = poped.db$settings$iFIMCalculationType,
- use_laplace = poped.db$settings$iEDCalculationType,
- laplace.fim = FALSE,
- ofv_fun = poped.db$settings$ofv_fun,
- evaluate_fim = TRUE,
- ...
-)
A PopED database.
The current ofv. If other than zero then this value is simply returned unchanged.
The current FIM. If other than zero then this value is simply returned unchanged.
******START OF CRITERION SPECIFICATION OPTIONS**********
D-family design (1) or ED-family design (0) (with or without parameter uncertainty)
Matrix defining the fixed effects, per row (row number = -parameter_number) we should have:
column 1 the type of the -distribution for E-family designs (0 = Fixed, 1 = Normal, 2 = Uniform, 3 = -User Defined Distribution, 4 = lognormal and 5 = truncated normal)
column 2 defines the mean.
column 3 defines the variance of the -distribution (or length of uniform distribution).
Matrix defining the diagonals of the IIV (same logic as for
-the bpopdescr
).
Matrix defining the fixed effects, per row (row number = parameter_number) we should have:
column 1 the type of the distribution for E-family designs (0 = Fixed, 1 = Normal, 2 = Uniform, - 3 = User Defined Distribution, 4 = lognormal and 5 = truncated normal)
column 2 defines the mean.
column 3 defines the variance of the distribution (or length of uniform distribution).
Can also just supply the parameter values as a vector c()
if no uncertainty around the
-parameter value is to be used. The parameter order of 'bpop' is defined in the 'fg_fun' or 'fg_file'. If you use named
-arguments in 'bpop' then the order will be worked out automatically.
Matrix defining the diagonals of the IIV (same logic as for the fixed effects
-matrix bpop to define uncertainty). One can also just supply the parameter values as a c()
.
-The parameter order of 'd' is defined in the 'fg_fun' or 'fg_file'. If you use named
-arguments in 'd' then the order will be worked out automatically.
A between occasion variability matrix.
A matrix that is the same size as xt, specifying which model each sample belongs to.
A vector of the number of samples in each group.
A matrix of sample times. Each row is a vector of sample times for a group.
A matrix for the discrete design variables. Each row is a group.
A matrix of covariates. Each row is a group.
The method used for calculating the FIM. Potential values:
0 = Full FIM. No assumption that fixed and random effects are uncorrelated.
1 = Reduced FIM. Assume that there is no correlation in the FIM between the fixed and random effects, and set these elements in -the FIM to zero.
2 = weighted models (placeholder).
3 = Not currently used.
4 = Reduced FIM and computing all derivatives with respect to the standard deviation of the residual unexplained variation (sqrt(SIGMA) in NONMEM). -This matches what is done in PFIM, and assumes that the standard deviation of the residual unexplained variation is the estimated parameter -(NOTE: NONMEM estimates the variance of the residual unexplained variation by default).
5 = Full FIM parameterized with A,B,C matrices & derivative of variance.
6 = Calculate one model switch at a time, good for large matrices.
7 = Reduced FIM parameterized with A,B,C matrices & derivative of variance.
Should the Laplace method be used in calculating the expectation of the OFV?
Should an E(FIM) be calculated when computing the Laplace approximated E(OFV). Typically -the FIM does not need to be computed and, if desired, this calculation -is done using the standard MC integration technique, so can be slow.
User defined function used to compute the objective function. The function must have a poped database object as its first -argument and have "..." in its argument list. Can be referenced as a function or as a file name where the function defined in the file has the same name as the file. -e.g. "cost.txt" has a function named "cost" in it.
Should the FIM be calculated?
Other arguments passed to the function.
A list containing the FIM and OFV(FIM) or the E(FIM) and E(OFV(FIM)) according to the function arguments.
-Other FIM:
-LinMatrixH()
,
-LinMatrixLH()
,
-LinMatrixL_occ()
,
-ed_laplace_ofv()
,
-ed_mftot()
,
-efficiency()
,
-evaluate.e.ofv.fim()
,
-evaluate.fim()
,
-gradf_eps()
,
-mf3()
,
-mf7()
,
-mftot()
,
-ofv_criterion()
,
-ofv_fim()
Other E-family:
-ed_laplace_ofv()
,
-ed_mftot()
,
-evaluate.e.ofv.fim()
Other evaluate_FIM:
-evaluate.e.ofv.fim()
,
-evaluate.fim()
,
-ofv_fim()
library(PopED)
-
-############# START #################
-## Create PopED database
-## (warfarin model for optimization
-## with parameter uncertainty)
-#####################################
-
-## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## Optimization using an additive + proportional reidual error
-## to avoid sample times at very low concentrations (time 0 or very late samoples).
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-# Adding 10% log-normal Uncertainty to fixed effects (not Favail)
-bpop_vals <- c(CL=0.15, V=8, KA=1.0, Favail=1)
-bpop_vals_ed_ln <- cbind(ones(length(bpop_vals),1)*4, # log-normal distribution
- bpop_vals,
- ones(length(bpop_vals),1)*(bpop_vals*0.1)^2) # 10% of bpop value
-bpop_vals_ed_ln["Favail",] <- c(0,1,0)
-bpop_vals_ed_ln
-#> bpop_vals
-#> CL 4 0.15 0.000225
-#> V 4 8.00 0.640000
-#> KA 4 1.00 0.010000
-#> Favail 0 1.00 0.000000
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- bpop=bpop_vals_ed_ln,
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(0.01,0.25),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0,
- maxxt=120,
- a=70,
- mina=0,
- maxa=100)
-
-############# END ###################
-## Create PopED database
-## (warfarin model for optimization
-## with parameter uncertainty)
-#####################################
-
-
-calc_ofv_and_fim(poped.db)
-#> $ofv
-#> [1] 55.39645
-#>
-#> $fim
-#> [,1] [,2] [,3] [,4] [,5] [,6]
-#> [1,] 17141.83891 20.838375 10.011000 0.000000e+00 0.000000 0.00000000
-#> [2,] 20.83837 17.268051 -3.423641 0.000000e+00 0.000000 0.00000000
-#> [3,] 10.01100 -3.423641 49.864697 0.000000e+00 0.000000 0.00000000
-#> [4,] 0.00000 0.000000 0.000000 2.324341e+03 9.770352 0.03523364
-#> [5,] 0.00000 0.000000 0.000000 9.770352e+00 19083.877564 11.72131703
-#> [6,] 0.00000 0.000000 0.000000 3.523364e-02 11.721317 38.85137516
-#> [7,] 0.00000 0.000000 0.000000 7.268410e+02 9656.158553 64.78095548
-#> [8,] 0.00000 0.000000 0.000000 9.062739e+01 266.487127 2.94728469
-#> [,7] [,8]
-#> [1,] 0.00000 0.000000
-#> [2,] 0.00000 0.000000
-#> [3,] 0.00000 0.000000
-#> [4,] 726.84097 90.627386
-#> [5,] 9656.15855 266.487127
-#> [6,] 64.78096 2.947285
-#> [7,] 192840.20092 6659.569867
-#> [8,] 6659.56987 475.500111
-#>
-
-if (FALSE) {
-
- calc_ofv_and_fim(poped.db,d_switch=0)
- calc_ofv_and_fim(poped.db,d_switch=0,use_laplace=TRUE)
- calc_ofv_and_fim(poped.db,d_switch=0,use_laplace=TRUE,laplace.fim=TRUE)
-
-}
-
Compute an objective function and gradient with respect to the optimization parameters.
-This function can be passed to the Broyden Fletcher Goldfarb Shanno (BFGS)
-method for nonlinear minimization with box constraints implemented in bfgsb_min
.
calc_ofv_and_grad(
- x,
- optxt,
- opta,
- model_switch,
- aa,
- axt,
- groupsize,
- ni,
- xtopto,
- xopto,
- aopto,
- bpop,
- d,
- sigma,
- docc_full,
- poped.db,
- only_fim = FALSE
-)
A matrix for the discrete design variables. Each row is a group.
If sampling times are optimized
If continuous design variables are optimized
A matrix that is the same size as xt, specifying which model each sample belongs to.
The aa value
the axt value
A vector of the number of individuals in each group.
A vector of the number of samples in each group.
the xtopto value
the xopto value
the aopto value
Matrix defining the fixed effects, per row (row number = parameter_number) we should have:
column 1 the type of the distribution for E-family designs (0 = Fixed, 1 = Normal, 2 = Uniform, - 3 = User Defined Distribution, 4 = lognormal and 5 = truncated normal)
column 2 defines the mean.
column 3 defines the variance of the distribution (or length of uniform distribution).
Can also just supply the parameter values as a vector c()
if no uncertainty around the
-parameter value is to be used. The parameter order of 'bpop' is defined in the 'fg_fun' or 'fg_file'. If you use named
-arguments in 'bpop' then the order will be worked out automatically.
Matrix defining the diagonals of the IIV (same logic as for the fixed effects
-matrix bpop to define uncertainty). One can also just supply the parameter values as a c()
.
-The parameter order of 'd' is defined in the 'fg_fun' or 'fg_file'. If you use named
-arguments in 'd' then the order will be worked out automatically.
Matrix defining the variances can covariances of the residual variability terms of the model.
-can also just supply the diagonal parameter values (variances) as a c()
.
A between occasion variability matrix.
A PopED database.
Should the gradient be calculated?
A list containing:
-The objective function.
The gradient.
Other Optimize:
-Doptim()
,
-LEDoptim()
,
-RS_opt()
,
-a_line_search()
,
-bfgsb_min()
,
-calc_autofocus()
,
-mfea()
,
-optim_ARS()
,
-optim_LS()
,
-poped_optim_1()
,
-poped_optim_2()
,
-poped_optim_3()
,
-poped_optimize()
,
-poped_optim()
library(PopED)
-
-############# START #################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## Optimization using an additive + proportional reidual error
-## to avoid sample times at very low concentrations (time 0 or very late samples).
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(prop=0.01,add=0.25),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0.01,
- maxxt=120,
- a=c(DOSE=70),
- mina=c(DOSE=0.01),
- maxa=c(DOSE=100))
-
-############# END ###################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-
-opta=TRUE
-aa=opta*poped.db$settings$cfaa*matrix(1,poped.db$design$m,size(poped.db$design$a,2))
-aa
-#> [,1]
-#> [1,] 0.001
-
-optxt=TRUE
-axt=optxt*poped.db$settings$cfaxt*matrix(1,poped.db$design$m,max(poped.db$design_space$maxni))
-axt
-#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
-#> [1,] 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001
-
-calc_ofv_and_grad(x=c(poped.db$design$xt,poped.db$design$a),
- optxt=optxt, opta=opta,
- model_switch=poped.db$design$model_switch,
- aa=aa,
- axt=axt,
- groupsize=poped.db$design$groupsize,
- ni=poped.db$design$ni,
- xtopto=poped.db$design$xt,
- xopto=poped.db$design$x,
- aopto=poped.db$design$a,
- bpop=poped.db$parameters$param.pt.val$bpop,
- d=poped.db$parameters$param.pt.val$d,
- sigma=poped.db$parameters$param.pt.val$sigma,
- docc_full=poped.db$parameters$param.pt.val$docc,
- poped.db,
- only_fim=FALSE)
-#> $f
-#> [1] -55.39645
-#>
-#> $g
-#> [,1]
-#> [1,] 0.079631184
-#> [2,] -0.025697327
-#> [3,] -0.312973786
-#> [4,] 0.009484130
-#> [5,] 0.019485306
-#> [6,] -0.001675713
-#> [7,] -0.009544063
-#> [8,] -0.001929802
-#> [9,] -0.035844547
-#>
-
-if (FALSE) {
-
- # BFGS search, DOSE and sample time optimization
- bfgs.output <- poped_optimize(poped.db,opt_xt=1,opt_a=1,
- bUseRandomSearch= 0,
- bUseStochasticGradient = 0,
- bUseBFGSMinimizer = 1,
- bUseLineSearch = 0)
-
-}
-
-
-
-
-
Create a cell array as in MATLAB.
-cell(...)
Dimensions for the cell array.
A list of empty lists.
-This is a modified version of the same function in the matlab R-package.
-
-cell(3)
-#> [,1] [,2] [,3]
-#> [1,] numeric,0 numeric,0 numeric,0
-#> [2,] numeric,0 numeric,0 numeric,0
-#> [3,] numeric,0 numeric,0 numeric,0
-cell(2,3)
-#> [,1] [,2] [,3]
-#> [1,] numeric,0 numeric,0 numeric,0
-#> [2,] numeric,0 numeric,0 numeric,0
-
-## define possible values of 2 categorical design variable
-x.space <- cell(1,2)
-x.space[1,1] <- list(seq(10,100,10))
-x.space[1,2] <- list(seq(10,300,10))
-x.space
-#> [,1] [,2]
-#> [1,] numeric,10 numeric,30
-x.space[1,1]
-#> [[1]]
-#> [1] 10 20 30 40 50 60 70 80 90 100
-#>
-x.space[1,2]
-#> [[1]]
-#> [1] 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190
-#> [20] 200 210 220 230 240 250 260 270 280 290 300
-#>
-
R/convert_variables.R
- convert_variables.Rd
Function takes design variables from input files
-and converts them to the global variables needed
-in PopED. Typically not used by the user. Instead
-use the function create.poped.database
.
convert_variables(poped.db)
A PopED database
A PopED database
-Other poped_input:
-create.poped.database()
,
-create_design_space()
,
-create_design()
,
-downsizing_general_design()
,
-poped.choose()
This function takes the input file (a previously created poped database) supplied by the user, or function arguments, -and creates a database that can then be used to -run all other PopED functions. The function supplies default values to elements of the -database that are not specified in the -input file or as function arguments. Default arguments are supplied in the Usage section -(easiest to use a text search to find values you are interested in).
-create.poped.database(
- popedInput = list(),
- ff_file = NULL,
- ff_fun = poped.choose(popedInput$model$ff_pointer, NULL),
- fg_file = NULL,
- fg_fun = poped.choose(popedInput$model$fg_pointer, NULL),
- fError_file = NULL,
- fError_fun = poped.choose(popedInput$model$ferror_pointer, NULL),
- optsw = poped.choose(popedInput$settings$optsw, cbind(0, 0, 0, 0, 0)),
- xt = poped.choose(popedInput$design[["xt"]], stop("'xt' needs to be defined")),
- m = poped.choose(popedInput$design[["m"]], NULL),
- x = poped.choose(popedInput$design[["x"]], NULL),
- nx = poped.choose(popedInput$design$nx, NULL),
- a = poped.choose(popedInput$design[["a"]], NULL),
- groupsize = poped.choose(popedInput$design$groupsize,
- stop("'groupsize' needs to be defined")),
- ni = poped.choose(popedInput$design$ni, NULL),
- model_switch = poped.choose(popedInput$design$model_switch, NULL),
- maxni = poped.choose(popedInput$design_space$maxni, NULL),
- minni = poped.choose(popedInput$design_space$minni, NULL),
- maxtotni = poped.choose(popedInput$design_space$maxtotni, NULL),
- mintotni = poped.choose(popedInput$design_space$mintotni, NULL),
- maxgroupsize = poped.choose(popedInput$design_space$maxgroupsize, NULL),
- mingroupsize = poped.choose(popedInput$design_space$mingroupsize, NULL),
- maxtotgroupsize = poped.choose(popedInput$design_space$maxtotgroupsize, NULL),
- mintotgroupsize = poped.choose(popedInput$design_space$mintotgroupsize, NULL),
- maxxt = poped.choose(popedInput$design_space$maxxt, NULL),
- minxt = poped.choose(popedInput$design_space$minxt, NULL),
- discrete_xt = poped.choose(popedInput$design_space$xt_space, NULL),
- discrete_x = poped.choose(popedInput$design_space$discrete_x, NULL),
- maxa = poped.choose(popedInput$design_space$maxa, NULL),
- mina = poped.choose(popedInput$design_space$mina, NULL),
- discrete_a = poped.choose(popedInput$design_space$a_space, NULL),
- bUseGrouped_xt = poped.choose(popedInput$design_space$bUseGrouped_xt, FALSE),
- G_xt = poped.choose(popedInput$design_space$G_xt, NULL),
- bUseGrouped_a = poped.choose(popedInput$design_space$bUseGrouped_a, FALSE),
- G_a = poped.choose(popedInput$design_space$G_a, NULL),
- bUseGrouped_x = poped.choose(popedInput$design_space$bUseGrouped_x, FALSE),
- G_x = poped.choose(popedInput$design_space[["G_x"]], NULL),
- iFIMCalculationType = poped.choose(popedInput$settings$iFIMCalculationType, 1),
- iApproximationMethod = poped.choose(popedInput$settings$iApproximationMethod, 0),
- iFOCENumInd = poped.choose(popedInput$settings$iFOCENumInd, 1000),
- prior_fim = poped.choose(popedInput$settings$prior_fim, matrix(0, 0, 1)),
- strAutoCorrelationFile = poped.choose(popedInput$model$auto_pointer, ""),
- d_switch = poped.choose(popedInput$settings$d_switch, 1),
- ofv_calc_type = poped.choose(popedInput$settings$ofv_calc_type, 4),
- ds_index = popedInput$parameters$ds_index,
- strEDPenaltyFile = poped.choose(popedInput$settings$strEDPenaltyFile, ""),
- ofv_fun = poped.choose(popedInput$settings$ofv_fun, NULL),
- iEDCalculationType = poped.choose(popedInput$settings$iEDCalculationType, 0),
- ED_samp_size = poped.choose(popedInput$settings$ED_samp_size, 45),
- bLHS = poped.choose(popedInput$settings$bLHS, 1),
- strUserDistributionFile = poped.choose(popedInput$model$user_distribution_pointer, ""),
- nbpop = popedInput$parameters$nbpop,
- NumRanEff = popedInput$parameters$NumRanEff,
- NumDocc = popedInput$parameters$NumDocc,
- NumOcc = popedInput$parameters$NumOcc,
- bpop = poped.choose(popedInput$parameters$bpop, stop("bpop must be defined")),
- d = poped.choose(popedInput$parameters$d, NULL),
- covd = popedInput$parameters$covd,
- sigma = popedInput$parameters$sigma,
- docc = poped.choose(popedInput$parameters$docc, matrix(0, 0, 3)),
- covdocc = poped.choose(popedInput$parameters$covdocc, zeros(1, length(docc[, 2, drop =
- F]) * (length(docc[, 2, drop = F]) - 1)/2)),
- notfixed_bpop = popedInput$parameters$notfixed_bpop,
- notfixed_d = popedInput$parameters$notfixed_d,
- notfixed_covd = popedInput$parameters$notfixed_covd,
- notfixed_docc = popedInput$parameters$notfixed_docc,
- notfixed_covdocc = poped.choose(popedInput$parameters$notfixed_covdocc, zeros(1,
- length(covdocc))),
- notfixed_sigma = poped.choose(popedInput$parameters$notfixed_sigma, t(rep(1,
- size(sigma, 2)))),
- notfixed_covsigma = poped.choose(popedInput$parameters$notfixed_covsigma, zeros(1,
- length(notfixed_sigma) * (length(notfixed_sigma) - 1)/2)),
- bUseRandomSearch = poped.choose(popedInput$settings$bUseRandomSearch, TRUE),
- bUseStochasticGradient = poped.choose(popedInput$settings$bUseStochasticGradient, TRUE),
- bUseLineSearch = poped.choose(popedInput$settings$bUseLineSearch, TRUE),
- bUseExchangeAlgorithm = poped.choose(popedInput$settings$bUseExchangeAlgorithm, FALSE),
- bUseBFGSMinimizer = poped.choose(popedInput$settings$bUseBFGSMinimizer, FALSE),
- EACriteria = poped.choose(popedInput$settings$EACriteria, 1),
- strRunFile = poped.choose(popedInput$settings$run_file_pointer, ""),
- poped_version = poped.choose(popedInput$settings$poped_version,
- packageVersion("PopED")),
- modtit = poped.choose(popedInput$settings$modtit, "PopED model"),
- output_file = poped.choose(popedInput$settings$output_file, paste("PopED_output",
- "_summary", sep = "")),
- output_function_file = poped.choose(popedInput$settings$output_function_file,
- paste("PopED", "_output_", sep = "")),
- strIterationFileName = poped.choose(popedInput$settings$strIterationFileName,
- paste("PopED", "_current.R", sep = "")),
- user_data = poped.choose(popedInput$settings$user_data, cell(0, 0)),
- ourzero = poped.choose(popedInput$settings$ourzero, 1e-05),
- dSeed = poped.choose(popedInput$settings$dSeed, NULL),
- line_opta = poped.choose(popedInput$settings$line_opta, NULL),
- line_optx = poped.choose(popedInput$settings$line_optx, NULL),
- bShowGraphs = poped.choose(popedInput$settings$bShowGraphs, FALSE),
- use_logfile = poped.choose(popedInput$settings$use_logfile, FALSE),
- m1_switch = poped.choose(popedInput$settings$m1_switch, 1),
- m2_switch = poped.choose(popedInput$settings$m2_switch, 1),
- hle_switch = poped.choose(popedInput$settings$hle_switch, 1),
- gradff_switch = poped.choose(popedInput$settings$gradff_switch, 1),
- gradfg_switch = poped.choose(popedInput$settings$gradfg_switch, 1),
- grad_all_switch = poped.choose(popedInput$settings$grad_all_switch, 1),
- rsit_output = poped.choose(popedInput$settings$rsit_output, 5),
- sgit_output = poped.choose(popedInput$settings$sgit_output, 1),
- hm1 = poped.choose(popedInput$settings[["hm1"]], 1e-05),
- hlf = poped.choose(popedInput$settings[["hlf"]], 1e-05),
- hlg = poped.choose(popedInput$settings[["hlg"]], 1e-05),
- hm2 = poped.choose(popedInput$settings[["hm2"]], 1e-05),
- hgd = poped.choose(popedInput$settings[["hgd"]], 1e-05),
- hle = poped.choose(popedInput$settings[["hle"]], 1e-05),
- AbsTol = poped.choose(popedInput$settings$AbsTol, 1e-06),
- RelTol = poped.choose(popedInput$settings$RelTol, 1e-06),
- iDiffSolverMethod = poped.choose(popedInput$settings$iDiffSolverMethod, NULL),
- bUseMemorySolver = poped.choose(popedInput$settings$bUseMemorySolver, FALSE),
- rsit = poped.choose(popedInput$settings[["rsit"]], 300),
- sgit = poped.choose(popedInput$settings[["sgit"]], 150),
- intrsit = poped.choose(popedInput$settings$intrsit, 250),
- intsgit = poped.choose(popedInput$settings$intsgit, 50),
- maxrsnullit = poped.choose(popedInput$settings$maxrsnullit, 50),
- convergence_eps = poped.choose(popedInput$settings$convergence_eps, 1e-08),
- rslxt = poped.choose(popedInput$settings$rslxt, 10),
- rsla = poped.choose(popedInput$settings$rsla, 10),
- cfaxt = poped.choose(popedInput$settings$cfaxt, 0.001),
- cfaa = poped.choose(popedInput$settings$cfaa, 0.001),
- bGreedyGroupOpt = poped.choose(popedInput$settings$bGreedyGroupOpt, FALSE),
- EAStepSize = poped.choose(popedInput$settings$EAStepSize, 0.01),
- EANumPoints = poped.choose(popedInput$settings$EANumPoints, FALSE),
- EAConvergenceCriteria = poped.choose(popedInput$settings$EAConvergenceCriteria, 1e-20),
- bEANoReplicates = poped.choose(popedInput$settings$bEANoReplicates, FALSE),
- BFGSConvergenceCriteriaMinStep = NULL,
- BFGSProjectedGradientTol = poped.choose(popedInput$settings$BFGSProjectedGradientTol,
- 1e-04),
- BFGSTolerancef = poped.choose(popedInput$settings$BFGSTolerancef, 0.001),
- BFGSToleranceg = poped.choose(popedInput$settings$BFGSToleranceg, 0.9),
- BFGSTolerancex = poped.choose(popedInput$settings$BFGSTolerancex, 0.1),
- ED_diff_it = poped.choose(popedInput$settings$ED_diff_it, 30),
- ED_diff_percent = poped.choose(popedInput$settings$ED_diff_percent, 10),
- line_search_it = poped.choose(popedInput$settings$ls_step_size, 50),
- Doptim_iter = poped.choose(popedInput$settings$iNumSearchIterationsIfNotLineSearch, 1),
- iCompileOption = poped.choose(popedInput$settings$parallel$iCompileOption, -1),
- iUseParallelMethod = poped.choose(popedInput$settings$parallel$iUseParallelMethod, 1),
- MCC_Dep = NULL,
- strExecuteName = poped.choose(popedInput$settings$parallel$strExecuteName,
- "calc_fim.exe"),
- iNumProcesses = poped.choose(popedInput$settings$parallel$iNumProcesses, 2),
- iNumChunkDesignEvals = poped.choose(popedInput$settings$parallel$iNumChunkDesignEvals,
- -2),
- Mat_Out_Pre = poped.choose(popedInput$settings$parallel$strMatFileOutputPrefix,
- "parallel_output"),
- strExtraRunOptions = poped.choose(popedInput$settings$parallel$strExtraRunOptions, ""),
- dPollResultTime = poped.choose(popedInput$settings$parallel$dPollResultTime, 0.1),
- strFunctionInputName = poped.choose(popedInput$settings$parallel$strFunctionInputName,
- "function_input"),
- bParallelRS = poped.choose(popedInput$settings$parallel$bParallelRS, FALSE),
- bParallelSG = poped.choose(popedInput$settings$parallel$bParallelSG, FALSE),
- bParallelMFEA = poped.choose(popedInput$settings$parallel$bParallelMFEA, FALSE),
- bParallelLS = poped.choose(popedInput$settings$parallel$bParallelLS, FALSE)
-)
A PopED database file or an empty list list()
. List elements should match the values seen in
-the Usage section (the defaults to function arguments).
******START OF MODEL DEFINITION OPTIONS**********
A string giving the function name or filename and path of the structural model.
-The filename and the function name must be the same if giving a filename.
-e.g. "ff.PK.1.comp.oral.md.KE"
Function describing the structural model. e.g. ff.PK.1.comp.oral.md.KE
.
A string giving the function name or filename and path of the
-parameter model.
-The filename and the function name must be the same if giving a filename.
-e.g. "parameter.model"
Function describing the parameter model. e.g. parameter.model
.
A string giving the function name or filename and path of the
-residual error model.
-The filename and the function name must be the same if giving a filename.
-e.g. "feps.prop"
.
Function describing the residual error model. e.g. feps.prop
.
******WHAT TO OPTIMIZE**********
Row vector of optimization tasks (1=TRUE,0=FALSE) in the following order: -(Samples per subject, Sampling schedule, Discrete design variable, Continuous design variable, Number of id per group). -All elements set to zero => only calculate the FIM with current design
******START OF INITIAL DESIGN OPTIONS**********
Matrix defining the initial sampling schedule.
- Each row is a group/individual.
- If only one vector is supplied, e.g. c(1,2,3,4)
, then all groups will
-have the same initial design.
Number of groups in the study. Each individual in a group will have the same design.
A matrix defining the initial discrete values for the model -Each row is a group/individual.
Number of discrete design variables.
Matrix defining the initial continuous covariate values. -n_rows=number of groups, n_cols=number of covariates. -If the number of rows is one and the number of groups > 1 then all groups are assigned the -same values.
Vector defining the size of the different groups (num individuals in each group). -If only one number then the number will be the same in every group.
Vector defining the number of samples for each group.
Matrix defining which response a certain sampling time belongs to.
******START OF DESIGN SPACE OPTIONS**********
Max number of samples per group/individual
Min number of samples per group/individual
Number defining the maximum number of samples allowed in the experiment.
Number defining the minimum number of samples allowed in the experiment.
Vector defining the max size of the different groups (max number of individuals in each group)
Vector defining the min size of the different groups (min num individuals in each group) --
The total maximal groupsize over all groups
The total minimal groupsize over all groups
Matrix or single value defining the maximum value for each xt sample. If a single value is -supplied then all xt values are given the same maximum value.
Matrix or single value defining the minimum value for each xt sample. If a single value is -supplied then all xt values are given the same minimum value
Cell array cell
defining the discrete variables allowed for each xt value.
- Can also be a list of values list(1:10)
(same values allowed for all xt), or a list of lists
-list(1:10, 2:23, 4:6)
(one for each value in xt). See examples in create_design_space
.
Cell array defining the discrete variables for each x value.
-See examples in create_design_space
.
Vector defining the max value for each covariate. If a single value is supplied then -all a values are given the same max value
Vector defining the min value for each covariate. If a single value is supplied then -all a values are given the same max value
Cell array cell
defining the discrete variables allowed for each a value.
- Can also be a list of values list(1:10)
(same values allowed for all a), or a list of lists
-list(1:10, 2:23, 4:6)
(one for each value in a). See examples in create_design_space
.
Use grouped time points (1=TRUE, 0=FALSE).
Matrix defining the grouping of sample points. Matching integers mean that the points are matched.
Use grouped covariates (1=TRUE, 0=FALSE)
Matrix defining the grouping of covariates. Matching integers mean that the points are matched.
Use grouped discrete design variables (1=TRUE, 0=FALSE).
Matrix defining the grouping of discrete design variables. Matching integers mean that the points are matched.
******START OF FIM CALCULATION OPTIONS**********
Fisher Information Matrix type
0=Full FIM
1=Reduced FIM
2=weighted models
3=Loc models
4=reduced FIM with derivative of SD of sigma as in PFIM
5=FULL FIM parameterized with A,B,C matrices & derivative of variance
6=Calculate one model switch at a time, good for large matrices
7=Reduced FIM parameterized with A,B,C matrices & derivative of variance
Approximation method for model, 0=FO, 1=FOCE, 2=FOCEI, 3=FOI
Num individuals in each step of FOCE
The prior FIM (added to calculated FIM)
Filename and path, or function name, for the Autocorrelation function, -empty string means no autocorrelation.
******START OF CRITERION SPECIFICATION OPTIONS**********
D-family design (1) or ED-family design (0) (with or without parameter uncertainty)
OFV calculation type for FIM
1 = "D-optimality". Determinant of the FIM: det(FIM)
2 = "A-optimality". Inverse of the sum of the expected parameter variances: -1/trace_matrix(inv(FIM))
4 = "lnD-optimality". Natural logarithm of the determinant of the FIM: log(det(FIM))
6 = "Ds-optimality". Ratio of the Determinant of the FIM and the Determinant of the uninteresting -rows and columns of the FIM: det(FIM)/det(FIM_u)
7 = Inverse of the sum of the expected parameter RSE: 1/sum(get_rse(FIM,poped.db,use_percent=FALSE))
Ds_index is a vector set to 1 if a parameter is uninteresting, otherwise 0.
-size=(1,num unfixed parameters). First unfixed bpop, then unfixed d, then unfixed docc and last unfixed sigma.
-Default is the fixed effects being important, everything else not important. Used in conjunction with
-ofv_calc_type=6
.
Penalty function name or path and filename, empty string means no penalty. -User defined criterion can be defined this way.
User defined function used to compute the objective function. The function must have a poped database object as its first -argument and have "..." in its argument list. Can be referenced as a function or as a file name where the function defined in the file has the same name as the file. -e.g. "cost.txt" has a function named "cost" in it.
******START OF E-FAMILY CRITERION SPECIFICATION OPTIONS**********
ED Integral Calculation, 0=Monte-Carlo-Integration, 1=Laplace Approximation, 2=BFGS Laplace Approximation -- --
Sample size for E-family sampling
How to sample from distributions in E-family calculations. 0=Random Sampling, 1=LatinHyperCube --
Filename and path, or function name, for user defined distributions for E-family designs
******START OF Model parameters SPECIFICATION OPTIONS**********
Number of typical values
Number of IIV parameters. Typically can be computed from other values and not supplied.
Number of IOV variance parameters. Typically can be computed from other values and not supplied.
Number of occasions. Typically can be computed from other values and not supplied.
Matrix defining the fixed effects, per row (row number = parameter_number) we should have:
column 1 the type of the distribution for E-family designs (0 = Fixed, 1 = Normal, 2 = Uniform, - 3 = User Defined Distribution, 4 = lognormal and 5 = truncated normal)
column 2 defines the mean.
column 3 defines the variance of the distribution (or length of uniform distribution).
Can also just supply the parameter values as a vector c()
if no uncertainty around the
-parameter value is to be used. The parameter order of 'bpop' is defined in the 'fg_fun' or 'fg_file'. If you use named
-arguments in 'bpop' then the order will be worked out automatically.
Matrix defining the diagonals of the IIV (same logic as for the fixed effects
-matrix bpop to define uncertainty). One can also just supply the parameter values as a c()
.
-The parameter order of 'd' is defined in the 'fg_fun' or 'fg_file'. If you use named
-arguments in 'd' then the order will be worked out automatically.
Column major vector defining the covariances of the IIV variances.
-That is, from your full IIV matrix covd <- IIV[lower.tri(IIV)]
.
Matrix defining the variances can covariances of the residual variability terms of the model.
-can also just supply the diagonal parameter values (variances) as a c()
.
Matrix defining the IOV, the IOV variances and the IOV distribution as for d and bpop.
Column major vector defining the covariance of the IOV, as in covd.
******START OF Model parameters fixed or not SPECIFICATION OPTIONS**********
Vector defining if a typical value is fixed or not (1=not fixed, 0=fixed). -The parameter order of 'notfixed_bpop' is defined in the 'fg_fun' or 'fg_file'. If you use named -arguments in 'notfixed_bpop' then the order will be worked out automatically.
Vector defining if a IIV is fixed or not (1=not fixed, 0=fixed). -The parameter order of 'notfixed_d' is defined in the 'fg_fun' or 'fg_file'. If you use named -arguments in 'notfixed_d' then the order will be worked out automatically.
Vector defining if a covariance IIV is fixed or not (1=not fixed, 0=fixed)
Vector defining if an IOV variance is fixed or not (1=not fixed, 0=fixed)
Vector row major order for lower triangular matrix defining if a covariance IOV is fixed or not (1=not fixed, 0=fixed)
Vector defining if a residual error parameter is fixed or not (1=not fixed, 0=fixed)
Vector defining if a covariance residual error parameter is fixed or not (1=not fixed, 0=fixed). -Default is fixed.
******START OF Optimization algorithm SPECIFICATION OPTIONS**********
Use random search (1=TRUE, 0=FALSE)
Use Stochastic Gradient search (1=TRUE, 0=FALSE)
Use Line search (1=TRUE, 0=FALSE)
Use Exchange algorithm (1=TRUE, 0=FALSE)
Use BFGS Minimizer (1=TRUE, 0=FALSE)
Exchange Algorithm Criteria, 1 = Modified, 2 = Fedorov
Filename and path, or function name, for a run file that is used instead of the regular PopED call.
******START OF Labeling and file names SPECIFICATION OPTIONS**********
The current PopED version
The model title
Filename and path of the output file during search
Filename suffix of the result function file
Filename and path for storage of current optimal design
******START OF Miscellaneous SPECIFICATION OPTIONS**********
User defined data structure that, for example could be used to send in data to the model
Value to interpret as zero in design
The seed number used for optimization and sampling -- integer or -1 which creates a random seed as.integer(Sys.time())
or NULL.
Vector for line search on continuous design variables (1=TRUE,0=FALSE)
Vector for line search on discrete design variables (1=TRUE,0=FALSE)
Use graph output during search
If a log file should be used (0=FALSE, 1=TRUE)
Method used to calculate M1 -(0=Complex difference, 1=Central difference, 20=Analytic derivative, 30=Automatic differentiation)
Method used to calculate M2 -(0=Central difference, 1=Central difference, 20=Analytic derivative, 30=Automatic differentiation)
Method used to calculate linearization of residual error -(0=Complex difference, 1=Central difference, 30=Automatic differentiation)
Method used to calculate the gradient of the model -(0=Complex difference, 1=Central difference, 20=Analytic derivative, 30=Automatic differentiation)
Method used to calculate the gradient of the parameter vector g -(0=Complex difference, 1=Central difference, 20=Analytic derivative, 30=Automatic differentiation)
Method used to calculate all the gradients -(0=Complex difference, 1=Central difference)
Number of iterations in random search between screen output
Number of iterations in stochastic gradient search between screen output
Step length of derivative of linearized model w.r.t. typical values
Step length of derivative of model w.r.t. g
Step length of derivative of g w.r.t. b
Step length of derivative of variance w.r.t. typical values
Step length of derivative of OFV w.r.t. time
Step length of derivative of model w.r.t. sigma
The absolute tolerance for the diff equation solver
The relative tolerance for the diff equation solver
The diff equation solver method, NULL as default.
If the differential equation results should be stored in memory (1) or not (0)
Number of Random search iterations
Number of stochastic gradient iterations
Number of Random search iterations with discrete optimization.
Number of Stochastic Gradient search iterations with discrete optimization
Iterations until adaptive narrowing in random search
Stochastic Gradient convergence value, -(difference in OFV for D-optimal, difference in gradient for ED-optimal)
Random search locality factor for sample times
Random search locality factor for covariates
Stochastic Gradient search first step factor for sample times
Stochastic Gradient search first step factor for covariates
Use greedy algorithm for group assignment optimization
Exchange Algorithm StepSize
Exchange Algorithm NumPoints
Exchange Algorithm Convergence Limit/Criteria
Avoid replicate samples when using Exchange Algorithm
BFGS Minimizer Convergence Criteria Minimum Step
BFGS Minimizer Convergence Criteria Normalized Projected Gradient Tolerance
BFGS Minimizer Line Search Tolerance f
BFGS Minimizer Line Search Tolerance g
BFGS Minimizer Line Search Tolerance x
Number of iterations in ED-optimal design to calculate convergence criteria
ED-optimal design convergence criteria in percent
Number of grid points in the line search
Number of iterations of full Random search and full Stochastic Gradient if line search is not used
******START OF PARALLEL OPTIONS********** Compile options for PopED
-1 = No compilation,
0 or 3 = Full compilation,
1 or 4 = Only using MCC (shared lib),
2 or 5 = Only MPI,
Option 0,1,2 runs PopED and option 3,4,5 stops after compilation
Parallel method to use (0 = Matlab PCT, 1 = MPI)
Additional dependencies used in MCC compilation (mat-files), if several space separated
Compilation output executable name
Number of processes to use when running in parallel (e.g. 3 = 2 workers, 1 job manager)
Number of design evaluations that should be evaluated in each process before getting new work from job manager
The prefix of the output mat file to communicate with the executable
Extra options send to e$g. the MPI executable or a batch script, see execute_parallel$m for more information and options
Polling time to check if the parallel execution is finished
The file containing the popedInput structure that should be used to evaluate the designs
If the random search is going to be executed in parallel
If the stochastic gradient search is going to be executed in parallel
If the modified exchange algorithm is going to be executed in parallel
If the line search is going to be executed in parallel
A PopED database
-Other poped_input:
-convert_variables()
,
-create_design_space()
,
-create_design()
,
-downsizing_general_design()
,
-poped.choose()
## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-library(PopED)
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.md.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> N = floor(xt/TAU) + 1
-#> y = (DOSE * Favail/V) * (KA/(KA - CL/V)) * (exp(-CL/V *
-#> (xt - (N - 1) * TAU)) * (1 - exp(-N * CL/V * TAU))/(1 -
-#> exp(-CL/V * TAU)) - exp(-KA * (xt - (N - 1) * TAU)) *
-#> (1 - exp(-N * KA * TAU))/(1 - exp(-KA * TAU)))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1104c9b70>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_file="ff.PK.1.comp.oral.sd.CL",
- fg_file="sfg",
- fError_file="feps.prop",
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=0.01,
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0,
- maxxt=120,
- a=70)
-#> Warning: cannot open file 'sfg': No such file or directory
-#> Error in file(filename, "r", encoding = encoding): cannot open the connection
-
-
-## evaluate initial design
-evaluate_design(poped.db)
-#> Error in eval(expr, envir, enclos): object 'poped.db' not found
-
R/create_design.R
- create_design.Rd
Create design variables to fully describe a design. -If variables are supplied then these variables are checked for -consistency and, if possible, changed to sizes that make -sense if there are inconsistencies. -Returns a list of matricies compatible with PopED.
-create_design(
- xt,
- groupsize,
- m = NULL,
- x = NULL,
- a = NULL,
- ni = NULL,
- model_switch = NULL
-)
Matrix defining the sampling schedule. -Each row is a group.
Vector defining the size of the different groups (number of individuals in each group).
A number defining the number of groups. Computed from xt if not defined.
A matrix defining the discrete design variables for the model -Each row is a group.
Matrix defining the continuous design variables. Each row is a group.
Vector defining the number of samples for each group, computed as all elements of xt for each group by default.
Matrix defining which response a certain sampling time belongs to. Defaults to one for all elements of xt.
If a value (or a vector/list of values) is supplied that corresponds to only one group and the design has -multiple groups then all groups will have the same value(s). If a matrix is expected then a list of lists can be supplied -instead, each list corresponding to a group.
-Other poped_input:
-convert_variables()
,
-create.poped.database()
,
-create_design_space()
,
-downsizing_general_design()
,
-poped.choose()
library(PopED)
-
-xt1 <- list(c(1,2,3),c(1,2,3,4))
-xt4 <- list(c(1,2,3,4,5),c(1,2,3,4))
-xt2 <- rbind(c(1,2,3,4),c(1,2,3,4))
-xt3 <- c(1,2,3,4)
-
-design_1 <- create_design(xt=xt1,groupsize=20)
-design_2 <- create_design(xt=xt4,groupsize=20)
-design_3 <- create_design(xt=xt2,groupsize=20)
-design_4 <- create_design(xt=xt3,groupsize=20)
-
-design_5 <- create_design(xt=xt3,groupsize=20,m=3)
-
-design_6 <- create_design(xt=xt1,groupsize=20,model_switch=ones(2,4))
-
-design_7 <-create_design(xt=xt1,groupsize=20,a=c(2,3,4))
-design_8 <-create_design(xt=xt1,groupsize=20,a=rbind(c(2,3,4),c(4,5,6)))
-design_9 <-create_design(xt=xt1,groupsize=20,a=list(c(2,3,4,6),c(4,5,6)))
-design_10 <-create_design(xt=xt1,groupsize=20,a=list(c(2,3,4),c(4,5,6)))
-
-design_11 <-create_design(xt=c(0,1,2,4,6,8,24),
- groupsize=50,
- a=c(WT=70,DOSE=1000))
-
-design_12 <-create_design(xt=c(0,1,2,4,6,8,24),
- groupsize=50,
- a=c(WT=70,DOSE=1000),m=2)
-
-design_13 <-create_design(xt=c(0,1,2,4,6,8,24),
- groupsize=50,
- a=list(c(WT=70,DOSE=1000),c(DOSE=90,WT=200,AGE=45)),m=2)
-
-design_14 <-create_design(xt=c(0,1,2,4,6,8,24),
- groupsize=50,
- a=list(list(WT=70,DOSE=1000),list(DOSE=90,WT=200,AGE=45)),m=2)
-
-design_15 <-create_design(xt=xt4,
- groupsize=c(50,20),
- a=rbind(c("DOSE"=2,"WT"=3,"AGE"=4),
- c(4,5,6)))
-
-
R/create_design_space.R
- create_design_space.Rd
create_design_space
takes an initial design and arguments for a design space and
-creates a design and design space for design optimization.
-Checks the sizes of supplied design space variables and
-changes them to sizes that make sense if there are inconsistencies.
-Function arguments can use shorthand notation (single values, vectors, lists of vectors and
-list of list) or matricies.
-Returns a list of matricies compatible with PopED.
create_design_space(
- design,
- maxni = NULL,
- minni = NULL,
- maxtotni = NULL,
- mintotni = NULL,
- maxgroupsize = NULL,
- mingroupsize = NULL,
- maxtotgroupsize = NULL,
- mintotgroupsize = NULL,
- maxxt = NULL,
- minxt = NULL,
- xt_space = NULL,
- maxa = NULL,
- mina = NULL,
- a_space = NULL,
- x_space = NULL,
- use_grouped_xt = FALSE,
- grouped_xt = NULL,
- use_grouped_a = FALSE,
- grouped_a = NULL,
- use_grouped_x = FALSE,
- grouped_x = NULL,
- our_zero = NULL
-)
The output from a call to create_design
.
Vector defining the maximum number of samples per group.
Vector defining the minimum number of samples per group.
Number defining the maximum number of samples allowed in the experiment.
Number defining the minimum number of samples allowed in the experiment.
Vector defining the maximum size of the different groups (maximum number of individuals in each group)
Vector defining the minimum size of the different groups (minimum num individuals in each group)
The total maximal groupsize over all groups
The total minimal groupsize over all groups
Matrix or single value defining the maximum value for each xt sample. If a single value is -supplied then all xt values are given the same maximum value.
Matrix or single value defining the minimum value for each xt sample. If a single value is -supplied then all xt values are given the same minimum value
Cell array cell
defining the discrete variables allowed for each xt value.
- Can also be a vector of values c(1:10)
(same values allowed for all xt), or a list of lists
-list(1:10, 2:23, 4:6)
(one for each value in xt in row major order or just for one row in xt,
-and all other rows will be duplicated).
Vector defining the maximum value for each covariate. IF a single value is supplied then -all a values are given the same maximum value
Vector defining the minimum value for each covariate. IF a single value is supplied then -all a values are given the same minimum value
Cell array cell
defining the discrete variables allowed for each a value.
- Can also be a list of values list(1:10)
(same values allowed for all a), or a list of lists
-list(1:10, 2:23, 4:6)
(one for each value in a).
Cell array cell
defining the discrete variables for each x value.
Group sampling times between groups so that each group has the same values (TRUE
or FALSE
).
Matrix defining the grouping of sample points. Matching integers mean that the points are matched.
-Allows for finer control than use_grouped_xt
Group continuous design variables between groups so that each group has the same values (TRUE
or FALSE
).
Matrix defining the grouping of continuous design variables. Matching integers mean that the values are matched.
-Allows for finer control than use_grouped_a
.
Group discrete design variables between groups so that each group has the same values (TRUE
or FALSE
).
Matrix defining the grouping of discrete design variables. Matching integers mean that the values are matched.
-Allows for finer control than use_grouped_x
.
Value to interpret as zero in design.
If a value (or a vector or a list of values) is supplied that corresponds to only one group and the design has -multiple groups then all groups will have the same value(s). If a matrix is expected then a list of lists can be supplied -instead, each list corresponding to a group.
-Other poped_input:
-convert_variables()
,
-create.poped.database()
,
-create_design()
,
-downsizing_general_design()
,
-poped.choose()
library(PopED)
-
-design_1 <- create_design(xt=list(c(1,2,3,4,5),
- c(1,2,3,4)),
- groupsize=c(50,20),
- a=list(c(WT=70,DOSE=1000),
- c(DOSE=1000,WT=35)))
-
-ds_1 <- create_design_space(design_1)
-
-ds_1_a <- create_design_space(design_1,our_zero = 1e-5)
-
-ds_2 <- create_design_space(design_1,maxni=10,maxxt=10,minxt=0)
-
-ds_3 <- create_design_space(design_1,maxni=10,mingroupsize=20,maxxt=10,minxt=0)
-
-ds_4 <- create_design_space(design_1,maxa=c(100,2000))
-
-ds_5 <- create_design_space(design_1,mina=c(10,20))
-
-design_2 <- create_design(xt=list(c(1,2,3,4,5),
- c(1,2,3,4)),
- groupsize=c(50,20),
- a=list(c(WT=70,DOSE=1000),
- c(WT=35,DOSE=1000)),
- x=list(c(SEX=1,DOSE_discrete=100),
- c(SEX=2,DOSE_discrete=200)))
-
-ds_6 <- create_design_space(design_2)
-
-ds_7 <- create_design_space(design_2,
- x_space=list(SEX=c(1,2),
- DOSE_discrete=seq(100,400,by=20)))
-
-ds_8 <- create_design_space(design_2,
- x_space=list(SEX=c(1,2),
- DOSE_discrete=seq(100,400,by=20)),
- grouped_xt=c(1,2,3,4,5))
-
-ds_9 <- create_design_space(design_2,
- x_space=list(SEX=c(1,2),
- DOSE_discrete=seq(100,400,by=20)),
- use_grouped_xt=TRUE)
-
-design_3 <- create_design(xt=list(c(1,2,3,4,5),
- c(1,2,3,4)),
- groupsize=c(50,20),
- a=list(c(WT=35,DOSE=1000)),
- x=list(c(SEX=1,DOSE_discrete=100)))
-
-ds_10 <- create_design_space(design_3,
- x_space=list(SEX=c(1,2),DOSE_discrete=seq(100,400,by=20)),
- use_grouped_a=TRUE)
-
-ds_11 <- create_design_space(design_2,
- x_space=list(SEX=c(1,2),DOSE_discrete=seq(100,400,by=20)),
- grouped_a=list(c(1,2),c(3,2)))
-
-ds_12 <- create_design_space(design_3,
- x_space=list(SEX=c(1,2),DOSE_discrete=seq(100,400,by=20)),
- use_grouped_x=TRUE)
-
-ds_13 <- create_design_space(design_3,
- x_space=list(SEX=c(1,2),DOSE_discrete=seq(100,400,by=20)),
- grouped_x=list(c(1,2),c(3,2)))
-
-seq_1 <- 1:10
-ds_14 <- create_design_space(design_1,maxxt=10,minxt=0,
- xt_space = list(seq_1,seq_1,seq_1,seq_1,seq_1))
-ds_15 <- create_design_space(design_1,maxxt=10,minxt=0,xt_space = list(seq_1))
-
-possible_values <- as.matrix(cbind(list(0:10),list(0:10),list(0:10),list(0:20),list(0:20)))
-xt_space <- as.matrix(rbind(possible_values,possible_values))
-
-ds_16 <- create_design_space(design_1,maxxt=10,minxt=0,xt_space = xt_space)
-
-ds_17 <- create_design_space(design_1,a_space = list(1:100,seq(1000,100000,by=1000)))
-
-
Display a summary of output from poped_db
-design_summary(poped_db, file = "", ...)
An object returned from create.poped.database
to summarize.
A file handle to write to. Default is to the R console.
Additional arguments. Passed to blockfinal
.
There are some differences between tha MATLAB and the R version of diag.
-Specifically, if a 1xN or a Nx1 matrix is supplied to the R
-diag
function then just the first element of this vector is
-returned. This function tries to match the MATLAB version in handling vectors
-(matricies with one dimension equal to one), and will return a diagonal
-matrix in these situations.
diag_matlab(mat)
Either a vector to make into a diagonal matrix or a matrix you -want to extract the diagonal from
Either a diagonal matrix or the diagonal of a matrix.
-
-diag_matlab(3)
-#> [,1] [,2] [,3]
-#> [1,] 1 0 0
-#> [2,] 0 1 0
-#> [3,] 0 0 1
-diag_matlab(c(1,2,3))
-#> [,1] [,2] [,3]
-#> [1,] 1 0 0
-#> [2,] 0 2 0
-#> [3,] 0 0 3
-diag_matlab(cbind(1,2,3))
-#> [,1] [,2] [,3]
-#> [1,] 1 0 0
-#> [2,] 0 2 0
-#> [3,] 0 0 3
-diag_matlab(rbind(1,2,3))
-#> [,1] [,2] [,3]
-#> [1,] 1 0 0
-#> [2,] 0 2 0
-#> [3,] 0 0 3
-
-diag_matlab(matrix(c(1, 2, 3),6,6))
-#> [1] 1 2 3 1 2 3
-
-# here is where the R default does something different
-diag(cbind(1,2,3))
-#> [1] 1
-diag(rbind(1,2,3))
-#> [1] 1
-
-
R/downsizing_general_design.R
- downsizing_general_design.Rd
Function takes a design with potentially empty design
-variables and rescues the design so that a FIM can be calculated using mftot
.
downsizing_general_design(poped.db)
A PopED database
A list containing:
-A vector of the number of samples in each group.
A matrix of sample times. Each row is a vector of sample times for a group.
A matrix that is the same size as xt, specifying which model each sample belongs to.
A matrix for the discrete design variables. Each row is a group.
A matrix of covariates. Each row is a group.
A matrix of fixed effect parameter values.
Other poped_input:
-convert_variables()
,
-create.poped.database()
,
-create_design_space()
,
-create_design()
,
-poped.choose()
R/ed_laplace_ofv.R
- ed_laplace_ofv.Rd
Compute the expectation of the det(FIM)
using the Laplace
-approximation to the expectation. Computations are made based on the model,
-parameters, distributions of parameter uncertainty, design and methods
-defined in the PopED database or as arguments to the function.
ed_laplace_ofv(
- model_switch,
- groupsize,
- ni,
- xtopto,
- xopto,
- aopto,
- bpopdescr,
- ddescr,
- covd,
- sigma,
- docc,
- poped.db,
- method = 1,
- return_gradient = FALSE,
- optxt = poped.db$settings$optsw[2],
- opta = poped.db$settings$optsw[4],
- x = c(),
- ...
-)
A matrix that is the same size as xt, specifying which model each sample belongs to.
A vector of the number of individuals in each group.
A vector of the number of samples in each group.
the sampling times
the discrete design variables
the continuous design variables
Matrix defining the fixed effects, per row (row number = -parameter_number) we should have:
column 1 the type of the -distribution for E-family designs (0 = Fixed, 1 = Normal, 2 = Uniform, 3 = -User Defined Distribution, 4 = lognormal and 5 = truncated normal)
column 2 defines the mean.
column 3 defines the variance of the -distribution (or length of uniform distribution).
Matrix defining the diagonals of the IIV (same logic as for
-the bpopdescr
).
Column major vector defining the covariances of the IIV variances.
-That is, from your full IIV matrix covd <- IIV[lower.tri(IIV)]
.
Matrix defining the variances can covariances of the residual variability terms of the model.
-can also just supply the diagonal parameter values (variances) as a c()
.
Matrix defining the IOV, the IOV variances and the IOV distribution as for d and bpop.
A PopED database.
If 0 then use an optimization routine translated from PopED code written in MATLAB to
-optimize the parameters in the Laplace approximation. If 1 then use optim
to compute both
-k and the hessian of k (see Dodds et al, JPP, 2005 for more information). If 2 then use fdHess
-to compute the hessian.
Should the gradient be returned.
If sampling times are optimized
If continuous design variables are optimized
The design parameters to compute the gradient on.
Arguments passed through from other functions, does not pass anything to another function.
The FIM and the hessian of the FIM.
-This computation follows the method outlined in Dodds et al, -"Robust Population Pharmacokinetic Experiment Design" JPP, 2005, equation 16.
-Typically this function will not be run by the user. Instead use evaluate.e.ofv.fim
.
Other FIM:
-LinMatrixH()
,
-LinMatrixLH()
,
-LinMatrixL_occ()
,
-calc_ofv_and_fim()
,
-ed_mftot()
,
-efficiency()
,
-evaluate.e.ofv.fim()
,
-evaluate.fim()
,
-gradf_eps()
,
-mf3()
,
-mf7()
,
-mftot()
,
-ofv_criterion()
,
-ofv_fim()
Other E-family:
-calc_ofv_and_fim()
,
-ed_mftot()
,
-evaluate.e.ofv.fim()
## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## Optimization using an additive + proportional reidual error to
-## avoid sample times at very low concentrations (time 0 or very late samoples).
-library(PopED)
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-######################
-# Normal distribution
-######################
-bpop_vals <- c(CL=0.15, V=8, KA=1.0, Favail=1)
-bpop_vals_ed_n <- cbind(ones(length(bpop_vals),1)*1, # normal distribution
- bpop_vals,
- ones(length(bpop_vals),1)*(bpop_vals*0.1)^2) # 10% of bpop value
-bpop_vals_ed_n["Favail",] <- c(0,1,0)
-bpop_vals_ed_n
-#> bpop_vals
-#> CL 1 0.15 0.000225
-#> V 1 8.00 0.640000
-#> KA 1 1.00 0.010000
-#> Favail 0 1.00 0.000000
-
-## -- Define initial design and design space
-poped.db.n <- create.poped.database(ff_file="ff.PK.1.comp.oral.sd.CL",
- fg_file="sfg",
- fError_file="feps.add.prop",
- bpop=bpop_vals_ed_n,
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(0.01,0.25),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0,
- maxxt=120,
- a=70,
- mina=0,
- maxa=100)
-#> Warning: cannot open file 'sfg': No such file or directory
-#> Error in file(filename, "r", encoding = encoding): cannot open the connection
-
-
-## ED evaluate using LaPlace approximation
-tic(); output <- evaluate.e.ofv.fim(poped.db.n,use_laplace=TRUE); toc()
-#> Error in eval(expr, envir, enclos): object 'poped.db.n' not found
-#> Elapsed time: 0 seconds.
-output$E_ofv
-#> Error in eval(expr, envir, enclos): object 'output' not found
-
-if (FALSE) {
-
-
- ## ED value using MC integration (roughly)
- tic();e_ofv_mc_n <- evaluate.e.ofv.fim(poped.db.n,ED_samp_size=500,ofv_calc_type = 1);toc()
- e_ofv_mc_n$E_ofv
-
-
- ## Using ed_laplce_ofv directly
- ed_laplace_ofv(model_switch=poped.db.n$design$model_switch,
- groupsize=poped.db.n$design$groupsize,
- ni=poped.db.n$design$ni,
- xtopto=poped.db.n$design$xt,
- xopto=poped.db.n$design$x,
- aopto=poped.db.n$design$a,
- bpopdescr=poped.db.n$parameters$bpop,
- ddescr=poped.db.n$parameters$d,
- covd=poped.db.n$parameters$covd,
- sigma=poped.db.n$parameters$sigma,
- docc=poped.db.n$parameters$docc,
- poped.db.n)
-
-
- ######################
- # Log-normal distribution
- ######################
-
- # Adding 10% log-normal Uncertainty to fixed effects (not Favail)
- bpop_vals <- c(CL=0.15, V=8, KA=1.0, Favail=1)
- bpop_vals_ed_ln <- cbind(ones(length(bpop_vals),1)*4, # log-normal distribution
- bpop_vals,
- ones(length(bpop_vals),1)*(bpop_vals*0.1)^2) # 10% of bpop value
- bpop_vals_ed_ln["Favail",] <- c(0,1,0)
- bpop_vals_ed_ln
-
- ## -- Define initial design and design space
- poped.db.ln <- create.poped.database(ff_file="ff.PK.1.comp.oral.sd.CL",
- fg_file="sfg",
- fError_file="feps.add.prop",
- bpop=bpop_vals_ed_ln,
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(0.01,0.25),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0,
- maxxt=120,
- a=70,
- mina=0,
- maxa=100)
-
-
-
- ## ED evaluate using LaPlace approximation
- tic()
- output <- evaluate.e.ofv.fim(poped.db.ln,use_laplace=TRUE)
- toc()
- output$E_ofv
-
- ## expected value (roughly)
- tic()
- e_ofv_mc_ln <- evaluate.e.ofv.fim(poped.db.ln,ED_samp_size=500,ofv_calc_type = 1)[["E_ofv"]]
- toc()
- e_ofv_mc_ln
-
- ## Using ed_laplce_ofv directly
- ed_laplace_ofv(model_switch=poped.db.ln$design$model_switch,
- groupsize=poped.db.ln$design$groupsize,
- ni=poped.db.ln$design$ni,
- xtopto=poped.db.ln$design$xt,
- xopto=poped.db.ln$design$x,
- aopto=poped.db.ln$design$a,
- bpopdescr=poped.db.ln$parameters$bpop,
- ddescr=poped.db.ln$parameters$d,
- covd=poped.db.ln$parameters$covd,
- sigma=poped.db.ln$parameters$sigma,
- docc=poped.db.ln$parameters$docc,
- poped.db.ln)
-
-
-
-
-}
-
-
R/ed_mftot.R
- ed_mftot.Rd
Compute the expectation of the FIM given the model, parameters, distributions of parameter uncertainty, design and methods defined in the -PopED database.
-ed_mftot(
- model_switch,
- groupsize,
- ni,
- xtoptn,
- xoptn,
- aoptn,
- bpopdescr,
- ddescr,
- covd,
- sigma,
- docc,
- poped.db,
- calc_fim = TRUE,
- ...
-)
A matrix that is the same size as xt, specifying which model each sample belongs to.
A vector of the number of individuals in each group.
A vector of the number of samples in each group.
The xtoptn value
The xoptn
The aoptn value
Matrix defining the fixed effects, per row (row number = -parameter_number) we should have:
column 1 the type of the -distribution for E-family designs (0 = Fixed, 1 = Normal, 2 = Uniform, 3 = -User Defined Distribution, 4 = lognormal and 5 = truncated normal)
column 2 defines the mean.
column 3 defines the variance of the -distribution (or length of uniform distribution).
Matrix defining the diagonals of the IIV (same logic as for
-the bpopdescr
).
Column major vector defining the covariances of the IIV variances.
-That is, from your full IIV matrix covd <- IIV[lower.tri(IIV)]
.
Matrix defining the variances can covariances of the residual variability terms of the model.
-can also just supply the diagonal parameter values (variances) as a c()
.
Matrix defining the IOV, the IOV variances and the IOV distribution as for d and bpop.
A PopED database.
Should the FIM be calculated or should we just use the user defined ed_penalty_pointer.
Other arguments passed to the function.
A list containing the E(FIM) and E(OFV(FIM)) and the a poped.db.
-Other FIM:
-LinMatrixH()
,
-LinMatrixLH()
,
-LinMatrixL_occ()
,
-calc_ofv_and_fim()
,
-ed_laplace_ofv()
,
-efficiency()
,
-evaluate.e.ofv.fim()
,
-evaluate.fim()
,
-gradf_eps()
,
-mf3()
,
-mf7()
,
-mftot()
,
-ofv_criterion()
,
-ofv_fim()
Other E-family:
-calc_ofv_and_fim()
,
-ed_laplace_ofv()
,
-evaluate.e.ofv.fim()
library(PopED)
-
-############# START #################
-## Create PopED database
-## (warfarin model for optimization
-## with parameter uncertainty)
-#####################################
-
-## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## Optimization using an additive + proportional reidual error
-## to avoid sample times at very low concentrations (time 0 or very late samoples).
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-# Adding 10% log-normal Uncertainty to fixed effects (not Favail)
-bpop_vals <- c(CL=0.15, V=8, KA=1.0, Favail=1)
-bpop_vals_ed_ln <- cbind(ones(length(bpop_vals),1)*4, # log-normal distribution
- bpop_vals,
- ones(length(bpop_vals),1)*(bpop_vals*0.1)^2) # 10% of bpop value
-bpop_vals_ed_ln["Favail",] <- c(0,1,0)
-bpop_vals_ed_ln
-#> bpop_vals
-#> CL 4 0.15 0.000225
-#> V 4 8.00 0.640000
-#> KA 4 1.00 0.010000
-#> Favail 0 1.00 0.000000
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- bpop=bpop_vals_ed_ln,
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(0.01,0.25),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0,
- maxxt=120,
- a=70,
- mina=0,
- maxa=100)
-
-############# END ###################
-## Create PopED database
-## (warfarin model for optimization
-## with parameter uncertainty)
-#####################################
-
-
-# very few samples
-poped.db$settings$ED_samp_size=10
-ed_mftot(model_switch=poped.db$design$model_switch,
- groupsize=poped.db$design$groupsize,
- ni=poped.db$design$ni,
- xtoptn=poped.db$design$xt,
- xoptn=poped.db$design$x,
- aoptn=poped.db$design$a,
- bpopdescr=poped.db$parameters$bpop,
- ddescr=poped.db$parameters$d,
- covd=poped.db$parameters$covd,
- sigma=poped.db$parameters$sigma,
- docc=poped.db$parameters$docc,
- poped.db)["ED_ofv"]
-#> $ED_ofv
-#> [1] 55.39808
-#>
-
-
-
Efficiency calculation between two designs.
-efficiency(
- ofv_init,
- ofv_final,
- poped_db,
- npar = get_fim_size(poped_db),
- ofv_calc_type = poped_db$settings$ofv_calc_type,
- ds_index = poped_db$parameters$ds_index,
- use_log = TRUE,
- ...
-)
An initial objective function
A final objective function.
a poped database
The number of parameters to use for normalization.
OFV calculation type for FIM
1 = "D-optimality". Determinant of the FIM: det(FIM)
2 = "A-optimality". Inverse of the sum of the expected parameter variances: -1/trace_matrix(inv(FIM))
4 = "lnD-optimality". Natural logarithm of the determinant of the FIM: log(det(FIM))
6 = "Ds-optimality". Ratio of the Determinant of the FIM and the Determinant of the uninteresting -rows and columns of the FIM: det(FIM)/det(FIM_u)
7 = Inverse of the sum of the expected parameter RSE: 1/sum(get_rse(FIM,poped.db,use_percent=FALSE))
Ds_index is a vector set to 1 if a parameter is uninteresting, otherwise 0.
-size=(1,num unfixed parameters). First unfixed bpop, then unfixed d, then unfixed docc and last unfixed sigma.
-Default is the fixed effects being important, everything else not important. Used in conjunction with
-ofv_calc_type=6
.
Are the `ofv` arguments in the log space?
arguments passed to evaluate.fim
and ofv_fim
.
The specified efficiency value depending on the ofv_calc_type.
-The attribute "description" tells you how the calculation was made
-attr(return_vale,"description")
Other FIM:
-LinMatrixH()
,
-LinMatrixLH()
,
-LinMatrixL_occ()
,
-calc_ofv_and_fim()
,
-ed_laplace_ofv()
,
-ed_mftot()
,
-evaluate.e.ofv.fim()
,
-evaluate.fim()
,
-gradf_eps()
,
-mf3()
,
-mf7()
,
-mftot()
,
-ofv_criterion()
,
-ofv_fim()
R/evaluate.e.ofv.fim.R
- evaluate.e.ofv.fim.Rd
Compute the expectation of the FIM and OFV(FIM) given the model, parameters, distributions of parameter uncertainty, design and methods defined in the
-PopED database. Some of the arguments coming from the PopED database can be overwritten;
-by default these arguments are NULL
in the
-function, if they are supplied then they are used instead of the arguments from the PopED database.
evaluate.e.ofv.fim(
- poped.db,
- fim.calc.type = NULL,
- bpop = poped.db$parameters$bpop,
- d = poped.db$parameters$d,
- covd = poped.db$parameters$covd,
- docc = poped.db$parameters$docc,
- sigma = poped.db$parameters$sigma,
- model_switch = NULL,
- ni = NULL,
- xt = NULL,
- x = NULL,
- a = NULL,
- groupsize = poped.db$design$groupsize,
- deriv.type = NULL,
- bLHS = poped.db$settings$bLHS,
- ofv_calc_type = poped.db$settings$ofv_calc_type,
- ED_samp_size = poped.db$settings$ED_samp_size,
- use_laplace = poped.db$settings$iEDCalculationType,
- laplace.fim = FALSE,
- ...
-)
A PopED database.
The method used for calculating the FIM. Potential values:
0 = Full FIM. No assumption that fixed and random effects are uncorrelated.
1 = Reduced FIM. Assume that there is no correlation in the FIM between the fixed and random effects, and set these elements in -the FIM to zero.
2 = weighted models (placeholder).
3 = Not currently used.
4 = Reduced FIM and computing all derivatives with respect to the standard deviation of the residual unexplained variation (sqrt(SIGMA) in NONMEM). -This matches what is done in PFIM, and assumes that the standard deviation of the residual unexplained variation is the estimated parameter -(NOTE: NONMEM estimates the variance of the residual unexplained variation by default).
5 = Full FIM parameterized with A,B,C matrices & derivative of variance.
6 = Calculate one model switch at a time, good for large matrices.
7 = Reduced FIM parameterized with A,B,C matrices & derivative of variance.
Matrix defining the fixed effects, per row (row number = parameter_number) we should have:
column 1 the type of the distribution for E-family designs (0 = Fixed, 1 = Normal, 2 = Uniform, - 3 = User Defined Distribution, 4 = lognormal and 5 = truncated normal)
column 2 defines the mean.
column 3 defines the variance of the distribution (or length of uniform distribution).
Can also just supply the parameter values as a vector c()
if no uncertainty around the
-parameter value is to be used. The parameter order of 'bpop' is defined in the 'fg_fun' or 'fg_file'. If you use named
-arguments in 'bpop' then the order will be worked out automatically.
Matrix defining the diagonals of the IIV (same logic as for the fixed effects
-matrix bpop to define uncertainty). One can also just supply the parameter values as a c()
.
-The parameter order of 'd' is defined in the 'fg_fun' or 'fg_file'. If you use named
-arguments in 'd' then the order will be worked out automatically.
Column major vector defining the covariances of the IIV variances.
-That is, from your full IIV matrix covd <- IIV[lower.tri(IIV)]
.
Matrix defining the IOV, the IOV variances and the IOV distribution as for d and bpop.
Matrix defining the variances can covariances of the residual variability terms of the model.
-can also just supply the diagonal parameter values (variances) as a c()
.
A matrix that is the same size as xt, specifying which model each sample belongs to.
A vector of the number of samples in each group.
A matrix of sample times. Each row is a vector of sample times for a group.
A matrix for the discrete design variables. Each row is a group.
A matrix of covariates. Each row is a group.
A vector of the number of individuals in each group.
A number indicating the type of derivative to use:
0=Complex difference
1=Central difference
20=Analytic derivative (placeholder)
30=Automatic differentiation (placeholder)
How to sample from distributions in E-family calculations. 0=Random Sampling, 1=LatinHyperCube --
OFV calculation type for FIM
1 = "D-optimality". Determinant of the FIM: det(FIM)
2 = "A-optimality". Inverse of the sum of the expected parameter variances: -1/trace_matrix(inv(FIM))
4 = "lnD-optimality". Natural logarithm of the determinant of the FIM: log(det(FIM))
6 = "Ds-optimality". Ratio of the Determinant of the FIM and the Determinant of the uninteresting -rows and columns of the FIM: det(FIM)/det(FIM_u)
7 = Inverse of the sum of the expected parameter RSE: 1/sum(get_rse(FIM,poped.db,use_percent=FALSE))
Sample size for E-family sampling
Should the Laplace method be used in calculating the expectation of the OFV?
Should an E(FIM) be calculated when computing the Laplace approximated E(OFV). Typically -the FIM does not need to be computed and, if desired, this calculation -is done using the standard MC integration technique, so can be slow.
Other arguments passed to the function.
A list containing the E(FIM) and E(OFV(FIM)) and the a poped.db updated according to the function arguments.
-Other FIM:
-LinMatrixH()
,
-LinMatrixLH()
,
-LinMatrixL_occ()
,
-calc_ofv_and_fim()
,
-ed_laplace_ofv()
,
-ed_mftot()
,
-efficiency()
,
-evaluate.fim()
,
-gradf_eps()
,
-mf3()
,
-mf7()
,
-mftot()
,
-ofv_criterion()
,
-ofv_fim()
Other E-family:
-calc_ofv_and_fim()
,
-ed_laplace_ofv()
,
-ed_mftot()
Other evaluate_FIM:
-calc_ofv_and_fim()
,
-evaluate.fim()
,
-ofv_fim()
library(PopED)
-
-############# START #################
-## Create PopED database
-## (warfarin model for optimization
-## with parameter uncertainty)
-#####################################
-
-## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## Optimization using an additive + proportional reidual error
-## to avoid sample times at very low concentrations (time 0 or very late samoples).
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-# Adding 10% log-normal Uncertainty to fixed effects (not Favail)
-bpop_vals <- c(CL=0.15, V=8, KA=1.0, Favail=1)
-bpop_vals_ed_ln <- cbind(ones(length(bpop_vals),1)*4, # log-normal distribution
- bpop_vals,
- ones(length(bpop_vals),1)*(bpop_vals*0.1)^2) # 10% of bpop value
-bpop_vals_ed_ln["Favail",] <- c(0,1,0)
-bpop_vals_ed_ln
-#> bpop_vals
-#> CL 4 0.15 0.000225
-#> V 4 8.00 0.640000
-#> KA 4 1.00 0.010000
-#> Favail 0 1.00 0.000000
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- bpop=bpop_vals_ed_ln,
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(0.01,0.25),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0,
- maxxt=120,
- a=70,
- mina=0,
- maxa=100)
-
-############# END ###################
-## Create PopED database
-## (warfarin model for optimization
-## with parameter uncertainty)
-#####################################
-
-
-## ED evaluate (with very few samples)
-output <- evaluate.e.ofv.fim(poped.db,ED_samp_size=10)
-output$E_ofv
-#> [1] 55.46269
-
-## API evaluate (with very few samples)
-output <- evaluate.e.ofv.fim(poped.db,ED_samp_size=10,ofv_calc_type=4)
-output$E_ofv
-#> [1] 55.41279
-
-## ED evaluate using Laplace approximation
-tic()
-output <- evaluate.e.ofv.fim(poped.db,use_laplace=TRUE)
-toc()
-#> Elapsed time: 0.429 seconds.
-output$E_ofv
-#> [1] 1.302805e+24
-
-if (FALSE) {
-
- ## ED expected value with more precision.
- ## Compare time and value to Laplace approximation.
- ## Run a couple of times to see stochasticity of calculation.
- tic()
- e_ofv_mc <- evaluate.e.ofv.fim(poped.db,ED_samp_size=500)
- toc()
- e_ofv_mc$E_ofv
-
- # If you want to get an E(FIM) from the laplace approximation you have to ask for it
- # and it will take more time.
- output <- evaluate.e.ofv.fim(poped.db,use_laplace=TRUE,laplace.fim=TRUE)
- output$E_fim
-
-
-
-}
-
Compute the FIM given the model, parameters, design and methods defined in the
-PopED database. Some of the arguments coming from the PopED database can be overwritten;
-by default these arguments are NULL
in the
-function, if they are supplied then they are used instead of the arguments from the PopED database.
evaluate.fim(
- poped.db,
- fim.calc.type = NULL,
- approx.method = NULL,
- FOCE.num = NULL,
- bpop.val = NULL,
- d_full = NULL,
- docc_full = NULL,
- sigma_full = NULL,
- model_switch = NULL,
- ni = NULL,
- xt = NULL,
- x = NULL,
- a = NULL,
- groupsize = NULL,
- deriv.type = NULL,
- ...
-)
A PopED database.
The method used for calculating the FIM. Potential values:
0 = Full FIM. No assumption that fixed and random effects are uncorrelated.
1 = Reduced FIM. Assume that there is no correlation in the FIM between the fixed and random effects, and set these elements in -the FIM to zero.
2 = weighted models (placeholder).
3 = Not currently used.
4 = Reduced FIM and computing all derivatives with respect to the standard deviation of the residual unexplained variation (sqrt(SIGMA) in NONMEM). -This matches what is done in PFIM, and assumes that the standard deviation of the residual unexplained variation is the estimated parameter -(NOTE: NONMEM estimates the variance of the residual unexplained variation by default).
5 = Full FIM parameterized with A,B,C matrices & derivative of variance.
6 = Calculate one model switch at a time, good for large matrices.
7 = Reduced FIM parameterized with A,B,C matrices & derivative of variance.
Approximation method for model, 0=FO, 1=FOCE, 2=FOCEI, 3=FOI
Number individuals in each step of FOCE approximation method
The fixed effects parameter values. Supplied as a vector.
A between subject variability matrix (OMEGA in NONMEM).
A between occasion variability matrix.
A residual unexplained variability matrix (SIGMA in NONMEM).
A matrix that is the same size as xt, specifying which model each sample belongs to.
A vector of the number of samples in each group.
A matrix of sample times. Each row is a vector of sample times for a group.
A matrix for the discrete design variables. Each row is a group.
A matrix of covariates. Each row is a group.
A vector of the number of individuals in each group.
A number indicating the type of derivative to use:
0=Complex difference
1=Central difference
20=Analytic derivative (placeholder)
30=Automatic differentiation (placeholder)
Other arguments passed to the function.
The FIM.
-Other FIM:
-LinMatrixH()
,
-LinMatrixLH()
,
-LinMatrixL_occ()
,
-calc_ofv_and_fim()
,
-ed_laplace_ofv()
,
-ed_mftot()
,
-efficiency()
,
-evaluate.e.ofv.fim()
,
-gradf_eps()
,
-mf3()
,
-mf7()
,
-mftot()
,
-ofv_criterion()
,
-ofv_fim()
Other evaluate_design:
-evaluate_design()
,
-evaluate_power()
,
-get_rse()
,
-model_prediction()
,
-plot_efficiency_of_windows()
,
-plot_model_prediction()
Other evaluate_FIM:
-calc_ofv_and_fim()
,
-evaluate.e.ofv.fim()
,
-ofv_fim()
## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-library(PopED)
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.md.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> N = floor(xt/TAU) + 1
-#> y = (DOSE * Favail/V) * (KA/(KA - CL/V)) * (exp(-CL/V *
-#> (xt - (N - 1) * TAU)) * (1 - exp(-N * CL/V * TAU))/(1 -
-#> exp(-CL/V * TAU)) - exp(-KA * (xt - (N - 1) * TAU)) *
-#> (1 - exp(-N * KA * TAU))/(1 - exp(-KA * TAU)))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1104c9b70>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_fun = ff.PK.1.comp.oral.sd.CL,
- fg_fun = sfg,
- fError_fun = feps.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- # notfixed_bpop=c(1,1,1,0),
- notfixed_bpop=c(CL=1,V=1,KA=1,Favail=0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=0.01,
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0,
- maxxt=120,
- a=70)
-
-
-## evaluate initial design with the reduced FIM
-FIM.1 <- evaluate.fim(poped.db)
-FIM.1
-#> [,1] [,2] [,3] [,4] [,5] [,6]
-#> [1,] 19821.28445 -21.836551 -8.622140 0.000000e+00 0.000000 0.00000000
-#> [2,] -21.83655 20.656071 -1.807099 0.000000e+00 0.000000 0.00000000
-#> [3,] -8.62214 -1.807099 51.729039 0.000000e+00 0.000000 0.00000000
-#> [4,] 0.00000 0.000000 0.000000 3.107768e+03 10.728786 0.02613561
-#> [5,] 0.00000 0.000000 0.000000 1.072879e+01 27307.089308 3.26560786
-#> [6,] 0.00000 0.000000 0.000000 2.613561e-02 3.265608 41.81083599
-#> [7,] 0.00000 0.000000 0.000000 5.215403e+02 11214.210707 71.08763902
-#> [,7]
-#> [1,] 0.00000
-#> [2,] 0.00000
-#> [3,] 0.00000
-#> [4,] 521.54030
-#> [5,] 11214.21071
-#> [6,] 71.08764
-#> [7,] 806176.95068
-det(FIM.1)
-#> [1] 5.996147e+22
-det(FIM.1)^(1/7)
-#> [1] 1794.658
-get_rse(FIM.1,poped.db)
-#> CL V KA d_CL d_V d_KA SIGMA[1,1]
-#> 4.738266 2.756206 13.925829 25.627205 30.344316 25.777327 11.170784
-
-## evaluate initial design with the full FIM
-FIM.0 <- evaluate.fim(poped.db,fim.calc.type=0)
-FIM.0
-#> [,1] [,2] [,3] [,4] [,5]
-#> [1,] 47625.234145 -341.996566 35.504624 -2.073844e+03 -5899.486674
-#> [2,] -341.996566 30.887205 -12.589615 -1.686280e+01 -54.629529
-#> [3,] 35.504624 -12.589615 452.758773 -8.336530e-01 -43.619195
-#> [4,] -2073.844369 -16.862802 -0.833653 3.107768e+03 10.728786
-#> [5,] -5899.486674 -54.629529 -43.619195 1.072879e+01 27307.089308
-#> [6,] 4.490538 -6.550313 18.653863 2.613561e-02 3.265608
-#> [7,] -54419.723543 -1070.933661 2955.924225 5.215403e+02 11214.210707
-#> [,6] [,7]
-#> [1,] 4.49053810 -54419.72354
-#> [2,] -6.55031322 -1070.93366
-#> [3,] 18.65386273 2955.92422
-#> [4,] 0.02613561 521.54030
-#> [5,] 3.26560786 11214.21071
-#> [6,] 41.81083599 71.08764
-#> [7,] 71.08763902 806176.95068
-det(FIM.0)
-#> [1] 1.220371e+24
-det(FIM.0)^(1/7)
-#> [1] 2760.117
-get_rse(FIM.0,poped.db)
-#> CL V KA d_CL d_V d_KA SIGMA[1,1]
-#> 3.560994 2.560413 4.811952 26.270324 30.901555 26.503936 12.409516
-
-## evaluate initial design with the reduced FIM
-## computing all derivatives with respect to the
-## standard deviation of the residual unexplained variation
-FIM.4 <- evaluate.fim(poped.db,fim.calc.type=4)
-FIM.4
-#> [,1] [,2] [,3] [,4] [,5] [,6]
-#> [1,] 19821.28445 -21.836551 -8.622140 0.000000e+00 0.000000 0.00000000
-#> [2,] -21.83655 20.656071 -1.807099 0.000000e+00 0.000000 0.00000000
-#> [3,] -8.62214 -1.807099 51.729039 0.000000e+00 0.000000 0.00000000
-#> [4,] 0.00000 0.000000 0.000000 3.107768e+03 10.728786 0.02613561
-#> [5,] 0.00000 0.000000 0.000000 1.072879e+01 27307.089308 3.26560786
-#> [6,] 0.00000 0.000000 0.000000 2.613561e-02 3.265608 41.81083599
-#> [7,] 0.00000 0.000000 0.000000 1.043081e+02 2242.842141 14.21752780
-#> [,7]
-#> [1,] 0.00000
-#> [2,] 0.00000
-#> [3,] 0.00000
-#> [4,] 104.30806
-#> [5,] 2242.84214
-#> [6,] 14.21753
-#> [7,] 32247.07803
-det(FIM.4)
-#> [1] 2.398459e+21
-get_rse(FIM.4,poped.db,fim.calc.type=4)
-#> CL V KA d_CL d_V d_KA SIGMA[1,1]
-#> 4.738266 2.756206 13.925829 25.627205 30.344316 25.777327 5.585392
-
-## evaluate initial design with the full FIM with A,B,C matricies
-## should give same answer as fim.calc.type=0
-FIM.5 <- evaluate.fim(poped.db,fim.calc.type=5)
-FIM.5
-#> [,1] [,2] [,3] [,4] [,5]
-#> [1,] 47625.234145 -341.996566 35.504624 -2.073844e+03 -5899.486674
-#> [2,] -341.996566 30.887205 -12.589615 -1.686280e+01 -54.629529
-#> [3,] 35.504624 -12.589615 452.758773 -8.336530e-01 -43.619195
-#> [4,] -2073.844369 -16.862802 -0.833653 3.107768e+03 10.728786
-#> [5,] -5899.486674 -54.629529 -43.619195 1.072879e+01 27307.089308
-#> [6,] 4.490538 -6.550313 18.653863 2.613561e-02 3.265608
-#> [7,] -54419.723543 -1070.933661 2955.924225 5.215403e+02 11214.210707
-#> [,6] [,7]
-#> [1,] 4.49053810 -54419.72354
-#> [2,] -6.55031322 -1070.93366
-#> [3,] 18.65386273 2955.92422
-#> [4,] 0.02613561 521.54030
-#> [5,] 3.26560786 11214.21071
-#> [6,] 41.81083599 71.08764
-#> [7,] 71.08763902 806176.95068
-det(FIM.5)
-#> [1] 1.220371e+24
-get_rse(FIM.5,poped.db,fim.calc.type=5)
-#> CL V KA d_CL d_V d_KA SIGMA[1,1]
-#> 3.560994 2.560413 4.811952 26.270324 30.901555 26.503936 12.409516
-
-## evaluate initial design with the reduced FIM with
-## A,B,C matricies and derivative of variance
-## should give same answer as fim.calc.type=1 (default)
-FIM.7 <- evaluate.fim(poped.db,fim.calc.type=7)
-FIM.7
-#> [,1] [,2] [,3] [,4] [,5] [,6]
-#> [1,] 19821.28445 -21.836551 -8.622140 0.000000e+00 0.000000 0.00000000
-#> [2,] -21.83655 20.656071 -1.807099 0.000000e+00 0.000000 0.00000000
-#> [3,] -8.62214 -1.807099 51.729039 0.000000e+00 0.000000 0.00000000
-#> [4,] 0.00000 0.000000 0.000000 3.107768e+03 10.728786 0.02613561
-#> [5,] 0.00000 0.000000 0.000000 1.072879e+01 27307.089308 3.26560786
-#> [6,] 0.00000 0.000000 0.000000 2.613561e-02 3.265608 41.81083599
-#> [7,] 0.00000 0.000000 0.000000 5.215403e+02 11214.210707 71.08763902
-#> [,7]
-#> [1,] 0.00000
-#> [2,] 0.00000
-#> [3,] 0.00000
-#> [4,] 521.54030
-#> [5,] 11214.21071
-#> [6,] 71.08764
-#> [7,] 806176.95068
-det(FIM.7)
-#> [1] 5.996147e+22
-get_rse(FIM.7,poped.db,fim.calc.type=7)
-#> CL V KA d_CL d_V d_KA SIGMA[1,1]
-#> 4.738266 2.756206 13.925829 25.627205 30.344316 25.777327 11.170784
-
-## evaluate FIM and rse with prior FIM.1
-poped.db.prior = create.poped.database(poped.db, prior_fim = FIM.1)
-FIM.1.prior <- evaluate.fim(poped.db.prior)
-all.equal(FIM.1.prior,FIM.1) # the FIM is only computed from the design in the poped.db
-#> [1] TRUE
-get_rse(FIM.1.prior,poped.db.prior) # the RSE is computed with the prior information
-#> CL V KA d_CL d_V d_KA SIGMA[1,1]
-#> 3.350460 1.948932 9.847048 18.121170 21.456671 18.227322 7.898937
-
This function evaluates the design defined in a poped database.
-evaluate_design(poped.db, ...)
A poped database
Extra parameters passed to calc_ofv_and_fim
and get_rse
A list of elements evaluating the current design.
-Other evaluate_design:
-evaluate.fim()
,
-evaluate_power()
,
-get_rse()
,
-model_prediction()
,
-plot_efficiency_of_windows()
,
-plot_model_prediction()
library(PopED)
-
-############# START #################
-## Create PopED database
-## (warfarin example)
-#####################################
-
-## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define model, parameters, initial design
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(prop=0.01),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- a=c(DOSE=70))
-
-############# END ###################
-## Create PopED database
-## (warfarin example)
-#####################################
-
-evaluate_design(poped.db)
-#> $ofv
-#> [1] 52.44799
-#>
-#> $fim
-#> CL V KA d_CL d_V d_KA
-#> CL 19821.28445 -21.836551 -8.622140 0.000000e+00 0.000000 0.00000000
-#> V -21.83655 20.656071 -1.807099 0.000000e+00 0.000000 0.00000000
-#> KA -8.62214 -1.807099 51.729039 0.000000e+00 0.000000 0.00000000
-#> d_CL 0.00000 0.000000 0.000000 3.107768e+03 10.728786 0.02613561
-#> d_V 0.00000 0.000000 0.000000 1.072879e+01 27307.089308 3.26560786
-#> d_KA 0.00000 0.000000 0.000000 2.613561e-02 3.265608 41.81083599
-#> sig_prop 0.00000 0.000000 0.000000 5.215403e+02 11214.210707 71.08763902
-#> sig_prop
-#> CL 0.00000
-#> V 0.00000
-#> KA 0.00000
-#> d_CL 521.54030
-#> d_V 11214.21071
-#> d_KA 71.08764
-#> sig_prop 806176.95068
-#>
-#> $rse
-#> CL V KA d_CL d_V d_KA sig_prop
-#> 4.738266 2.756206 13.925829 25.627205 30.344316 25.777327 11.170784
-#>
-
-
-
R/evaluate_fim_map.R
- evaluate_fim_map.Rd
Computation of the Bayesian Fisher information matrix for -individual parameters of a population model based on -Maximum A Posteriori (MAP) estimation of the empirical Bayes estimates (EBEs) in a population model
-evaluate_fim_map(
- poped.db,
- use_mc = FALSE,
- num_sim_ids = 1000,
- use_purrr = FALSE,
- shrink_mat = F
-)
A PopED database
Should the calculation be based on monte-carlo simulations. If -not then then a first order approximation is used
If use_mc=TRUE
, how many individuals should be
-simulated to make the computations.
If use_mc=TRUE
then should the method use the package
-purrr in calculations? This may speed up computations (potentially).
Should the shrinkage matrix be returned. Calculated as the -inverse of the Bayesian Fisher information matrix times the inverse of the -omega matrix (variance matrix of the between-subject variability).
The Bayesian Fisher information matrix for each design group
-Combes, F. P., Retout, S., - Frey, N., & Mentre, F. (2013). Prediction of shrinkage of individual - parameters using the Bayesian information matrix in non-linear mixed effect - models with evaluation in pharmacokinetics. Pharmaceutical Research, 30(9), - 2355-67. doi:10.1007/s11095-013-1079-3 -.
Hennig, S., Nyberg, J., Fanta, S., Backman, J. - T., Hoppu, K., Hooker, A. C., & Karlsson, M. O. (2012). Application of the - optimal design approach to improve a pretransplant drug dose finding design - for ciclosporin. Journal of Clinical Pharmacology, 52(3), 347-360. - doi:10.1177/0091270010397731 -.
library(PopED)
-
-############# START #################
-## Create PopED database
-## (warfarin example)
-#####################################
-
-## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define model, parameters, initial design
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(prop=0.01),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- a=c(DOSE=70))
-
-############# END ###################
-## Create PopED database
-## (warfarin example)
-#####################################
-
-shrinkage(poped.db)
-#> # A tibble: 3 × 5
-#> d_CL d_V d_KA type group
-#> <dbl> <dbl> <dbl> <chr> <chr>
-#> 1 0.0244 0.174 0.0301 shrink_var grp_1
-#> 2 0.0123 0.0910 0.0152 shrink_sd grp_1
-#> 3 0.0413 0.0590 0.134 se grp_1
-
-
-
Evaluate the power of a design to estimate a parameter value different than -some assumed value (often the assumed value is zero). The power is calculated -using the linear Wald test and the the design is defined in a poped database.
-evaluate_power(
- poped.db,
- bpop_idx,
- h0 = 0,
- alpha = 0.05,
- power = 0.8,
- twoSided = TRUE,
- find_min_n = TRUE,
- fim = NULL,
- out = NULL,
- ...
-)
A poped database
Index for an unfixed population parameter (bpop) for -which the power should be -evaluated for being different than the null hypothesis (h0).
The null hypothesized value for the parameter.
Type 1 error.
Targeted power.
Is this a two-sided test.
Should the function compute the minimum n needed (given the -current design) to achieve the desired power?
Provide the FIM from a previous calculation
provide output from a previous calculation (e.g., -calc_ofv_and_fim, ...)
Extra parameters passed to calc_ofv_and_fim
and
-get_rse
A list of elements evaluating the current design including the power.
-Retout, S., Comets, E., Samson, A., and Mentre, - F. (2007). Design in nonlinear mixed effects models: Optimization using the - Fedorov-Wynn algorithm and power of the Wald test for binary covariates. - Statistics in Medicine, 26(28), 5162-5179. - doi:10.1002/sim.2910 -.
Ueckert, S., Hennig, S., - Nyberg, J., Karlsson, M. O., and Hooker, A. C. (2013). Optimizing disease - progression study designs for drug effect discrimination. Journal of - Pharmacokinetics and Pharmacodynamics, 40(5), 587-596. - doi:10.1007/s10928-013-9331-3 -.
Other evaluate_design:
-evaluate.fim()
,
-evaluate_design()
,
-get_rse()
,
-model_prediction()
,
-plot_efficiency_of_windows()
,
-plot_model_prediction()
# Folowing the examples presented in Retout, 2007
-
-ff <- function(model_switch,xt,parameters,poped.db){
- with(as.list(parameters),{
-
- lambda1 <- lam1a
- if(TREAT==2) lambda1 <- lam1b
-
- y=log10(P1*exp(-lambda1*xt)+P2*exp(-lam2*xt))
-
- return(list(y=y,poped.db=poped.db))
- })
-}
-
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(P1=exp(bpop[1]+b[1]),
- P2=exp(bpop[2]+b[2]),
- lam1a=exp(bpop[3]+b[3]),
- lam1b=exp(bpop[3]+bpop[4]+b[3]),
- lam2=exp(bpop[5]+b[4]),
- TREAT=a[1])
- return(parameters)
-}
-
-
-poped.db <- create.poped.database(ff_fun = ff,
- fg_fun = sfg,
- fError_fun = feps.add,
- bpop=c(P1=12, P2=8,
- lam1=-0.7,beta=0,lam2=-3.0),
- d=c(P1=0.3, P2=0.3,
- lam1=0.3,lam2=0.3),
- sigma=c(0.065^2),
- groupsize=100,
- m=2,
- xt=c(1, 3, 7, 14, 28, 56),
- minxt=0,
- maxxt=100,
- a=list(c(TREAT=1),c(TREAT=2)))
-
-plot_model_prediction(poped.db)
-
-evaluate_design(poped.db)
-#> $ofv
-#> [1] 74.52441
-#>
-#> $fim
-#> P1 P2 lam1 beta lam2 d_P1
-#> P1 611.712173 -12.723468 -24.210864 -12.105432 -5.109809 0.000000e+00
-#> P2 -12.723468 580.838635 -16.202945 -8.101473 -39.342222 0.000000e+00
-#> lam1 -24.210864 -16.202945 648.887537 324.443769 -6.742703 0.000000e+00
-#> beta -12.105432 -8.101473 324.443769 324.443769 -3.371351 0.000000e+00
-#> lam2 -5.109809 -39.342222 -6.742703 -3.371351 643.716238 0.000000e+00
-#> d_P1 0.000000 0.000000 0.000000 0.000000 0.000000 9.354418e+02
-#> d_P2 0.000000 0.000000 0.000000 0.000000 0.000000 4.051226e-01
-#> d_lam1 0.000000 0.000000 0.000000 0.000000 0.000000 1.465796e+00
-#> d_lam2 0.000000 0.000000 0.000000 0.000000 0.000000 6.533665e-02
-#> SIGMA[1,1] 0.000000 0.000000 0.000000 0.000000 0.000000 5.831126e+03
-#> d_P2 d_lam1 d_lam2 SIGMA[1,1]
-#> P1 0.0000000 0.0000000 0.000000e+00 0.000
-#> P2 0.0000000 0.0000000 0.000000e+00 0.000
-#> lam1 0.0000000 0.0000000 0.000000e+00 0.000
-#> beta 0.0000000 0.0000000 0.000000e+00 0.000
-#> lam2 0.0000000 0.0000000 0.000000e+00 0.000
-#> d_P1 0.4051226 1.4657963 6.533665e-02 5831.126
-#> d_P2 843.4338997 0.6563403 3.869526e+00 8499.377
-#> d_lam1 0.6563403 1052.6375905 1.136601e-01 1889.172
-#> d_lam2 3.8695261 0.1136601 1.035926e+03 2335.057
-#> SIGMA[1,1] 8499.3770552 1889.1722061 2.335057e+03 11411954.974
-#>
-#> $rse
-#> P1 P2 lam1 beta lam2 d_P1
-#> 0.33728477 0.52006496 7.93579642 0.07851367 1.31669814 10.91610610
-#> d_P2 d_lam1 d_lam2 SIGMA[1,1]
-#> 11.52111962 10.27552547 10.35895352 7.04673895
-#>
-
-poped.db_2 <- create.poped.database(poped.db,bpop=c(P1=12, P2=8,
- lam1=-0.7,beta=0.262,lam2=-3.0))
-
-plot_model_prediction(poped.db_2)
-
-evaluate_design(poped.db_2)
-#> $ofv
-#> [1] 74.54742
-#>
-#> $fim
-#> P1 P2 lam1 beta lam2 d_P1
-#> P1 606.082950 -12.698834 -26.35693 -14.251496 -5.275302 0.000000e+00
-#> P2 -12.698834 590.575894 -15.71391 -7.612439 -35.363104 0.000000e+00
-#> lam1 -26.356928 -15.713911 647.69637 323.252599 -6.706090 0.000000e+00
-#> beta -14.251496 -7.612439 323.25260 323.252599 -3.334739 0.000000e+00
-#> lam2 -5.275302 -35.363104 -6.70609 -3.334739 645.343252 0.000000e+00
-#> d_P1 0.000000 0.000000 0.00000 0.000000 0.000000 9.184102e+02
-#> d_P2 0.000000 0.000000 0.00000 0.000000 0.000000 4.034200e-01
-#> d_lam1 0.000000 0.000000 0.00000 0.000000 0.000000 1.748309e+00
-#> d_lam2 0.000000 0.000000 0.00000 0.000000 0.000000 6.967871e-02
-#> SIGMA[1,1] 0.000000 0.000000 0.00000 0.000000 0.000000 6.355107e+03
-#> d_P2 d_lam1 d_lam2 SIGMA[1,1]
-#> P1 0.0000000 0.0000000 0.000000e+00 0.000
-#> P2 0.0000000 0.0000000 0.000000e+00 0.000
-#> lam1 0.0000000 0.0000000 0.000000e+00 0.000
-#> beta 0.0000000 0.0000000 0.000000e+00 0.000
-#> lam2 0.0000000 0.0000000 0.000000e+00 0.000
-#> d_P1 0.4034200 1.7483086 6.967871e-02 6355.107
-#> d_P2 872.1867153 0.6179178 3.165957e+00 7662.897
-#> d_lam1 0.6179178 1048.7800081 1.124325e-01 2004.872
-#> d_lam2 3.1659572 0.1124325 1.041176e+03 2204.565
-#> SIGMA[1,1] 7662.8965806 2004.8718676 2.204565e+03 11396937.363
-#>
-#> $rse
-#> P1 P2 lam1 beta lam2 d_P1 d_P2
-#> 0.3388993 0.5155216 7.9357907 29.9948348 1.3144681 11.0205784 11.3204964
-#> d_lam1 d_lam2 SIGMA[1,1]
-#> 10.2946079 10.3325269 7.0480558
-#>
-
-evaluate_power(poped.db_2,bpop_idx = 4)
-#> $ofv
-#> [1] 74.54742
-#>
-#> $fim
-#> [,1] [,2] [,3] [,4] [,5] [,6]
-#> [1,] 606.082950 -12.698834 -26.35693 -14.251496 -5.275302 0.000000e+00
-#> [2,] -12.698834 590.575894 -15.71391 -7.612439 -35.363104 0.000000e+00
-#> [3,] -26.356928 -15.713911 647.69637 323.252599 -6.706090 0.000000e+00
-#> [4,] -14.251496 -7.612439 323.25260 323.252599 -3.334739 0.000000e+00
-#> [5,] -5.275302 -35.363104 -6.70609 -3.334739 645.343252 0.000000e+00
-#> [6,] 0.000000 0.000000 0.00000 0.000000 0.000000 9.184102e+02
-#> [7,] 0.000000 0.000000 0.00000 0.000000 0.000000 4.034200e-01
-#> [8,] 0.000000 0.000000 0.00000 0.000000 0.000000 1.748309e+00
-#> [9,] 0.000000 0.000000 0.00000 0.000000 0.000000 6.967871e-02
-#> [10,] 0.000000 0.000000 0.00000 0.000000 0.000000 6.355107e+03
-#> [,7] [,8] [,9] [,10]
-#> [1,] 0.0000000 0.0000000 0.000000e+00 0.000
-#> [2,] 0.0000000 0.0000000 0.000000e+00 0.000
-#> [3,] 0.0000000 0.0000000 0.000000e+00 0.000
-#> [4,] 0.0000000 0.0000000 0.000000e+00 0.000
-#> [5,] 0.0000000 0.0000000 0.000000e+00 0.000
-#> [6,] 0.4034200 1.7483086 6.967871e-02 6355.107
-#> [7,] 872.1867153 0.6179178 3.165957e+00 7662.897
-#> [8,] 0.6179178 1048.7800081 1.124325e-01 2004.872
-#> [9,] 3.1659572 0.1124325 1.041176e+03 2204.565
-#> [10,] 7662.8965806 2004.8718676 2.204565e+03 11396937.363
-#>
-#> $rse
-#> P1 P2 lam1 beta lam2 d_P1 d_P2
-#> 0.3388993 0.5155216 7.9357907 29.9948348 1.3144681 11.0205784 11.3204964
-#> d_lam1 d_lam2 SIGMA[1,1]
-#> 10.2946079 10.3325269 7.0480558
-#>
-#> $power
-#> Value RSE power_pred power_want need_rse min_N_tot
-#> beta 0.262 29.99483 91.52704 80 35.69408 142
-#>
-
Extract an individual FIM for each group in a design
-extract_norm_group_fim(poped.db, ...)
A PopED database
Arguments passed to evaluate.fim
A list of FIMs, one for each group in a design.
-This is a residual unexplained variability (RUV) model function that encodes the model described above.
-The function is suitable for input to the create.poped.database
function using the
- fError_file
argument.
feps.add(model_switch, xt, parameters, epsi, poped.db)
a vector of values, the same size as xt
, identifying which model
-response should be computed for the
-corresponding xt value. Used for multiple response models.
a vector of independent variable values (often time).
A named list of parameter values.
A matrix with the same number of rows as the xt
vector, columns match the numbers defined in this
-function.
a poped database. This can be used to extract information that may be needed in the model file.
A list consisting of:
y the values of the model at the specified points.
poped.db A (potentially modified) poped database.
Other models:
-feps.add.prop()
,
-feps.prop()
,
-ff.PK.1.comp.oral.md.CL()
,
-ff.PK.1.comp.oral.md.KE()
,
-ff.PK.1.comp.oral.sd.CL()
,
-ff.PK.1.comp.oral.sd.KE()
,
-ff.PKPD.1.comp.oral.md.CL.imax()
,
-ff.PKPD.1.comp.sd.CL.emax()
Other RUV_models:
-feps.add.prop()
,
-feps.prop()
-library(PopED)
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.KE
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - KE))) * (exp(-KE *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x113f468e0>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(KE=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.KE,
- fg_fun=sfg,
- fError_fun=feps.add,
- bpop=c(KE=0.15/8, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(KE=0.07, V=0.02, KA=0.6),
- sigma=1,
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0,
- maxxt=120,
- a=70)
-
-## create plot of model without variability
-plot_model_prediction(poped.db)
-
-
-## evaluate initial design
-FIM <- evaluate.fim(poped.db)
-FIM
-#> [,1] [,2] [,3] [,4] [,5] [,6]
-#> [1,] 746643.9218 1031.526838 485.621863 0.000000 0.00000 0.000000
-#> [2,] 1031.5268 16.667994 -3.901736 0.000000 0.00000 0.000000
-#> [3,] 485.6219 -3.901736 47.787464 0.000000 0.00000 0.000000
-#> [4,] 0.0000 0.000000 0.000000 1076.594563 374.07924 1.295445
-#> [5,] 0.0000 0.000000 0.000000 374.079240 17780.60889 15.223541
-#> [6,] 0.0000 0.000000 0.000000 1.295445 15.22354 35.681901
-#> [7,] 0.0000 0.000000 0.000000 47.625531 142.44395 2.089439
-#> [,7]
-#> [1,] 0.000000
-#> [2,] 0.000000
-#> [3,] 0.000000
-#> [4,] 47.625531
-#> [5,] 142.443949
-#> [6,] 2.089439
-#> [7,] 86.372695
-det(FIM)
-#> [1] 2.960928e+19
-get_rse(FIM,poped.db)
-#> KE V KA d_KE d_V d_KA SIGMA[1,1]
-#> 6.508287 3.248953 14.728214 44.184490 37.841158 27.924203 10.959023
-
-
This is a residual unexplained variability (RUV) model function that encodes the model described above.
-The function is suitable for input to the create.poped.database
function using the
- fError_file
argument.
feps.add.prop(model_switch, xt, parameters, epsi, poped.db)
a vector of values, the same size as xt
, identifying which model
-response should be computed for the
-corresponding xt value. Used for multiple response models.
a vector of independent variable values (often time).
A named list of parameter values.
A matrix with the same number of rows as the xt
vector, columns match the numbers defined in this
-function.
a poped database. This can be used to extract information that may be needed in the model file.
A list consisting of:
y the values of the model at the specified points.
poped.db A (potentially modified) poped database.
Other models:
-feps.add()
,
-feps.prop()
,
-ff.PK.1.comp.oral.md.CL()
,
-ff.PK.1.comp.oral.md.KE()
,
-ff.PK.1.comp.oral.sd.CL()
,
-ff.PK.1.comp.oral.sd.KE()
,
-ff.PKPD.1.comp.oral.md.CL.imax()
,
-ff.PKPD.1.comp.sd.CL.emax()
library(PopED)
-
-## find the parameters that are needed to define in the structural model
-ff.PK.1.comp.oral.md.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> N = floor(xt/TAU) + 1
-#> y = (DOSE * Favail/V) * (KA/(KA - CL/V)) * (exp(-CL/V *
-#> (xt - (N - 1) * TAU)) * (1 - exp(-N * CL/V * TAU))/(1 -
-#> exp(-CL/V * TAU)) - exp(-KA * (xt - (N - 1) * TAU)) *
-#> (1 - exp(-N * KA * TAU))/(1 - exp(-KA * TAU)))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1104c9b70>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c( V=bpop[1]*exp(b[1]),
- KA=bpop[2]*exp(b[2]),
- CL=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1],
- TAU=a[2])
- return( parameters )
-}
-
-## -- Define design and design space
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.md.CL,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- groupsize=20,
- m=2,
- sigma=c(0.04,5e-6),
- bpop=c(V=72.8,KA=0.25,CL=3.75,Favail=0.9),
- d=c(V=0.09,KA=0.09,CL=0.25^2),
- notfixed_bpop=c(1,1,1,0),
- notfixed_sigma=c(0,0),
- xt=c( 1,2,8,240,245),
- minxt=c(0,0,0,240,240),
- maxxt=c(10,10,10,248,248),
- a=cbind(c(20,40),c(24,24)),
- bUseGrouped_xt=1,
- maxa=c(200,24),
- mina=c(0,24))
-
-## create plot of model without variability
-plot_model_prediction(poped.db)
-
-
-## evaluate initial design
-FIM <- evaluate.fim(poped.db)
-FIM
-#> [,1] [,2] [,3] [,4] [,5] [,6]
-#> [1,] 0.05336692 -8.683963 -0.05863412 0.000000 0.000000 0.000000
-#> [2,] -8.68396266 2999.851007 -14.43058560 0.000000 0.000000 0.000000
-#> [3,] -0.05863412 -14.430586 37.15243290 0.000000 0.000000 0.000000
-#> [4,] 0.00000000 0.000000 0.00000000 999.953587 312.240246 3.202847
-#> [5,] 0.00000000 0.000000 0.00000000 312.240246 439.412556 2.287838
-#> [6,] 0.00000000 0.000000 0.00000000 3.202847 2.287838 3412.005199
-det(FIM)
-#> [1] 3.627987e+12
-get_rse(FIM,poped.db)
-#> V KA CL d_V d_KA d_CL
-#> 8.215338 10.090955 4.400304 39.833230 60.089601 27.391518
-
-
This is a residual unexplained variability (RUV) model function that encodes the model described above.
-The function is suitable for input to the create.poped.database
function using the
- fError_file
argument.
feps.prop(model_switch, xt, parameters, epsi, poped.db)
a vector of values, the same size as xt
, identifying which model
-response should be computed for the
-corresponding xt value. Used for multiple response models.
a vector of independent variable values (often time).
A named list of parameter values.
A matrix with the same number of rows as the xt
vector, columns match the numbers defined in this
-function.
a poped database. This can be used to extract information that may be needed in the model file.
A list consisting of:
y the values of the model at the specified points.
poped.db A (potentially modified) poped database.
Other models:
-feps.add.prop()
,
-feps.add()
,
-ff.PK.1.comp.oral.md.CL()
,
-ff.PK.1.comp.oral.md.KE()
,
-ff.PK.1.comp.oral.sd.CL()
,
-ff.PK.1.comp.oral.sd.KE()
,
-ff.PKPD.1.comp.oral.md.CL.imax()
,
-ff.PKPD.1.comp.sd.CL.emax()
Other RUV_models:
-feps.add.prop()
,
-feps.add()
library(PopED)
-
-############# START #################
-## Create PopED database
-## (warfarin example)
-#####################################
-
-## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define model, parameters, initial design
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(prop=0.01),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- a=c(DOSE=70))
-
-############# END ###################
-## Create PopED database
-## (warfarin example)
-#####################################
-
-
-## create plot of model without variability
-plot_model_prediction(poped.db)
-
-
-## evaluate initial design
-FIM <- evaluate.fim(poped.db)
-FIM
-#> [,1] [,2] [,3] [,4] [,5] [,6]
-#> [1,] 19821.28445 -21.836551 -8.622140 0.000000e+00 0.000000 0.00000000
-#> [2,] -21.83655 20.656071 -1.807099 0.000000e+00 0.000000 0.00000000
-#> [3,] -8.62214 -1.807099 51.729039 0.000000e+00 0.000000 0.00000000
-#> [4,] 0.00000 0.000000 0.000000 3.107768e+03 10.728786 0.02613561
-#> [5,] 0.00000 0.000000 0.000000 1.072879e+01 27307.089308 3.26560786
-#> [6,] 0.00000 0.000000 0.000000 2.613561e-02 3.265608 41.81083599
-#> [7,] 0.00000 0.000000 0.000000 5.215403e+02 11214.210707 71.08763902
-#> [,7]
-#> [1,] 0.00000
-#> [2,] 0.00000
-#> [3,] 0.00000
-#> [4,] 521.54030
-#> [5,] 11214.21071
-#> [6,] 71.08764
-#> [7,] 806176.95068
-det(FIM)
-#> [1] 5.996147e+22
-get_rse(FIM,poped.db)
-#> CL V KA d_CL d_V d_KA sig_prop
-#> 4.738266 2.756206 13.925829 25.627205 30.344316 25.777327 11.170784
-
-
This is just a wrapper for the do.call
function to behave like the feval function in MATLAB.
feval(file.name, ...)
A function or a string that is the name of a function.
Arguments for the function. Multiple arguments separated by a comma.
Output from the defined function.
-
-feval("sin",pi/2)
-#> [1] 1
-
-
R/models.R
- ff.PK.1.comp.oral.md.CL.Rd
This is a structural model function that encodes a model that is
-one-compartment, oral absorption, multiple bolus dose, parameterized using CL.
-The function is suitable for input to the create.poped.database
function using the
- ff_file
argument.
ff.PK.1.comp.oral.md.CL(model_switch, xt, parameters, poped.db)
a vector of values, the same size as xt
, identifying which model
-response should be computed for the
-corresponding xt value. Used for multiple response models.
a vector of independent variable values (often time).
A named list of parameter values.
a poped database. This can be used to extract information that may be needed in the model file.
A list consisting of:
y the values of the model at the specified points.
poped.db A (potentially modified) poped database.
Other models:
-feps.add.prop()
,
-feps.add()
,
-feps.prop()
,
-ff.PK.1.comp.oral.md.KE()
,
-ff.PK.1.comp.oral.sd.CL()
,
-ff.PK.1.comp.oral.sd.KE()
,
-ff.PKPD.1.comp.oral.md.CL.imax()
,
-ff.PKPD.1.comp.sd.CL.emax()
Other structural_models:
-ff.PK.1.comp.oral.md.KE()
,
-ff.PK.1.comp.oral.sd.CL()
,
-ff.PK.1.comp.oral.sd.KE()
,
-ff.PKPD.1.comp.oral.md.CL.imax()
,
-ff.PKPD.1.comp.sd.CL.emax()
library(PopED)
-
-## find the parameters that are needed to define in the structural model
-ff.PK.1.comp.oral.md.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> N = floor(xt/TAU) + 1
-#> y = (DOSE * Favail/V) * (KA/(KA - CL/V)) * (exp(-CL/V *
-#> (xt - (N - 1) * TAU)) * (1 - exp(-N * CL/V * TAU))/(1 -
-#> exp(-CL/V * TAU)) - exp(-KA * (xt - (N - 1) * TAU)) *
-#> (1 - exp(-N * KA * TAU))/(1 - exp(-KA * TAU)))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1104c9b70>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c( V=bpop[1]*exp(b[1]),
- KA=bpop[2]*exp(b[2]),
- CL=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1],
- TAU=a[2])
- return( parameters )
-}
-
-## -- Define design and design space
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.md.CL,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- groupsize=20,
- m=2,
- sigma=c(0.04,5e-6),
- bpop=c(V=72.8,KA=0.25,CL=3.75,Favail=0.9),
- d=c(V=0.09,KA=0.09,CL=0.25^2),
- notfixed_bpop=c(1,1,1,0),
- notfixed_sigma=c(0,0),
- xt=c( 1,2,8,240,245),
- minxt=c(0,0,0,240,240),
- maxxt=c(10,10,10,248,248),
- a=cbind(c(20,40),c(24,24)),
- bUseGrouped_xt=1,
- maxa=c(200,24),
- mina=c(0,24))
-
-## create plot of model without variability
-plot_model_prediction(poped.db)
-
-
-## evaluate initial design
-FIM <- evaluate.fim(poped.db)
-FIM
-#> [,1] [,2] [,3] [,4] [,5] [,6]
-#> [1,] 0.05336692 -8.683963 -0.05863412 0.000000 0.000000 0.000000
-#> [2,] -8.68396266 2999.851007 -14.43058560 0.000000 0.000000 0.000000
-#> [3,] -0.05863412 -14.430586 37.15243290 0.000000 0.000000 0.000000
-#> [4,] 0.00000000 0.000000 0.00000000 999.953587 312.240246 3.202847
-#> [5,] 0.00000000 0.000000 0.00000000 312.240246 439.412556 2.287838
-#> [6,] 0.00000000 0.000000 0.00000000 3.202847 2.287838 3412.005199
-det(FIM)
-#> [1] 3.627987e+12
-get_rse(FIM,poped.db)
-#> V KA CL d_V d_KA d_CL
-#> 8.215338 10.090955 4.400304 39.833230 60.089601 27.391518
-
-
R/models.R
- ff.PK.1.comp.oral.md.KE.Rd
This is a structural model function that encodes a model that is
-one-compartment, oral absorption, multiple bolus dose, parameterized using KE.
-The function is suitable for input to the create.poped.database
function using the
- ff_file
argument.
ff.PK.1.comp.oral.md.KE(model_switch, xt, parameters, poped.db)
a vector of values, the same size as xt
, identifying which model
-response should be computed for the
-corresponding xt value. Used for multiple response models.
a vector of independent variable values (often time).
A named list of parameter values.
a poped database. This can be used to extract information that may be needed in the model file.
A list consisting of:
y the values of the model at the specified points.
poped.db A (potentially modified) poped database.
Other models:
-feps.add.prop()
,
-feps.add()
,
-feps.prop()
,
-ff.PK.1.comp.oral.md.CL()
,
-ff.PK.1.comp.oral.sd.CL()
,
-ff.PK.1.comp.oral.sd.KE()
,
-ff.PKPD.1.comp.oral.md.CL.imax()
,
-ff.PKPD.1.comp.sd.CL.emax()
Other structural_models:
-ff.PK.1.comp.oral.md.CL()
,
-ff.PK.1.comp.oral.sd.CL()
,
-ff.PK.1.comp.oral.sd.KE()
,
-ff.PKPD.1.comp.oral.md.CL.imax()
,
-ff.PKPD.1.comp.sd.CL.emax()
library(PopED)
-
-## find the parameters that are needed to define in the structural model
-ff.PK.1.comp.oral.md.KE
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> N = floor(xt/TAU) + 1
-#> y = (DOSE * Favail/V) * (KA/(KA - KE)) * (exp(-KE * (xt -
-#> (N - 1) * TAU)) * (1 - exp(-N * KE * TAU))/(1 - exp(-KE *
-#> TAU)) - exp(-KA * (xt - (N - 1) * TAU)) * (1 - exp(-N *
-#> KA * TAU))/(1 - exp(-KA * TAU)))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x133e26ed8>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- ## -- parameter definition function
- parameters=c( V=bpop[1]*exp(b[1]),
- KA=bpop[2]*exp(b[2]),
- KE=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1],
- TAU=a[2])
- return( parameters )
-}
-
-## -- Define design and design space
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.md.KE,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- groupsize=20,
- m=2,
- sigma=c(0.04,5e-6),
- bpop=c(V=72.8,KA=0.25,KE=3.75/72.8,Favail=0.9),
- d=c(V=0.09,KA=0.09,KE=0.25^2),
- notfixed_bpop=c(1,1,1,0),
- notfixed_sigma=c(0,0),
- xt=c( 1,2,8,240,245),
- minxt=c(0,0,0,240,240),
- maxxt=c(10,10,10,248,248),
- a=cbind(c(20,40),c(24,24)),
- bUseGrouped_xt=1,
- maxa=c(200,40),
- mina=c(0,2))
-
-## create plot of model without variability
-plot_model_prediction(poped.db)
-
-
-## evaluate initial design
-FIM <- evaluate.fim(poped.db)
-FIM
-#> [,1] [,2] [,3] [,4] [,5] [,6]
-#> [1,] 0.06138421 -6.369454 34.30738 0.0000 0.0000 0.0000
-#> [2,] -6.36945403 3667.860710 9887.52379 0.0000 0.0000 0.0000
-#> [3,] 34.30737724 9887.523789 145132.13111 0.0000 0.0000 0.0000
-#> [4,] 0.00000000 0.000000 0.00000 1322.9667 167.9800 206.8939
-#> [5,] 0.00000000 0.000000 0.00000 167.9800 656.8986 202.6588
-#> [6,] 0.00000000 0.000000 0.00000 206.8939 202.6588 1853.6889
-det(FIM)
-#> [1] 1.810534e+16
-get_rse(FIM,poped.db)
-#> V KA KE d_V d_KA d_KE
-#> 8.215338 10.090955 7.566975 31.220520 44.677836 38.005067
-
-
R/models.R
- ff.PK.1.comp.oral.sd.CL.Rd
This is a structural model function that encodes a model that is
-one-compartment, oral absorption, single bolus dose, parameterized using CL.
-The function is suitable for input to the create.poped.database
function using the
- ff_file
argument.
ff.PK.1.comp.oral.sd.CL(model_switch, xt, parameters, poped.db)
a vector of values, the same size as xt
, identifying which model
-response should be computed for the
-corresponding xt value. Used for multiple response models.
a vector of independent variable values (often time).
A named list of parameter values.
a poped database. This can be used to extract information that may be needed in the model file.
A list consisting of:
y the values of the model at the specified points.
poped.db A (potentially modified) poped database.
Other models:
-feps.add.prop()
,
-feps.add()
,
-feps.prop()
,
-ff.PK.1.comp.oral.md.CL()
,
-ff.PK.1.comp.oral.md.KE()
,
-ff.PK.1.comp.oral.sd.KE()
,
-ff.PKPD.1.comp.oral.md.CL.imax()
,
-ff.PKPD.1.comp.sd.CL.emax()
Other structural_models:
-ff.PK.1.comp.oral.md.CL()
,
-ff.PK.1.comp.oral.md.KE()
,
-ff.PK.1.comp.oral.sd.KE()
,
-ff.PKPD.1.comp.oral.md.CL.imax()
,
-ff.PKPD.1.comp.sd.CL.emax()
library(PopED)
-
-############# START #################
-## Create PopED database
-## (warfarin example)
-#####################################
-
-## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define model, parameters, initial design
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(prop=0.01),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- a=c(DOSE=70))
-
-############# END ###################
-## Create PopED database
-## (warfarin example)
-#####################################
-
-
-## create plot of model without variability
-plot_model_prediction(poped.db)
-
-
-## evaluate initial design
-FIM <- evaluate.fim(poped.db)
-FIM
-#> [,1] [,2] [,3] [,4] [,5] [,6]
-#> [1,] 19821.28445 -21.836551 -8.622140 0.000000e+00 0.000000 0.00000000
-#> [2,] -21.83655 20.656071 -1.807099 0.000000e+00 0.000000 0.00000000
-#> [3,] -8.62214 -1.807099 51.729039 0.000000e+00 0.000000 0.00000000
-#> [4,] 0.00000 0.000000 0.000000 3.107768e+03 10.728786 0.02613561
-#> [5,] 0.00000 0.000000 0.000000 1.072879e+01 27307.089308 3.26560786
-#> [6,] 0.00000 0.000000 0.000000 2.613561e-02 3.265608 41.81083599
-#> [7,] 0.00000 0.000000 0.000000 5.215403e+02 11214.210707 71.08763902
-#> [,7]
-#> [1,] 0.00000
-#> [2,] 0.00000
-#> [3,] 0.00000
-#> [4,] 521.54030
-#> [5,] 11214.21071
-#> [6,] 71.08764
-#> [7,] 806176.95068
-det(FIM)
-#> [1] 5.996147e+22
-get_rse(FIM,poped.db)
-#> CL V KA d_CL d_V d_KA sig_prop
-#> 4.738266 2.756206 13.925829 25.627205 30.344316 25.777327 11.170784
-
-
R/models.R
- ff.PK.1.comp.oral.sd.KE.Rd
This is a structural model function that encodes a model that is
-one-compartment, oral absorption, single bolus dose, parameterized using KE.
-The function is suitable for input to the create.poped.database
function using the
- ff_file
argument.
ff.PK.1.comp.oral.sd.KE(model_switch, xt, parameters, poped.db)
a vector of values, the same size as xt
, identifying which model
-response should be computed for the
-corresponding xt value. Used for multiple response models.
a vector of independent variable values (often time).
A named list of parameter values.
a poped database. This can be used to extract information that may be needed in the model file.
A list consisting of:
y the values of the model at the specified points.
poped.db A (potentially modified) poped database.
Other models:
-feps.add.prop()
,
-feps.add()
,
-feps.prop()
,
-ff.PK.1.comp.oral.md.CL()
,
-ff.PK.1.comp.oral.md.KE()
,
-ff.PK.1.comp.oral.sd.CL()
,
-ff.PKPD.1.comp.oral.md.CL.imax()
,
-ff.PKPD.1.comp.sd.CL.emax()
Other structural_models:
-ff.PK.1.comp.oral.md.CL()
,
-ff.PK.1.comp.oral.md.KE()
,
-ff.PK.1.comp.oral.sd.CL()
,
-ff.PKPD.1.comp.oral.md.CL.imax()
,
-ff.PKPD.1.comp.sd.CL.emax()
-library(PopED)
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.KE
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - KE))) * (exp(-KE *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x113f468e0>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(KE=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.KE,
- fg_fun=sfg,
- fError_fun=feps.prop,
- bpop=c(KE=0.15/8, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(KE=0.07, V=0.02, KA=0.6),
- sigma=0.01,
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0,
- maxxt=120,
- a=70)
-
-## create plot of model without variability
-plot_model_prediction(poped.db)
-
-
-## evaluate initial design
-FIM <- evaluate.fim(poped.db)
-FIM
-#> [,1] [,2] [,3] [,4] [,5] [,6]
-#> [1,] 1248651.3457 339.370439 144.758375 0.0000000 0.000000 0.0000000
-#> [2,] 339.3704 20.724252 -1.777254 0.0000000 0.000000 0.0000000
-#> [3,] 144.7584 -1.777254 51.742071 0.0000000 0.000000 0.0000000
-#> [4,] 0.0000 0.000000 0.000000 3010.9773834 40.490260 0.1151092
-#> [5,] 0.0000 0.000000 0.000000 40.4902598 27487.656006 3.1586320
-#> [6,] 0.0000 0.000000 0.000000 0.1151092 3.158632 41.8319046
-#> [7,] 0.0000 0.000000 0.000000 784.2206814 10869.344969 70.0662365
-#> [,7]
-#> [1,] 0.00000
-#> [2,] 0.00000
-#> [3,] 0.00000
-#> [4,] 784.22068
-#> [5,] 10869.34497
-#> [6,] 70.06624
-#> [7,] 807063.71904
-det(FIM)
-#> [1] 3.690649e+24
-get_rse(FIM,poped.db)
-#> KE V KA d_KE d_V d_KA SIGMA[1,1]
-#> 4.784638 2.756206 13.925829 26.037875 30.238758 25.770773 11.163214
-
-
R/models.R
- ff.PKPD.1.comp.oral.md.CL.imax.Rd
This is a structural model function that encodes the model described above.
-The function is suitable for input to the create.poped.database
function using the
- ff_file
argument.
ff.PKPD.1.comp.oral.md.CL.imax(model_switch, xt, parameters, poped.db)
a vector of values, the same size as xt
, identifying which model
-response should be computed for the
-corresponding xt value. Used for multiple response models.
a vector of independent variable values (often time).
A named list of parameter values.
a poped database. This can be used to extract information that may be needed in the model file.
A list consisting of:
y the values of the model at the specified points.
poped.db A (potentially modified) poped database.
Other models:
-feps.add.prop()
,
-feps.add()
,
-feps.prop()
,
-ff.PK.1.comp.oral.md.CL()
,
-ff.PK.1.comp.oral.md.KE()
,
-ff.PK.1.comp.oral.sd.CL()
,
-ff.PK.1.comp.oral.sd.KE()
,
-ff.PKPD.1.comp.sd.CL.emax()
Other structural_models:
-ff.PK.1.comp.oral.md.CL()
,
-ff.PK.1.comp.oral.md.KE()
,
-ff.PK.1.comp.oral.sd.CL()
,
-ff.PK.1.comp.oral.sd.KE()
,
-ff.PKPD.1.comp.sd.CL.emax()
-library(PopED)
-
-## find the parameters that are needed to define from the structural model
-ff.PKPD.1.comp.oral.md.CL.imax
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> MS <- model_switch
-#> returnArgs = ff.PK.1.comp.oral.md.CL(model_switch, xt,
-#> parameters, poped.db)
-#> CONC = returnArgs$y
-#> EFF = E0 * (1 - CONC * IMAX/(IC50 + CONC))
-#> y[MS == 1] = CONC[MS == 1]
-#> y[MS == 2] = EFF[MS == 2]
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x110514c58>
-#> <environment: namespace:PopED>
-ff.PK.1.comp.oral.md.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> N = floor(xt/TAU) + 1
-#> y = (DOSE * Favail/V) * (KA/(KA - CL/V)) * (exp(-CL/V *
-#> (xt - (N - 1) * TAU)) * (1 - exp(-N * CL/V * TAU))/(1 -
-#> exp(-CL/V * TAU)) - exp(-KA * (xt - (N - 1) * TAU)) *
-#> (1 - exp(-N * KA * TAU))/(1 - exp(-KA * TAU)))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1104c9b70>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- ## -- parameter definition function
- parameters=c( V=bpop[1]*exp(b[1]),
- KA=bpop[2]*exp(b[2]),
- CL=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1],
- TAU = a[2],
- E0=bpop[5]*exp(b[4]),
- IMAX=bpop[6],
- IC50=bpop[7])
- return( parameters )
-}
-
-
-
-feps <- function(model_switch,xt,parameters,epsi,poped.db){
- ## -- Residual Error function
- returnArgs <- do.call(poped.db$model$ff_pointer,list(model_switch,xt,parameters,poped.db))
- y <- returnArgs[[1]]
- poped.db <- returnArgs[[2]]
-
- MS <- model_switch
-
- pk.dv <- y*(1+epsi[,1])+epsi[,2]
- pd.dv <- y*(1+epsi[,3])+epsi[,4]
-
- y[MS==1] = pk.dv[MS==1]
- y[MS==2] = pd.dv[MS==2]
-
- return(list( y= y,poped.db =poped.db ))
-}
-
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_fun=ff.PKPD.1.comp.oral.md.CL.imax,
- fError_fun=feps,
- fg_fun=sfg,
- groupsize=20,
- m=3,
- bpop=c(V=72.8,KA=0.25,CL=3.75,Favail=0.9,
- E0=1120,IMAX=0.807,IC50=0.0993),
- notfixed_bpop=c(1,1,1,0,1,1,1),
- d=c(V=0.09,KA=0.09,CL=0.25^2,E0=0.09),
- sigma=c(0.04,5e-6,0.09,100),
- notfixed_sigma=c(0,0,0,0),
- xt=c( 1,2,8,240,240,1,2,8,240,240),
- minxt=c(0,0,0,240,240,0,0,0,240,240),
- maxxt=c(10,10,10,248,248,10,10,10,248,248),
- G_xt=c(1,2,3,4,5,1,2,3,4,5),
- model_switch=c(1,1,1,1,1,2,2,2,2,2),
- a=cbind(c(20,40,0),c(24,24,24)),
- bUseGrouped_xt=1,
- ourzero=0,
- maxa=c(200,40),
- mina=c(0,2))
-
-
-## create plot of model without variability
-plot_model_prediction(poped.db,facet_scales="free")
-
-
-## evaluate initial design
-FIM <- evaluate.fim(poped.db)
-FIM
-#> [,1] [,2] [,3] [,4] [,5]
-#> [1,] 5.382083e-02 -8.55463620 -0.115087642 8.293963e-05 -0.2103527
-#> [2,] -8.554636e+00 3038.24916173 -14.769854387 -1.351406e-02 -69.0609684
-#> [3,] -1.150876e-01 -14.76985439 39.394916550 3.372827e-03 -7.0857453
-#> [4,] 8.293963e-05 -0.01351406 0.003372827 4.403253e-04 -0.4017382
-#> [5,] -2.103527e-01 -69.06096842 -7.085745293 -4.017382e-01 821.9499022
-#> [6,] 3.704090e-01 5.89767799 16.302391418 1.181080e+00 -1818.6277909
-#> [7,] 0.000000e+00 0.00000000 0.000000000 0.000000e+00 0.0000000
-#> [8,] 0.000000e+00 0.00000000 0.000000000 0.000000e+00 0.0000000
-#> [9,] 0.000000e+00 0.00000000 0.000000000 0.000000e+00 0.0000000
-#> [10,] 0.000000e+00 0.00000000 0.000000000 0.000000e+00 0.0000000
-#> [,6] [,7] [,8] [,9] [,10]
-#> [1,] 0.370409 0.0000000 0.000000 0.000000 0.0000000
-#> [2,] 5.897678 0.0000000 0.000000 0.000000 0.0000000
-#> [3,] 16.302391 0.0000000 0.000000 0.000000 0.0000000
-#> [4,] 1.181080 0.0000000 0.000000 0.000000 0.0000000
-#> [5,] -1818.627791 0.0000000 0.000000 0.000000 0.0000000
-#> [6,] 5030.928571 0.0000000 0.000000 0.000000 0.0000000
-#> [7,] 0.000000 1017.0362159 303.009671 12.339375 0.5721641
-#> [8,] 0.000000 303.0096709 450.738936 2.396824 0.1852950
-#> [9,] 0.000000 12.3393753 2.396824 3836.326713 2.5117794
-#> [10,] 0.000000 0.5721641 0.185295 2.511779 2542.4091838
-det(FIM)
-#> [1] 1.593643e+18
-get_rse(FIM,poped.db)
-#> V KA CL E0 IMAX IC50 d_V d_KA
-#> 8.119842 9.968612 4.304635 7.076883 9.895340 39.478269 38.960998 58.523188
-#> d_CL d_E0
-#> 25.832775 22.036110
-
-
R/models.R
- ff.PKPD.1.comp.sd.CL.emax.Rd
This is a structural model function that encodes the model described above.
-The function is suitable for input to the create.poped.database
function using the
- ff_file
argument.
ff.PKPD.1.comp.sd.CL.emax(model_switch, xt, parameters, poped.db)
a vector of values, the same size as xt
, identifying which model
-response should be computed for the
-corresponding xt value. Used for multiple response models.
a vector of independent variable values (often time).
A named list of parameter values.
a poped database. This can be used to extract information that may be needed in the model file.
A list consisting of:
y the values of the model at the specified points.
poped.db A (potentially modified) poped database.
Other models:
-feps.add.prop()
,
-feps.add()
,
-feps.prop()
,
-ff.PK.1.comp.oral.md.CL()
,
-ff.PK.1.comp.oral.md.KE()
,
-ff.PK.1.comp.oral.sd.CL()
,
-ff.PK.1.comp.oral.sd.KE()
,
-ff.PKPD.1.comp.oral.md.CL.imax()
Other structural_models:
-ff.PK.1.comp.oral.md.CL()
,
-ff.PK.1.comp.oral.md.KE()
,
-ff.PK.1.comp.oral.sd.CL()
,
-ff.PK.1.comp.oral.sd.KE()
,
-ff.PKPD.1.comp.oral.md.CL.imax()
-library(PopED)
-
-## find the parameters that are needed to define from the structural model
-ff.PKPD.1.comp.sd.CL.emax
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> MS <- model_switch
-#> CONC = DOSE/V * exp(-CL/V * xt)
-#> EFF = E0 + CONC * EMAX/(EC50 + CONC)
-#> y[MS == 1] = CONC[MS == 1]
-#> y[MS == 2] = EFF[MS == 2]
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x115efa528>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- ## -- parameter definition function
- parameters=c(
- CL=bpop[1]*exp(b[1]) ,
- V=bpop[2]*exp(b[2]) ,
- E0=bpop[3]*exp(b[3]) ,
- EMAX=bpop[4]*exp(b[4]) ,
- EC50=bpop[5]*exp(b[5]) ,
- DOSE=a[1]
- )
- return( parameters )
-}
-
-feps <- function(model_switch,xt,parameters,epsi,poped.db){
- ## -- Residual Error function
- ## -- Proportional PK + additive PD
- returnArgs <- do.call(poped.db$model$ff_pointer,list(model_switch,xt,parameters,poped.db))
- y <- returnArgs[[1]]
- poped.db <- returnArgs[[2]]
-
- MS <- model_switch
-
- prop.err <- y*(1+epsi[,1])
- add.err <- y+epsi[,2]
-
- y[MS==1] = prop.err[MS==1]
- y[MS==2] = add.err[MS==2]
-
- return(list( y= y,poped.db =poped.db ))
-}
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_fun=ff.PKPD.1.comp.sd.CL.emax,
- fError_fun=feps,
- fg_fun=sfg,
- groupsize=20,
- m=3,
- sigma=diag(c(0.15,0.15)),
- bpop=c(CL=0.5,V=0.2,E0=1,EMAX=1,EC50=1),
- d=c(CL=0.01,V=0.01,E0=0.01,EMAX=0.01,EC50=0.01),
- xt=c( 0.33,0.66,0.9,5,0.1,1,2,5),
- model_switch=c( 1,1,1,1,2,2,2,2),
- minxt=0,
- maxxt=5,
- a=rbind(2.75,5,10),
- bUseGrouped_xt=1,
- maxa=10,
- mina=0.1)
-
-
-## create plot of model without variability
-plot_model_prediction(poped.db,facet_scales="free")
-
-
-## evaluate initial design
-FIM <- evaluate.fim(poped.db)
-FIM
-#> [,1] [,2] [,3] [,4] [,5] [,6]
-#> [1,] 13423.83149 -26148.43438 -104.9746 -55.87794 20.58619 0.000000e+00
-#> [2,] -26148.43438 70314.08833 -137.2793 -103.59890 26.32348 0.000000e+00
-#> [3,] -104.97460 -137.27932 1209.7986 516.06655 -116.00915 0.000000e+00
-#> [4,] -55.87794 -103.59890 516.0666 449.35861 -62.47406 0.000000e+00
-#> [5,] 20.58619 26.32348 -116.0092 -62.47406 22.73598 0.000000e+00
-#> [6,] 0.00000 0.00000 0.0000 0.00000 0.00000 9.385378e+04
-#> [7,] 0.00000 0.00000 0.0000 0.00000 0.00000 5.697839e+04
-#> [8,] 0.00000 0.00000 0.0000 0.00000 0.00000 2.298710e+01
-#> [9,] 0.00000 0.00000 0.0000 0.00000 0.00000 6.524561e+00
-#> [10,] 0.00000 0.00000 0.0000 0.00000 0.00000 8.880407e-01
-#> [11,] 0.00000 0.00000 0.0000 0.00000 0.00000 1.115568e+03
-#> [12,] 0.00000 0.00000 0.0000 0.00000 0.00000 1.345372e+01
-#> [,7] [,8] [,9] [,10] [,11]
-#> [1,] 0.000000e+00 0.000000 0.0000000 0.0000000 0.0000000
-#> [2,] 0.000000e+00 0.000000 0.0000000 0.0000000 0.0000000
-#> [3,] 0.000000e+00 0.000000 0.0000000 0.0000000 0.0000000
-#> [4,] 0.000000e+00 0.000000 0.0000000 0.0000000 0.0000000
-#> [5,] 0.000000e+00 0.000000 0.0000000 0.0000000 0.0000000
-#> [6,] 5.697839e+04 22.987097 6.5245606 0.8880407 1115.5680152
-#> [7,] 6.592095e+04 6.586597 3.6779636 0.2558559 1176.6041001
-#> [8,] 6.586597e+00 12197.738218 2243.7358555 112.3394149 4.8902658
-#> [9,] 3.677964e+00 2243.735855 1714.4795989 32.6395909 0.5891989
-#> [10,] 2.558559e-01 112.339415 32.6395909 4.3373414 0.1964359
-#> [11,] 1.176604e+03 4.890266 0.5891989 0.1964359 3811.1481605
-#> [12,] 4.616968e+00 3055.546022 1230.5356715 65.5594938 3.8335502
-#> [,12]
-#> [1,] 0.000000
-#> [2,] 0.000000
-#> [3,] 0.000000
-#> [4,] 0.000000
-#> [5,] 0.000000
-#> [6,] 13.453723
-#> [7,] 4.616968
-#> [8,] 3055.546022
-#> [9,] 1230.535671
-#> [10,] 65.559494
-#> [11,] 3.833550
-#> [12,] 4658.810828
-det(FIM)
-#> [1] 1.421054e+39
-get_rse(FIM,poped.db)
-#> CL V E0 EMAX EC50 d_CL
-#> 3.306524 3.610227 4.575451 6.825531 30.397923 47.350220
-#> d_V d_E0 d_EMAX d_EC50 SIGMA[1,1] SIGMA[2,2]
-#> 56.556024 113.036005 291.542904 5854.936456 10.829134 11.705173
-
-
Get the various parts of a file with path string.
-fileparts(filename.with.path)
A string of a filename with a path
A list with the following components:
-The path name
The file name
The file extension
This is a modified version of the same function in the matlab R-package.
-
-fileparts("ggg/ttt/lll.R")
-#> $pathname
-#> [1] "ggg/ttt"
-#>
-#> $filename
-#> [1] "lll"
-#>
-#> $fileext
-#> [1] ".R"
-#>
-
-
R/getTruncatedNormal.R
- getTruncatedNormal.Rd
Generate a random sample from a truncated normal distribution.
-getTruncatedNormal(mean, variance)
the mean of the normal distribution
The variance of the normal distribution
A random sample from the specified truncated normal distribution
-
-getTruncatedNormal(mean=3,variance=100)
-#> [,1]
-#> [1,] 5.223929
-
-
-
R/get_all_params.R
- get_all_params.Rd
Extract all model parameters from the PopED database.
-get_all_params(poped.db)
A PopED database.
A list containing:
-A vector of fixed effect parameter values.
A vector of between subject variability parameters
A vector of the covariances of the between subject variability parameters. Row major format of the lower triangular portion of the D (OMEGA) matrix
A vector of the between occasion variability (BOV) terms in the model
A vector of the covariances between the BOV terms. Row major of the lower triangular portion of the BOV matrix.
A vector of the residual unexplained variances (RUV)
A vector of the covariances between the RUV terms
A vector with all of the above, in the order of this list.
library(PopED)
-
-############# START #################
-## Create PopED database
-## (warfarin example)
-#####################################
-
-## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define model, parameters, initial design
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(prop=0.01),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- a=c(DOSE=70))
-
-############# END ###################
-## Create PopED database
-## (warfarin example)
-#####################################
-
-
-get_all_params(poped.db)
-#> $bpop
-#> [,1]
-#> CL 0.15
-#> V 8.00
-#> KA 1.00
-#> Favail 1.00
-#>
-#> $d
-#> [,1]
-#> CL 0.07
-#> V 0.02
-#> KA 0.60
-#>
-#> $covd
-#> [,1] [,2] [,3]
-#> [1,] 0 0 0
-#>
-#> $docc
-#> [,1]
-#>
-#> $covdocc
-#>
-#> [1,]
-#>
-#> $sigma
-#> [1] 0.01
-#>
-#> $covsigma
-#>
-#> [1,]
-#>
-#> $all
-#> [,1]
-#> [1,] 0.15
-#> [2,] 8.00
-#> [3,] 1.00
-#> [4,] 1.00
-#> [5,] 0.07
-#> [6,] 0.02
-#> [7,] 0.60
-#> [8,] 0.00
-#> [9,] 0.00
-#> [10,] 0.00
-#> [11,] 0.01
-#>
-
-
-
This function computes the expected relative standard errors of a model given a design and a previously computed -FIM.
-get_rse(
- fim,
- poped.db,
- bpop = poped.db$parameters$bpop[, 2],
- d = poped.db$parameters$d[, 2],
- docc = poped.db$parameters$docc,
- sigma = poped.db$parameters$sigma,
- use_percent = TRUE,
- fim.calc.type = poped.db$settings$iFIMCalculationType,
- prior_fim = poped.db$settings$prior_fim,
- ...
-)
A Fisher Information Matrix (FIM).
A PopED database.
A vector containing the values of the fixed effects used to compute the fim
.
A vector containing the values of the diagonals of the between subject variability matrix.
Matrix defining the IOV, the IOV variances and the IOV distribution as for d and bpop.
Matrix defining the variances can covariances of the residual variability terms of the model.
-can also just supply the diagonal parameter values (variances) as a c()
.
Should RSE be reported as percent?
The method used for calculating the FIM. Potential values:
0 = Full FIM. No assumption that fixed and random effects are uncorrelated.
1 = Reduced FIM. Assume that there is no correlation in the FIM between the fixed and random effects, and set these elements in -the FIM to zero.
2 = weighted models (placeholder).
3 = Not currently used.
4 = Reduced FIM and computing all derivatives with respect to the standard deviation of the residual unexplained variation (sqrt(SIGMA) in NONMEM). -This matches what is done in PFIM, and assumes that the standard deviation of the residual unexplained variation is the estimated parameter -(NOTE: NONMEM estimates the variance of the residual unexplained variation by default).
5 = Full FIM parameterized with A,B,C matrices & derivative of variance.
6 = Calculate one model switch at a time, good for large matrices.
7 = Reduced FIM parameterized with A,B,C matrices & derivative of variance.
A prior FIM to be added to the fim
. Should be the same size as the fim
.
Additional arguments passed to inv
.
A named list of RSE values. If the estimated parameter is assumed to be zero then for that - parameter the standard error is returned.
-Other evaluate_design:
-evaluate.fim()
,
-evaluate_design()
,
-evaluate_power()
,
-model_prediction()
,
-plot_efficiency_of_windows()
,
-plot_model_prediction()
## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-library(PopED)
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.md.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> N = floor(xt/TAU) + 1
-#> y = (DOSE * Favail/V) * (KA/(KA - CL/V)) * (exp(-CL/V *
-#> (xt - (N - 1) * TAU)) * (1 - exp(-N * CL/V * TAU))/(1 -
-#> exp(-CL/V * TAU)) - exp(-KA * (xt - (N - 1) * TAU)) *
-#> (1 - exp(-N * KA * TAU))/(1 - exp(-KA * TAU)))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1104c9b70>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_fun = ff.PK.1.comp.oral.sd.CL,
- fg_fun = sfg,
- fError_fun = feps.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- # notfixed_bpop=c(1,1,1,0),
- notfixed_bpop=c(CL=1,V=1,KA=1,Favail=0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=0.01,
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0,
- maxxt=120,
- a=70)
-
-
-## evaluate initial design with the reduced FIM
-FIM.1 <- evaluate.fim(poped.db)
-FIM.1
-#> [,1] [,2] [,3] [,4] [,5] [,6]
-#> [1,] 19821.28445 -21.836551 -8.622140 0.000000e+00 0.000000 0.00000000
-#> [2,] -21.83655 20.656071 -1.807099 0.000000e+00 0.000000 0.00000000
-#> [3,] -8.62214 -1.807099 51.729039 0.000000e+00 0.000000 0.00000000
-#> [4,] 0.00000 0.000000 0.000000 3.107768e+03 10.728786 0.02613561
-#> [5,] 0.00000 0.000000 0.000000 1.072879e+01 27307.089308 3.26560786
-#> [6,] 0.00000 0.000000 0.000000 2.613561e-02 3.265608 41.81083599
-#> [7,] 0.00000 0.000000 0.000000 5.215403e+02 11214.210707 71.08763902
-#> [,7]
-#> [1,] 0.00000
-#> [2,] 0.00000
-#> [3,] 0.00000
-#> [4,] 521.54030
-#> [5,] 11214.21071
-#> [6,] 71.08764
-#> [7,] 806176.95068
-det(FIM.1)
-#> [1] 5.996147e+22
-det(FIM.1)^(1/7)
-#> [1] 1794.658
-get_rse(FIM.1,poped.db)
-#> CL V KA d_CL d_V d_KA SIGMA[1,1]
-#> 4.738266 2.756206 13.925829 25.627205 30.344316 25.777327 11.170784
-
-## evaluate initial design with the full FIM
-FIM.0 <- evaluate.fim(poped.db,fim.calc.type=0)
-FIM.0
-#> [,1] [,2] [,3] [,4] [,5]
-#> [1,] 47625.234145 -341.996566 35.504624 -2.073844e+03 -5899.486674
-#> [2,] -341.996566 30.887205 -12.589615 -1.686280e+01 -54.629529
-#> [3,] 35.504624 -12.589615 452.758773 -8.336530e-01 -43.619195
-#> [4,] -2073.844369 -16.862802 -0.833653 3.107768e+03 10.728786
-#> [5,] -5899.486674 -54.629529 -43.619195 1.072879e+01 27307.089308
-#> [6,] 4.490538 -6.550313 18.653863 2.613561e-02 3.265608
-#> [7,] -54419.723543 -1070.933661 2955.924225 5.215403e+02 11214.210707
-#> [,6] [,7]
-#> [1,] 4.49053810 -54419.72354
-#> [2,] -6.55031322 -1070.93366
-#> [3,] 18.65386273 2955.92422
-#> [4,] 0.02613561 521.54030
-#> [5,] 3.26560786 11214.21071
-#> [6,] 41.81083599 71.08764
-#> [7,] 71.08763902 806176.95068
-det(FIM.0)
-#> [1] 1.220371e+24
-det(FIM.0)^(1/7)
-#> [1] 2760.117
-get_rse(FIM.0,poped.db)
-#> CL V KA d_CL d_V d_KA SIGMA[1,1]
-#> 3.560994 2.560413 4.811952 26.270324 30.901555 26.503936 12.409516
-
-## evaluate initial design with the reduced FIM
-## computing all derivatives with respect to the
-## standard deviation of the residual unexplained variation
-FIM.4 <- evaluate.fim(poped.db,fim.calc.type=4)
-FIM.4
-#> [,1] [,2] [,3] [,4] [,5] [,6]
-#> [1,] 19821.28445 -21.836551 -8.622140 0.000000e+00 0.000000 0.00000000
-#> [2,] -21.83655 20.656071 -1.807099 0.000000e+00 0.000000 0.00000000
-#> [3,] -8.62214 -1.807099 51.729039 0.000000e+00 0.000000 0.00000000
-#> [4,] 0.00000 0.000000 0.000000 3.107768e+03 10.728786 0.02613561
-#> [5,] 0.00000 0.000000 0.000000 1.072879e+01 27307.089308 3.26560786
-#> [6,] 0.00000 0.000000 0.000000 2.613561e-02 3.265608 41.81083599
-#> [7,] 0.00000 0.000000 0.000000 1.043081e+02 2242.842141 14.21752780
-#> [,7]
-#> [1,] 0.00000
-#> [2,] 0.00000
-#> [3,] 0.00000
-#> [4,] 104.30806
-#> [5,] 2242.84214
-#> [6,] 14.21753
-#> [7,] 32247.07803
-det(FIM.4)
-#> [1] 2.398459e+21
-get_rse(FIM.4,poped.db,fim.calc.type=4)
-#> CL V KA d_CL d_V d_KA SIGMA[1,1]
-#> 4.738266 2.756206 13.925829 25.627205 30.344316 25.777327 5.585392
-
-## evaluate initial design with the full FIM with A,B,C matricies
-## should give same answer as fim.calc.type=0
-FIM.5 <- evaluate.fim(poped.db,fim.calc.type=5)
-FIM.5
-#> [,1] [,2] [,3] [,4] [,5]
-#> [1,] 47625.234145 -341.996566 35.504624 -2.073844e+03 -5899.486674
-#> [2,] -341.996566 30.887205 -12.589615 -1.686280e+01 -54.629529
-#> [3,] 35.504624 -12.589615 452.758773 -8.336530e-01 -43.619195
-#> [4,] -2073.844369 -16.862802 -0.833653 3.107768e+03 10.728786
-#> [5,] -5899.486674 -54.629529 -43.619195 1.072879e+01 27307.089308
-#> [6,] 4.490538 -6.550313 18.653863 2.613561e-02 3.265608
-#> [7,] -54419.723543 -1070.933661 2955.924225 5.215403e+02 11214.210707
-#> [,6] [,7]
-#> [1,] 4.49053810 -54419.72354
-#> [2,] -6.55031322 -1070.93366
-#> [3,] 18.65386273 2955.92422
-#> [4,] 0.02613561 521.54030
-#> [5,] 3.26560786 11214.21071
-#> [6,] 41.81083599 71.08764
-#> [7,] 71.08763902 806176.95068
-det(FIM.5)
-#> [1] 1.220371e+24
-get_rse(FIM.5,poped.db,fim.calc.type=5)
-#> CL V KA d_CL d_V d_KA SIGMA[1,1]
-#> 3.560994 2.560413 4.811952 26.270324 30.901555 26.503936 12.409516
-
-## evaluate initial design with the reduced FIM with
-## A,B,C matricies and derivative of variance
-## should give same answer as fim.calc.type=1 (default)
-FIM.7 <- evaluate.fim(poped.db,fim.calc.type=7)
-FIM.7
-#> [,1] [,2] [,3] [,4] [,5] [,6]
-#> [1,] 19821.28445 -21.836551 -8.622140 0.000000e+00 0.000000 0.00000000
-#> [2,] -21.83655 20.656071 -1.807099 0.000000e+00 0.000000 0.00000000
-#> [3,] -8.62214 -1.807099 51.729039 0.000000e+00 0.000000 0.00000000
-#> [4,] 0.00000 0.000000 0.000000 3.107768e+03 10.728786 0.02613561
-#> [5,] 0.00000 0.000000 0.000000 1.072879e+01 27307.089308 3.26560786
-#> [6,] 0.00000 0.000000 0.000000 2.613561e-02 3.265608 41.81083599
-#> [7,] 0.00000 0.000000 0.000000 5.215403e+02 11214.210707 71.08763902
-#> [,7]
-#> [1,] 0.00000
-#> [2,] 0.00000
-#> [3,] 0.00000
-#> [4,] 521.54030
-#> [5,] 11214.21071
-#> [6,] 71.08764
-#> [7,] 806176.95068
-det(FIM.7)
-#> [1] 5.996147e+22
-get_rse(FIM.7,poped.db,fim.calc.type=7)
-#> CL V KA d_CL d_V d_KA SIGMA[1,1]
-#> 4.738266 2.756206 13.925829 25.627205 30.344316 25.777327 11.170784
-
-## evaluate FIM and rse with prior FIM.1
-poped.db.prior = create.poped.database(poped.db, prior_fim = FIM.1)
-FIM.1.prior <- evaluate.fim(poped.db.prior)
-all.equal(FIM.1.prior,FIM.1) # the FIM is only computed from the design in the poped.db
-#> [1] TRUE
-get_rse(FIM.1.prior,poped.db.prior) # the RSE is computed with the prior information
-#> CL V KA d_CL d_V d_KA SIGMA[1,1]
-#> 3.350460 1.948932 9.847048 18.121170 21.456671 18.227322 7.898937
-
all = vector of all unfixed params var derivative is a vector of 1 and 0, 1 -means derivative of parameter is taken w.r.t. variance otherwise w.r.t. sd If -params is supplied then the parameter is taken from this vector instead of -poped.db
-get_unfixed_params(poped.db, params = NULL)
a PopED database.
If params is supplied then the parameters are taken from this vector.
A list with the parameters. All unfixed parameters are also
- returned in the "all
output with the specified order
- (bpop,d,covd,docc,covdocc,sigma,covsigma). var_derivative
is a
- vector of 1's or 0's, 1 means derivative of parameter is taken with respect
- to the variance otherwise with respect to standard deviation.
R/getfulld.R
- getfulld.Rd
Create a full D (between subject variability) matrix given a vector of variances and covariances. -Note, this does not test matching vector lengths.
-getfulld(variance_vector, covariance_vector = NULL)
The vector of the variances.
A vector of the covariances. Written in column major -order for the lower triangular matrix.
The full matrix of variances for the between subject variances
-The function performs a linearization of the model with respect to the residual variability. -Derivative of model w.r.t. eps evaluated at eps=0 and b=b_ind.
-gradf_eps(model_switch, xt_ind, x, a, bpop, b_ind, bocc_ind, num_eps, poped.db)
A matrix that is the same size as xt, specifying which model each sample belongs to.
A vector of the individual/group sample times
A matrix for the discrete design variables. Each row is a group.
A matrix of covariates. Each row is a group.
The fixed effects parameter values. Supplied as a vector.
vector of individual realization of the BSV terms b
Vector of individual realizations of the BOV terms bocc
The number of eps()
in the model.
A PopED database.
A matrix of size (samples per individual x number of epsilons)
-Other FIM:
-LinMatrixH()
,
-LinMatrixLH()
,
-LinMatrixL_occ()
,
-calc_ofv_and_fim()
,
-ed_laplace_ofv()
,
-ed_mftot()
,
-efficiency()
,
-evaluate.e.ofv.fim()
,
-evaluate.fim()
,
-mf3()
,
-mf7()
,
-mftot()
,
-ofv_criterion()
,
-ofv_fim()
library(PopED)
-
-############# START #################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## Optimization using an additive + proportional reidual error
-## to avoid sample times at very low concentrations (time 0 or very late samples).
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(prop=0.01,add=0.25),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0.01,
- maxxt=120,
- a=c(DOSE=70),
- mina=c(DOSE=0.01),
- maxa=c(DOSE=100))
-
-############# END ###################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-
-#for the FO approximation
-ind=1
-gradf_eps(model_switch=t(poped.db$design$model_switch[ind,,drop=FALSE]),
- xt_ind=t(poped.db$design$xt[ind,,drop=FALSE]),
- x=zeros(0,1),
- a=t(poped.db$design$a[ind,,drop=FALSE]),
- bpop=poped.db$parameters$bpop[,2,drop=FALSE],
- b_ind=zeros(poped.db$parameters$NumRanEff,1),
- bocc_ind=zeros(poped.db$parameters$NumDocc,1),
- num_eps=size(poped.db$parameters$sigma,1),
- poped.db)["dfeps_de0"]
-#> $dfeps_de0
-#> [,1] [,2]
-#> [1,] 3.4254357 1
-#> [2,] 5.4711041 1
-#> [3,] 7.3821834 1
-#> [4,] 7.9462805 1
-#> [5,] 5.6858561 1
-#> [6,] 4.5402483 1
-#> [7,] 2.3116966 1
-#> [8,] 0.9398657 1
-#>
-
- General information- - |
- |
---|---|
- - | -PopED - Population (and individual) optimal Experimental Design. |
-
- Predefined structural models- - |
- |
- - | -Structural model: one-compartment, oral absorption, multiple bolus dose, parameterized using CL. |
-
- - | -Structural model: one-compartment, oral absorption, multiple bolus dose, parameterized using KE. |
-
- - | -Structural model: one-compartment, oral absorption, single bolus dose, parameterized using CL. |
-
- - | -Structural model: one-compartment, oral absorption, single bolus dose, parameterized using KE. |
-
- - | -Structural model: one-compartment, oral absorption, multiple bolus dose, -parameterized using CL driving an inhibitory IMAX model with a direct effect. |
-
- - | -Structural model: one-compartment, single bolus IV dose, parameterized using CL driving an EMAX model with a direct effect. |
-
- Between subject variability models- - |
- |
- - | -Build PopED parameter function from a model function |
-
- Predefined residual error models-Define a residual unexplained variability (RUV) model. - |
- |
- - | -RUV model: -Additive . |
-
- - | -RUV model: -Additive and Proportional. |
-
- - | -RUV model: -Proportional. |
-
- Create an initial study design and design space-Create an initial study design, and design space, if optimizing. Input the design and model information into a format that PopED understands. - |
- |
- - | -Create a PopED database |
-
- - | -Create design variables for a full description of a design. |
-
- - | -Create design variables and a design space for a full description of an optimization problem. |
-
- Simulate from the model and design- - |
- |
- - | -Plot model predictions |
-
- - | -Model predictions |
-
- Evaluate or summarize the design(s)- - |
- |
- - | -Evaluate the expectation of the Fisher Information Matrix (FIM) and the expectation of the OFV(FIM). |
-
- - | -Evaluate the Fisher Information Matrix (FIM) |
-
- - | -Evaluate a design |
-
- - | -Compute the Bayesian Fisher information matrix |
-
- - | -Power of a design to estimate a parameter. |
-
- - | -Predict shrinkage of empirical Bayes estimates (EBEs) in a population model |
-
- - | -Calculate the Fisher Information Matrix (FIM) and the OFV(FIM) for either point values or parameters or distributions. |
-
- - | -Evaluate a criterion of the Fisher Information Matrix (FIM) |
-
- - | -Normalize an objective function by the size of the FIM matrix |
-
- - | -Compute the expected parameter relative standard errors |
-
- - | -Plot the efficiency of windows |
-
- - | -Compute efficiency. |
-
- - | -Display a summary of output from poped_db |
-
- Optimize a design-Optimize a design given a model, design and design space. - |
- |
- - | -Optimize a design defined in a PopED database |
-
- - | -Display a summary of output from poped_optim |
-
- - | -Optimize a function using adaptive random search. |
-
- - | -Optimize a function using a line search algorithm. |
-
- - | -Title Optimize the proportion of individuals in the design groups |
-
- - | -Translate efficiency to number of subjects |
-
- - | -Optimize the number of subjects based on desired uncertainty of a parameter. |
-
- - | -Optimization function for D-family, E-family and Laplace approximated ED designs |
-
- - | -Optimize the objective function using an adaptive random search algorithm for D-family and E-family designs. |
-
- - | -Optimize using line search |
-
- - | -Retired optimization module for PopED |
-
- Miscellaneous- - |
- |
- - | -Create a cell array (a matrix of lists) |
-
- - | -Compute the monte-carlo mean of a function |
-
- - | -Wrap summary functions from Hmisc and ggplot to work with stat_summary in ggplot |
-
- - | -Create a matrix of ones |
-
- - | -Parameter simulation |
-
- - | -Run the graphical interface for PopED |
-
- - | -Function written to match MATLAB's size function |
-
- - | -Start parallel computational processes |
-
- - | -Timer function (as in MATLAB) |
-
- - | -Timer function (as in MATLAB) |
-
- - | -Create a matrix of zeros. |
-
Function computes the inverse of a matrix.
-inv(mat, method = 1, tol = .Machine$double.eps, pseudo_on_fail = TRUE, ...)
A matrix
Which method to use. 1 is Cholesky chol2inv(chol(mat)
,
-2 is using solve(mat)
and 3 is the Moore-Penrose generalized inverse (pseudoinverse).
The tolerance at which we should identify a singular value as zero (used in pseudoinverse calculation).
If another method fails should the Moore-Penrose generalized inverse (pseudoinverse) be used?
Not used.
The inverse matrix
-Function written to match MATLAB's isempty function
-isempty(...)
arguments to pass to the function. Typically a matrix.
Logical. True if the passed object has any dimension that is zero.
-Check if a list or dataframe has an element with a specific name.
- - -isfield(obj, sub.obj.str)- -
Logical. True if the element exists.
- -Other MATLAB: cell
,
- diag_matlab
, feval
,
- fileparts
, isempty
,
- ones
, randn
,
- randperm
, rand
,
- size
, tic
, toc
,
- zeros
--foo <- list("fff"=8,"ggg"=9) - -isfield(foo,"fff")#> [1] TRUEisfield(foo,"lll")#> [1] FALSE
R/log_prior_pdf.R
- log_prior_pdf.Rd
Compute the natural log of the PDF for the parameters in an E-family design
-log_prior_pdf(
- alpha,
- bpopdescr,
- ddescr,
- return_gradient = F,
- return_hessian = F
-)
A parameter vector.
Matrix defining the fixed effects, per row (row number = -parameter_number) we should have:
column 1 the type of the -distribution for E-family designs (0 = Fixed, 1 = Normal, 2 = Uniform, 3 = -User Defined Distribution, 4 = lognormal and 5 = truncated normal)
column 2 defines the mean.
column 3 defines the variance of the -distribution (or length of uniform distribution).
Matrix defining the diagonals of the IIV (same logic as for
-the bpopdescr
).
Should the gradient be returned.
Should the hessian be returned?
Function computes the monte-carlo mean of a function by varying the parameter inputs to the function
-mc_mean(
- ofv_fcn,
- poped.db,
- bpopdescr = poped.db$parameters$bpop,
- ddescr = poped.db$parameters$d,
- doccdescr = poped.db$parameters$d,
- user_distribution_pointer = poped.db$model$user_distribution_pointer,
- ED_samp_size = poped.db$settings$ED_samp_size,
- bLHS = poped.db$settings$bLHS,
- ...
-)
A function with poped.db as the first input
A PopED database.
Matrix defining the fixed effects, per row (row number = -parameter_number) we should have:
column 1 the type of the -distribution for E-family designs (0 = Fixed, 1 = Normal, 2 = Uniform, 3 = -User Defined Distribution, 4 = lognormal and 5 = truncated normal)
column 2 defines the mean.
column 3 defines the variance of the -distribution (or length of uniform distribution).
Matrix defining the diagonals of the IIV (same logic as for
-the bpopdescr
).
Matrix defining the IOV. -per row (row number = parameter_number) we should have:
column 1 the type of the distribution for E-family designs (0 = Fixed, 1 = Normal, 2 = Uniform, - 3 = User Defined Distribution, 4 = lognormal and 5 = truncated normal)
column 2 defines the mean of the variance.
column 3 defines the variance of the distribution (or length of uniform distribution).
Function name for user defined distributions for E-family designs
Sample size for E-family sampling
How to sample from distributions in E-family calculations. 0=Random Sampling, 1=LatinHyperCube --
Other arguments passed to the function.
The mean of the function evaluated at different parameter values.
-R/median_hilow_poped.R
- median_hilow_poped.Rd
Created for back compatibility with older versions of ggplot, and so that -PopED does not have to load ggplot when started.
-median_hilow_poped(x, ...)
A numeric vector
Additional arguments passed to Hmisc's smedian.hilow function or -ggplot2's median_hilow function, depending on your version of ggplot.
Compute the full FIM for one individual given specific model(s), parameters, design and methods. -This computation makes no assumption that fixed and random effects are uncorrelated.
- - -mf(model_switch, xt_ind, x, a, bpop, d, sigma, docc, poped.db)- -
As a list:
- -Used by mftot0
.
Other FIM: LinMatrixH
,
- LinMatrixLH
, LinMatrixL_occ
,
- calc_ofv_and_fim
,
- ed_laplace_ofv
, ed_mftot
,
- efficiency
,
- evaluate.e.ofv.fim
,
- evaluate.fim
, gradf_eps
,
- mf3
, mf5
, mf6
,
- mf7
, mf8
,
- mftot0
, mftot1
,
- mftot2
, mftot3
,
- mftot4
, mftot5
,
- mftot6
, mftot7
,
- mftot
, ofv_criterion
,
- ofv_fim
-library(PopED) - -############# START ################# -## Create PopED database -## (warfarin example) -##################################### - -## Warfarin example from software comparison in: -## Nyberg et al., "Methods and software tools for design evaluation -## for population pharmacokinetics-pharmacodynamics studies", -## Br. J. Clin. Pharm., 2014. - -## find the parameters that are needed to define from the structural model -ff.PK.1.comp.oral.sd.CL#> function(model_switch,xt,parameters,poped.db){ -#> ##-- Model: One comp first order absorption -#> with(as.list(parameters),{ -#> y=xt -#> y=(DOSE*Favail*KA/(V*(KA-CL/V)))*(exp(-CL/V*xt)-exp(-KA*xt)) -#> return(list( y= y,poped.db=poped.db)) -#> }) -#> } -#> <environment: namespace:PopED>-## -- parameter definition function -## -- names match parameters in function ff -sfg <- function(x,a,bpop,b,bocc){ - parameters=c(CL=bpop[1]*exp(b[1]), - V=bpop[2]*exp(b[2]), - KA=bpop[3]*exp(b[3]), - Favail=bpop[4], - DOSE=a[1]) - return(parameters) -} - -## -- Define initial design and design space -poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL, - fg_fun=sfg, - fError_fun=feps.prop, - bpop=c(CL=0.15, V=8, KA=1.0, Favail=1), - notfixed_bpop=c(1,1,1,0), - d=c(CL=0.07, V=0.02, KA=0.6), - sigma=0.01, - groupsize=32, - xt=c( 0.5,1,2,6,24,36,72,120), - minxt=0, - maxxt=120, - a=70) - -############# END ################### -## Create PopED database -## (warfarin example) -##################################### - - -#for the FO approximation -ind=1 - -# no occasion defined in this example, so result is zero -output <- mf(model_switch=t(poped.db$design$model_switch[ind,,drop=FALSE]), - xt_ind=t(poped.db$design$xt[ind,,drop=FALSE]), - x=zeros(0,1), - a=t(poped.db$design$a[ind,,drop=FALSE]), - bpop=poped.db$parameters$bpop[,2,drop=FALSE], - d=poped.db$parameters$param.pt.val$d, - sigma=poped.db$parameters$sigma, - docc=poped.db$parameters$param.pt.val$docc, - poped.db) - -# in this simple case the full FIM is just the sum of the individual FIMs -# and all the individual FIMs are the same -det(output$ret*32) == det(evaluate.fim(poped.db,fim.calc.type=0))#> [1] TRUE
Compute the FIM for one individual given specific model(s), parameters, design and methods.
-mf3(model_switch, xt, x, a, bpop, d, sigma, docc, poped.db)
A vector that is the same size as xt, specifying which model each sample belongs to.
A vector of sample times.
A vector for the discrete design variables.
A vector of covariates.
The fixed effects parameter values. Supplied as a vector.
A between subject variability matrix (OMEGA in NONMEM).
A residual unexplained variability matrix (SIGMA in NONMEM).
A between occasion variability matrix.
A PopED database.
As a list:
-The FIM for one individual
A PopED database
Other FIM:
-LinMatrixH()
,
-LinMatrixLH()
,
-LinMatrixL_occ()
,
-calc_ofv_and_fim()
,
-ed_laplace_ofv()
,
-ed_mftot()
,
-efficiency()
,
-evaluate.e.ofv.fim()
,
-evaluate.fim()
,
-gradf_eps()
,
-mf7()
,
-mftot()
,
-ofv_criterion()
,
-ofv_fim()
Compute the reduced FIM for one individual using the standard deviation of the residual unexplained variability (RUV) terms as a parameter, -given specific model(s), parameters, design and methods. -This computation -assumes that there is no correlation in the FIM between the fixed and random effects, -and set these elements in the FIM to zero. -In addition all derivatives in the computation are made -with respect to the standard deviation of the RUV terms (sqrt(SIGMA) in NONMEM). -This matches what is done in PFIM, and assumes that the standard deviation of the residual unexplained variation is the estimated parameter -(NOTE: NONMEM estimates the variance of the resudual unexplained variation by default).
- - -mf5(model_switch, xt, x, a, bpop, d, sigma, docc, poped.db)- -
As a list:
- -Used by mftot4
.
Other FIM: LinMatrixH
,
- LinMatrixLH
, LinMatrixL_occ
,
- calc_ofv_and_fim
,
- ed_laplace_ofv
, ed_mftot
,
- efficiency
,
- evaluate.e.ofv.fim
,
- evaluate.fim
, gradf_eps
,
- mf3
, mf6
, mf7
,
- mf8
, mftot0
,
- mftot1
, mftot2
,
- mftot3
, mftot4
,
- mftot5
, mftot6
,
- mftot7
, mftot
,
- mf
, ofv_criterion
,
- ofv_fim
-library(PopED) - -############# START ################# -## Create PopED database -## (warfarin example) -##################################### - -## Warfarin example from software comparison in: -## Nyberg et al., "Methods and software tools for design evaluation -## for population pharmacokinetics-pharmacodynamics studies", -## Br. J. Clin. Pharm., 2014. - -## find the parameters that are needed to define from the structural model -ff.PK.1.comp.oral.sd.CL#> function(model_switch,xt,parameters,poped.db){ -#> ##-- Model: One comp first order absorption -#> with(as.list(parameters),{ -#> y=xt -#> y=(DOSE*Favail*KA/(V*(KA-CL/V)))*(exp(-CL/V*xt)-exp(-KA*xt)) -#> return(list( y= y,poped.db=poped.db)) -#> }) -#> } -#> <environment: namespace:PopED>-## -- parameter definition function -## -- names match parameters in function ff -sfg <- function(x,a,bpop,b,bocc){ - parameters=c(CL=bpop[1]*exp(b[1]), - V=bpop[2]*exp(b[2]), - KA=bpop[3]*exp(b[3]), - Favail=bpop[4], - DOSE=a[1]) - return(parameters) -} - -## -- Define initial design and design space -poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL, - fg_fun=sfg, - fError_fun=feps.prop, - bpop=c(CL=0.15, V=8, KA=1.0, Favail=1), - notfixed_bpop=c(1,1,1,0), - d=c(CL=0.07, V=0.02, KA=0.6), - sigma=0.01, - groupsize=32, - xt=c( 0.5,1,2,6,24,36,72,120), - minxt=0, - maxxt=120, - a=70) - -############# END ################### -## Create PopED database -## (warfarin example) -##################################### - - -#for the FO approximation -ind=1 - -# no occasion defined in this example, so result is zero -output <- mf5(model_switch=t(poped.db$design$model_switch[ind,,drop=FALSE]), - xt=t(poped.db$design$xt[ind,,drop=FALSE]), - x=zeros(0,1), - a=t(poped.db$design$a[ind,,drop=FALSE]), - bpop=poped.db$parameters$bpop[,2,drop=FALSE], - d=poped.db$parameters$param.pt.val$d, - sigma=poped.db$parameters$sigma, - docc=poped.db$parameters$param.pt.val$docc, - poped.db) - -# in this simple case the full FIM is just the sum of the individual FIMs -# and all the individual FIMs are the same -det(output$ret*32) == det(evaluate.fim(poped.db,fim.calc.type=4))#> [1] TRUE
Compute the full FIM for one individual given specific model(s), parameters, design and methods.
-This computation parameterizes the FIM calculation using
-A,B,C matrices (as in Retout et al.) but uses the derivative of variances.
-Should give the same answer as mf
but computation times may be different.
mf6(model_switch, xt_ind, x, a, bpop, d, sigma, docc, poped.db)- -
As a list:
- -S. Retout and F. Mentre, "Further developments of the Fisher Information Matrix in -nonlinear mixed effects models with evaluation in population pharmacokinetics", J. of Biopharm. Stats., 13(2), 2003.
- -Used by mftot5
.
Other FIM: LinMatrixH
,
- LinMatrixLH
, LinMatrixL_occ
,
- calc_ofv_and_fim
,
- ed_laplace_ofv
, ed_mftot
,
- efficiency
,
- evaluate.e.ofv.fim
,
- evaluate.fim
, gradf_eps
,
- mf3
, mf5
, mf7
,
- mf8
, mftot0
,
- mftot1
, mftot2
,
- mftot3
, mftot4
,
- mftot5
, mftot6
,
- mftot7
, mftot
,
- mf
, ofv_criterion
,
- ofv_fim
-library(PopED) - -############# START ################# -## Create PopED database -## (warfarin example) -##################################### - -## Warfarin example from software comparison in: -## Nyberg et al., "Methods and software tools for design evaluation -## for population pharmacokinetics-pharmacodynamics studies", -## Br. J. Clin. Pharm., 2014. - -## find the parameters that are needed to define from the structural model -ff.PK.1.comp.oral.sd.CL#> function(model_switch,xt,parameters,poped.db){ -#> ##-- Model: One comp first order absorption -#> with(as.list(parameters),{ -#> y=xt -#> y=(DOSE*Favail*KA/(V*(KA-CL/V)))*(exp(-CL/V*xt)-exp(-KA*xt)) -#> return(list( y= y,poped.db=poped.db)) -#> }) -#> } -#> <environment: namespace:PopED>-## -- parameter definition function -## -- names match parameters in function ff -sfg <- function(x,a,bpop,b,bocc){ - parameters=c(CL=bpop[1]*exp(b[1]), - V=bpop[2]*exp(b[2]), - KA=bpop[3]*exp(b[3]), - Favail=bpop[4], - DOSE=a[1]) - return(parameters) -} - -## -- Define initial design and design space -poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL, - fg_fun=sfg, - fError_fun=feps.prop, - bpop=c(CL=0.15, V=8, KA=1.0, Favail=1), - notfixed_bpop=c(1,1,1,0), - d=c(CL=0.07, V=0.02, KA=0.6), - sigma=0.01, - groupsize=32, - xt=c( 0.5,1,2,6,24,36,72,120), - minxt=0, - maxxt=120, - a=70) - -############# END ################### -## Create PopED database -## (warfarin example) -##################################### - - -#for the FO approximation -ind=1 - -# no occasion defined in this example, so result is zero -output <- mf6(model_switch=t(poped.db$design$model_switch[ind,,drop=FALSE]), - xt=t(poped.db$design$xt[ind,,drop=FALSE]), - x=zeros(0,1), - a=t(poped.db$design$a[ind,,drop=FALSE]), - bpop=poped.db$parameters$bpop[,2,drop=FALSE], - d=poped.db$parameters$param.pt.val$d, - sigma=poped.db$parameters$sigma, - docc=poped.db$parameters$param.pt.val$docc, - poped.db) - -# in this simple case the full FIM is just the sum of the individual FIMs -# and all the individual FIMs are the same -det(output$ret*32) == det(evaluate.fim(poped.db,fim.calc.type=5))#> [1] TRUE
R/mf7.R
- mf7.Rd
Compute the full FIM for one individual given specific model(s), parameters, design and methods. -This computation calculates the FIM for each model switch separately. Correlations between the models parameters are assumed to be zero.
-mf7(model_switch, xt_ind, x, a, bpop, d, sigma, docc, poped.db)
A vector that is the same size as xt, specifying which model each sample belongs to.
A vector for the discrete design variables.
A vector of covariates.
The fixed effects parameter values. Supplied as a vector.
A between subject variability matrix (OMEGA in NONMEM).
A residual unexplained variability matrix (SIGMA in NONMEM).
A between occasion variability matrix.
A PopED database.
As a list:
-The FIM for one individual
A PopED database
Other FIM:
-LinMatrixH()
,
-LinMatrixLH()
,
-LinMatrixL_occ()
,
-calc_ofv_and_fim()
,
-ed_laplace_ofv()
,
-ed_mftot()
,
-efficiency()
,
-evaluate.e.ofv.fim()
,
-evaluate.fim()
,
-gradf_eps()
,
-mf3()
,
-mftot()
,
-ofv_criterion()
,
-ofv_fim()
Compute the reduced FIM for one individual given specific model(s), parameters, design and methods.
-This computation assumes that there is no correlation in the FIM between the fixed and random effects,
-and set these elements in the FIM to zero.
-This computation parameterizes the FIM calculation using
-A,B,C matrices (as in Retout et al.) but uses the derivative of variances.
-Should give the same answer as mf3
but computation times may be different.
mf8(model_switch, xt_ind, x, a, bpop, d, sigma, docc, poped.db)- -
As a list:
- -S. Retout and F. Mentre, "Further developments of the Fisher Information Matrix in -nonlinear mixed effects models with evaluation in population pharmacokinetics", J. of Biopharm. Stats., 13(2), 2003.
- -Used by mftot7
.
Other FIM: LinMatrixH
,
- LinMatrixLH
, LinMatrixL_occ
,
- calc_ofv_and_fim
,
- ed_laplace_ofv
, ed_mftot
,
- efficiency
,
- evaluate.e.ofv.fim
,
- evaluate.fim
, gradf_eps
,
- mf3
, mf5
, mf6
,
- mf7
, mftot0
,
- mftot1
, mftot2
,
- mftot3
, mftot4
,
- mftot5
, mftot6
,
- mftot7
, mftot
,
- mf
, ofv_criterion
,
- ofv_fim
-library(PopED) - -############# START ################# -## Create PopED database -## (warfarin example) -##################################### - -## Warfarin example from software comparison in: -## Nyberg et al., "Methods and software tools for design evaluation -## for population pharmacokinetics-pharmacodynamics studies", -## Br. J. Clin. Pharm., 2014. - -## find the parameters that are needed to define from the structural model -ff.PK.1.comp.oral.sd.CL#> function(model_switch,xt,parameters,poped.db){ -#> ##-- Model: One comp first order absorption -#> with(as.list(parameters),{ -#> y=xt -#> y=(DOSE*Favail*KA/(V*(KA-CL/V)))*(exp(-CL/V*xt)-exp(-KA*xt)) -#> return(list( y= y,poped.db=poped.db)) -#> }) -#> } -#> <environment: namespace:PopED>-## -- parameter definition function -## -- names match parameters in function ff -sfg <- function(x,a,bpop,b,bocc){ - parameters=c(CL=bpop[1]*exp(b[1]), - V=bpop[2]*exp(b[2]), - KA=bpop[3]*exp(b[3]), - Favail=bpop[4], - DOSE=a[1]) - return(parameters) -} - -## -- Define initial design and design space -poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL, - fg_fun=sfg, - fError_fun=feps.prop, - bpop=c(CL=0.15, V=8, KA=1.0, Favail=1), - notfixed_bpop=c(1,1,1,0), - d=c(CL=0.07, V=0.02, KA=0.6), - sigma=0.01, - groupsize=32, - xt=c( 0.5,1,2,6,24,36,72,120), - minxt=0, - maxxt=120, - a=70) - -############# END ################### -## Create PopED database -## (warfarin example) -##################################### - - -#for the FO approximation -ind=1 - -# no occasion defined in this example, so result is zero -output <- mf8(model_switch=t(poped.db$design$model_switch[ind,,drop=FALSE]), - xt=t(poped.db$design$xt[ind,,drop=FALSE]), - x=zeros(0,1), - a=t(poped.db$design$a[ind,,drop=FALSE]), - bpop=poped.db$parameters$bpop[,2,drop=FALSE], - d=poped.db$parameters$param.pt.val$d, - sigma=poped.db$parameters$sigma, - docc=poped.db$parameters$param.pt.val$docc, - poped.db) - -# in this simple case the full FIM is just the sum of the individual FIMs -# and all the individual FIMs are the same -det(output$ret*32) == det(evaluate.fim(poped.db,fim.calc.type=7))#> [1] TRUE
Optimize the objective function using a modified Fedorov exchange algorithm. -The function works for continuous and discrete optimization variables. -This function takes information from the PopED database supplied as an argument. -The PopED database supplies information about the the model, parameters, design and methods to use. -Some of the arguments coming from the PopED database can be overwritten; -if they are supplied then they are used instead of the arguments from the PopED database.
-mfea(
- poped.db,
- model_switch,
- ni,
- xt,
- x,
- a,
- bpopdescr,
- ddescr,
- maxxt,
- minxt,
- maxa,
- mina,
- fmf,
- dmf,
- EAStepSize = poped.db$settings$EAStepSize,
- ourzero = poped.db$settings$ourzero,
- opt_xt = poped.db$settings$optsw[2],
- opt_a = poped.db$settings$optsw[4],
- opt_x = poped.db$settings$optsw[3],
- trflag = T,
- ...
-)
A PopED database.
A matrix that is the same size as xt, specifying which model each sample belongs to.
A vector of the number of samples in each group.
A matrix of sample times. Each row is a vector of sample times for a group.
A matrix for the discrete design variables. Each row is a group.
A matrix of covariates. Each row is a group.
Matrix defining the fixed effects, per row (row number = -parameter_number) we should have:
column 1 the type of the -distribution for E-family designs (0 = Fixed, 1 = Normal, 2 = Uniform, 3 = -User Defined Distribution, 4 = lognormal and 5 = truncated normal)
column 2 defines the mean.
column 3 defines the variance of the -distribution (or length of uniform distribution).
Matrix defining the diagonals of the IIV (same logic as for
-the bpopdescr
).
Matrix or single value defining the maximum value for each xt sample. If a single value is -supplied then all xt values are given the same maximum value.
Matrix or single value defining the minimum value for each xt sample. If a single value is -supplied then all xt values are given the same minimum value
Vector defining the max value for each covariate. If a single value is supplied then -all a values are given the same max value
Vector defining the min value for each covariate. If a single value is supplied then -all a values are given the same max value
The initial value of the FIM. If set to zero then it is computed.
The initial OFV. If set to zero then it is computed.
Exchange Algorithm StepSize
Value to interpret as zero in design
Should the sample times be optimized?
Should the continuous design variables be optimized?
Should the discrete design variables be optimized?
Should the optimization be output to the screen and to a file?
arguments passed to evaluate.fim
and ofv_fim
.
J. Nyberg, S. Ueckert, E.A. Stroemberg, S. Hennig, M.O. Karlsson and A.C. Hooker, "PopED: An extended, -parallelized, nonlinear mixed effects models optimal design tool", -Computer Methods and Programs in Biomedicine, 108, 2012.
Other Optimize:
-Doptim()
,
-LEDoptim()
,
-RS_opt()
,
-a_line_search()
,
-bfgsb_min()
,
-calc_autofocus()
,
-calc_ofv_and_grad()
,
-optim_ARS()
,
-optim_LS()
,
-poped_optim_1()
,
-poped_optim_2()
,
-poped_optim_3()
,
-poped_optimize()
,
-poped_optim()
library(PopED)
-
-############# START #################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## Optimization using an additive + proportional reidual error
-## to avoid sample times at very low concentrations (time 0 or very late samples).
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(prop=0.01,add=0.25),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0.01,
- maxxt=120,
- a=c(DOSE=70),
- mina=c(DOSE=0.01),
- maxa=c(DOSE=100))
-
-############# END ###################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-##############
-# typically one will use poped_optimize
-# This then calls mfea
-##############
-
-# optimization of covariate, with coarse grid
-out_1 <- poped_optimize(poped.db,opt_a=1,
- bUseExchangeAlgorithm=1,
- EAStepSize=25,out_file = "")
-#> ===============================================================================
-#> Initial design evaluation
-#>
-#> Initial OFV = 55.3964
-#>
-#> Initial design
-#> expected relative standard error
-#> (%RSE, rounded to nearest integer)
-#> Parameter Values RSE_0
-#> CL 0.15 5
-#> V 8 3
-#> KA 1 14
-#> d_CL 0.07 30
-#> d_V 0.02 37
-#> d_KA 0.6 27
-#> sig_prop 0.01 32
-#> sig_add 0.25 26
-#>
-#> ==============================================================================
-#> Optimization of design parameters
-#>
-#> * Optimize Covariates
-#>
-#> MFEA - It. : 1
-#> MFEA - It. : 1
-#> Exchanged covariate 1 in group/ind 1 from 70 to 100
-#> Exchanged covariate 1 in group/ind 1 from 70 to 100
-#> Delta : 0.0114735 OFV. : 56.032
-#> Delta : 0.0114735 OFV. : 56.032
-#> MFEA - It. : 2
-#> MFEA - It. : 2
-#> Delta : 0 OFV. : 56.032
-#> Delta : 0 OFV. : 56.032
-#> ===============================================================================
-#> FINAL RESULTS
-#>
-#> Optimized Covariates:
-#> Group 1: 100
-#>
-#> OFV = 56.032
-#>
-#> Efficiency:
-#> ((exp(ofv_final) / exp(ofv_init))^(1/n_parameters)) = 1.0827
-#>
-#> Expected relative standard error
-#> (%RSE, rounded to nearest integer):
-#> Parameter Values RSE_0 RSE
-#> CL 0.15 5 5
-#> V 8 3 3
-#> KA 1 14 14
-#> d_CL 0.07 0 0
-#> d_V 0.02 37 34
-#> d_KA 0.6 0 0
-#> sig_prop 0.01 32 23
-#> sig_add 0.25 26 30
-#>
-#> Total running time: 0.025 seconds
-
-
-if (FALSE) {
-
-
-
- # MFEA optimization with only integer times allowed
- out_2 <- poped_optimize(poped.db,opt_xt=1,
- bUseExchangeAlgorithm=1,
- EAStepSize=1)
- get_rse(out_2$fmf,out_2$poped.db)
- plot_model_prediction(out_2$poped.db)
-
-
- ##############
- # If you really want to you can use mfea dirtectly
- ##############
- dsl <- downsizing_general_design(poped.db)
-
- output <- mfea(poped.db,
- model_switch=dsl$model_switch,
- ni=dsl$ni,
- xt=dsl$xt,
- x=dsl$x,
- a=dsl$a,
- bpopdescr=dsl$bpop,
- ddescr=dsl$d,
- maxxt=dsl$maxxt,
- minxt=dsl$minxt,
- maxa=dsl$maxa,
- mina=dsl$mina,
- fmf=0,dmf=0,
- EAStepSize=1,
- opt_xt=1)
-
-
-}
-
-
-
Compute the FIM given specific model(s), parameters, design and methods.
-mftot(
- model_switch,
- groupsize,
- ni,
- xt,
- x,
- a,
- bpop,
- d,
- sigma,
- docc,
- poped.db,
- ...
-)
A matrix that is the same size as xt, specifying which model each sample belongs to.
A vector of the number of individuals in each group.
A vector of the number of samples in each group.
A matrix of sample times. Each row is a vector of sample times for a group.
A matrix for the discrete design variables. Each row is a group.
A matrix of covariates. Each row is a group.
The fixed effects parameter values. Supplied as a vector.
A between subject variability matrix (OMEGA in NONMEM).
A residual unexplained variability matrix (SIGMA in NONMEM).
A between occasion variability matrix.
A PopED database.
As a list:
-The FIM
A PopED database
For an easier function to use, please see evaluate.fim
.
Other FIM:
-LinMatrixH()
,
-LinMatrixLH()
,
-LinMatrixL_occ()
,
-calc_ofv_and_fim()
,
-ed_laplace_ofv()
,
-ed_mftot()
,
-efficiency()
,
-evaluate.e.ofv.fim()
,
-evaluate.fim()
,
-gradf_eps()
,
-mf3()
,
-mf7()
,
-ofv_criterion()
,
-ofv_fim()
library(PopED)
-
-############# START #################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## Optimization using an additive + proportional reidual error
-## to avoid sample times at very low concentrations (time 0 or very late samples).
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(prop=0.01,add=0.25),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0.01,
- maxxt=120,
- a=c(DOSE=70),
- mina=c(DOSE=0.01),
- maxa=c(DOSE=100))
-
-############# END ###################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-
-mftot(model_switch=poped.db$design$model_switch,
- groupsize=poped.db$design$groupsize,
- ni=poped.db$design$ni,
- xt=poped.db$design$xt,
- x=poped.db$design$x,
- a=poped.db$design$a,
- bpop=poped.db$parameters$param.pt.val$bpop,
- d=poped.db$parameters$param.pt.val$d,
- sigma=poped.db$parameters$sigma,
- docc=poped.db$parameters$param.pt.val$docc,
- poped.db)["ret"]
-#> $ret
-#> [,1] [,2] [,3] [,4] [,5] [,6]
-#> [1,] 17141.83891 20.838375 10.011000 0.000000e+00 0.000000 0.00000000
-#> [2,] 20.83837 17.268051 -3.423641 0.000000e+00 0.000000 0.00000000
-#> [3,] 10.01100 -3.423641 49.864697 0.000000e+00 0.000000 0.00000000
-#> [4,] 0.00000 0.000000 0.000000 2.324341e+03 9.770352 0.03523364
-#> [5,] 0.00000 0.000000 0.000000 9.770352e+00 19083.877564 11.72131703
-#> [6,] 0.00000 0.000000 0.000000 3.523364e-02 11.721317 38.85137516
-#> [7,] 0.00000 0.000000 0.000000 7.268410e+02 9656.158553 64.78095548
-#> [8,] 0.00000 0.000000 0.000000 9.062739e+01 266.487127 2.94728469
-#> [,7] [,8]
-#> [1,] 0.00000 0.000000
-#> [2,] 0.00000 0.000000
-#> [3,] 0.00000 0.000000
-#> [4,] 726.84097 90.627386
-#> [5,] 9656.15855 266.487127
-#> [6,] 64.78096 2.947285
-#> [7,] 192840.20092 6659.569867
-#> [8,] 6659.56987 475.500111
-#>
-
-
Compute the full FIM given specific model(s), parameters, design and methods. -This computation makes no assumption that fixed and random effects are uncorrelated.
- - -mftot0(model_switch, groupsize, ni, xt, x, a, bpop, d, sigma, docc, poped.db)- -
As a list:
- -For an easier function to use, please see evaluate.fim
.
Other FIM: LinMatrixH
,
- LinMatrixLH
, LinMatrixL_occ
,
- calc_ofv_and_fim
,
- ed_laplace_ofv
, ed_mftot
,
- efficiency
,
- evaluate.e.ofv.fim
,
- evaluate.fim
, gradf_eps
,
- mf3
, mf5
, mf6
,
- mf7
, mf8
,
- mftot1
, mftot2
,
- mftot3
, mftot4
,
- mftot5
, mftot6
,
- mftot7
, mftot
,
- mf
, ofv_criterion
,
- ofv_fim
-library(PopED) - -############# START ################# -## Create PopED database -## (warfarin model for optimization) -##################################### - -## Warfarin example from software comparison in: -## Nyberg et al., "Methods and software tools for design evaluation -## for population pharmacokinetics-pharmacodynamics studies", -## Br. J. Clin. Pharm., 2014. - -## Optimization using an additive + proportional reidual error -## to avoid sample times at very low concentrations (time 0 or very late samples). - -## find the parameters that are needed to define from the structural model -ff.PK.1.comp.oral.sd.CL#> function(model_switch,xt,parameters,poped.db){ -#> ##-- Model: One comp first order absorption -#> with(as.list(parameters),{ -#> y=xt -#> y=(DOSE*Favail*KA/(V*(KA-CL/V)))*(exp(-CL/V*xt)-exp(-KA*xt)) -#> return(list( y= y,poped.db=poped.db)) -#> }) -#> } -#> <environment: namespace:PopED>-## -- parameter definition function -## -- names match parameters in function ff -sfg <- function(x,a,bpop,b,bocc){ - parameters=c(CL=bpop[1]*exp(b[1]), - V=bpop[2]*exp(b[2]), - KA=bpop[3]*exp(b[3]), - Favail=bpop[4], - DOSE=a[1]) - return(parameters) -} - -## -- Define initial design and design space -poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL, - fg_fun=sfg, - fError_fun=feps.add.prop, - bpop=c(CL=0.15, V=8, KA=1.0, Favail=1), - notfixed_bpop=c(1,1,1,0), - d=c(CL=0.07, V=0.02, KA=0.6), - sigma=c(0.01,0.25), - groupsize=32, - xt=c( 0.5,1,2,6,24,36,72,120), - minxt=0.01, - maxxt=120, - a=70, - mina=0.01, - maxa=100) - -############# END ################### -## Create PopED database -## (warfarin model for optimization) -##################################### - - -mftot0(model_switch=poped.db$design$model_switch, - groupsize=poped.db$design$groupsize, - ni=poped.db$design$ni, - xt=poped.db$design$xt, - x=poped.db$design$x, - a=poped.db$design$a, - bpop=poped.db$parameters$param.pt.val$bpop, - d=poped.db$parameters$param.pt.val$d, - sigma=poped.db$parameters$sigma, - docc=poped.db$parameters$param.pt.val$docc, - poped.db)["ret"]#> $ret -#> [,1] [,2] [,3] [,4] [,5] [,6] -#> [1,] 19865.003641 1.431549 11.016119 -708.59723999 -1875.499055 4.61927134 -#> [2,] 1.431549 20.679817 -6.826283 -29.26097775 -86.321369 -6.13548328 -#> [3,] 11.016119 -6.826283 239.199604 -0.21645901 -71.065641 13.00805966 -#> [4,] -708.597240 -29.260978 -0.216459 2324.34120373 9.770352 0.03523364 -#> [5,] -1875.499055 -86.321369 -71.065641 9.77035192 19083.877564 11.72131703 -#> [6,] 4.619271 -6.135483 13.008060 0.03523364 11.721317 38.85137516 -#> [7,] -4227.062232 -473.560406 716.704415 726.84097215 9656.158553 64.78095548 -#> [8,] -470.162834 -11.193854 36.702955 90.62738594 266.487127 2.94728469 -#> [,7] [,8] -#> [1,] -4227.06223 -470.162834 -#> [2,] -473.56041 -11.193854 -#> [3,] 716.70442 36.702955 -#> [4,] 726.84097 90.627386 -#> [5,] 9656.15855 266.487127 -#> [6,] 64.78096 2.947285 -#> [7,] 192840.20092 6659.569867 -#> [8,] 6659.56987 475.500111 -#>-
Compute the reduced FIM given specific model(s), parameters, design and methods. -This computation assumes that there is no correlation in the FIM between the fixed and random effects, -and set these elements in the FIM to zero.
- - -mftot1(model_switch, groupsize, ni, xt, x, a, bpop, d, sigma, docc, poped.db)- -
As a list:
- -For an easier function to use, please see evaluate.fim
.
Other FIM: LinMatrixH
,
- LinMatrixLH
, LinMatrixL_occ
,
- calc_ofv_and_fim
,
- ed_laplace_ofv
, ed_mftot
,
- efficiency
,
- evaluate.e.ofv.fim
,
- evaluate.fim
, gradf_eps
,
- mf3
, mf5
, mf6
,
- mf7
, mf8
,
- mftot0
, mftot2
,
- mftot3
, mftot4
,
- mftot5
, mftot6
,
- mftot7
, mftot
,
- mf
, ofv_criterion
,
- ofv_fim
-library(PopED) - -############# START ################# -## Create PopED database -## (warfarin model for optimization) -##################################### - -## Warfarin example from software comparison in: -## Nyberg et al., "Methods and software tools for design evaluation -## for population pharmacokinetics-pharmacodynamics studies", -## Br. J. Clin. Pharm., 2014. - -## Optimization using an additive + proportional reidual error -## to avoid sample times at very low concentrations (time 0 or very late samples). - -## find the parameters that are needed to define from the structural model -ff.PK.1.comp.oral.sd.CL#> function(model_switch,xt,parameters,poped.db){ -#> ##-- Model: One comp first order absorption -#> with(as.list(parameters),{ -#> y=xt -#> y=(DOSE*Favail*KA/(V*(KA-CL/V)))*(exp(-CL/V*xt)-exp(-KA*xt)) -#> return(list( y= y,poped.db=poped.db)) -#> }) -#> } -#> <environment: namespace:PopED>-## -- parameter definition function -## -- names match parameters in function ff -sfg <- function(x,a,bpop,b,bocc){ - parameters=c(CL=bpop[1]*exp(b[1]), - V=bpop[2]*exp(b[2]), - KA=bpop[3]*exp(b[3]), - Favail=bpop[4], - DOSE=a[1]) - return(parameters) -} - -## -- Define initial design and design space -poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL, - fg_fun=sfg, - fError_fun=feps.add.prop, - bpop=c(CL=0.15, V=8, KA=1.0, Favail=1), - notfixed_bpop=c(1,1,1,0), - d=c(CL=0.07, V=0.02, KA=0.6), - sigma=c(0.01,0.25), - groupsize=32, - xt=c( 0.5,1,2,6,24,36,72,120), - minxt=0.01, - maxxt=120, - a=70, - mina=0.01, - maxa=100) - -############# END ################### -## Create PopED database -## (warfarin model for optimization) -##################################### - - -mftot1(model_switch=poped.db$design$model_switch, - groupsize=poped.db$design$groupsize, - ni=poped.db$design$ni, - xt=poped.db$design$xt, - x=poped.db$design$x, - a=poped.db$design$a, - bpop=poped.db$parameters$param.pt.val$bpop, - d=poped.db$parameters$param.pt.val$d, - sigma=poped.db$parameters$sigma, - docc=poped.db$parameters$param.pt.val$docc, - poped.db)["ret"]#> $ret -#> [,1] [,2] [,3] [,4] [,5] [,6] -#> [1,] 17141.83891 20.838375 10.011000 0.000000e+00 0.000000 0.00000000 -#> [2,] 20.83837 17.268051 -3.423641 0.000000e+00 0.000000 0.00000000 -#> [3,] 10.01100 -3.423641 49.864697 0.000000e+00 0.000000 0.00000000 -#> [4,] 0.00000 0.000000 0.000000 2.324341e+03 9.770352 0.03523364 -#> [5,] 0.00000 0.000000 0.000000 9.770352e+00 19083.877564 11.72131703 -#> [6,] 0.00000 0.000000 0.000000 3.523364e-02 11.721317 38.85137516 -#> [7,] 0.00000 0.000000 0.000000 7.268410e+02 9656.158553 64.78095548 -#> [8,] 0.00000 0.000000 0.000000 9.062739e+01 266.487127 2.94728469 -#> [,7] [,8] -#> [1,] 0.00000 0.000000 -#> [2,] 0.00000 0.000000 -#> [3,] 0.00000 0.000000 -#> [4,] 726.84097 90.627386 -#> [5,] 9656.15855 266.487127 -#> [6,] 64.78096 2.947285 -#> [7,] 192840.20092 6659.569867 -#> [8,] 6659.56987 475.500111 -#>-
Compute the FIM using weighted models given specific model(s), parameters, design and methods. Not currently available.
- - -mftot2(model_switch, groupsize, ni, xt, x, a, bpop, d, sigma, docc, poped.db)- -
For an easier function to use, please see evaluate.fim
.
Other FIM: LinMatrixH
,
- LinMatrixLH
, LinMatrixL_occ
,
- calc_ofv_and_fim
,
- ed_laplace_ofv
, ed_mftot
,
- efficiency
,
- evaluate.e.ofv.fim
,
- evaluate.fim
, gradf_eps
,
- mf3
, mf5
, mf6
,
- mf7
, mf8
,
- mftot0
, mftot1
,
- mftot3
, mftot4
,
- mftot5
, mftot6
,
- mftot7
, mftot
,
- mf
, ofv_criterion
,
- ofv_fim
Compute the FIM using some other method given specific model(s), parameters, design and methods. This is a placeholder.
- - -mftot3(model_switch, groupsize, ni, xt, x, a, bpop, d, sigma, docc, poped.db)- -
For an easier function to use, please see evaluate.fim
.
Other FIM: LinMatrixH
,
- LinMatrixLH
, LinMatrixL_occ
,
- calc_ofv_and_fim
,
- ed_laplace_ofv
, ed_mftot
,
- efficiency
,
- evaluate.e.ofv.fim
,
- evaluate.fim
, gradf_eps
,
- mf3
, mf5
, mf6
,
- mf7
, mf8
,
- mftot0
, mftot1
,
- mftot2
, mftot4
,
- mftot5
, mftot6
,
- mftot7
, mftot
,
- mf
, ofv_criterion
,
- ofv_fim
Compute the reduced FIM using the standard deviation of the residual unexplained variability (RUV) terms as a parameter, -given specific model(s), parameters, design and methods. -This computation -assumes that there is no correlation in the FIM between the fixed and random effects, -and set these elements in the FIM to zero. -In addition all derivatives in the computation are made -with respect to the standard deviation of the RUV terms (sqrt(SIGMA) in NONMEM). -This matches what is done in PFIM, and assumes that the standard deviation of the residual unexplained variation is the estimated parameter -(NOTE: NONMEM estimates the variance of the resudual unexplained variation by default).
- - -mftot4(model_switch, groupsize, ni, xt, x, a, bpop, d, sigma, docc, poped.db)- -
As a list:
- -For an easier function to use, please see evaluate.fim
.
Other FIM: LinMatrixH
,
- LinMatrixLH
, LinMatrixL_occ
,
- calc_ofv_and_fim
,
- ed_laplace_ofv
, ed_mftot
,
- efficiency
,
- evaluate.e.ofv.fim
,
- evaluate.fim
, gradf_eps
,
- mf3
, mf5
, mf6
,
- mf7
, mf8
,
- mftot0
, mftot1
,
- mftot2
, mftot3
,
- mftot5
, mftot6
,
- mftot7
, mftot
,
- mf
, ofv_criterion
,
- ofv_fim
-library(PopED) - -############# START ################# -## Create PopED database -## (warfarin model for optimization) -##################################### - -## Warfarin example from software comparison in: -## Nyberg et al., "Methods and software tools for design evaluation -## for population pharmacokinetics-pharmacodynamics studies", -## Br. J. Clin. Pharm., 2014. - -## Optimization using an additive + proportional reidual error -## to avoid sample times at very low concentrations (time 0 or very late samples). - -## find the parameters that are needed to define from the structural model -ff.PK.1.comp.oral.sd.CL#> function(model_switch,xt,parameters,poped.db){ -#> ##-- Model: One comp first order absorption -#> with(as.list(parameters),{ -#> y=xt -#> y=(DOSE*Favail*KA/(V*(KA-CL/V)))*(exp(-CL/V*xt)-exp(-KA*xt)) -#> return(list( y= y,poped.db=poped.db)) -#> }) -#> } -#> <environment: namespace:PopED>-## -- parameter definition function -## -- names match parameters in function ff -sfg <- function(x,a,bpop,b,bocc){ - parameters=c(CL=bpop[1]*exp(b[1]), - V=bpop[2]*exp(b[2]), - KA=bpop[3]*exp(b[3]), - Favail=bpop[4], - DOSE=a[1]) - return(parameters) -} - -## -- Define initial design and design space -poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL, - fg_fun=sfg, - fError_fun=feps.add.prop, - bpop=c(CL=0.15, V=8, KA=1.0, Favail=1), - notfixed_bpop=c(1,1,1,0), - d=c(CL=0.07, V=0.02, KA=0.6), - sigma=c(0.01,0.25), - groupsize=32, - xt=c( 0.5,1,2,6,24,36,72,120), - minxt=0.01, - maxxt=120, - a=70, - mina=0.01, - maxa=100) - -############# END ################### -## Create PopED database -## (warfarin model for optimization) -##################################### - - -mftot4(model_switch=poped.db$design$model_switch, - groupsize=poped.db$design$groupsize, - ni=poped.db$design$ni, - xt=poped.db$design$xt, - x=poped.db$design$x, - a=poped.db$design$a, - bpop=poped.db$parameters$param.pt.val$bpop, - d=poped.db$parameters$param.pt.val$d, - sigma=poped.db$parameters$sigma, - docc=poped.db$parameters$param.pt.val$docc, - poped.db)["ret"]#> $ret -#> [,1] [,2] [,3] [,4] [,5] [,6] -#> [1,] 17141.83891 20.838375 10.011000 0.000000e+00 0.000000 0.00000000 -#> [2,] 20.83837 17.268051 -3.423641 0.000000e+00 0.000000 0.00000000 -#> [3,] 10.01100 -3.423641 49.864697 0.000000e+00 0.000000 0.00000000 -#> [4,] 0.00000 0.000000 0.000000 2.324341e+03 9.770352 0.03523364 -#> [5,] 0.00000 0.000000 0.000000 9.770352e+00 19083.877564 11.72131703 -#> [6,] 0.00000 0.000000 0.000000 3.523364e-02 11.721317 38.85137516 -#> [7,] 0.00000 0.000000 0.000000 1.453682e+02 1931.231711 12.95619110 -#> [8,] 0.00000 0.000000 0.000000 9.062739e+01 266.487127 2.94728469 -#> [,7] [,8] -#> [1,] 0.00000 0.000000 -#> [2,] 0.00000 0.000000 -#> [3,] 0.00000 0.000000 -#> [4,] 145.36819 90.627386 -#> [5,] 1931.23171 266.487127 -#> [6,] 12.95619 2.947285 -#> [7,] 7713.60804 1331.913973 -#> [8,] 1331.91397 475.500111 -#>-
Compute the full FIM given specific model(s), parameters, design and methods.
-This computation parameterizes the FIM calculation using
-A,B,C matrices (as in Retout et al.) but uses the derivative of variances.
-Should give the same answer as mftot0
but computation times may be different.
mftot5(model_switch, groupsize, ni, xt, x, a, bpop, d, sigma, docc, poped.db)- -
As a list:
- -S. Retout and F. Mentre, "Further developments of the Fisher Information Matrix in -nonlinear mixed effects models with evaluation in population pharmacokinetics", J. of Biopharm. Stats., 13(2), 2003.
- -For an easier function to use, please see evaluate.fim
.
Other FIM: LinMatrixH
,
- LinMatrixLH
, LinMatrixL_occ
,
- calc_ofv_and_fim
,
- ed_laplace_ofv
, ed_mftot
,
- efficiency
,
- evaluate.e.ofv.fim
,
- evaluate.fim
, gradf_eps
,
- mf3
, mf5
, mf6
,
- mf7
, mf8
,
- mftot0
, mftot1
,
- mftot2
, mftot3
,
- mftot4
, mftot6
,
- mftot7
, mftot
,
- mf
, ofv_criterion
,
- ofv_fim
-library(PopED) - -############# START ################# -## Create PopED database -## (warfarin model for optimization) -##################################### - -## Warfarin example from software comparison in: -## Nyberg et al., "Methods and software tools for design evaluation -## for population pharmacokinetics-pharmacodynamics studies", -## Br. J. Clin. Pharm., 2014. - -## Optimization using an additive + proportional reidual error -## to avoid sample times at very low concentrations (time 0 or very late samples). - -## find the parameters that are needed to define from the structural model -ff.PK.1.comp.oral.sd.CL#> function(model_switch,xt,parameters,poped.db){ -#> ##-- Model: One comp first order absorption -#> with(as.list(parameters),{ -#> y=xt -#> y=(DOSE*Favail*KA/(V*(KA-CL/V)))*(exp(-CL/V*xt)-exp(-KA*xt)) -#> return(list( y= y,poped.db=poped.db)) -#> }) -#> } -#> <environment: namespace:PopED>-## -- parameter definition function -## -- names match parameters in function ff -sfg <- function(x,a,bpop,b,bocc){ - parameters=c(CL=bpop[1]*exp(b[1]), - V=bpop[2]*exp(b[2]), - KA=bpop[3]*exp(b[3]), - Favail=bpop[4], - DOSE=a[1]) - return(parameters) -} - -## -- Define initial design and design space -poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL, - fg_fun=sfg, - fError_fun=feps.add.prop, - bpop=c(CL=0.15, V=8, KA=1.0, Favail=1), - notfixed_bpop=c(1,1,1,0), - d=c(CL=0.07, V=0.02, KA=0.6), - sigma=c(0.01,0.25), - groupsize=32, - xt=c( 0.5,1,2,6,24,36,72,120), - minxt=0.01, - maxxt=120, - a=70, - mina=0.01, - maxa=100) - -############# END ################### -## Create PopED database -## (warfarin model for optimization) -##################################### - - -mftot5(model_switch=poped.db$design$model_switch, - groupsize=poped.db$design$groupsize, - ni=poped.db$design$ni, - xt=poped.db$design$xt, - x=poped.db$design$x, - a=poped.db$design$a, - bpop=poped.db$parameters$param.pt.val$bpop, - d=poped.db$parameters$param.pt.val$d, - sigma=poped.db$parameters$sigma, - docc=poped.db$parameters$param.pt.val$docc, - poped.db)["ret"]#> $ret -#> [,1] [,2] [,3] [,4] [,5] [,6] -#> [1,] 19865.003641 1.431549 11.016119 -708.59723999 -1875.499055 4.61927134 -#> [2,] 1.431549 20.679817 -6.826283 -29.26097775 -86.321369 -6.13548328 -#> [3,] 11.016119 -6.826283 239.199604 -0.21645901 -71.065641 13.00805966 -#> [4,] -708.597240 -29.260978 -0.216459 2324.34120373 9.770352 0.03523364 -#> [5,] -1875.499055 -86.321369 -71.065641 9.77035192 19083.877564 11.72131703 -#> [6,] 4.619271 -6.135483 13.008060 0.03523364 11.721317 38.85137516 -#> [7,] -4227.062232 -473.560406 716.704415 726.84097215 9656.158553 64.78095548 -#> [8,] -470.162834 -11.193854 36.702955 90.62738594 266.487127 2.94728469 -#> [,7] [,8] -#> [1,] -4227.06223 -470.162834 -#> [2,] -473.56041 -11.193854 -#> [3,] 716.70442 36.702955 -#> [4,] 726.84097 90.627386 -#> [5,] 9656.15855 266.487127 -#> [6,] 64.78096 2.947285 -#> [7,] 192840.20092 6659.569867 -#> [8,] 6659.56987 475.500111 -#>-
Compute the full FIM given specific model(s), parameters, design and methods. -This computation calculates the FIM for each model switch separately. Correlations between the models parameters are assumed to be zero.
- - -mftot6(model_switch, groupsize, ni, xt, x, a, bpop, d, sigma, docc, poped.db)- -
As a list:
- -For an easier function to use, please see evaluate.fim
.
Other FIM: LinMatrixH
,
- LinMatrixLH
, LinMatrixL_occ
,
- calc_ofv_and_fim
,
- ed_laplace_ofv
, ed_mftot
,
- efficiency
,
- evaluate.e.ofv.fim
,
- evaluate.fim
, gradf_eps
,
- mf3
, mf5
, mf6
,
- mf7
, mf8
,
- mftot0
, mftot1
,
- mftot2
, mftot3
,
- mftot4
, mftot5
,
- mftot7
, mftot
,
- mf
, ofv_criterion
,
- ofv_fim
-library(PopED) - -############# START ################# -## Create PopED database -## (warfarin model for optimization) -##################################### - -## Warfarin example from software comparison in: -## Nyberg et al., "Methods and software tools for design evaluation -## for population pharmacokinetics-pharmacodynamics studies", -## Br. J. Clin. Pharm., 2014. - -## Optimization using an additive + proportional reidual error -## to avoid sample times at very low concentrations (time 0 or very late samples). - -## find the parameters that are needed to define from the structural model -ff.PK.1.comp.oral.sd.CL#> function(model_switch,xt,parameters,poped.db){ -#> ##-- Model: One comp first order absorption -#> with(as.list(parameters),{ -#> y=xt -#> y=(DOSE*Favail*KA/(V*(KA-CL/V)))*(exp(-CL/V*xt)-exp(-KA*xt)) -#> return(list( y= y,poped.db=poped.db)) -#> }) -#> } -#> <environment: namespace:PopED>-## -- parameter definition function -## -- names match parameters in function ff -sfg <- function(x,a,bpop,b,bocc){ - parameters=c(CL=bpop[1]*exp(b[1]), - V=bpop[2]*exp(b[2]), - KA=bpop[3]*exp(b[3]), - Favail=bpop[4], - DOSE=a[1]) - return(parameters) -} - -## -- Define initial design and design space -poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL, - fg_fun=sfg, - fError_fun=feps.add.prop, - bpop=c(CL=0.15, V=8, KA=1.0, Favail=1), - notfixed_bpop=c(1,1,1,0), - d=c(CL=0.07, V=0.02, KA=0.6), - sigma=c(0.01,0.25), - groupsize=32, - xt=c( 0.5,1,2,6,24,36,72,120), - minxt=0.01, - maxxt=120, - a=70, - mina=0.01, - maxa=100) - -############# END ################### -## Create PopED database -## (warfarin model for optimization) -##################################### - - -mftot6(model_switch=poped.db$design$model_switch, - groupsize=poped.db$design$groupsize, - ni=poped.db$design$ni, - xt=poped.db$design$xt, - x=poped.db$design$x, - a=poped.db$design$a, - bpop=poped.db$parameters$param.pt.val$bpop, - d=poped.db$parameters$param.pt.val$d, - sigma=poped.db$parameters$sigma, - docc=poped.db$parameters$param.pt.val$docc, - poped.db)["ret"]#> $ret -#> [,1] [,2] [,3] [,4] [,5] [,6] -#> [1,] 19865.003641 1.431549 11.016119 -708.59723999 -1875.499055 4.61927134 -#> [2,] 1.431549 20.679817 -6.826283 -29.26097775 -86.321369 -6.13548328 -#> [3,] 11.016119 -6.826283 239.199604 -0.21645901 -71.065641 13.00805966 -#> [4,] -708.597240 -29.260978 -0.216459 2324.34120373 9.770352 0.03523364 -#> [5,] -1875.499055 -86.321369 -71.065641 9.77035192 19083.877564 11.72131703 -#> [6,] 4.619271 -6.135483 13.008060 0.03523364 11.721317 38.85137516 -#> [7,] -4227.062232 -473.560406 716.704415 726.84097215 9656.158553 64.78095548 -#> [8,] -470.162834 -11.193854 36.702955 90.62738594 266.487127 2.94728469 -#> [,7] [,8] -#> [1,] -4227.06223 -470.162834 -#> [2,] -473.56041 -11.193854 -#> [3,] 716.70442 36.702955 -#> [4,] 726.84097 90.627386 -#> [5,] 9656.15855 266.487127 -#> [6,] 64.78096 2.947285 -#> [7,] 192840.20092 6659.569867 -#> [8,] 6659.56987 475.500111 -#>-
Compute the reduced FIM given specific model(s), parameters, design and methods.
-This computation assumes that there is no correlation in the FIM between the fixed and random effects,
-and set these elements in the FIM to zero.
-This computation parameterizes the FIM calculation using
-A,B,C matrices (as in Retout et al.) but uses the derivative of variances.
-Should give the same answer as mftot1
but computation times may be different.
mftot7(model_switch, groupsize, ni, xt, x, a, bpop, d, sigma, docc, poped.db)- -
As a list:
- -S. Retout and F. Mentre, "Further developments of the Fisher Information Matrix in -nonlinear mixed effects models with evaluation in population pharmacokinetics", J. of Biopharm. Stats., 13(2), 2003.
- -For an easier function to use, please see evaluate.fim
.
Other FIM: LinMatrixH
,
- LinMatrixLH
, LinMatrixL_occ
,
- calc_ofv_and_fim
,
- ed_laplace_ofv
, ed_mftot
,
- efficiency
,
- evaluate.e.ofv.fim
,
- evaluate.fim
, gradf_eps
,
- mf3
, mf5
, mf6
,
- mf7
, mf8
,
- mftot0
, mftot1
,
- mftot2
, mftot3
,
- mftot4
, mftot5
,
- mftot6
, mftot
,
- mf
, ofv_criterion
,
- ofv_fim
-library(PopED) - -############# START ################# -## Create PopED database -## (warfarin model for optimization) -##################################### - -## Warfarin example from software comparison in: -## Nyberg et al., "Methods and software tools for design evaluation -## for population pharmacokinetics-pharmacodynamics studies", -## Br. J. Clin. Pharm., 2014. - -## Optimization using an additive + proportional reidual error -## to avoid sample times at very low concentrations (time 0 or very late samples). - -## find the parameters that are needed to define from the structural model -ff.PK.1.comp.oral.sd.CL#> function(model_switch,xt,parameters,poped.db){ -#> ##-- Model: One comp first order absorption -#> with(as.list(parameters),{ -#> y=xt -#> y=(DOSE*Favail*KA/(V*(KA-CL/V)))*(exp(-CL/V*xt)-exp(-KA*xt)) -#> return(list( y= y,poped.db=poped.db)) -#> }) -#> } -#> <environment: namespace:PopED>-## -- parameter definition function -## -- names match parameters in function ff -sfg <- function(x,a,bpop,b,bocc){ - parameters=c(CL=bpop[1]*exp(b[1]), - V=bpop[2]*exp(b[2]), - KA=bpop[3]*exp(b[3]), - Favail=bpop[4], - DOSE=a[1]) - return(parameters) -} - -## -- Define initial design and design space -poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL, - fg_fun=sfg, - fError_fun=feps.add.prop, - bpop=c(CL=0.15, V=8, KA=1.0, Favail=1), - notfixed_bpop=c(1,1,1,0), - d=c(CL=0.07, V=0.02, KA=0.6), - sigma=c(0.01,0.25), - groupsize=32, - xt=c( 0.5,1,2,6,24,36,72,120), - minxt=0.01, - maxxt=120, - a=70, - mina=0.01, - maxa=100) - -############# END ################### -## Create PopED database -## (warfarin model for optimization) -##################################### - - -mftot7(model_switch=poped.db$design$model_switch, - groupsize=poped.db$design$groupsize, - ni=poped.db$design$ni, - xt=poped.db$design$xt, - x=poped.db$design$x, - a=poped.db$design$a, - bpop=poped.db$parameters$param.pt.val$bpop, - d=poped.db$parameters$param.pt.val$d, - sigma=poped.db$parameters$sigma, - docc=poped.db$parameters$param.pt.val$docc, - poped.db)["ret"]#> $ret -#> [,1] [,2] [,3] [,4] [,5] [,6] -#> [1,] 17141.83891 20.838375 10.011000 0.000000e+00 0.000000 0.00000000 -#> [2,] 20.83837 17.268051 -3.423641 0.000000e+00 0.000000 0.00000000 -#> [3,] 10.01100 -3.423641 49.864697 0.000000e+00 0.000000 0.00000000 -#> [4,] 0.00000 0.000000 0.000000 2.324341e+03 9.770352 0.03523364 -#> [5,] 0.00000 0.000000 0.000000 9.770352e+00 19083.877564 11.72131703 -#> [6,] 0.00000 0.000000 0.000000 3.523364e-02 11.721317 38.85137516 -#> [7,] 0.00000 0.000000 0.000000 7.268410e+02 9656.158553 64.78095548 -#> [8,] 0.00000 0.000000 0.000000 9.062739e+01 266.487127 2.94728469 -#> [,7] [,8] -#> [1,] 0.00000 0.000000 -#> [2,] 0.00000 0.000000 -#> [3,] 0.00000 0.000000 -#> [4,] 726.84097 90.627386 -#> [5,] 9656.15855 266.487127 -#> [6,] 64.78096 2.947285 -#> [7,] 192840.20092 6659.569867 -#> [8,] 6659.56987 475.500111 -#>-
Function generates a data frame of model predictions for the typical value in the population, -individual predictions and data predictions. The function can also be used to generate datasets -without predictions using the design specified in the arguments.
-model_prediction(
- poped.db = NULL,
- design = list(xt = poped.db$design[["xt"]], groupsize = poped.db$design$groupsize, m =
- poped.db$design[["m"]], x = poped.db$design[["x"]], a = poped.db$design[["a"]], ni =
- poped.db$design$ni, model_switch = poped.db$design$model_switch),
- model = list(fg_pointer = poped.db$model$fg_pointer, ff_pointer =
- poped.db$model$ff_pointer, ferror_pointer = poped.db$model$ferror_pointer),
- parameters = list(docc = poped.db$parameters$docc, d = poped.db$parameters$d, bpop =
- poped.db$parameters$bpop, covd = poped.db$parameters$covd, covdocc =
- poped.db$parameters$covdocc, sigma = poped.db$parameters$sigma),
- IPRED = FALSE,
- DV = FALSE,
- dosing = NULL,
- predictions = NULL,
- filename = NULL,
- models_to_use = "all",
- model_num_points = NULL,
- model_minxt = NULL,
- model_maxxt = NULL,
- include_sample_times = T,
- groups_to_use = "all",
- include_a = TRUE,
- include_x = TRUE,
- manipulation = NULL,
- PI = FALSE,
- PI_conf_level = 0.95,
- PI_ln_dist = TRUE
-)
A PopED database created by create.poped.database
.
A list that is passed as arguments to the function create_design
to create a design object.
A list containing the model elements to use for the predictions
A list of parameters to use in the model predictions.
Should we simulate individual predictions?
should we simulate observations?
A list of lists that adds dosing records to the data frame (Each inner list corresponding to a group in the design).
Should the resulting data frame have predictions? Either TRUE
or FALSE
-or NULL
in which case the function decides based on other arguments.
A filename that the data frame should be written to in comma separate value (csv) format.
Which model numbers should we use?
-Model numbers are defined in design
below using model_switch
. For an explanation see create_design
.
How many extra observation rows should be created in the data frame for each group or individual
-per model. If used then the points are placed evenly between model_minxt
and model_maxxt
. This option
-is used by plot_model_prediction
to simulate the response of the model on a finer grid then the defined design.
-If NULL
then only the input design is used. Can be a single value or a vector the same length as the number of models.
The minimum time value for extra observation rows indicated by model_num_points
.
-A vector the same length as the number of models
The minimum time value for extra observation rows indicated by model_num_points
.
-A vector the same length as the number of models
Should observations rows in the output data frame include the times indicated in the input design?
Which groups should we include in the output data frame?Allowed values are "all"
or
-a vector of numbers indicating the groups to include, e.g. c(1,3,6)
.
Should we include the continuous design variables in the output?
Should we include the discrete design variables in the output?
A list of one or more expression
arguments. Each expression is
-evaluated using the code for(i in 1:length(manipulation)){df <- within(df,{eval(manipulation[[i]])})}
.
-Can be used to transform
-or create new columns in the resulting data frame. Note that these transformations are created after any model predictions occur,
-so transformations in columns having to do with input to model predictions will not affect the predictions.
Compute prediction intervals for the data given the model. Predictions are based on first-order approximations to -the model variance and a log-normality assumption of that variance (by default), if all predictions are positive, otherwise a -normal distribution is assumed.
The confidence level for the prediction interval computed.
Should the PI calculation be done assuming log-normal or a normal distribution. TRUE is the default and -indicates a log-normal distribution. If any of the PRED values from the model are negative then a normal distribution is -assumed.
A dataframe containing a design and (potentially) simulated data with some dense grid of samples and/or -based on the input design.
-Other evaluate_design:
-evaluate.fim()
,
-evaluate_design()
,
-evaluate_power()
,
-get_rse()
,
-plot_efficiency_of_windows()
,
-plot_model_prediction()
Other Simulation:
-plot_efficiency_of_windows()
,
-plot_model_prediction()
## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-library(PopED)
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.md.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> N = floor(xt/TAU) + 1
-#> y = (DOSE * Favail/V) * (KA/(KA - CL/V)) * (exp(-CL/V *
-#> (xt - (N - 1) * TAU)) * (1 - exp(-N * CL/V * TAU))/(1 -
-#> exp(-CL/V * TAU)) - exp(-KA * (xt - (N - 1) * TAU)) *
-#> (1 - exp(-N * KA * TAU))/(1 - exp(-KA * TAU)))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1104c9b70>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=0.01,
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0,
- maxxt=120,
- a=70)
-
-## data frame with model predictions
-df_1 <- model_prediction(poped.db)
-head(df_1,n=20)
-#> Time PRED Group Model a_i
-#> 1 0.5 3.4254357 1 1 70
-#> 2 1.0 5.4711041 1 1 70
-#> 3 2.0 7.3821834 1 1 70
-#> 4 6.0 7.9462805 1 1 70
-#> 5 24.0 5.6858561 1 1 70
-#> 6 36.0 4.5402483 1 1 70
-#> 7 72.0 2.3116966 1 1 70
-#> 8 120.0 0.9398657 1 1 70
-
-## data frame with variability
-df_2 <- model_prediction(poped.db,DV=TRUE)
-head(df_2,n=20)
-#> ID Time DV IPRED PRED Group Model a_i
-#> 1 1 0.5 3.273208 3.363554 3.4254357 1 1 70
-#> 2 1 1.0 4.925244 5.366761 5.4711041 1 1 70
-#> 3 1 2.0 7.196765 7.233603 7.3821834 1 1 70
-#> 4 1 6.0 7.146286 7.807924 7.9462805 1 1 70
-#> 5 1 24.0 6.701808 5.727427 5.6858561 1 1 70
-#> 6 1 36.0 3.576081 4.650296 4.5402483 1 1 70
-#> 7 1 72.0 2.280191 2.489108 2.3116966 1 1 70
-#> 8 1 120.0 1.003259 1.081753 0.9398657 1 1 70
-#> 9 2 0.5 2.813017 2.913682 3.4254357 1 1 70
-#> 10 2 1.0 5.025580 4.786920 5.4711041 1 1 70
-#> 11 2 2.0 6.092136 6.737522 7.3821834 1 1 70
-#> 12 2 6.0 7.434007 7.688839 7.9462805 1 1 70
-#> 13 2 24.0 4.624765 5.714743 5.6858561 1 1 70
-#> 14 2 36.0 4.353947 4.668906 4.5402483 1 1 70
-#> 15 2 72.0 2.297259 2.546071 2.3116966 1 1 70
-#> 16 2 120.0 1.011634 1.134343 0.9398657 1 1 70
-#> 17 3 0.5 1.945226 2.161844 3.4254357 1 1 70
-#> 18 3 1.0 3.679038 3.680427 5.4711041 1 1 70
-#> 19 3 2.0 4.991466 5.486561 7.3821834 1 1 70
-#> 20 3 6.0 7.361465 6.976866 7.9462805 1 1 70
-
-## data frame with variability (only IPRED, no DV)
-df_3 <- model_prediction(poped.db,IPRED=TRUE)
-head(df_3,n=20)
-#> ID Time IPRED PRED Group Model a_i
-#> 1 1 0.5 2.4094357 3.4254357 1 1 70
-#> 2 1 1.0 4.2546116 5.4711041 1 1 70
-#> 3 1 2.0 6.7306305 7.3821834 1 1 70
-#> 4 1 6.0 9.4340164 7.9462805 1 1 70
-#> 5 1 24.0 6.9288565 5.6858561 1 1 70
-#> 6 1 36.0 5.4365627 4.5402483 1 1 70
-#> 7 1 72.0 2.6260445 2.3116966 1 1 70
-#> 8 1 120.0 0.9952656 0.9398657 1 1 70
-#> 9 2 0.5 1.8181102 3.4254357 1 1 70
-#> 10 2 1.0 3.2312714 5.4711041 1 1 70
-#> 11 2 2.0 5.1743526 7.3821834 1 1 70
-#> 12 2 6.0 7.5504514 7.9462805 1 1 70
-#> 13 2 24.0 6.3388270 5.6858561 1 1 70
-#> 14 2 36.0 5.4205265 4.5402483 1 1 70
-#> 15 2 72.0 3.3894121 2.3116966 1 1 70
-#> 16 2 120.0 1.8123201 0.9398657 1 1 70
-#> 17 3 0.5 0.7018305 3.4254357 1 1 70
-#> 18 3 1.0 1.3365014 5.4711041 1 1 70
-#> 19 3 2.0 2.4276238 7.3821834 1 1 70
-#> 20 3 6.0 5.0715504 7.9462805 1 1 70
-
-## data frame with model predictions, no continuous design variables in data frame
-df_4 <- model_prediction(poped.db,include_a = FALSE)
-head(df_4,n=20)
-#> Time PRED Group Model
-#> 1 0.5 3.4254357 1 1
-#> 2 1.0 5.4711041 1 1
-#> 3 2.0 7.3821834 1 1
-#> 4 6.0 7.9462805 1 1
-#> 5 24.0 5.6858561 1 1
-#> 6 36.0 4.5402483 1 1
-#> 7 72.0 2.3116966 1 1
-#> 8 120.0 0.9398657 1 1
-
-## -- 2 groups
-poped.db.2 <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=0.01,
- groupsize=rbind(3,3),
- m=2,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0,
- maxxt=120,
- a=rbind(70,50))
-
-df_5 <- model_prediction(poped.db.2,DV=TRUE)
-head(df_5,n=20)
-#> ID Time DV IPRED PRED Group Model a_i
-#> 1 1 0.5 4.8267134 5.2962007 3.4254357 1 1 70
-#> 2 1 1.0 7.2429516 7.7283651 5.4711041 1 1 70
-#> 3 1 2.0 9.4324183 9.2935117 7.3821834 1 1 70
-#> 4 1 6.0 8.5338344 9.1750629 7.9462805 1 1 70
-#> 5 1 24.0 7.3124022 6.9085487 5.6858561 1 1 70
-#> 6 1 36.0 5.9028504 5.7174760 4.5402483 1 1 70
-#> 7 1 72.0 3.5444716 3.2408352 2.3116966 1 1 70
-#> 8 1 120.0 1.5138498 1.5202922 0.9398657 1 1 70
-#> 9 2 0.5 2.5840091 2.7763962 3.4254357 1 1 70
-#> 10 2 1.0 3.6425586 4.6537822 5.4711041 1 1 70
-#> 11 2 2.0 5.7065338 6.7515213 7.3821834 1 1 70
-#> 12 2 6.0 6.4834592 7.9850029 7.9462805 1 1 70
-#> 13 2 24.0 5.6318378 5.5624196 5.6858561 1 1 70
-#> 14 2 36.0 4.6277194 4.3348244 4.5402483 1 1 70
-#> 15 2 72.0 2.0872410 2.0516098 2.3116966 1 1 70
-#> 16 2 120.0 0.7747501 0.7567035 0.9398657 1 1 70
-#> 17 3 0.5 2.5020473 2.3727827 3.4254357 1 1 70
-#> 18 3 1.0 4.2426113 4.0803712 5.4711041 1 1 70
-#> 19 3 2.0 6.4726439 6.1728475 7.3821834 1 1 70
-#> 20 3 6.0 8.2993452 7.8958656 7.9462805 1 1 70
-
-## without a poped database, just describing the design
-## Useful for creating datasets for use in other software (like NONMEM)
-design_1 <- list(
- xt=c( 0.5,1,2,6,24,36,72,120),
- m=2,
- groupsize=3)
-
-design_2 <- list(
- xt=c( 0.5,1,2,6,24,36,72,120),
- m=2,
- groupsize=3,
- a=c(WT=70,AGE=50))
-
-design_3 <- list(
- xt=c( 0.5,1,2,6,24,36,72,120),
- m=2,
- groupsize=3,
- a=list(c(WT=70,AGE=50),c(AGE=45,WT=60)))
-
-(df_6 <- model_prediction(design=design_1))
-#> Time PRED Group Model
-#> 1 0.5 NA 1 1
-#> 2 1.0 NA 1 1
-#> 3 2.0 NA 1 1
-#> 4 6.0 NA 1 1
-#> 5 24.0 NA 1 1
-#> 6 36.0 NA 1 1
-#> 7 72.0 NA 1 1
-#> 8 120.0 NA 1 1
-#> 9 0.5 NA 2 1
-#> 10 1.0 NA 2 1
-#> 11 2.0 NA 2 1
-#> 12 6.0 NA 2 1
-#> 13 24.0 NA 2 1
-#> 14 36.0 NA 2 1
-#> 15 72.0 NA 2 1
-#> 16 120.0 NA 2 1
-(df_7 <- model_prediction(design=design_2))
-#> Time PRED Group Model WT AGE
-#> 1 0.5 NA 1 1 70 50
-#> 2 1.0 NA 1 1 70 50
-#> 3 2.0 NA 1 1 70 50
-#> 4 6.0 NA 1 1 70 50
-#> 5 24.0 NA 1 1 70 50
-#> 6 36.0 NA 1 1 70 50
-#> 7 72.0 NA 1 1 70 50
-#> 8 120.0 NA 1 1 70 50
-#> 9 0.5 NA 2 1 70 50
-#> 10 1.0 NA 2 1 70 50
-#> 11 2.0 NA 2 1 70 50
-#> 12 6.0 NA 2 1 70 50
-#> 13 24.0 NA 2 1 70 50
-#> 14 36.0 NA 2 1 70 50
-#> 15 72.0 NA 2 1 70 50
-#> 16 120.0 NA 2 1 70 50
-(df_8 <- model_prediction(design=design_3))
-#> Time PRED Group Model WT AGE
-#> 1 0.5 NA 1 1 70 50
-#> 2 1.0 NA 1 1 70 50
-#> 3 2.0 NA 1 1 70 50
-#> 4 6.0 NA 1 1 70 50
-#> 5 24.0 NA 1 1 70 50
-#> 6 36.0 NA 1 1 70 50
-#> 7 72.0 NA 1 1 70 50
-#> 8 120.0 NA 1 1 70 50
-#> 9 0.5 NA 2 1 60 45
-#> 10 1.0 NA 2 1 60 45
-#> 11 2.0 NA 2 1 60 45
-#> 12 6.0 NA 2 1 60 45
-#> 13 24.0 NA 2 1 60 45
-#> 14 36.0 NA 2 1 60 45
-#> 15 72.0 NA 2 1 60 45
-#> 16 120.0 NA 2 1 60 45
-(df_9 <- model_prediction(design=design_3,DV=TRUE))
-#> ID Time DV IPRED PRED Group Model WT AGE
-#> 1 1 0.5 NA NA NA 1 1 70 50
-#> 2 1 1.0 NA NA NA 1 1 70 50
-#> 3 1 2.0 NA NA NA 1 1 70 50
-#> 4 1 6.0 NA NA NA 1 1 70 50
-#> 5 1 24.0 NA NA NA 1 1 70 50
-#> 6 1 36.0 NA NA NA 1 1 70 50
-#> 7 1 72.0 NA NA NA 1 1 70 50
-#> 8 1 120.0 NA NA NA 1 1 70 50
-#> 9 2 0.5 NA NA NA 1 1 70 50
-#> 10 2 1.0 NA NA NA 1 1 70 50
-#> 11 2 2.0 NA NA NA 1 1 70 50
-#> 12 2 6.0 NA NA NA 1 1 70 50
-#> 13 2 24.0 NA NA NA 1 1 70 50
-#> 14 2 36.0 NA NA NA 1 1 70 50
-#> 15 2 72.0 NA NA NA 1 1 70 50
-#> 16 2 120.0 NA NA NA 1 1 70 50
-#> 17 3 0.5 NA NA NA 1 1 70 50
-#> 18 3 1.0 NA NA NA 1 1 70 50
-#> 19 3 2.0 NA NA NA 1 1 70 50
-#> 20 3 6.0 NA NA NA 1 1 70 50
-#> 21 3 24.0 NA NA NA 1 1 70 50
-#> 22 3 36.0 NA NA NA 1 1 70 50
-#> 23 3 72.0 NA NA NA 1 1 70 50
-#> 24 3 120.0 NA NA NA 1 1 70 50
-#> 25 4 0.5 NA NA NA 2 1 60 45
-#> 26 4 1.0 NA NA NA 2 1 60 45
-#> 27 4 2.0 NA NA NA 2 1 60 45
-#> 28 4 6.0 NA NA NA 2 1 60 45
-#> 29 4 24.0 NA NA NA 2 1 60 45
-#> 30 4 36.0 NA NA NA 2 1 60 45
-#> 31 4 72.0 NA NA NA 2 1 60 45
-#> 32 4 120.0 NA NA NA 2 1 60 45
-#> 33 5 0.5 NA NA NA 2 1 60 45
-#> 34 5 1.0 NA NA NA 2 1 60 45
-#> 35 5 2.0 NA NA NA 2 1 60 45
-#> 36 5 6.0 NA NA NA 2 1 60 45
-#> 37 5 24.0 NA NA NA 2 1 60 45
-#> 38 5 36.0 NA NA NA 2 1 60 45
-#> 39 5 72.0 NA NA NA 2 1 60 45
-#> 40 5 120.0 NA NA NA 2 1 60 45
-#> 41 6 0.5 NA NA NA 2 1 60 45
-#> 42 6 1.0 NA NA NA 2 1 60 45
-#> 43 6 2.0 NA NA NA 2 1 60 45
-#> 44 6 6.0 NA NA NA 2 1 60 45
-#> 45 6 24.0 NA NA NA 2 1 60 45
-#> 46 6 36.0 NA NA NA 2 1 60 45
-#> 47 6 72.0 NA NA NA 2 1 60 45
-#> 48 6 120.0 NA NA NA 2 1 60 45
-
-# generate random deviations in WT for each individual
-df_10 <- model_prediction(design=design_3,DV=TRUE,
- manipulation=expression({for(id in unique(ID))
- WT[ID==id] = rnorm(1,WT[ID==id],WT[ID==id]*0.1);id <- NULL}))
-head(df_10,n=20)
-#> ID Time DV IPRED PRED Group Model WT AGE
-#> 1 1 0.5 NA NA NA 1 1 70.11811 50
-#> 2 1 1.0 NA NA NA 1 1 70.11811 50
-#> 3 1 2.0 NA NA NA 1 1 70.11811 50
-#> 4 1 6.0 NA NA NA 1 1 70.11811 50
-#> 5 1 24.0 NA NA NA 1 1 70.11811 50
-#> 6 1 36.0 NA NA NA 1 1 70.11811 50
-#> 7 1 72.0 NA NA NA 1 1 70.11811 50
-#> 8 1 120.0 NA NA NA 1 1 70.11811 50
-#> 9 2 0.5 NA NA NA 1 1 55.95341 50
-#> 10 2 1.0 NA NA NA 1 1 55.95341 50
-#> 11 2 2.0 NA NA NA 1 1 55.95341 50
-#> 12 2 6.0 NA NA NA 1 1 55.95341 50
-#> 13 2 24.0 NA NA NA 1 1 55.95341 50
-#> 14 2 36.0 NA NA NA 1 1 55.95341 50
-#> 15 2 72.0 NA NA NA 1 1 55.95341 50
-#> 16 2 120.0 NA NA NA 1 1 55.95341 50
-#> 17 3 0.5 NA NA NA 1 1 67.63716 50
-#> 18 3 1.0 NA NA NA 1 1 67.63716 50
-#> 19 3 2.0 NA NA NA 1 1 67.63716 50
-#> 20 3 6.0 NA NA NA 1 1 67.63716 50
-
-# generate random deviations in WT and AGE for each individual
-df_11 <- model_prediction(design=design_3,DV=TRUE,
- manipulation=list(
- expression(for(id in unique(ID))
- WT[ID==id] = rnorm(1,WT[ID==id],WT[ID==id]*0.1)),
- expression(for(id in unique(ID))
- AGE[ID==id] = rnorm(1,AGE[ID==id],AGE[ID==id]*0.2)),
- expression(id <- NULL)
- ))
-head(df_10,n=20)
-#> ID Time DV IPRED PRED Group Model WT AGE
-#> 1 1 0.5 NA NA NA 1 1 70.11811 50
-#> 2 1 1.0 NA NA NA 1 1 70.11811 50
-#> 3 1 2.0 NA NA NA 1 1 70.11811 50
-#> 4 1 6.0 NA NA NA 1 1 70.11811 50
-#> 5 1 24.0 NA NA NA 1 1 70.11811 50
-#> 6 1 36.0 NA NA NA 1 1 70.11811 50
-#> 7 1 72.0 NA NA NA 1 1 70.11811 50
-#> 8 1 120.0 NA NA NA 1 1 70.11811 50
-#> 9 2 0.5 NA NA NA 1 1 55.95341 50
-#> 10 2 1.0 NA NA NA 1 1 55.95341 50
-#> 11 2 2.0 NA NA NA 1 1 55.95341 50
-#> 12 2 6.0 NA NA NA 1 1 55.95341 50
-#> 13 2 24.0 NA NA NA 1 1 55.95341 50
-#> 14 2 36.0 NA NA NA 1 1 55.95341 50
-#> 15 2 72.0 NA NA NA 1 1 55.95341 50
-#> 16 2 120.0 NA NA NA 1 1 55.95341 50
-#> 17 3 0.5 NA NA NA 1 1 67.63716 50
-#> 18 3 1.0 NA NA NA 1 1 67.63716 50
-#> 19 3 2.0 NA NA NA 1 1 67.63716 50
-#> 20 3 6.0 NA NA NA 1 1 67.63716 50
-
-## create dosing rows
-dosing_1 <- list(list(AMT=1000,RATE=NA,Time=0.5),list(AMT=3000,RATE=NA,Time=0.5))
-dosing_2 <- list(list(AMT=1000,RATE=NA,Time=0.5))
-dosing_3 <- list(list(AMT=1000,Time=0.5))
-dosing_4 <- list(list(AMT=c(1000,20),Time=c(0.5,10))) # multiple dosing
-
-
-(df_12 <- model_prediction(design=design_3,DV=TRUE,dosing=dosing_1))
-#> ID Time DV IPRED PRED AMT RATE Group Model WT AGE
-#> 1 1 0.5 NA NA NA 1000 NA 1 1 70 50
-#> 2 1 0.5 NA NA NA NA NA 1 1 70 50
-#> 3 1 1.0 NA NA NA NA NA 1 1 70 50
-#> 4 1 2.0 NA NA NA NA NA 1 1 70 50
-#> 5 1 6.0 NA NA NA NA NA 1 1 70 50
-#> 6 1 24.0 NA NA NA NA NA 1 1 70 50
-#> 7 1 36.0 NA NA NA NA NA 1 1 70 50
-#> 8 1 72.0 NA NA NA NA NA 1 1 70 50
-#> 9 1 120.0 NA NA NA NA NA 1 1 70 50
-#> 10 2 0.5 NA NA NA 1000 NA 1 1 70 50
-#> 11 2 0.5 NA NA NA NA NA 1 1 70 50
-#> 12 2 1.0 NA NA NA NA NA 1 1 70 50
-#> 13 2 2.0 NA NA NA NA NA 1 1 70 50
-#> 14 2 6.0 NA NA NA NA NA 1 1 70 50
-#> 15 2 24.0 NA NA NA NA NA 1 1 70 50
-#> 16 2 36.0 NA NA NA NA NA 1 1 70 50
-#> 17 2 72.0 NA NA NA NA NA 1 1 70 50
-#> 18 2 120.0 NA NA NA NA NA 1 1 70 50
-#> 19 3 0.5 NA NA NA 1000 NA 1 1 70 50
-#> 20 3 0.5 NA NA NA NA NA 1 1 70 50
-#> 21 3 1.0 NA NA NA NA NA 1 1 70 50
-#> 22 3 2.0 NA NA NA NA NA 1 1 70 50
-#> 23 3 6.0 NA NA NA NA NA 1 1 70 50
-#> 24 3 24.0 NA NA NA NA NA 1 1 70 50
-#> 25 3 36.0 NA NA NA NA NA 1 1 70 50
-#> 26 3 72.0 NA NA NA NA NA 1 1 70 50
-#> 27 3 120.0 NA NA NA NA NA 1 1 70 50
-#> 28 4 0.5 NA NA NA 3000 NA 2 1 60 45
-#> 29 4 0.5 NA NA NA NA NA 2 1 60 45
-#> 30 4 1.0 NA NA NA NA NA 2 1 60 45
-#> 31 4 2.0 NA NA NA NA NA 2 1 60 45
-#> 32 4 6.0 NA NA NA NA NA 2 1 60 45
-#> 33 4 24.0 NA NA NA NA NA 2 1 60 45
-#> 34 4 36.0 NA NA NA NA NA 2 1 60 45
-#> 35 4 72.0 NA NA NA NA NA 2 1 60 45
-#> 36 4 120.0 NA NA NA NA NA 2 1 60 45
-#> 37 5 0.5 NA NA NA 3000 NA 2 1 60 45
-#> 38 5 0.5 NA NA NA NA NA 2 1 60 45
-#> 39 5 1.0 NA NA NA NA NA 2 1 60 45
-#> 40 5 2.0 NA NA NA NA NA 2 1 60 45
-#> 41 5 6.0 NA NA NA NA NA 2 1 60 45
-#> 42 5 24.0 NA NA NA NA NA 2 1 60 45
-#> 43 5 36.0 NA NA NA NA NA 2 1 60 45
-#> 44 5 72.0 NA NA NA NA NA 2 1 60 45
-#> 45 5 120.0 NA NA NA NA NA 2 1 60 45
-#> 46 6 0.5 NA NA NA 3000 NA 2 1 60 45
-#> 47 6 0.5 NA NA NA NA NA 2 1 60 45
-#> 48 6 1.0 NA NA NA NA NA 2 1 60 45
-#> 49 6 2.0 NA NA NA NA NA 2 1 60 45
-#> 50 6 6.0 NA NA NA NA NA 2 1 60 45
-#> 51 6 24.0 NA NA NA NA NA 2 1 60 45
-#> 52 6 36.0 NA NA NA NA NA 2 1 60 45
-#> 53 6 72.0 NA NA NA NA NA 2 1 60 45
-#> 54 6 120.0 NA NA NA NA NA 2 1 60 45
-(df_13 <- model_prediction(design=design_3,DV=TRUE,dosing=dosing_2))
-#> ID Time DV IPRED PRED AMT RATE Group Model WT AGE
-#> 1 1 0.5 NA NA NA 1000 NA 1 1 70 50
-#> 2 1 0.5 NA NA NA NA NA 1 1 70 50
-#> 3 1 1.0 NA NA NA NA NA 1 1 70 50
-#> 4 1 2.0 NA NA NA NA NA 1 1 70 50
-#> 5 1 6.0 NA NA NA NA NA 1 1 70 50
-#> 6 1 24.0 NA NA NA NA NA 1 1 70 50
-#> 7 1 36.0 NA NA NA NA NA 1 1 70 50
-#> 8 1 72.0 NA NA NA NA NA 1 1 70 50
-#> 9 1 120.0 NA NA NA NA NA 1 1 70 50
-#> 10 2 0.5 NA NA NA 1000 NA 1 1 70 50
-#> 11 2 0.5 NA NA NA NA NA 1 1 70 50
-#> 12 2 1.0 NA NA NA NA NA 1 1 70 50
-#> 13 2 2.0 NA NA NA NA NA 1 1 70 50
-#> 14 2 6.0 NA NA NA NA NA 1 1 70 50
-#> 15 2 24.0 NA NA NA NA NA 1 1 70 50
-#> 16 2 36.0 NA NA NA NA NA 1 1 70 50
-#> 17 2 72.0 NA NA NA NA NA 1 1 70 50
-#> 18 2 120.0 NA NA NA NA NA 1 1 70 50
-#> 19 3 0.5 NA NA NA 1000 NA 1 1 70 50
-#> 20 3 0.5 NA NA NA NA NA 1 1 70 50
-#> 21 3 1.0 NA NA NA NA NA 1 1 70 50
-#> 22 3 2.0 NA NA NA NA NA 1 1 70 50
-#> 23 3 6.0 NA NA NA NA NA 1 1 70 50
-#> 24 3 24.0 NA NA NA NA NA 1 1 70 50
-#> 25 3 36.0 NA NA NA NA NA 1 1 70 50
-#> 26 3 72.0 NA NA NA NA NA 1 1 70 50
-#> 27 3 120.0 NA NA NA NA NA 1 1 70 50
-#> 28 4 0.5 NA NA NA 1000 NA 2 1 60 45
-#> 29 4 0.5 NA NA NA NA NA 2 1 60 45
-#> 30 4 1.0 NA NA NA NA NA 2 1 60 45
-#> 31 4 2.0 NA NA NA NA NA 2 1 60 45
-#> 32 4 6.0 NA NA NA NA NA 2 1 60 45
-#> 33 4 24.0 NA NA NA NA NA 2 1 60 45
-#> 34 4 36.0 NA NA NA NA NA 2 1 60 45
-#> 35 4 72.0 NA NA NA NA NA 2 1 60 45
-#> 36 4 120.0 NA NA NA NA NA 2 1 60 45
-#> 37 5 0.5 NA NA NA 1000 NA 2 1 60 45
-#> 38 5 0.5 NA NA NA NA NA 2 1 60 45
-#> 39 5 1.0 NA NA NA NA NA 2 1 60 45
-#> 40 5 2.0 NA NA NA NA NA 2 1 60 45
-#> 41 5 6.0 NA NA NA NA NA 2 1 60 45
-#> 42 5 24.0 NA NA NA NA NA 2 1 60 45
-#> 43 5 36.0 NA NA NA NA NA 2 1 60 45
-#> 44 5 72.0 NA NA NA NA NA 2 1 60 45
-#> 45 5 120.0 NA NA NA NA NA 2 1 60 45
-#> 46 6 0.5 NA NA NA 1000 NA 2 1 60 45
-#> 47 6 0.5 NA NA NA NA NA 2 1 60 45
-#> 48 6 1.0 NA NA NA NA NA 2 1 60 45
-#> 49 6 2.0 NA NA NA NA NA 2 1 60 45
-#> 50 6 6.0 NA NA NA NA NA 2 1 60 45
-#> 51 6 24.0 NA NA NA NA NA 2 1 60 45
-#> 52 6 36.0 NA NA NA NA NA 2 1 60 45
-#> 53 6 72.0 NA NA NA NA NA 2 1 60 45
-#> 54 6 120.0 NA NA NA NA NA 2 1 60 45
-(df_14 <- model_prediction(design=design_3,DV=TRUE,dosing=dosing_3))
-#> ID Time DV IPRED PRED AMT Group Model WT AGE
-#> 1 1 0.5 NA NA NA 1000 1 1 70 50
-#> 2 1 0.5 NA NA NA NA 1 1 70 50
-#> 3 1 1.0 NA NA NA NA 1 1 70 50
-#> 4 1 2.0 NA NA NA NA 1 1 70 50
-#> 5 1 6.0 NA NA NA NA 1 1 70 50
-#> 6 1 24.0 NA NA NA NA 1 1 70 50
-#> 7 1 36.0 NA NA NA NA 1 1 70 50
-#> 8 1 72.0 NA NA NA NA 1 1 70 50
-#> 9 1 120.0 NA NA NA NA 1 1 70 50
-#> 10 2 0.5 NA NA NA 1000 1 1 70 50
-#> 11 2 0.5 NA NA NA NA 1 1 70 50
-#> 12 2 1.0 NA NA NA NA 1 1 70 50
-#> 13 2 2.0 NA NA NA NA 1 1 70 50
-#> 14 2 6.0 NA NA NA NA 1 1 70 50
-#> 15 2 24.0 NA NA NA NA 1 1 70 50
-#> 16 2 36.0 NA NA NA NA 1 1 70 50
-#> 17 2 72.0 NA NA NA NA 1 1 70 50
-#> 18 2 120.0 NA NA NA NA 1 1 70 50
-#> 19 3 0.5 NA NA NA 1000 1 1 70 50
-#> 20 3 0.5 NA NA NA NA 1 1 70 50
-#> 21 3 1.0 NA NA NA NA 1 1 70 50
-#> 22 3 2.0 NA NA NA NA 1 1 70 50
-#> 23 3 6.0 NA NA NA NA 1 1 70 50
-#> 24 3 24.0 NA NA NA NA 1 1 70 50
-#> 25 3 36.0 NA NA NA NA 1 1 70 50
-#> 26 3 72.0 NA NA NA NA 1 1 70 50
-#> 27 3 120.0 NA NA NA NA 1 1 70 50
-#> 28 4 0.5 NA NA NA 1000 2 1 60 45
-#> 29 4 0.5 NA NA NA NA 2 1 60 45
-#> 30 4 1.0 NA NA NA NA 2 1 60 45
-#> 31 4 2.0 NA NA NA NA 2 1 60 45
-#> 32 4 6.0 NA NA NA NA 2 1 60 45
-#> 33 4 24.0 NA NA NA NA 2 1 60 45
-#> 34 4 36.0 NA NA NA NA 2 1 60 45
-#> 35 4 72.0 NA NA NA NA 2 1 60 45
-#> 36 4 120.0 NA NA NA NA 2 1 60 45
-#> 37 5 0.5 NA NA NA 1000 2 1 60 45
-#> 38 5 0.5 NA NA NA NA 2 1 60 45
-#> 39 5 1.0 NA NA NA NA 2 1 60 45
-#> 40 5 2.0 NA NA NA NA 2 1 60 45
-#> 41 5 6.0 NA NA NA NA 2 1 60 45
-#> 42 5 24.0 NA NA NA NA 2 1 60 45
-#> 43 5 36.0 NA NA NA NA 2 1 60 45
-#> 44 5 72.0 NA NA NA NA 2 1 60 45
-#> 45 5 120.0 NA NA NA NA 2 1 60 45
-#> 46 6 0.5 NA NA NA 1000 2 1 60 45
-#> 47 6 0.5 NA NA NA NA 2 1 60 45
-#> 48 6 1.0 NA NA NA NA 2 1 60 45
-#> 49 6 2.0 NA NA NA NA 2 1 60 45
-#> 50 6 6.0 NA NA NA NA 2 1 60 45
-#> 51 6 24.0 NA NA NA NA 2 1 60 45
-#> 52 6 36.0 NA NA NA NA 2 1 60 45
-#> 53 6 72.0 NA NA NA NA 2 1 60 45
-#> 54 6 120.0 NA NA NA NA 2 1 60 45
-(df_15 <- model_prediction(design=design_3,DV=TRUE,dosing=dosing_4))
-#> ID Time DV IPRED PRED AMT Group Model WT AGE
-#> 1 1 0.5 NA NA NA 1000 1 1 70 50
-#> 2 1 0.5 NA NA NA NA 1 1 70 50
-#> 3 1 1.0 NA NA NA NA 1 1 70 50
-#> 4 1 2.0 NA NA NA NA 1 1 70 50
-#> 5 1 6.0 NA NA NA NA 1 1 70 50
-#> 6 1 10.0 NA NA NA 20 1 1 70 50
-#> 7 1 24.0 NA NA NA NA 1 1 70 50
-#> 8 1 36.0 NA NA NA NA 1 1 70 50
-#> 9 1 72.0 NA NA NA NA 1 1 70 50
-#> 10 1 120.0 NA NA NA NA 1 1 70 50
-#> 11 2 0.5 NA NA NA 1000 1 1 70 50
-#> 12 2 0.5 NA NA NA NA 1 1 70 50
-#> 13 2 1.0 NA NA NA NA 1 1 70 50
-#> 14 2 2.0 NA NA NA NA 1 1 70 50
-#> 15 2 6.0 NA NA NA NA 1 1 70 50
-#> 16 2 10.0 NA NA NA 20 1 1 70 50
-#> 17 2 24.0 NA NA NA NA 1 1 70 50
-#> 18 2 36.0 NA NA NA NA 1 1 70 50
-#> 19 2 72.0 NA NA NA NA 1 1 70 50
-#> 20 2 120.0 NA NA NA NA 1 1 70 50
-#> 21 3 0.5 NA NA NA 1000 1 1 70 50
-#> 22 3 0.5 NA NA NA NA 1 1 70 50
-#> 23 3 1.0 NA NA NA NA 1 1 70 50
-#> 24 3 2.0 NA NA NA NA 1 1 70 50
-#> 25 3 6.0 NA NA NA NA 1 1 70 50
-#> 26 3 10.0 NA NA NA 20 1 1 70 50
-#> 27 3 24.0 NA NA NA NA 1 1 70 50
-#> 28 3 36.0 NA NA NA NA 1 1 70 50
-#> 29 3 72.0 NA NA NA NA 1 1 70 50
-#> 30 3 120.0 NA NA NA NA 1 1 70 50
-#> 31 4 0.5 NA NA NA 1000 2 1 60 45
-#> 32 4 0.5 NA NA NA NA 2 1 60 45
-#> 33 4 1.0 NA NA NA NA 2 1 60 45
-#> 34 4 2.0 NA NA NA NA 2 1 60 45
-#> 35 4 6.0 NA NA NA NA 2 1 60 45
-#> 36 4 10.0 NA NA NA 20 2 1 60 45
-#> 37 4 24.0 NA NA NA NA 2 1 60 45
-#> 38 4 36.0 NA NA NA NA 2 1 60 45
-#> 39 4 72.0 NA NA NA NA 2 1 60 45
-#> 40 4 120.0 NA NA NA NA 2 1 60 45
-#> 41 5 0.5 NA NA NA 1000 2 1 60 45
-#> 42 5 0.5 NA NA NA NA 2 1 60 45
-#> 43 5 1.0 NA NA NA NA 2 1 60 45
-#> 44 5 2.0 NA NA NA NA 2 1 60 45
-#> 45 5 6.0 NA NA NA NA 2 1 60 45
-#> 46 5 10.0 NA NA NA 20 2 1 60 45
-#> 47 5 24.0 NA NA NA NA 2 1 60 45
-#> 48 5 36.0 NA NA NA NA 2 1 60 45
-#> 49 5 72.0 NA NA NA NA 2 1 60 45
-#> 50 5 120.0 NA NA NA NA 2 1 60 45
-#> 51 6 0.5 NA NA NA 1000 2 1 60 45
-#> 52 6 0.5 NA NA NA NA 2 1 60 45
-#> 53 6 1.0 NA NA NA NA 2 1 60 45
-#> 54 6 2.0 NA NA NA NA 2 1 60 45
-#> 55 6 6.0 NA NA NA NA 2 1 60 45
-#> 56 6 10.0 NA NA NA 20 2 1 60 45
-#> 57 6 24.0 NA NA NA NA 2 1 60 45
-#> 58 6 36.0 NA NA NA NA 2 1 60 45
-#> 59 6 72.0 NA NA NA NA 2 1 60 45
-#> 60 6 120.0 NA NA NA NA 2 1 60 45
-
-
-model_prediction(design=design_3,DV=TRUE,dosing=dosing_4,model_num_points = 10)
-#> ID Time DV IPRED PRED AMT Group Model WT AGE
-#> 1 1 0.50000 NA NA NA 1000 1 1 70 50
-#> 2 1 0.50000 NA NA NA NA 1 1 70 50
-#> 3 1 1.00000 NA NA NA NA 1 1 70 50
-#> 4 1 2.00000 NA NA NA NA 1 1 70 50
-#> 5 1 6.00000 NA NA NA NA 1 1 70 50
-#> 6 1 10.00000 NA NA NA 20 1 1 70 50
-#> 7 1 13.77778 NA NA NA NA 1 1 70 50
-#> 8 1 24.00000 NA NA NA NA 1 1 70 50
-#> 9 1 27.05556 NA NA NA NA 1 1 70 50
-#> 10 1 36.00000 NA NA NA NA 1 1 70 50
-#> 11 1 40.33333 NA NA NA NA 1 1 70 50
-#> 12 1 53.61111 NA NA NA NA 1 1 70 50
-#> 13 1 66.88889 NA NA NA NA 1 1 70 50
-#> 14 1 72.00000 NA NA NA NA 1 1 70 50
-#> 15 1 80.16667 NA NA NA NA 1 1 70 50
-#> 16 1 93.44444 NA NA NA NA 1 1 70 50
-#> 17 1 106.72222 NA NA NA NA 1 1 70 50
-#> 18 1 120.00000 NA NA NA NA 1 1 70 50
-#> 19 2 0.50000 NA NA NA 1000 1 1 70 50
-#> 20 2 0.50000 NA NA NA NA 1 1 70 50
-#> 21 2 1.00000 NA NA NA NA 1 1 70 50
-#> 22 2 2.00000 NA NA NA NA 1 1 70 50
-#> 23 2 6.00000 NA NA NA NA 1 1 70 50
-#> 24 2 10.00000 NA NA NA 20 1 1 70 50
-#> 25 2 13.77778 NA NA NA NA 1 1 70 50
-#> 26 2 24.00000 NA NA NA NA 1 1 70 50
-#> 27 2 27.05556 NA NA NA NA 1 1 70 50
-#> 28 2 36.00000 NA NA NA NA 1 1 70 50
-#> 29 2 40.33333 NA NA NA NA 1 1 70 50
-#> 30 2 53.61111 NA NA NA NA 1 1 70 50
-#> 31 2 66.88889 NA NA NA NA 1 1 70 50
-#> 32 2 72.00000 NA NA NA NA 1 1 70 50
-#> 33 2 80.16667 NA NA NA NA 1 1 70 50
-#> 34 2 93.44444 NA NA NA NA 1 1 70 50
-#> 35 2 106.72222 NA NA NA NA 1 1 70 50
-#> 36 2 120.00000 NA NA NA NA 1 1 70 50
-#> 37 3 0.50000 NA NA NA 1000 1 1 70 50
-#> 38 3 0.50000 NA NA NA NA 1 1 70 50
-#> 39 3 1.00000 NA NA NA NA 1 1 70 50
-#> 40 3 2.00000 NA NA NA NA 1 1 70 50
-#> 41 3 6.00000 NA NA NA NA 1 1 70 50
-#> 42 3 10.00000 NA NA NA 20 1 1 70 50
-#> 43 3 13.77778 NA NA NA NA 1 1 70 50
-#> 44 3 24.00000 NA NA NA NA 1 1 70 50
-#> 45 3 27.05556 NA NA NA NA 1 1 70 50
-#> 46 3 36.00000 NA NA NA NA 1 1 70 50
-#> 47 3 40.33333 NA NA NA NA 1 1 70 50
-#> 48 3 53.61111 NA NA NA NA 1 1 70 50
-#> 49 3 66.88889 NA NA NA NA 1 1 70 50
-#> 50 3 72.00000 NA NA NA NA 1 1 70 50
-#> 51 3 80.16667 NA NA NA NA 1 1 70 50
-#> 52 3 93.44444 NA NA NA NA 1 1 70 50
-#> 53 3 106.72222 NA NA NA NA 1 1 70 50
-#> 54 3 120.00000 NA NA NA NA 1 1 70 50
-#> 55 4 0.50000 NA NA NA 1000 2 1 60 45
-#> 56 4 0.50000 NA NA NA NA 2 1 60 45
-#> 57 4 1.00000 NA NA NA NA 2 1 60 45
-#> 58 4 2.00000 NA NA NA NA 2 1 60 45
-#> 59 4 6.00000 NA NA NA NA 2 1 60 45
-#> 60 4 10.00000 NA NA NA 20 2 1 60 45
-#> 61 4 13.77778 NA NA NA NA 2 1 60 45
-#> 62 4 24.00000 NA NA NA NA 2 1 60 45
-#> 63 4 27.05556 NA NA NA NA 2 1 60 45
-#> 64 4 36.00000 NA NA NA NA 2 1 60 45
-#> 65 4 40.33333 NA NA NA NA 2 1 60 45
-#> 66 4 53.61111 NA NA NA NA 2 1 60 45
-#> 67 4 66.88889 NA NA NA NA 2 1 60 45
-#> 68 4 72.00000 NA NA NA NA 2 1 60 45
-#> 69 4 80.16667 NA NA NA NA 2 1 60 45
-#> 70 4 93.44444 NA NA NA NA 2 1 60 45
-#> 71 4 106.72222 NA NA NA NA 2 1 60 45
-#> 72 4 120.00000 NA NA NA NA 2 1 60 45
-#> 73 5 0.50000 NA NA NA 1000 2 1 60 45
-#> 74 5 0.50000 NA NA NA NA 2 1 60 45
-#> 75 5 1.00000 NA NA NA NA 2 1 60 45
-#> 76 5 2.00000 NA NA NA NA 2 1 60 45
-#> 77 5 6.00000 NA NA NA NA 2 1 60 45
-#> 78 5 10.00000 NA NA NA 20 2 1 60 45
-#> 79 5 13.77778 NA NA NA NA 2 1 60 45
-#> 80 5 24.00000 NA NA NA NA 2 1 60 45
-#> 81 5 27.05556 NA NA NA NA 2 1 60 45
-#> 82 5 36.00000 NA NA NA NA 2 1 60 45
-#> 83 5 40.33333 NA NA NA NA 2 1 60 45
-#> 84 5 53.61111 NA NA NA NA 2 1 60 45
-#> 85 5 66.88889 NA NA NA NA 2 1 60 45
-#> 86 5 72.00000 NA NA NA NA 2 1 60 45
-#> 87 5 80.16667 NA NA NA NA 2 1 60 45
-#> 88 5 93.44444 NA NA NA NA 2 1 60 45
-#> 89 5 106.72222 NA NA NA NA 2 1 60 45
-#> 90 5 120.00000 NA NA NA NA 2 1 60 45
-#> 91 6 0.50000 NA NA NA 1000 2 1 60 45
-#> 92 6 0.50000 NA NA NA NA 2 1 60 45
-#> 93 6 1.00000 NA NA NA NA 2 1 60 45
-#> 94 6 2.00000 NA NA NA NA 2 1 60 45
-#> 95 6 6.00000 NA NA NA NA 2 1 60 45
-#> 96 6 10.00000 NA NA NA 20 2 1 60 45
-#> 97 6 13.77778 NA NA NA NA 2 1 60 45
-#> 98 6 24.00000 NA NA NA NA 2 1 60 45
-#> 99 6 27.05556 NA NA NA NA 2 1 60 45
-#> 100 6 36.00000 NA NA NA NA 2 1 60 45
-#> 101 6 40.33333 NA NA NA NA 2 1 60 45
-#> 102 6 53.61111 NA NA NA NA 2 1 60 45
-#> 103 6 66.88889 NA NA NA NA 2 1 60 45
-#> 104 6 72.00000 NA NA NA NA 2 1 60 45
-#> 105 6 80.16667 NA NA NA NA 2 1 60 45
-#> 106 6 93.44444 NA NA NA NA 2 1 60 45
-#> 107 6 106.72222 NA NA NA NA 2 1 60 45
-#> 108 6 120.00000 NA NA NA NA 2 1 60 45
-model_prediction(design=design_3,DV=TRUE,dosing=dosing_4,model_num_points = 10,model_minxt=20)
-#> ID Time DV IPRED PRED AMT Group Model WT AGE
-#> 1 1 0.50000 NA NA NA 1000 1 1 70 50
-#> 2 1 0.50000 NA NA NA NA 1 1 70 50
-#> 3 1 1.00000 NA NA NA NA 1 1 70 50
-#> 4 1 2.00000 NA NA NA NA 1 1 70 50
-#> 5 1 6.00000 NA NA NA NA 1 1 70 50
-#> 6 1 10.00000 NA NA NA 20 1 1 70 50
-#> 7 1 20.00000 NA NA NA NA 1 1 70 50
-#> 8 1 24.00000 NA NA NA NA 1 1 70 50
-#> 9 1 31.11111 NA NA NA NA 1 1 70 50
-#> 10 1 36.00000 NA NA NA NA 1 1 70 50
-#> 11 1 42.22222 NA NA NA NA 1 1 70 50
-#> 12 1 53.33333 NA NA NA NA 1 1 70 50
-#> 13 1 64.44444 NA NA NA NA 1 1 70 50
-#> 14 1 72.00000 NA NA NA NA 1 1 70 50
-#> 15 1 75.55556 NA NA NA NA 1 1 70 50
-#> 16 1 86.66667 NA NA NA NA 1 1 70 50
-#> 17 1 97.77778 NA NA NA NA 1 1 70 50
-#> 18 1 108.88889 NA NA NA NA 1 1 70 50
-#> 19 1 120.00000 NA NA NA NA 1 1 70 50
-#> 20 2 0.50000 NA NA NA 1000 1 1 70 50
-#> 21 2 0.50000 NA NA NA NA 1 1 70 50
-#> 22 2 1.00000 NA NA NA NA 1 1 70 50
-#> 23 2 2.00000 NA NA NA NA 1 1 70 50
-#> 24 2 6.00000 NA NA NA NA 1 1 70 50
-#> 25 2 10.00000 NA NA NA 20 1 1 70 50
-#> 26 2 20.00000 NA NA NA NA 1 1 70 50
-#> 27 2 24.00000 NA NA NA NA 1 1 70 50
-#> 28 2 31.11111 NA NA NA NA 1 1 70 50
-#> 29 2 36.00000 NA NA NA NA 1 1 70 50
-#> 30 2 42.22222 NA NA NA NA 1 1 70 50
-#> 31 2 53.33333 NA NA NA NA 1 1 70 50
-#> 32 2 64.44444 NA NA NA NA 1 1 70 50
-#> 33 2 72.00000 NA NA NA NA 1 1 70 50
-#> 34 2 75.55556 NA NA NA NA 1 1 70 50
-#> 35 2 86.66667 NA NA NA NA 1 1 70 50
-#> 36 2 97.77778 NA NA NA NA 1 1 70 50
-#> 37 2 108.88889 NA NA NA NA 1 1 70 50
-#> 38 2 120.00000 NA NA NA NA 1 1 70 50
-#> 39 3 0.50000 NA NA NA 1000 1 1 70 50
-#> 40 3 0.50000 NA NA NA NA 1 1 70 50
-#> 41 3 1.00000 NA NA NA NA 1 1 70 50
-#> 42 3 2.00000 NA NA NA NA 1 1 70 50
-#> 43 3 6.00000 NA NA NA NA 1 1 70 50
-#> 44 3 10.00000 NA NA NA 20 1 1 70 50
-#> 45 3 20.00000 NA NA NA NA 1 1 70 50
-#> 46 3 24.00000 NA NA NA NA 1 1 70 50
-#> 47 3 31.11111 NA NA NA NA 1 1 70 50
-#> 48 3 36.00000 NA NA NA NA 1 1 70 50
-#> 49 3 42.22222 NA NA NA NA 1 1 70 50
-#> 50 3 53.33333 NA NA NA NA 1 1 70 50
-#> 51 3 64.44444 NA NA NA NA 1 1 70 50
-#> 52 3 72.00000 NA NA NA NA 1 1 70 50
-#> 53 3 75.55556 NA NA NA NA 1 1 70 50
-#> 54 3 86.66667 NA NA NA NA 1 1 70 50
-#> 55 3 97.77778 NA NA NA NA 1 1 70 50
-#> 56 3 108.88889 NA NA NA NA 1 1 70 50
-#> 57 3 120.00000 NA NA NA NA 1 1 70 50
-#> 58 4 0.50000 NA NA NA 1000 2 1 60 45
-#> 59 4 0.50000 NA NA NA NA 2 1 60 45
-#> 60 4 1.00000 NA NA NA NA 2 1 60 45
-#> 61 4 2.00000 NA NA NA NA 2 1 60 45
-#> 62 4 6.00000 NA NA NA NA 2 1 60 45
-#> 63 4 10.00000 NA NA NA 20 2 1 60 45
-#> 64 4 20.00000 NA NA NA NA 2 1 60 45
-#> 65 4 24.00000 NA NA NA NA 2 1 60 45
-#> 66 4 31.11111 NA NA NA NA 2 1 60 45
-#> 67 4 36.00000 NA NA NA NA 2 1 60 45
-#> 68 4 42.22222 NA NA NA NA 2 1 60 45
-#> 69 4 53.33333 NA NA NA NA 2 1 60 45
-#> 70 4 64.44444 NA NA NA NA 2 1 60 45
-#> 71 4 72.00000 NA NA NA NA 2 1 60 45
-#> 72 4 75.55556 NA NA NA NA 2 1 60 45
-#> 73 4 86.66667 NA NA NA NA 2 1 60 45
-#> 74 4 97.77778 NA NA NA NA 2 1 60 45
-#> 75 4 108.88889 NA NA NA NA 2 1 60 45
-#> 76 4 120.00000 NA NA NA NA 2 1 60 45
-#> 77 5 0.50000 NA NA NA 1000 2 1 60 45
-#> 78 5 0.50000 NA NA NA NA 2 1 60 45
-#> 79 5 1.00000 NA NA NA NA 2 1 60 45
-#> 80 5 2.00000 NA NA NA NA 2 1 60 45
-#> 81 5 6.00000 NA NA NA NA 2 1 60 45
-#> 82 5 10.00000 NA NA NA 20 2 1 60 45
-#> 83 5 20.00000 NA NA NA NA 2 1 60 45
-#> 84 5 24.00000 NA NA NA NA 2 1 60 45
-#> 85 5 31.11111 NA NA NA NA 2 1 60 45
-#> 86 5 36.00000 NA NA NA NA 2 1 60 45
-#> 87 5 42.22222 NA NA NA NA 2 1 60 45
-#> 88 5 53.33333 NA NA NA NA 2 1 60 45
-#> 89 5 64.44444 NA NA NA NA 2 1 60 45
-#> 90 5 72.00000 NA NA NA NA 2 1 60 45
-#> 91 5 75.55556 NA NA NA NA 2 1 60 45
-#> 92 5 86.66667 NA NA NA NA 2 1 60 45
-#> 93 5 97.77778 NA NA NA NA 2 1 60 45
-#> 94 5 108.88889 NA NA NA NA 2 1 60 45
-#> 95 5 120.00000 NA NA NA NA 2 1 60 45
-#> 96 6 0.50000 NA NA NA 1000 2 1 60 45
-#> 97 6 0.50000 NA NA NA NA 2 1 60 45
-#> 98 6 1.00000 NA NA NA NA 2 1 60 45
-#> 99 6 2.00000 NA NA NA NA 2 1 60 45
-#> 100 6 6.00000 NA NA NA NA 2 1 60 45
-#> 101 6 10.00000 NA NA NA 20 2 1 60 45
-#> 102 6 20.00000 NA NA NA NA 2 1 60 45
-#> 103 6 24.00000 NA NA NA NA 2 1 60 45
-#> 104 6 31.11111 NA NA NA NA 2 1 60 45
-#> 105 6 36.00000 NA NA NA NA 2 1 60 45
-#> 106 6 42.22222 NA NA NA NA 2 1 60 45
-#> 107 6 53.33333 NA NA NA NA 2 1 60 45
-#> 108 6 64.44444 NA NA NA NA 2 1 60 45
-#> 109 6 72.00000 NA NA NA NA 2 1 60 45
-#> 110 6 75.55556 NA NA NA NA 2 1 60 45
-#> 111 6 86.66667 NA NA NA NA 2 1 60 45
-#> 112 6 97.77778 NA NA NA NA 2 1 60 45
-#> 113 6 108.88889 NA NA NA NA 2 1 60 45
-#> 114 6 120.00000 NA NA NA NA 2 1 60 45
-
-design_4 <- list(
- xt=c( 0.5,1,2,6,24,36,72,120),
- model_switch=c(1,1,1,1,2,2,2,2),
- m=2,
- groupsize=3,
- a=list(c(WT=70,AGE=50),c(AGE=45,WT=60)))
-
-model_prediction(design=design_4,DV=TRUE,dosing=dosing_4)
-#> ID Time DV IPRED PRED AMT Group Model WT AGE
-#> 1 1 0.5 NA NA NA 1000 1 1 70 50
-#> 2 1 0.5 NA NA NA NA 1 1 70 50
-#> 3 1 1.0 NA NA NA NA 1 1 70 50
-#> 4 1 2.0 NA NA NA NA 1 1 70 50
-#> 5 1 6.0 NA NA NA NA 1 1 70 50
-#> 6 1 10.0 NA NA NA 20 1 1 70 50
-#> 7 1 24.0 NA NA NA NA 1 2 70 50
-#> 8 1 36.0 NA NA NA NA 1 2 70 50
-#> 9 1 72.0 NA NA NA NA 1 2 70 50
-#> 10 1 120.0 NA NA NA NA 1 2 70 50
-#> 11 2 0.5 NA NA NA 1000 1 1 70 50
-#> 12 2 0.5 NA NA NA NA 1 1 70 50
-#> 13 2 1.0 NA NA NA NA 1 1 70 50
-#> 14 2 2.0 NA NA NA NA 1 1 70 50
-#> 15 2 6.0 NA NA NA NA 1 1 70 50
-#> 16 2 10.0 NA NA NA 20 1 1 70 50
-#> 17 2 24.0 NA NA NA NA 1 2 70 50
-#> 18 2 36.0 NA NA NA NA 1 2 70 50
-#> 19 2 72.0 NA NA NA NA 1 2 70 50
-#> 20 2 120.0 NA NA NA NA 1 2 70 50
-#> 21 3 0.5 NA NA NA 1000 1 1 70 50
-#> 22 3 0.5 NA NA NA NA 1 1 70 50
-#> 23 3 1.0 NA NA NA NA 1 1 70 50
-#> 24 3 2.0 NA NA NA NA 1 1 70 50
-#> 25 3 6.0 NA NA NA NA 1 1 70 50
-#> 26 3 10.0 NA NA NA 20 1 1 70 50
-#> 27 3 24.0 NA NA NA NA 1 2 70 50
-#> 28 3 36.0 NA NA NA NA 1 2 70 50
-#> 29 3 72.0 NA NA NA NA 1 2 70 50
-#> 30 3 120.0 NA NA NA NA 1 2 70 50
-#> 31 4 0.5 NA NA NA 1000 2 1 60 45
-#> 32 4 0.5 NA NA NA NA 2 1 60 45
-#> 33 4 1.0 NA NA NA NA 2 1 60 45
-#> 34 4 2.0 NA NA NA NA 2 1 60 45
-#> 35 4 6.0 NA NA NA NA 2 1 60 45
-#> 36 4 10.0 NA NA NA 20 2 1 60 45
-#> 37 4 24.0 NA NA NA NA 2 2 60 45
-#> 38 4 36.0 NA NA NA NA 2 2 60 45
-#> 39 4 72.0 NA NA NA NA 2 2 60 45
-#> 40 4 120.0 NA NA NA NA 2 2 60 45
-#> 41 5 0.5 NA NA NA 1000 2 1 60 45
-#> 42 5 0.5 NA NA NA NA 2 1 60 45
-#> 43 5 1.0 NA NA NA NA 2 1 60 45
-#> 44 5 2.0 NA NA NA NA 2 1 60 45
-#> 45 5 6.0 NA NA NA NA 2 1 60 45
-#> 46 5 10.0 NA NA NA 20 2 1 60 45
-#> 47 5 24.0 NA NA NA NA 2 2 60 45
-#> 48 5 36.0 NA NA NA NA 2 2 60 45
-#> 49 5 72.0 NA NA NA NA 2 2 60 45
-#> 50 5 120.0 NA NA NA NA 2 2 60 45
-#> 51 6 0.5 NA NA NA 1000 2 1 60 45
-#> 52 6 0.5 NA NA NA NA 2 1 60 45
-#> 53 6 1.0 NA NA NA NA 2 1 60 45
-#> 54 6 2.0 NA NA NA NA 2 1 60 45
-#> 55 6 6.0 NA NA NA NA 2 1 60 45
-#> 56 6 10.0 NA NA NA 20 2 1 60 45
-#> 57 6 24.0 NA NA NA NA 2 2 60 45
-#> 58 6 36.0 NA NA NA NA 2 2 60 45
-#> 59 6 72.0 NA NA NA NA 2 2 60 45
-#> 60 6 120.0 NA NA NA NA 2 2 60 45
-model_prediction(design=design_4,DV=TRUE,dosing=dosing_4,model_num_points = 10)
-#> ID Time DV IPRED PRED AMT Group Model WT AGE
-#> 1 1 0.500000 NA NA NA 1000 1 1 70 50
-#> 2 1 0.500000 NA NA NA NA 1 1 70 50
-#> 3 1 1.000000 NA NA NA NA 1 1 70 50
-#> 4 1 1.111111 NA NA NA NA 1 1 70 50
-#> 5 1 1.722222 NA NA NA NA 1 1 70 50
-#> 6 1 2.000000 NA NA NA NA 1 1 70 50
-#> 7 1 2.333333 NA NA NA NA 1 1 70 50
-#> 8 1 2.944444 NA NA NA NA 1 1 70 50
-#> 9 1 3.555556 NA NA NA NA 1 1 70 50
-#> 10 1 4.166667 NA NA NA NA 1 1 70 50
-#> 11 1 4.777778 NA NA NA NA 1 1 70 50
-#> 12 1 5.388889 NA NA NA NA 1 1 70 50
-#> 13 1 6.000000 NA NA NA NA 1 1 70 50
-#> 14 1 10.000000 NA NA NA 20 1 1 70 50
-#> 15 1 24.000000 NA NA NA NA 1 2 70 50
-#> 16 1 34.666667 NA NA NA NA 1 2 70 50
-#> 17 1 36.000000 NA NA NA NA 1 2 70 50
-#> 18 1 45.333333 NA NA NA NA 1 2 70 50
-#> 19 1 56.000000 NA NA NA NA 1 2 70 50
-#> 20 1 66.666667 NA NA NA NA 1 2 70 50
-#> 21 1 72.000000 NA NA NA NA 1 2 70 50
-#> 22 1 77.333333 NA NA NA NA 1 2 70 50
-#> 23 1 88.000000 NA NA NA NA 1 2 70 50
-#> 24 1 98.666667 NA NA NA NA 1 2 70 50
-#> 25 1 109.333333 NA NA NA NA 1 2 70 50
-#> 26 1 120.000000 NA NA NA NA 1 2 70 50
-#> 27 2 0.500000 NA NA NA 1000 1 1 70 50
-#> 28 2 0.500000 NA NA NA NA 1 1 70 50
-#> 29 2 1.000000 NA NA NA NA 1 1 70 50
-#> 30 2 1.111111 NA NA NA NA 1 1 70 50
-#> 31 2 1.722222 NA NA NA NA 1 1 70 50
-#> 32 2 2.000000 NA NA NA NA 1 1 70 50
-#> 33 2 2.333333 NA NA NA NA 1 1 70 50
-#> 34 2 2.944444 NA NA NA NA 1 1 70 50
-#> 35 2 3.555556 NA NA NA NA 1 1 70 50
-#> 36 2 4.166667 NA NA NA NA 1 1 70 50
-#> 37 2 4.777778 NA NA NA NA 1 1 70 50
-#> 38 2 5.388889 NA NA NA NA 1 1 70 50
-#> 39 2 6.000000 NA NA NA NA 1 1 70 50
-#> 40 2 10.000000 NA NA NA 20 1 1 70 50
-#> 41 2 24.000000 NA NA NA NA 1 2 70 50
-#> 42 2 34.666667 NA NA NA NA 1 2 70 50
-#> 43 2 36.000000 NA NA NA NA 1 2 70 50
-#> 44 2 45.333333 NA NA NA NA 1 2 70 50
-#> 45 2 56.000000 NA NA NA NA 1 2 70 50
-#> 46 2 66.666667 NA NA NA NA 1 2 70 50
-#> 47 2 72.000000 NA NA NA NA 1 2 70 50
-#> 48 2 77.333333 NA NA NA NA 1 2 70 50
-#> 49 2 88.000000 NA NA NA NA 1 2 70 50
-#> 50 2 98.666667 NA NA NA NA 1 2 70 50
-#> 51 2 109.333333 NA NA NA NA 1 2 70 50
-#> 52 2 120.000000 NA NA NA NA 1 2 70 50
-#> 53 3 0.500000 NA NA NA 1000 1 1 70 50
-#> 54 3 0.500000 NA NA NA NA 1 1 70 50
-#> 55 3 1.000000 NA NA NA NA 1 1 70 50
-#> 56 3 1.111111 NA NA NA NA 1 1 70 50
-#> 57 3 1.722222 NA NA NA NA 1 1 70 50
-#> 58 3 2.000000 NA NA NA NA 1 1 70 50
-#> 59 3 2.333333 NA NA NA NA 1 1 70 50
-#> 60 3 2.944444 NA NA NA NA 1 1 70 50
-#> 61 3 3.555556 NA NA NA NA 1 1 70 50
-#> 62 3 4.166667 NA NA NA NA 1 1 70 50
-#> 63 3 4.777778 NA NA NA NA 1 1 70 50
-#> 64 3 5.388889 NA NA NA NA 1 1 70 50
-#> 65 3 6.000000 NA NA NA NA 1 1 70 50
-#> 66 3 10.000000 NA NA NA 20 1 1 70 50
-#> 67 3 24.000000 NA NA NA NA 1 2 70 50
-#> 68 3 34.666667 NA NA NA NA 1 2 70 50
-#> 69 3 36.000000 NA NA NA NA 1 2 70 50
-#> 70 3 45.333333 NA NA NA NA 1 2 70 50
-#> 71 3 56.000000 NA NA NA NA 1 2 70 50
-#> 72 3 66.666667 NA NA NA NA 1 2 70 50
-#> 73 3 72.000000 NA NA NA NA 1 2 70 50
-#> 74 3 77.333333 NA NA NA NA 1 2 70 50
-#> 75 3 88.000000 NA NA NA NA 1 2 70 50
-#> 76 3 98.666667 NA NA NA NA 1 2 70 50
-#> 77 3 109.333333 NA NA NA NA 1 2 70 50
-#> 78 3 120.000000 NA NA NA NA 1 2 70 50
-#> 79 4 0.500000 NA NA NA 1000 2 1 60 45
-#> 80 4 0.500000 NA NA NA NA 2 1 60 45
-#> 81 4 1.000000 NA NA NA NA 2 1 60 45
-#> 82 4 1.111111 NA NA NA NA 2 1 60 45
-#> 83 4 1.722222 NA NA NA NA 2 1 60 45
-#> 84 4 2.000000 NA NA NA NA 2 1 60 45
-#> 85 4 2.333333 NA NA NA NA 2 1 60 45
-#> 86 4 2.944444 NA NA NA NA 2 1 60 45
-#> 87 4 3.555556 NA NA NA NA 2 1 60 45
-#> 88 4 4.166667 NA NA NA NA 2 1 60 45
-#> 89 4 4.777778 NA NA NA NA 2 1 60 45
-#> 90 4 5.388889 NA NA NA NA 2 1 60 45
-#> 91 4 6.000000 NA NA NA NA 2 1 60 45
-#> 92 4 10.000000 NA NA NA 20 2 1 60 45
-#> 93 4 24.000000 NA NA NA NA 2 2 60 45
-#> 94 4 34.666667 NA NA NA NA 2 2 60 45
-#> 95 4 36.000000 NA NA NA NA 2 2 60 45
-#> 96 4 45.333333 NA NA NA NA 2 2 60 45
-#> 97 4 56.000000 NA NA NA NA 2 2 60 45
-#> 98 4 66.666667 NA NA NA NA 2 2 60 45
-#> 99 4 72.000000 NA NA NA NA 2 2 60 45
-#> 100 4 77.333333 NA NA NA NA 2 2 60 45
-#> 101 4 88.000000 NA NA NA NA 2 2 60 45
-#> 102 4 98.666667 NA NA NA NA 2 2 60 45
-#> 103 4 109.333333 NA NA NA NA 2 2 60 45
-#> 104 4 120.000000 NA NA NA NA 2 2 60 45
-#> 105 5 0.500000 NA NA NA 1000 2 1 60 45
-#> 106 5 0.500000 NA NA NA NA 2 1 60 45
-#> 107 5 1.000000 NA NA NA NA 2 1 60 45
-#> 108 5 1.111111 NA NA NA NA 2 1 60 45
-#> 109 5 1.722222 NA NA NA NA 2 1 60 45
-#> 110 5 2.000000 NA NA NA NA 2 1 60 45
-#> 111 5 2.333333 NA NA NA NA 2 1 60 45
-#> 112 5 2.944444 NA NA NA NA 2 1 60 45
-#> 113 5 3.555556 NA NA NA NA 2 1 60 45
-#> 114 5 4.166667 NA NA NA NA 2 1 60 45
-#> 115 5 4.777778 NA NA NA NA 2 1 60 45
-#> 116 5 5.388889 NA NA NA NA 2 1 60 45
-#> 117 5 6.000000 NA NA NA NA 2 1 60 45
-#> 118 5 10.000000 NA NA NA 20 2 1 60 45
-#> 119 5 24.000000 NA NA NA NA 2 2 60 45
-#> 120 5 34.666667 NA NA NA NA 2 2 60 45
-#> 121 5 36.000000 NA NA NA NA 2 2 60 45
-#> 122 5 45.333333 NA NA NA NA 2 2 60 45
-#> 123 5 56.000000 NA NA NA NA 2 2 60 45
-#> 124 5 66.666667 NA NA NA NA 2 2 60 45
-#> 125 5 72.000000 NA NA NA NA 2 2 60 45
-#> 126 5 77.333333 NA NA NA NA 2 2 60 45
-#> 127 5 88.000000 NA NA NA NA 2 2 60 45
-#> 128 5 98.666667 NA NA NA NA 2 2 60 45
-#> 129 5 109.333333 NA NA NA NA 2 2 60 45
-#> 130 5 120.000000 NA NA NA NA 2 2 60 45
-#> 131 6 0.500000 NA NA NA 1000 2 1 60 45
-#> 132 6 0.500000 NA NA NA NA 2 1 60 45
-#> 133 6 1.000000 NA NA NA NA 2 1 60 45
-#> 134 6 1.111111 NA NA NA NA 2 1 60 45
-#> 135 6 1.722222 NA NA NA NA 2 1 60 45
-#> 136 6 2.000000 NA NA NA NA 2 1 60 45
-#> 137 6 2.333333 NA NA NA NA 2 1 60 45
-#> 138 6 2.944444 NA NA NA NA 2 1 60 45
-#> 139 6 3.555556 NA NA NA NA 2 1 60 45
-#> 140 6 4.166667 NA NA NA NA 2 1 60 45
-#> 141 6 4.777778 NA NA NA NA 2 1 60 45
-#> 142 6 5.388889 NA NA NA NA 2 1 60 45
-#> 143 6 6.000000 NA NA NA NA 2 1 60 45
-#> 144 6 10.000000 NA NA NA 20 2 1 60 45
-#> 145 6 24.000000 NA NA NA NA 2 2 60 45
-#> 146 6 34.666667 NA NA NA NA 2 2 60 45
-#> 147 6 36.000000 NA NA NA NA 2 2 60 45
-#> 148 6 45.333333 NA NA NA NA 2 2 60 45
-#> 149 6 56.000000 NA NA NA NA 2 2 60 45
-#> 150 6 66.666667 NA NA NA NA 2 2 60 45
-#> 151 6 72.000000 NA NA NA NA 2 2 60 45
-#> 152 6 77.333333 NA NA NA NA 2 2 60 45
-#> 153 6 88.000000 NA NA NA NA 2 2 60 45
-#> 154 6 98.666667 NA NA NA NA 2 2 60 45
-#> 155 6 109.333333 NA NA NA NA 2 2 60 45
-#> 156 6 120.000000 NA NA NA NA 2 2 60 45
-model_prediction(design=design_4,DV=TRUE,dosing=dosing_4,model_num_points = 10,
- model_minxt=10,model_maxxt=100)
-#> ID Time DV IPRED PRED AMT Group Model WT AGE
-#> 1 1 0.5 NA NA NA 1000 1 1 70 50
-#> 2 1 0.5 NA NA NA NA 1 1 70 50
-#> 3 1 1.0 NA NA NA NA 1 1 70 50
-#> 4 1 2.0 NA NA NA NA 1 1 70 50
-#> 5 1 6.0 NA NA NA NA 1 1 70 50
-#> 6 1 10.0 NA NA NA 20 1 1 70 50
-#> 7 1 10.0 NA NA NA NA 1 1 70 50
-#> 8 1 10.0 NA NA NA NA 1 2 70 50
-#> 9 1 20.0 NA NA NA NA 1 1 70 50
-#> 10 1 20.0 NA NA NA NA 1 2 70 50
-#> 11 1 24.0 NA NA NA NA 1 2 70 50
-#> 12 1 30.0 NA NA NA NA 1 1 70 50
-#> 13 1 30.0 NA NA NA NA 1 2 70 50
-#> 14 1 36.0 NA NA NA NA 1 2 70 50
-#> 15 1 40.0 NA NA NA NA 1 1 70 50
-#> 16 1 40.0 NA NA NA NA 1 2 70 50
-#> 17 1 50.0 NA NA NA NA 1 1 70 50
-#> 18 1 50.0 NA NA NA NA 1 2 70 50
-#> 19 1 60.0 NA NA NA NA 1 1 70 50
-#> 20 1 60.0 NA NA NA NA 1 2 70 50
-#> 21 1 70.0 NA NA NA NA 1 1 70 50
-#> 22 1 70.0 NA NA NA NA 1 2 70 50
-#> 23 1 72.0 NA NA NA NA 1 2 70 50
-#> 24 1 80.0 NA NA NA NA 1 1 70 50
-#> 25 1 80.0 NA NA NA NA 1 2 70 50
-#> 26 1 90.0 NA NA NA NA 1 1 70 50
-#> 27 1 90.0 NA NA NA NA 1 2 70 50
-#> 28 1 100.0 NA NA NA NA 1 1 70 50
-#> 29 1 100.0 NA NA NA NA 1 2 70 50
-#> 30 1 120.0 NA NA NA NA 1 2 70 50
-#> 31 2 0.5 NA NA NA 1000 1 1 70 50
-#> 32 2 0.5 NA NA NA NA 1 1 70 50
-#> 33 2 1.0 NA NA NA NA 1 1 70 50
-#> 34 2 2.0 NA NA NA NA 1 1 70 50
-#> 35 2 6.0 NA NA NA NA 1 1 70 50
-#> 36 2 10.0 NA NA NA 20 1 1 70 50
-#> 37 2 10.0 NA NA NA NA 1 1 70 50
-#> 38 2 10.0 NA NA NA NA 1 2 70 50
-#> 39 2 20.0 NA NA NA NA 1 1 70 50
-#> 40 2 20.0 NA NA NA NA 1 2 70 50
-#> 41 2 24.0 NA NA NA NA 1 2 70 50
-#> 42 2 30.0 NA NA NA NA 1 1 70 50
-#> 43 2 30.0 NA NA NA NA 1 2 70 50
-#> 44 2 36.0 NA NA NA NA 1 2 70 50
-#> 45 2 40.0 NA NA NA NA 1 1 70 50
-#> 46 2 40.0 NA NA NA NA 1 2 70 50
-#> 47 2 50.0 NA NA NA NA 1 1 70 50
-#> 48 2 50.0 NA NA NA NA 1 2 70 50
-#> 49 2 60.0 NA NA NA NA 1 1 70 50
-#> 50 2 60.0 NA NA NA NA 1 2 70 50
-#> 51 2 70.0 NA NA NA NA 1 1 70 50
-#> 52 2 70.0 NA NA NA NA 1 2 70 50
-#> 53 2 72.0 NA NA NA NA 1 2 70 50
-#> 54 2 80.0 NA NA NA NA 1 1 70 50
-#> 55 2 80.0 NA NA NA NA 1 2 70 50
-#> 56 2 90.0 NA NA NA NA 1 1 70 50
-#> 57 2 90.0 NA NA NA NA 1 2 70 50
-#> 58 2 100.0 NA NA NA NA 1 1 70 50
-#> 59 2 100.0 NA NA NA NA 1 2 70 50
-#> 60 2 120.0 NA NA NA NA 1 2 70 50
-#> 61 3 0.5 NA NA NA 1000 1 1 70 50
-#> 62 3 0.5 NA NA NA NA 1 1 70 50
-#> 63 3 1.0 NA NA NA NA 1 1 70 50
-#> 64 3 2.0 NA NA NA NA 1 1 70 50
-#> 65 3 6.0 NA NA NA NA 1 1 70 50
-#> 66 3 10.0 NA NA NA 20 1 1 70 50
-#> 67 3 10.0 NA NA NA NA 1 1 70 50
-#> 68 3 10.0 NA NA NA NA 1 2 70 50
-#> 69 3 20.0 NA NA NA NA 1 1 70 50
-#> 70 3 20.0 NA NA NA NA 1 2 70 50
-#> 71 3 24.0 NA NA NA NA 1 2 70 50
-#> 72 3 30.0 NA NA NA NA 1 1 70 50
-#> 73 3 30.0 NA NA NA NA 1 2 70 50
-#> 74 3 36.0 NA NA NA NA 1 2 70 50
-#> 75 3 40.0 NA NA NA NA 1 1 70 50
-#> 76 3 40.0 NA NA NA NA 1 2 70 50
-#> 77 3 50.0 NA NA NA NA 1 1 70 50
-#> 78 3 50.0 NA NA NA NA 1 2 70 50
-#> 79 3 60.0 NA NA NA NA 1 1 70 50
-#> 80 3 60.0 NA NA NA NA 1 2 70 50
-#> 81 3 70.0 NA NA NA NA 1 1 70 50
-#> 82 3 70.0 NA NA NA NA 1 2 70 50
-#> 83 3 72.0 NA NA NA NA 1 2 70 50
-#> 84 3 80.0 NA NA NA NA 1 1 70 50
-#> 85 3 80.0 NA NA NA NA 1 2 70 50
-#> 86 3 90.0 NA NA NA NA 1 1 70 50
-#> 87 3 90.0 NA NA NA NA 1 2 70 50
-#> 88 3 100.0 NA NA NA NA 1 1 70 50
-#> 89 3 100.0 NA NA NA NA 1 2 70 50
-#> 90 3 120.0 NA NA NA NA 1 2 70 50
-#> 91 4 0.5 NA NA NA 1000 2 1 60 45
-#> 92 4 0.5 NA NA NA NA 2 1 60 45
-#> 93 4 1.0 NA NA NA NA 2 1 60 45
-#> 94 4 2.0 NA NA NA NA 2 1 60 45
-#> 95 4 6.0 NA NA NA NA 2 1 60 45
-#> 96 4 10.0 NA NA NA 20 2 1 60 45
-#> 97 4 10.0 NA NA NA NA 2 1 60 45
-#> 98 4 10.0 NA NA NA NA 2 2 60 45
-#> 99 4 20.0 NA NA NA NA 2 1 60 45
-#> 100 4 20.0 NA NA NA NA 2 2 60 45
-#> 101 4 24.0 NA NA NA NA 2 2 60 45
-#> 102 4 30.0 NA NA NA NA 2 1 60 45
-#> 103 4 30.0 NA NA NA NA 2 2 60 45
-#> 104 4 36.0 NA NA NA NA 2 2 60 45
-#> 105 4 40.0 NA NA NA NA 2 1 60 45
-#> 106 4 40.0 NA NA NA NA 2 2 60 45
-#> 107 4 50.0 NA NA NA NA 2 1 60 45
-#> 108 4 50.0 NA NA NA NA 2 2 60 45
-#> 109 4 60.0 NA NA NA NA 2 1 60 45
-#> 110 4 60.0 NA NA NA NA 2 2 60 45
-#> 111 4 70.0 NA NA NA NA 2 1 60 45
-#> 112 4 70.0 NA NA NA NA 2 2 60 45
-#> 113 4 72.0 NA NA NA NA 2 2 60 45
-#> 114 4 80.0 NA NA NA NA 2 1 60 45
-#> 115 4 80.0 NA NA NA NA 2 2 60 45
-#> 116 4 90.0 NA NA NA NA 2 1 60 45
-#> 117 4 90.0 NA NA NA NA 2 2 60 45
-#> 118 4 100.0 NA NA NA NA 2 1 60 45
-#> 119 4 100.0 NA NA NA NA 2 2 60 45
-#> 120 4 120.0 NA NA NA NA 2 2 60 45
-#> 121 5 0.5 NA NA NA 1000 2 1 60 45
-#> 122 5 0.5 NA NA NA NA 2 1 60 45
-#> 123 5 1.0 NA NA NA NA 2 1 60 45
-#> 124 5 2.0 NA NA NA NA 2 1 60 45
-#> 125 5 6.0 NA NA NA NA 2 1 60 45
-#> 126 5 10.0 NA NA NA 20 2 1 60 45
-#> 127 5 10.0 NA NA NA NA 2 1 60 45
-#> 128 5 10.0 NA NA NA NA 2 2 60 45
-#> 129 5 20.0 NA NA NA NA 2 1 60 45
-#> 130 5 20.0 NA NA NA NA 2 2 60 45
-#> 131 5 24.0 NA NA NA NA 2 2 60 45
-#> 132 5 30.0 NA NA NA NA 2 1 60 45
-#> 133 5 30.0 NA NA NA NA 2 2 60 45
-#> 134 5 36.0 NA NA NA NA 2 2 60 45
-#> 135 5 40.0 NA NA NA NA 2 1 60 45
-#> 136 5 40.0 NA NA NA NA 2 2 60 45
-#> 137 5 50.0 NA NA NA NA 2 1 60 45
-#> 138 5 50.0 NA NA NA NA 2 2 60 45
-#> 139 5 60.0 NA NA NA NA 2 1 60 45
-#> 140 5 60.0 NA NA NA NA 2 2 60 45
-#> 141 5 70.0 NA NA NA NA 2 1 60 45
-#> 142 5 70.0 NA NA NA NA 2 2 60 45
-#> 143 5 72.0 NA NA NA NA 2 2 60 45
-#> 144 5 80.0 NA NA NA NA 2 1 60 45
-#> 145 5 80.0 NA NA NA NA 2 2 60 45
-#> 146 5 90.0 NA NA NA NA 2 1 60 45
-#> 147 5 90.0 NA NA NA NA 2 2 60 45
-#> 148 5 100.0 NA NA NA NA 2 1 60 45
-#> 149 5 100.0 NA NA NA NA 2 2 60 45
-#> 150 5 120.0 NA NA NA NA 2 2 60 45
-#> 151 6 0.5 NA NA NA 1000 2 1 60 45
-#> 152 6 0.5 NA NA NA NA 2 1 60 45
-#> 153 6 1.0 NA NA NA NA 2 1 60 45
-#> 154 6 2.0 NA NA NA NA 2 1 60 45
-#> 155 6 6.0 NA NA NA NA 2 1 60 45
-#> 156 6 10.0 NA NA NA 20 2 1 60 45
-#> 157 6 10.0 NA NA NA NA 2 1 60 45
-#> 158 6 10.0 NA NA NA NA 2 2 60 45
-#> 159 6 20.0 NA NA NA NA 2 1 60 45
-#> 160 6 20.0 NA NA NA NA 2 2 60 45
-#> 161 6 24.0 NA NA NA NA 2 2 60 45
-#> 162 6 30.0 NA NA NA NA 2 1 60 45
-#> 163 6 30.0 NA NA NA NA 2 2 60 45
-#> 164 6 36.0 NA NA NA NA 2 2 60 45
-#> 165 6 40.0 NA NA NA NA 2 1 60 45
-#> 166 6 40.0 NA NA NA NA 2 2 60 45
-#> 167 6 50.0 NA NA NA NA 2 1 60 45
-#> 168 6 50.0 NA NA NA NA 2 2 60 45
-#> 169 6 60.0 NA NA NA NA 2 1 60 45
-#> 170 6 60.0 NA NA NA NA 2 2 60 45
-#> 171 6 70.0 NA NA NA NA 2 1 60 45
-#> 172 6 70.0 NA NA NA NA 2 2 60 45
-#> 173 6 72.0 NA NA NA NA 2 2 60 45
-#> 174 6 80.0 NA NA NA NA 2 1 60 45
-#> 175 6 80.0 NA NA NA NA 2 2 60 45
-#> 176 6 90.0 NA NA NA NA 2 1 60 45
-#> 177 6 90.0 NA NA NA NA 2 2 60 45
-#> 178 6 100.0 NA NA NA NA 2 1 60 45
-#> 179 6 100.0 NA NA NA NA 2 2 60 45
-#> 180 6 120.0 NA NA NA NA 2 2 60 45
-model_prediction(design=design_4,DV=TRUE,dosing=dosing_4,model_num_points = 10,
- model_minxt=c(20,20),model_maxxt=c(100,100))
-#> ID Time DV IPRED PRED AMT Group Model WT AGE
-#> 1 1 0.50000 NA NA NA 1000 1 1 70 50
-#> 2 1 0.50000 NA NA NA NA 1 1 70 50
-#> 3 1 1.00000 NA NA NA NA 1 1 70 50
-#> 4 1 2.00000 NA NA NA NA 1 1 70 50
-#> 5 1 6.00000 NA NA NA NA 1 1 70 50
-#> 6 1 10.00000 NA NA NA 20 1 1 70 50
-#> 7 1 20.00000 NA NA NA NA 1 1 70 50
-#> 8 1 20.00000 NA NA NA NA 1 2 70 50
-#> 9 1 24.00000 NA NA NA NA 1 2 70 50
-#> 10 1 28.88889 NA NA NA NA 1 1 70 50
-#> 11 1 28.88889 NA NA NA NA 1 2 70 50
-#> 12 1 36.00000 NA NA NA NA 1 2 70 50
-#> 13 1 37.77778 NA NA NA NA 1 1 70 50
-#> 14 1 37.77778 NA NA NA NA 1 2 70 50
-#> 15 1 46.66667 NA NA NA NA 1 1 70 50
-#> 16 1 46.66667 NA NA NA NA 1 2 70 50
-#> 17 1 55.55556 NA NA NA NA 1 1 70 50
-#> 18 1 55.55556 NA NA NA NA 1 2 70 50
-#> 19 1 64.44444 NA NA NA NA 1 1 70 50
-#> 20 1 64.44444 NA NA NA NA 1 2 70 50
-#> 21 1 72.00000 NA NA NA NA 1 2 70 50
-#> 22 1 73.33333 NA NA NA NA 1 1 70 50
-#> 23 1 73.33333 NA NA NA NA 1 2 70 50
-#> 24 1 82.22222 NA NA NA NA 1 1 70 50
-#> 25 1 82.22222 NA NA NA NA 1 2 70 50
-#> 26 1 91.11111 NA NA NA NA 1 1 70 50
-#> 27 1 91.11111 NA NA NA NA 1 2 70 50
-#> 28 1 100.00000 NA NA NA NA 1 1 70 50
-#> 29 1 100.00000 NA NA NA NA 1 2 70 50
-#> 30 1 120.00000 NA NA NA NA 1 2 70 50
-#> 31 2 0.50000 NA NA NA 1000 1 1 70 50
-#> 32 2 0.50000 NA NA NA NA 1 1 70 50
-#> 33 2 1.00000 NA NA NA NA 1 1 70 50
-#> 34 2 2.00000 NA NA NA NA 1 1 70 50
-#> 35 2 6.00000 NA NA NA NA 1 1 70 50
-#> 36 2 10.00000 NA NA NA 20 1 1 70 50
-#> 37 2 20.00000 NA NA NA NA 1 1 70 50
-#> 38 2 20.00000 NA NA NA NA 1 2 70 50
-#> 39 2 24.00000 NA NA NA NA 1 2 70 50
-#> 40 2 28.88889 NA NA NA NA 1 1 70 50
-#> 41 2 28.88889 NA NA NA NA 1 2 70 50
-#> 42 2 36.00000 NA NA NA NA 1 2 70 50
-#> 43 2 37.77778 NA NA NA NA 1 1 70 50
-#> 44 2 37.77778 NA NA NA NA 1 2 70 50
-#> 45 2 46.66667 NA NA NA NA 1 1 70 50
-#> 46 2 46.66667 NA NA NA NA 1 2 70 50
-#> 47 2 55.55556 NA NA NA NA 1 1 70 50
-#> 48 2 55.55556 NA NA NA NA 1 2 70 50
-#> 49 2 64.44444 NA NA NA NA 1 1 70 50
-#> 50 2 64.44444 NA NA NA NA 1 2 70 50
-#> 51 2 72.00000 NA NA NA NA 1 2 70 50
-#> 52 2 73.33333 NA NA NA NA 1 1 70 50
-#> 53 2 73.33333 NA NA NA NA 1 2 70 50
-#> 54 2 82.22222 NA NA NA NA 1 1 70 50
-#> 55 2 82.22222 NA NA NA NA 1 2 70 50
-#> 56 2 91.11111 NA NA NA NA 1 1 70 50
-#> 57 2 91.11111 NA NA NA NA 1 2 70 50
-#> 58 2 100.00000 NA NA NA NA 1 1 70 50
-#> 59 2 100.00000 NA NA NA NA 1 2 70 50
-#> 60 2 120.00000 NA NA NA NA 1 2 70 50
-#> 61 3 0.50000 NA NA NA 1000 1 1 70 50
-#> 62 3 0.50000 NA NA NA NA 1 1 70 50
-#> 63 3 1.00000 NA NA NA NA 1 1 70 50
-#> 64 3 2.00000 NA NA NA NA 1 1 70 50
-#> 65 3 6.00000 NA NA NA NA 1 1 70 50
-#> 66 3 10.00000 NA NA NA 20 1 1 70 50
-#> 67 3 20.00000 NA NA NA NA 1 1 70 50
-#> 68 3 20.00000 NA NA NA NA 1 2 70 50
-#> 69 3 24.00000 NA NA NA NA 1 2 70 50
-#> 70 3 28.88889 NA NA NA NA 1 1 70 50
-#> 71 3 28.88889 NA NA NA NA 1 2 70 50
-#> 72 3 36.00000 NA NA NA NA 1 2 70 50
-#> 73 3 37.77778 NA NA NA NA 1 1 70 50
-#> 74 3 37.77778 NA NA NA NA 1 2 70 50
-#> 75 3 46.66667 NA NA NA NA 1 1 70 50
-#> 76 3 46.66667 NA NA NA NA 1 2 70 50
-#> 77 3 55.55556 NA NA NA NA 1 1 70 50
-#> 78 3 55.55556 NA NA NA NA 1 2 70 50
-#> 79 3 64.44444 NA NA NA NA 1 1 70 50
-#> 80 3 64.44444 NA NA NA NA 1 2 70 50
-#> 81 3 72.00000 NA NA NA NA 1 2 70 50
-#> 82 3 73.33333 NA NA NA NA 1 1 70 50
-#> 83 3 73.33333 NA NA NA NA 1 2 70 50
-#> 84 3 82.22222 NA NA NA NA 1 1 70 50
-#> 85 3 82.22222 NA NA NA NA 1 2 70 50
-#> 86 3 91.11111 NA NA NA NA 1 1 70 50
-#> 87 3 91.11111 NA NA NA NA 1 2 70 50
-#> 88 3 100.00000 NA NA NA NA 1 1 70 50
-#> 89 3 100.00000 NA NA NA NA 1 2 70 50
-#> 90 3 120.00000 NA NA NA NA 1 2 70 50
-#> 91 4 0.50000 NA NA NA 1000 2 1 60 45
-#> 92 4 0.50000 NA NA NA NA 2 1 60 45
-#> 93 4 1.00000 NA NA NA NA 2 1 60 45
-#> 94 4 2.00000 NA NA NA NA 2 1 60 45
-#> 95 4 6.00000 NA NA NA NA 2 1 60 45
-#> 96 4 10.00000 NA NA NA 20 2 1 60 45
-#> 97 4 20.00000 NA NA NA NA 2 1 60 45
-#> 98 4 20.00000 NA NA NA NA 2 2 60 45
-#> 99 4 24.00000 NA NA NA NA 2 2 60 45
-#> 100 4 28.88889 NA NA NA NA 2 1 60 45
-#> 101 4 28.88889 NA NA NA NA 2 2 60 45
-#> 102 4 36.00000 NA NA NA NA 2 2 60 45
-#> 103 4 37.77778 NA NA NA NA 2 1 60 45
-#> 104 4 37.77778 NA NA NA NA 2 2 60 45
-#> 105 4 46.66667 NA NA NA NA 2 1 60 45
-#> 106 4 46.66667 NA NA NA NA 2 2 60 45
-#> 107 4 55.55556 NA NA NA NA 2 1 60 45
-#> 108 4 55.55556 NA NA NA NA 2 2 60 45
-#> 109 4 64.44444 NA NA NA NA 2 1 60 45
-#> 110 4 64.44444 NA NA NA NA 2 2 60 45
-#> 111 4 72.00000 NA NA NA NA 2 2 60 45
-#> 112 4 73.33333 NA NA NA NA 2 1 60 45
-#> 113 4 73.33333 NA NA NA NA 2 2 60 45
-#> 114 4 82.22222 NA NA NA NA 2 1 60 45
-#> 115 4 82.22222 NA NA NA NA 2 2 60 45
-#> 116 4 91.11111 NA NA NA NA 2 1 60 45
-#> 117 4 91.11111 NA NA NA NA 2 2 60 45
-#> 118 4 100.00000 NA NA NA NA 2 1 60 45
-#> 119 4 100.00000 NA NA NA NA 2 2 60 45
-#> 120 4 120.00000 NA NA NA NA 2 2 60 45
-#> 121 5 0.50000 NA NA NA 1000 2 1 60 45
-#> 122 5 0.50000 NA NA NA NA 2 1 60 45
-#> 123 5 1.00000 NA NA NA NA 2 1 60 45
-#> 124 5 2.00000 NA NA NA NA 2 1 60 45
-#> 125 5 6.00000 NA NA NA NA 2 1 60 45
-#> 126 5 10.00000 NA NA NA 20 2 1 60 45
-#> 127 5 20.00000 NA NA NA NA 2 1 60 45
-#> 128 5 20.00000 NA NA NA NA 2 2 60 45
-#> 129 5 24.00000 NA NA NA NA 2 2 60 45
-#> 130 5 28.88889 NA NA NA NA 2 1 60 45
-#> 131 5 28.88889 NA NA NA NA 2 2 60 45
-#> 132 5 36.00000 NA NA NA NA 2 2 60 45
-#> 133 5 37.77778 NA NA NA NA 2 1 60 45
-#> 134 5 37.77778 NA NA NA NA 2 2 60 45
-#> 135 5 46.66667 NA NA NA NA 2 1 60 45
-#> 136 5 46.66667 NA NA NA NA 2 2 60 45
-#> 137 5 55.55556 NA NA NA NA 2 1 60 45
-#> 138 5 55.55556 NA NA NA NA 2 2 60 45
-#> 139 5 64.44444 NA NA NA NA 2 1 60 45
-#> 140 5 64.44444 NA NA NA NA 2 2 60 45
-#> 141 5 72.00000 NA NA NA NA 2 2 60 45
-#> 142 5 73.33333 NA NA NA NA 2 1 60 45
-#> 143 5 73.33333 NA NA NA NA 2 2 60 45
-#> 144 5 82.22222 NA NA NA NA 2 1 60 45
-#> 145 5 82.22222 NA NA NA NA 2 2 60 45
-#> 146 5 91.11111 NA NA NA NA 2 1 60 45
-#> 147 5 91.11111 NA NA NA NA 2 2 60 45
-#> 148 5 100.00000 NA NA NA NA 2 1 60 45
-#> 149 5 100.00000 NA NA NA NA 2 2 60 45
-#> 150 5 120.00000 NA NA NA NA 2 2 60 45
-#> 151 6 0.50000 NA NA NA 1000 2 1 60 45
-#> 152 6 0.50000 NA NA NA NA 2 1 60 45
-#> 153 6 1.00000 NA NA NA NA 2 1 60 45
-#> 154 6 2.00000 NA NA NA NA 2 1 60 45
-#> 155 6 6.00000 NA NA NA NA 2 1 60 45
-#> 156 6 10.00000 NA NA NA 20 2 1 60 45
-#> 157 6 20.00000 NA NA NA NA 2 1 60 45
-#> 158 6 20.00000 NA NA NA NA 2 2 60 45
-#> 159 6 24.00000 NA NA NA NA 2 2 60 45
-#> 160 6 28.88889 NA NA NA NA 2 1 60 45
-#> 161 6 28.88889 NA NA NA NA 2 2 60 45
-#> 162 6 36.00000 NA NA NA NA 2 2 60 45
-#> 163 6 37.77778 NA NA NA NA 2 1 60 45
-#> 164 6 37.77778 NA NA NA NA 2 2 60 45
-#> 165 6 46.66667 NA NA NA NA 2 1 60 45
-#> 166 6 46.66667 NA NA NA NA 2 2 60 45
-#> 167 6 55.55556 NA NA NA NA 2 1 60 45
-#> 168 6 55.55556 NA NA NA NA 2 2 60 45
-#> 169 6 64.44444 NA NA NA NA 2 1 60 45
-#> 170 6 64.44444 NA NA NA NA 2 2 60 45
-#> 171 6 72.00000 NA NA NA NA 2 2 60 45
-#> 172 6 73.33333 NA NA NA NA 2 1 60 45
-#> 173 6 73.33333 NA NA NA NA 2 2 60 45
-#> 174 6 82.22222 NA NA NA NA 2 1 60 45
-#> 175 6 82.22222 NA NA NA NA 2 2 60 45
-#> 176 6 91.11111 NA NA NA NA 2 1 60 45
-#> 177 6 91.11111 NA NA NA NA 2 2 60 45
-#> 178 6 100.00000 NA NA NA NA 2 1 60 45
-#> 179 6 100.00000 NA NA NA NA 2 2 60 45
-#> 180 6 120.00000 NA NA NA NA 2 2 60 45
-model_prediction(design=design_4,DV=TRUE,dosing=dosing_4,model_num_points = c(10,10),
- model_minxt=c(20,20),model_maxxt=c(100,100))
-#> ID Time DV IPRED PRED AMT Group Model WT AGE
-#> 1 1 0.50000 NA NA NA 1000 1 1 70 50
-#> 2 1 0.50000 NA NA NA NA 1 1 70 50
-#> 3 1 1.00000 NA NA NA NA 1 1 70 50
-#> 4 1 2.00000 NA NA NA NA 1 1 70 50
-#> 5 1 6.00000 NA NA NA NA 1 1 70 50
-#> 6 1 10.00000 NA NA NA 20 1 1 70 50
-#> 7 1 20.00000 NA NA NA NA 1 1 70 50
-#> 8 1 20.00000 NA NA NA NA 1 2 70 50
-#> 9 1 24.00000 NA NA NA NA 1 2 70 50
-#> 10 1 28.88889 NA NA NA NA 1 1 70 50
-#> 11 1 28.88889 NA NA NA NA 1 2 70 50
-#> 12 1 36.00000 NA NA NA NA 1 2 70 50
-#> 13 1 37.77778 NA NA NA NA 1 1 70 50
-#> 14 1 37.77778 NA NA NA NA 1 2 70 50
-#> 15 1 46.66667 NA NA NA NA 1 1 70 50
-#> 16 1 46.66667 NA NA NA NA 1 2 70 50
-#> 17 1 55.55556 NA NA NA NA 1 1 70 50
-#> 18 1 55.55556 NA NA NA NA 1 2 70 50
-#> 19 1 64.44444 NA NA NA NA 1 1 70 50
-#> 20 1 64.44444 NA NA NA NA 1 2 70 50
-#> 21 1 72.00000 NA NA NA NA 1 2 70 50
-#> 22 1 73.33333 NA NA NA NA 1 1 70 50
-#> 23 1 73.33333 NA NA NA NA 1 2 70 50
-#> 24 1 82.22222 NA NA NA NA 1 1 70 50
-#> 25 1 82.22222 NA NA NA NA 1 2 70 50
-#> 26 1 91.11111 NA NA NA NA 1 1 70 50
-#> 27 1 91.11111 NA NA NA NA 1 2 70 50
-#> 28 1 100.00000 NA NA NA NA 1 1 70 50
-#> 29 1 100.00000 NA NA NA NA 1 2 70 50
-#> 30 1 120.00000 NA NA NA NA 1 2 70 50
-#> 31 2 0.50000 NA NA NA 1000 1 1 70 50
-#> 32 2 0.50000 NA NA NA NA 1 1 70 50
-#> 33 2 1.00000 NA NA NA NA 1 1 70 50
-#> 34 2 2.00000 NA NA NA NA 1 1 70 50
-#> 35 2 6.00000 NA NA NA NA 1 1 70 50
-#> 36 2 10.00000 NA NA NA 20 1 1 70 50
-#> 37 2 20.00000 NA NA NA NA 1 1 70 50
-#> 38 2 20.00000 NA NA NA NA 1 2 70 50
-#> 39 2 24.00000 NA NA NA NA 1 2 70 50
-#> 40 2 28.88889 NA NA NA NA 1 1 70 50
-#> 41 2 28.88889 NA NA NA NA 1 2 70 50
-#> 42 2 36.00000 NA NA NA NA 1 2 70 50
-#> 43 2 37.77778 NA NA NA NA 1 1 70 50
-#> 44 2 37.77778 NA NA NA NA 1 2 70 50
-#> 45 2 46.66667 NA NA NA NA 1 1 70 50
-#> 46 2 46.66667 NA NA NA NA 1 2 70 50
-#> 47 2 55.55556 NA NA NA NA 1 1 70 50
-#> 48 2 55.55556 NA NA NA NA 1 2 70 50
-#> 49 2 64.44444 NA NA NA NA 1 1 70 50
-#> 50 2 64.44444 NA NA NA NA 1 2 70 50
-#> 51 2 72.00000 NA NA NA NA 1 2 70 50
-#> 52 2 73.33333 NA NA NA NA 1 1 70 50
-#> 53 2 73.33333 NA NA NA NA 1 2 70 50
-#> 54 2 82.22222 NA NA NA NA 1 1 70 50
-#> 55 2 82.22222 NA NA NA NA 1 2 70 50
-#> 56 2 91.11111 NA NA NA NA 1 1 70 50
-#> 57 2 91.11111 NA NA NA NA 1 2 70 50
-#> 58 2 100.00000 NA NA NA NA 1 1 70 50
-#> 59 2 100.00000 NA NA NA NA 1 2 70 50
-#> 60 2 120.00000 NA NA NA NA 1 2 70 50
-#> 61 3 0.50000 NA NA NA 1000 1 1 70 50
-#> 62 3 0.50000 NA NA NA NA 1 1 70 50
-#> 63 3 1.00000 NA NA NA NA 1 1 70 50
-#> 64 3 2.00000 NA NA NA NA 1 1 70 50
-#> 65 3 6.00000 NA NA NA NA 1 1 70 50
-#> 66 3 10.00000 NA NA NA 20 1 1 70 50
-#> 67 3 20.00000 NA NA NA NA 1 1 70 50
-#> 68 3 20.00000 NA NA NA NA 1 2 70 50
-#> 69 3 24.00000 NA NA NA NA 1 2 70 50
-#> 70 3 28.88889 NA NA NA NA 1 1 70 50
-#> 71 3 28.88889 NA NA NA NA 1 2 70 50
-#> 72 3 36.00000 NA NA NA NA 1 2 70 50
-#> 73 3 37.77778 NA NA NA NA 1 1 70 50
-#> 74 3 37.77778 NA NA NA NA 1 2 70 50
-#> 75 3 46.66667 NA NA NA NA 1 1 70 50
-#> 76 3 46.66667 NA NA NA NA 1 2 70 50
-#> 77 3 55.55556 NA NA NA NA 1 1 70 50
-#> 78 3 55.55556 NA NA NA NA 1 2 70 50
-#> 79 3 64.44444 NA NA NA NA 1 1 70 50
-#> 80 3 64.44444 NA NA NA NA 1 2 70 50
-#> 81 3 72.00000 NA NA NA NA 1 2 70 50
-#> 82 3 73.33333 NA NA NA NA 1 1 70 50
-#> 83 3 73.33333 NA NA NA NA 1 2 70 50
-#> 84 3 82.22222 NA NA NA NA 1 1 70 50
-#> 85 3 82.22222 NA NA NA NA 1 2 70 50
-#> 86 3 91.11111 NA NA NA NA 1 1 70 50
-#> 87 3 91.11111 NA NA NA NA 1 2 70 50
-#> 88 3 100.00000 NA NA NA NA 1 1 70 50
-#> 89 3 100.00000 NA NA NA NA 1 2 70 50
-#> 90 3 120.00000 NA NA NA NA 1 2 70 50
-#> 91 4 0.50000 NA NA NA 1000 2 1 60 45
-#> 92 4 0.50000 NA NA NA NA 2 1 60 45
-#> 93 4 1.00000 NA NA NA NA 2 1 60 45
-#> 94 4 2.00000 NA NA NA NA 2 1 60 45
-#> 95 4 6.00000 NA NA NA NA 2 1 60 45
-#> 96 4 10.00000 NA NA NA 20 2 1 60 45
-#> 97 4 20.00000 NA NA NA NA 2 1 60 45
-#> 98 4 20.00000 NA NA NA NA 2 2 60 45
-#> 99 4 24.00000 NA NA NA NA 2 2 60 45
-#> 100 4 28.88889 NA NA NA NA 2 1 60 45
-#> 101 4 28.88889 NA NA NA NA 2 2 60 45
-#> 102 4 36.00000 NA NA NA NA 2 2 60 45
-#> 103 4 37.77778 NA NA NA NA 2 1 60 45
-#> 104 4 37.77778 NA NA NA NA 2 2 60 45
-#> 105 4 46.66667 NA NA NA NA 2 1 60 45
-#> 106 4 46.66667 NA NA NA NA 2 2 60 45
-#> 107 4 55.55556 NA NA NA NA 2 1 60 45
-#> 108 4 55.55556 NA NA NA NA 2 2 60 45
-#> 109 4 64.44444 NA NA NA NA 2 1 60 45
-#> 110 4 64.44444 NA NA NA NA 2 2 60 45
-#> 111 4 72.00000 NA NA NA NA 2 2 60 45
-#> 112 4 73.33333 NA NA NA NA 2 1 60 45
-#> 113 4 73.33333 NA NA NA NA 2 2 60 45
-#> 114 4 82.22222 NA NA NA NA 2 1 60 45
-#> 115 4 82.22222 NA NA NA NA 2 2 60 45
-#> 116 4 91.11111 NA NA NA NA 2 1 60 45
-#> 117 4 91.11111 NA NA NA NA 2 2 60 45
-#> 118 4 100.00000 NA NA NA NA 2 1 60 45
-#> 119 4 100.00000 NA NA NA NA 2 2 60 45
-#> 120 4 120.00000 NA NA NA NA 2 2 60 45
-#> 121 5 0.50000 NA NA NA 1000 2 1 60 45
-#> 122 5 0.50000 NA NA NA NA 2 1 60 45
-#> 123 5 1.00000 NA NA NA NA 2 1 60 45
-#> 124 5 2.00000 NA NA NA NA 2 1 60 45
-#> 125 5 6.00000 NA NA NA NA 2 1 60 45
-#> 126 5 10.00000 NA NA NA 20 2 1 60 45
-#> 127 5 20.00000 NA NA NA NA 2 1 60 45
-#> 128 5 20.00000 NA NA NA NA 2 2 60 45
-#> 129 5 24.00000 NA NA NA NA 2 2 60 45
-#> 130 5 28.88889 NA NA NA NA 2 1 60 45
-#> 131 5 28.88889 NA NA NA NA 2 2 60 45
-#> 132 5 36.00000 NA NA NA NA 2 2 60 45
-#> 133 5 37.77778 NA NA NA NA 2 1 60 45
-#> 134 5 37.77778 NA NA NA NA 2 2 60 45
-#> 135 5 46.66667 NA NA NA NA 2 1 60 45
-#> 136 5 46.66667 NA NA NA NA 2 2 60 45
-#> 137 5 55.55556 NA NA NA NA 2 1 60 45
-#> 138 5 55.55556 NA NA NA NA 2 2 60 45
-#> 139 5 64.44444 NA NA NA NA 2 1 60 45
-#> 140 5 64.44444 NA NA NA NA 2 2 60 45
-#> 141 5 72.00000 NA NA NA NA 2 2 60 45
-#> 142 5 73.33333 NA NA NA NA 2 1 60 45
-#> 143 5 73.33333 NA NA NA NA 2 2 60 45
-#> 144 5 82.22222 NA NA NA NA 2 1 60 45
-#> 145 5 82.22222 NA NA NA NA 2 2 60 45
-#> 146 5 91.11111 NA NA NA NA 2 1 60 45
-#> 147 5 91.11111 NA NA NA NA 2 2 60 45
-#> 148 5 100.00000 NA NA NA NA 2 1 60 45
-#> 149 5 100.00000 NA NA NA NA 2 2 60 45
-#> 150 5 120.00000 NA NA NA NA 2 2 60 45
-#> 151 6 0.50000 NA NA NA 1000 2 1 60 45
-#> 152 6 0.50000 NA NA NA NA 2 1 60 45
-#> 153 6 1.00000 NA NA NA NA 2 1 60 45
-#> 154 6 2.00000 NA NA NA NA 2 1 60 45
-#> 155 6 6.00000 NA NA NA NA 2 1 60 45
-#> 156 6 10.00000 NA NA NA 20 2 1 60 45
-#> 157 6 20.00000 NA NA NA NA 2 1 60 45
-#> 158 6 20.00000 NA NA NA NA 2 2 60 45
-#> 159 6 24.00000 NA NA NA NA 2 2 60 45
-#> 160 6 28.88889 NA NA NA NA 2 1 60 45
-#> 161 6 28.88889 NA NA NA NA 2 2 60 45
-#> 162 6 36.00000 NA NA NA NA 2 2 60 45
-#> 163 6 37.77778 NA NA NA NA 2 1 60 45
-#> 164 6 37.77778 NA NA NA NA 2 2 60 45
-#> 165 6 46.66667 NA NA NA NA 2 1 60 45
-#> 166 6 46.66667 NA NA NA NA 2 2 60 45
-#> 167 6 55.55556 NA NA NA NA 2 1 60 45
-#> 168 6 55.55556 NA NA NA NA 2 2 60 45
-#> 169 6 64.44444 NA NA NA NA 2 1 60 45
-#> 170 6 64.44444 NA NA NA NA 2 2 60 45
-#> 171 6 72.00000 NA NA NA NA 2 2 60 45
-#> 172 6 73.33333 NA NA NA NA 2 1 60 45
-#> 173 6 73.33333 NA NA NA NA 2 2 60 45
-#> 174 6 82.22222 NA NA NA NA 2 1 60 45
-#> 175 6 82.22222 NA NA NA NA 2 2 60 45
-#> 176 6 91.11111 NA NA NA NA 2 1 60 45
-#> 177 6 91.11111 NA NA NA NA 2 2 60 45
-#> 178 6 100.00000 NA NA NA NA 2 1 60 45
-#> 179 6 100.00000 NA NA NA NA 2 2 60 45
-#> 180 6 120.00000 NA NA NA NA 2 2 60 45
-
-
R/ofv_criterion.R
- ofv_criterion.Rd
Compute a normalized OFV based on the size of the FIM matrix. This value can then be used in
-efficiency calculations. This is NOT the OFV used in optimization, see ofv_fim
.
ofv_criterion(
- ofv_f,
- num_parameters,
- poped.db,
- ofv_calc_type = poped.db$settings$ofv_calc_type
-)
An objective function
The number of parameters to use for normalization
a poped database
OFV calculation type for FIM
1 = "D-optimality". Determinant of the FIM: det(FIM)
2 = "A-optimality". Inverse of the sum of the expected parameter variances: -1/trace_matrix(inv(FIM))
4 = "lnD-optimality". Natural logarithm of the determinant of the FIM: log(det(FIM))
6 = "Ds-optimality". Ratio of the Determinant of the FIM and the Determinant of the uninteresting -rows and columns of the FIM: det(FIM)/det(FIM_u)
7 = Inverse of the sum of the expected parameter RSE: 1/sum(get_rse(FIM,poped.db,use_percent=FALSE))
The specified criterion value.
-Other FIM:
-LinMatrixH()
,
-LinMatrixLH()
,
-LinMatrixL_occ()
,
-calc_ofv_and_fim()
,
-ed_laplace_ofv()
,
-ed_mftot()
,
-efficiency()
,
-evaluate.e.ofv.fim()
,
-evaluate.fim()
,
-gradf_eps()
,
-mf3()
,
-mf7()
,
-mftot()
,
-ofv_fim()
library(PopED)
-
-############# START #################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## Optimization using an additive + proportional reidual error
-## to avoid sample times at very low concentrations (time 0 or very late samples).
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(prop=0.01,add=0.25),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0.01,
- maxxt=120,
- a=c(DOSE=70),
- mina=c(DOSE=0.01),
- maxa=c(DOSE=100))
-
-############# END ###################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-
-## evaluate initial design
-FIM <- evaluate.fim(poped.db) # new name for function needed
-FIM
-#> [,1] [,2] [,3] [,4] [,5] [,6]
-#> [1,] 17141.83891 20.838375 10.011000 0.000000e+00 0.000000 0.00000000
-#> [2,] 20.83837 17.268051 -3.423641 0.000000e+00 0.000000 0.00000000
-#> [3,] 10.01100 -3.423641 49.864697 0.000000e+00 0.000000 0.00000000
-#> [4,] 0.00000 0.000000 0.000000 2.324341e+03 9.770352 0.03523364
-#> [5,] 0.00000 0.000000 0.000000 9.770352e+00 19083.877564 11.72131703
-#> [6,] 0.00000 0.000000 0.000000 3.523364e-02 11.721317 38.85137516
-#> [7,] 0.00000 0.000000 0.000000 7.268410e+02 9656.158553 64.78095548
-#> [8,] 0.00000 0.000000 0.000000 9.062739e+01 266.487127 2.94728469
-#> [,7] [,8]
-#> [1,] 0.00000 0.000000
-#> [2,] 0.00000 0.000000
-#> [3,] 0.00000 0.000000
-#> [4,] 726.84097 90.627386
-#> [5,] 9656.15855 266.487127
-#> [6,] 64.78096 2.947285
-#> [7,] 192840.20092 6659.569867
-#> [8,] 6659.56987 475.500111
-get_rse(FIM,poped.db)
-#> CL V KA d_CL d_V d_KA sig_prop sig_add
-#> 5.096246 3.031164 14.260384 29.761226 36.681388 26.748640 32.011719 25.637971
-
-ofv_criterion(ofv_fim(FIM,poped.db,ofv_calc_type=1),
- length(get_unfixed_params(poped.db)[["all"]]),
- poped.db,
- ofv_calc_type=1) # det(FIM)
-#> [1] 1016.943
-
-ofv_criterion(ofv_fim(FIM,poped.db,ofv_calc_type=2),
- length(get_unfixed_params(poped.db)[["all"]]),
- poped.db,
- ofv_calc_type=2)
-#> [1] 1.140916
-
-ofv_criterion(ofv_fim(FIM,poped.db,ofv_calc_type=4),
- length(get_unfixed_params(poped.db)[["all"]]),
- poped.db,
- ofv_calc_type=4)
-#> [1] 1016.943
-
-ofv_criterion(ofv_fim(FIM,poped.db,ofv_calc_type=6),
- length(get_unfixed_params(poped.db)[["all"]]),
- poped.db,
- ofv_calc_type=6)
-#> [1] 1.75168
-
-ofv_criterion(ofv_fim(FIM,poped.db,ofv_calc_type=7),
- length(get_unfixed_params(poped.db)[["all"]]),
- poped.db,
- ofv_calc_type=7)
-#> [1] 0
-
-
Compute a criterion of the FIM given the model, parameters, design and methods defined in the -PopED database.
-ofv_fim(
- fmf,
- poped.db,
- ofv_calc_type = poped.db$settings$ofv_calc_type,
- ds_index = poped.db$parameters$ds_index,
- use_log = TRUE,
- ...
-)
The FIM
A poped database
OFV calculation type for FIM
1 = "D-optimality". Determinant of the FIM: det(FIM)
2 = "A-optimality". Inverse of the sum of the expected parameter variances: -1/trace_matrix(inv(FIM))
4 = "lnD-optimality". Natural logarithm of the determinant of the FIM: log(det(FIM))
6 = "Ds-optimality". Ratio of the Determinant of the FIM and the Determinant of the uninteresting -rows and columns of the FIM: det(FIM)/det(FIM_u)
7 = Inverse of the sum of the expected parameter RSE: 1/sum(get_rse(FIM,poped.db,use_percent=FALSE))
Ds_index is a vector set to 1 if a parameter is uninteresting, otherwise 0.
-size=(1,num unfixed parameters). First unfixed bpop, then unfixed d, then unfixed docc and last unfixed sigma.
-Default is the fixed effects being important, everything else not important. Used in conjunction with
-ofv_calc_type=6
.
Should the criterion be in the log domain?
arguments passed to evaluate.fim
and ofv_fim
.
The specified criterion value.
-Other FIM:
-LinMatrixH()
,
-LinMatrixLH()
,
-LinMatrixL_occ()
,
-calc_ofv_and_fim()
,
-ed_laplace_ofv()
,
-ed_mftot()
,
-efficiency()
,
-evaluate.e.ofv.fim()
,
-evaluate.fim()
,
-gradf_eps()
,
-mf3()
,
-mf7()
,
-mftot()
,
-ofv_criterion()
Other evaluate_FIM:
-calc_ofv_and_fim()
,
-evaluate.e.ofv.fim()
,
-evaluate.fim()
library(PopED)
-
-############# START #################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## Optimization using an additive + proportional reidual error
-## to avoid sample times at very low concentrations (time 0 or very late samples).
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(prop=0.01,add=0.25),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0.01,
- maxxt=120,
- a=c(DOSE=70),
- mina=c(DOSE=0.01),
- maxa=c(DOSE=100))
-
-############# END ###################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-
-## evaluate initial design
-FIM <- evaluate.fim(poped.db)
-FIM
-#> [,1] [,2] [,3] [,4] [,5] [,6]
-#> [1,] 17141.83891 20.838375 10.011000 0.000000e+00 0.000000 0.00000000
-#> [2,] 20.83837 17.268051 -3.423641 0.000000e+00 0.000000 0.00000000
-#> [3,] 10.01100 -3.423641 49.864697 0.000000e+00 0.000000 0.00000000
-#> [4,] 0.00000 0.000000 0.000000 2.324341e+03 9.770352 0.03523364
-#> [5,] 0.00000 0.000000 0.000000 9.770352e+00 19083.877564 11.72131703
-#> [6,] 0.00000 0.000000 0.000000 3.523364e-02 11.721317 38.85137516
-#> [7,] 0.00000 0.000000 0.000000 7.268410e+02 9656.158553 64.78095548
-#> [8,] 0.00000 0.000000 0.000000 9.062739e+01 266.487127 2.94728469
-#> [,7] [,8]
-#> [1,] 0.00000 0.000000
-#> [2,] 0.00000 0.000000
-#> [3,] 0.00000 0.000000
-#> [4,] 726.84097 90.627386
-#> [5,] 9656.15855 266.487127
-#> [6,] 64.78096 2.947285
-#> [7,] 192840.20092 6659.569867
-#> [8,] 6659.56987 475.500111
-get_rse(FIM,poped.db)
-#> CL V KA d_CL d_V d_KA sig_prop sig_add
-#> 5.096246 3.031164 14.260384 29.761226 36.681388 26.748640 32.011719 25.637971
-
-det(FIM)
-#> [1] 1.143859e+24
-ofv_fim(FIM,poped.db,ofv_calc_type=1) # det(FIM)
-#> [1] 1.143859e+24
-ofv_fim(FIM,poped.db,ofv_calc_type=2) # 1/trace_matrix(inv(FIM))
-#> [1] 9.127328
-ofv_fim(FIM,poped.db,ofv_calc_type=4) # log(det(FIM))
-#> [1] 55.39645
-ofv_fim(FIM,poped.db,ofv_calc_type=6) # Ds with fixed effects as "important"
-#> [1] 16.49204
-ofv_fim(FIM,poped.db,ofv_calc_type=6,
- ds_index=c(1,1,1,0,0,0,1,1)) # Ds with random effects as "important"
-#> [1] 21.23143
-ofv_fim(FIM,poped.db,ofv_calc_type=7) # 1/sum(get_rse(FIM,poped.db,use_percent=FALSE))
-#> [1] 0.5772714
-
-
Create a matrix of ones of size (dim1 x dim2).
-ones(dim1, dim2 = NULL)
The dimension of the matrix (if square) or the number of rows.
The number of columns
A matrix of ones
-
-ones(4)
-#> [,1] [,2] [,3] [,4]
-#> [1,] 1 1 1 1
-#> [2,] 1 1 1 1
-#> [3,] 1 1 1 1
-#> [4,] 1 1 1 1
-ones(3,4)
-#> [,1] [,2] [,3] [,4]
-#> [1,] 1 1 1 1
-#> [2,] 1 1 1 1
-#> [3,] 1 1 1 1
-
Optimize an objective function using an adaptive random search algorithm. -The function works for both discrete and continuous optimization parameters -and allows for box-constraints and sets of allowed values.
-optim_ARS(
- par,
- fn,
- lower = NULL,
- upper = NULL,
- allowed_values = NULL,
- loc_fac = 4,
- no_bounds_sd = par,
- iter = 400,
- iter_adapt = 50,
- adapt_scale = 1,
- max_run = 200,
- trace = TRUE,
- trace_iter = 5,
- new_par_max_it = 200,
- maximize = F,
- parallel = F,
- parallel_type = NULL,
- num_cores = NULL,
- mrgsolve_model = NULL,
- seed = round(runif(1, 0, 1e+07)),
- allow_replicates = TRUE,
- replicates_index = seq(1, length(par)),
- generator = NULL,
- ...
-)
A vector of initial values for the parameters to be optimized over.
A function to be minimized (or maximized), -with first argument the vector of parameters over which minimization is to take place. -It should return a scalar result.
Lower bounds on the parameters. A vector.
Upper bounds on the parameters. A vector.
A list containing allowed values for each parameter list(par1=c(2,3,4,5,6),par2=c(5,6,7,8))
.
-A vector containing allowed values for all parameters is also allowed c(2,3,4,5,6)
.
Locality factor for determining the standard deviation of the sampling distribution around the current
-position of the parameters. The initial standard deviation is normally calculated as (upper - lower)/loc_fac
-except in cases when there are no upper or lower limits (e.g. when upper=Inf
or lower=-Inf
).
The standard deviation of the sampling distribution around the current
-position of the parameters when there are no upper or lower limits (e.g. when upper=Inf
or lower=-Inf
).
The number of iterations for the algorithm to perform (this is a maximum number, it could be less).
The number of iterations before adapting (shrinking) the parameter search space.
The scale for adapting the size of the sampling distribution. The adaptation of the
-standard deviation of the sampling distribution around the current
-position of the parameters is done after iter_adapt
iteration with no change in the best objective function.
-When adapting, the standard deviation of the sampling distribution is calculated as
-(upper - lower)/(loc_fac*ff*adapt_scale)
where ff starts at 1 and increases by 1 for each adaptation.
The maximum number of iterations to run without a change in the best parameter estimates.
Should the algorithm output results intermittently.
How many iterations between each update to the screen about the result of the search.
The algorithm randomly chooses samples based on the current best set of parameters. If when drawing
-these samples the new parameter set has already been tested then a new draw is performed. After new_par_max_it
draws, with
-no new parameter sets, then the algorithm stops.
Should the function be maximized? Default is to minimize.
Should we use parallel computations?
Which type of parallelization should be used?
-Can be "snow" or "multicore". "snow" works on Linux-like systems & Windows. "multicore" works only on
-Linux-like systems. By default this is chosen for you depending on your operating system.
-See start_parallel
.
The number of cores to use in the parallelization. By default is set to the number
- output from
-parallel::detectCores()
.
-See start_parallel
.
If the computations require a mrgsolve model and you
-are using the "snow" method then you need to specify the name of the model
-object created by mread
or mcode
.
The random seed to use in the algorithm,
Should the algorithm allow parameters to have the same value?
A vector, the same length as the parameters. -If two values are the same in this vector then the parameters may not assume the same value in the optimization.
A user-defined function that generates new parameter sets to try in the algorithm. See examples below.
Additional arguments passed to fn
and start_parallel
.
M. Foracchia, A.C. Hooker, P. Vicini and A. Ruggeri, "PopED, a software fir optimal -experimental design in population kinetics", Computer Methods and Programs in Biomedicine, 74, 2004.
J. Nyberg, S. Ueckert, E.A. Stroemberg, S. Hennig, M.O. Karlsson and A.C. Hooker, "PopED: An extended, -parallelized, nonlinear mixed effects models optimal design tool", -Computer Methods and Programs in Biomedicine, 108, 2012.
Other Optimize:
-Doptim()
,
-LEDoptim()
,
-RS_opt()
,
-a_line_search()
,
-bfgsb_min()
,
-calc_autofocus()
,
-calc_ofv_and_grad()
,
-mfea()
,
-optim_LS()
,
-poped_optim_1()
,
-poped_optim_2()
,
-poped_optim_3()
,
-poped_optimize()
,
-poped_optim()
-## "wild" function , global minimum at about -15.81515
-fw <- function(x) 10*sin(0.3*x)*sin(1.3*x^2) + 0.00001*x^4 + 0.2*x+80
-
-# optimization with fewer function evaluations compared to SANN
-res1 <- optim_ARS(50, fw,lower = -50, upper=100)
-#> Initial OFV = 159.001
-#> It. 5 | OFV = 93.2516
-#> It. 10 | OFV = 74.4026
-#> It. 15 | OFV = 71.9214
-#> It. 20 | OFV = 71.9214
-#> It. 25 | OFV = 71.9214
-#> It. 30 | OFV = 71.9214
-#> It. 35 | OFV = 71.9214
-#> It. 40 | OFV = 71.9214
-#> It. 45 | OFV = 71.9214
-#> It. 50 | OFV = 71.9214
-#> It. 55 | OFV = 71.9214
-#> It. 60 | OFV = 71.9214
-#> It. 65 | OFV = 71.9214
-#> It. 70 | OFV = 71.9214
-#> It. 75 | OFV = 71.9214
-#> It. 80 | OFV = 70.2523
-#> It. 85 | OFV = 69.6812
-#> It. 90 | OFV = 69.6812
-#> It. 95 | OFV = 69.6812
-#> It. 100 | OFV = 69.6812
-#> It. 105 | OFV = 69.4204
-#> It. 110 | OFV = 69.4204
-#> It. 115 | OFV = 69.4204
-#> It. 120 | OFV = 69.4204
-#> It. 125 | OFV = 69.4204
-#> It. 130 | OFV = 69.4204
-#> It. 135 | OFV = 69.4204
-#> It. 140 | OFV = 69.4204
-#> It. 145 | OFV = 69.4204
-#> It. 150 | OFV = 69.4204
-#> It. 155 | OFV = 68.5244
-#> It. 160 | OFV = 68.5244
-#> It. 165 | OFV = 68.5244
-#> It. 170 | OFV = 68.5244
-#> It. 175 | OFV = 68.5244
-#> It. 180 | OFV = 68.5244
-#> It. 185 | OFV = 68.5244
-#> It. 190 | OFV = 68.5244
-#> It. 195 | OFV = 68.5244
-#> It. 200 | OFV = 68.5244
-#> It. 205 | OFV = 68.5244
-#> It. 210 | OFV = 68.5244
-#> It. 215 | OFV = 68.5244
-#> It. 220 | OFV = 68.5244
-#> It. 225 | OFV = 68.5244
-#> It. 230 | OFV = 68.5244
-#> It. 235 | OFV = 68.5244
-#> It. 240 | OFV = 68.4406
-#> It. 245 | OFV = 68.4406
-#> It. 250 | OFV = 68.4406
-#> It. 255 | OFV = 68.4406
-#> It. 260 | OFV = 68.4406
-#> It. 265 | OFV = 68.4406
-#> It. 270 | OFV = 68.4406
-#> It. 275 | OFV = 68.4406
-#> It. 280 | OFV = 68.4406
-#> It. 285 | OFV = 68.4406
-#> It. 290 | OFV = 68.4406
-#> It. 295 | OFV = 68.4406
-#> It. 300 | OFV = 68.4406
-#> It. 305 | OFV = 68.4406
-#> It. 310 | OFV = 68.4406
-#> It. 315 | OFV = 68.4406
-#> It. 320 | OFV = 68.4406
-#> It. 325 | OFV = 68.4406
-#> It. 330 | OFV = 68.4406
-#> It. 335 | OFV = 68.4406
-#> It. 340 | OFV = 68.4406
-#> It. 345 | OFV = 68.4406
-#> It. 350 | OFV = 68.4406
-#> It. 355 | OFV = 68.4406
-#> It. 360 | OFV = 68.4406
-#> It. 365 | OFV = 68.4406
-#> It. 370 | OFV = 68.4406
-#> It. 375 | OFV = 68.4406
-#> It. 380 | OFV = 68.4406
-#> It. 385 | OFV = 68.4406
-#> It. 390 | OFV = 68.4406
-#> It. 395 | OFV = 67.9743
-#> It. 400 | OFV = 67.9743
-#>
-#> Total iterations: 400
-#> Elapsed time: 0.151 seconds.
-#>
-#> Final OFV = 67.97435
-#> Parameters: -14.7069
-#>
-
-# often not as good performance when upper and lower bounds are poor
-res2 <- optim_ARS(50, fw, lower=-Inf,upper=Inf)
-#> Initial OFV = 159.001
-#> It. 5 | OFV = 81.8156
-#> It. 10 | OFV = 81.8156
-#> It. 15 | OFV = 81.8156
-#> It. 20 | OFV = 81.8156
-#> It. 25 | OFV = 68.0396
-#> It. 30 | OFV = 68.0396
-#> It. 35 | OFV = 68.0396
-#> It. 40 | OFV = 68.0396
-#> It. 45 | OFV = 68.0396
-#> It. 50 | OFV = 68.0396
-#> It. 55 | OFV = 67.5532
-#> It. 60 | OFV = 67.5532
-#> It. 65 | OFV = 67.5532
-#> It. 70 | OFV = 67.5532
-#> It. 75 | OFV = 67.5532
-#> It. 80 | OFV = 67.5532
-#> It. 85 | OFV = 67.5532
-#> It. 90 | OFV = 67.5532
-#> It. 95 | OFV = 67.5532
-#> It. 100 | OFV = 67.5532
-#> It. 105 | OFV = 67.5532
-#> It. 110 | OFV = 67.5532
-#> It. 115 | OFV = 67.5532
-#> It. 120 | OFV = 67.5532
-#> It. 125 | OFV = 67.5532
-#> It. 130 | OFV = 67.5532
-#> It. 135 | OFV = 67.5532
-#> It. 140 | OFV = 67.5532
-#> It. 145 | OFV = 67.5532
-#> It. 150 | OFV = 67.5532
-#> It. 155 | OFV = 67.5532
-#> It. 160 | OFV = 67.5532
-#> It. 165 | OFV = 67.5532
-#> It. 170 | OFV = 67.5532
-#> It. 175 | OFV = 67.5532
-#> It. 180 | OFV = 67.5532
-#> It. 185 | OFV = 67.5532
-#> It. 190 | OFV = 67.5532
-#> It. 195 | OFV = 67.5532
-#> It. 200 | OFV = 67.5532
-#> It. 205 | OFV = 67.5532
-#> It. 210 | OFV = 67.5532
-#> It. 215 | OFV = 67.5532
-#> It. 220 | OFV = 67.5532
-#> It. 225 | OFV = 67.5532
-#> It. 230 | OFV = 67.5532
-#> It. 235 | OFV = 67.5532
-#> It. 240 | OFV = 67.5532
-#> It. 245 | OFV = 67.5532
-#> It. 250 | OFV = 67.5532
-#> Maximum number of identical optimal values reached (max_run=200), optimization stopped.
-#>
-#> Total iterations: 250
-#> Elapsed time: 0.041 seconds.
-#>
-#> Final OFV = 67.55323
-#> Parameters: -15.34878
-#>
-
-# Only integer values allowed
-if (FALSE) {
-res_int <- optim_ARS(50, fw, allowed_values = seq(-50,100,by=1))
-}
-
-if (FALSE) {
- #plot of the function and solutions
- require(graphics)
- plot(fw, -50, 50, n = 1000, main = "Minimizing 'wild function'")
- points(-15.81515, fw(-15.81515), pch = 16, col = "red", cex = 1)
- points(res1$par, res1$ofv, pch = 16, col = "green", cex = 1)
- points(res2$par, res2$ofv, pch = 16, col = "blue", cex = 1)
-}
-
-# optim_ARS does not work great for hard to find minima on flat surface:
-# Rosenbrock Banana function
-# f(x, y) = (a-x)^2 + b(y-x^2)^2
-# global minimum at (x, y)=(a, a^2), where f(x, y)=0.
-# Usually a = 1 and b = 100.
-if (FALSE) {
- fr <- function(x,a=1,b=100) {
- x1 <- x[1]
- x2 <- x[2]
- b*(x2 - x1*x1)^2 + (a - x1)^2
- }
-
- res3 <- optim_ARS(c(-1.2,1), fr,lower = -5, upper = 5)
-
- # plot the surface
- x <- seq(-50, 50, length= 30)
- y <- x
- f <- function(x,y){apply(cbind(x,y),1,fr)}
- z <- outer(x, y, f)
- persp(x, y, z, theta = 30, phi = 30, expand = 0.5, col = "lightblue", ticktype="detailed") -> res
- points(trans3d(1, 1, 0, pmat = res), col = 2, pch = 16,cex=2)
- points(trans3d(res3$par[1], res3$par[1], res3$ofv, pmat = res), col = "green", pch = 16,cex=2)
-}
-
-# box constraints
-flb <- function(x){
- p <- length(x)
- sum(c(1, rep(4, p-1)) * (x - c(1, x[-p])^2)^2)
-}
-## 25-dimensional box constrained
-#optim(rep(3, 25), flb,lower = rep(2, 25), upper = rep(4, 25),method = "L-BFGS-B")
-res_box <- optim_ARS(rep(3, 25), flb,lower = rep(2, 25), upper = rep(4, 25))
-#> Initial OFV = 3460
-#> It. 5 | OFV = 2893.22
-#> It. 10 | OFV = 2843.53
-#> It. 15 | OFV = 2843.53
-#> It. 20 | OFV = 2534.71
-#> It. 25 | OFV = 2534.71
-#> It. 30 | OFV = 2534.71
-#> It. 35 | OFV = 2534.71
-#> It. 40 | OFV = 2534.71
-#> It. 45 | OFV = 2534.71
-#> It. 50 | OFV = 2534.71
-#> It. 55 | OFV = 2534.71
-#> It. 60 | OFV = 2534.71
-#> It. 65 | OFV = 2534.71
-#> It. 70 | OFV = 2534.71
-#> It. 75 | OFV = 2528.5
-#> It. 80 | OFV = 2352.4
-#> It. 85 | OFV = 1971.58
-#> It. 90 | OFV = 1842.28
-#> It. 95 | OFV = 1831.86
-#> It. 100 | OFV = 1760.66
-#> It. 105 | OFV = 1656.85
-#> It. 110 | OFV = 1640.83
-#> It. 115 | OFV = 1504.39
-#> It. 120 | OFV = 1504.25
-#> It. 125 | OFV = 1283.46
-#> It. 130 | OFV = 1272.11
-#> It. 135 | OFV = 1244.14
-#> It. 140 | OFV = 1244.14
-#> It. 145 | OFV = 1189.71
-#> It. 150 | OFV = 1093.24
-#> It. 155 | OFV = 1093.24
-#> It. 160 | OFV = 817.1
-#> It. 165 | OFV = 817.1
-#> It. 170 | OFV = 763.001
-#> It. 175 | OFV = 763.001
-#> It. 180 | OFV = 749.85
-#> It. 185 | OFV = 749.85
-#> It. 190 | OFV = 749.85
-#> It. 195 | OFV = 746.645
-#> It. 200 | OFV = 746.645
-#> It. 205 | OFV = 724.258
-#> It. 210 | OFV = 724.258
-#> It. 215 | OFV = 724.258
-#> It. 220 | OFV = 724.258
-#> It. 225 | OFV = 665.8
-#> It. 230 | OFV = 612.601
-#> It. 235 | OFV = 612.601
-#> It. 240 | OFV = 612.601
-#> It. 245 | OFV = 602.118
-#> It. 250 | OFV = 602.118
-#> It. 255 | OFV = 602.118
-#> It. 260 | OFV = 602.118
-#> It. 265 | OFV = 535.288
-#> It. 270 | OFV = 535.288
-#> It. 275 | OFV = 520.06
-#> It. 280 | OFV = 520.06
-#> It. 285 | OFV = 520.06
-#> It. 290 | OFV = 520.06
-#> It. 295 | OFV = 520.06
-#> It. 300 | OFV = 520.06
-#> It. 305 | OFV = 520.06
-#> It. 310 | OFV = 520.06
-#> It. 315 | OFV = 520.06
-#> It. 320 | OFV = 520.06
-#> It. 325 | OFV = 520.06
-#> It. 330 | OFV = 520.06
-#> It. 335 | OFV = 520.06
-#> It. 340 | OFV = 520.06
-#> It. 345 | OFV = 513.043
-#> It. 350 | OFV = 504.66
-#> It. 355 | OFV = 504.66
-#> It. 360 | OFV = 504.66
-#> It. 365 | OFV = 504.66
-#> It. 370 | OFV = 504.66
-#> It. 375 | OFV = 504.66
-#> It. 380 | OFV = 499.84
-#> It. 385 | OFV = 480.001
-#> It. 390 | OFV = 480.001
-#> It. 395 | OFV = 480.001
-#> It. 400 | OFV = 480.001
-#>
-#> Total iterations: 400
-#> Elapsed time: 0.084 seconds.
-#>
-#> Final OFV = 480.0015
-#> Parameters: 2 2 2.016557 2.168674 2.047529 2 2 2 2 2.09281 2 2 2 2 2 2.040247 2 2 2.220732 2.207626 2.156515 2.435454 2.29775 2.139542 3.804459
-#>
-
-
-## Combinatorial optimization: Traveling salesman problem
-eurodistmat <- as.matrix(eurodist)
-
-distance <- function(sq) { # Target function
- sq2 <- embed(sq, 2)
- sum(eurodistmat[cbind(sq2[,2], sq2[,1])])
-}
-
-genseq <- function(sq) { # Generate new candidate sequence
- idx <- seq(2, NROW(eurodistmat)-1)
- changepoints <- sample(idx, size = 2, replace = FALSE)
- tmp <- sq[changepoints[1]]
- sq[changepoints[1]] <- sq[changepoints[2]]
- sq[changepoints[2]] <- tmp
- sq
-}
-
-sq <- c(1:nrow(eurodistmat), 1) # Initial sequence: alphabetic
-res3 <- optim_ARS(sq,distance,generator=genseq) # Near optimum distance around 12842
-#> Initial OFV = 29625
-#> It. 5 | OFV = 29625
-#> It. 10 | OFV = 28278
-#> It. 15 | OFV = 26918
-#> It. 20 | OFV = 26195
-#> It. 25 | OFV = 24669
-#> It. 30 | OFV = 24669
-#> It. 35 | OFV = 24669
-#> It. 40 | OFV = 24323
-#> It. 45 | OFV = 24323
-#> It. 50 | OFV = 24323
-#> It. 55 | OFV = 24323
-#> It. 60 | OFV = 23222
-#> It. 65 | OFV = 23222
-#> It. 70 | OFV = 23050
-#> It. 75 | OFV = 23050
-#> It. 80 | OFV = 23050
-#> It. 85 | OFV = 22581
-#> It. 90 | OFV = 22581
-#> It. 95 | OFV = 22581
-#> It. 100 | OFV = 22581
-#> It. 105 | OFV = 21740
-#> It. 110 | OFV = 21740
-#> It. 115 | OFV = 19232
-#> It. 120 | OFV = 19232
-#> It. 125 | OFV = 19232
-#> It. 130 | OFV = 19232
-#> It. 135 | OFV = 19232
-#> It. 140 | OFV = 19232
-#> It. 145 | OFV = 19043
-#> It. 150 | OFV = 19043
-#> It. 155 | OFV = 19043
-#> It. 160 | OFV = 19043
-#> It. 165 | OFV = 18794
-#> It. 170 | OFV = 18794
-#> It. 175 | OFV = 18794
-#> It. 180 | OFV = 18794
-#> It. 185 | OFV = 18794
-#> It. 190 | OFV = 18794
-#> It. 195 | OFV = 18794
-#> It. 200 | OFV = 18794
-#> It. 205 | OFV = 18794
-#> It. 210 | OFV = 18794
-#> It. 215 | OFV = 18794
-#> It. 220 | OFV = 18794
-#> It. 225 | OFV = 18794
-#> It. 230 | OFV = 18794
-#> It. 235 | OFV = 18794
-#> It. 240 | OFV = 18794
-#> It. 245 | OFV = 18794
-#> It. 250 | OFV = 18794
-#> It. 255 | OFV = 18794
-#> It. 260 | OFV = 17874
-#> It. 265 | OFV = 17874
-#> It. 270 | OFV = 17874
-#> It. 275 | OFV = 17648
-#> It. 280 | OFV = 17648
-#> It. 285 | OFV = 17648
-#> It. 290 | OFV = 17648
-#> It. 295 | OFV = 17648
-#> It. 300 | OFV = 17648
-#> It. 305 | OFV = 17648
-#> It. 310 | OFV = 17648
-#> It. 315 | OFV = 17648
-#> It. 320 | OFV = 17589
-#> It. 325 | OFV = 17571
-#> It. 330 | OFV = 17571
-#> It. 335 | OFV = 17571
-#> It. 340 | OFV = 17571
-#> It. 345 | OFV = 17571
-#> It. 350 | OFV = 17571
-#> It. 355 | OFV = 17571
-#> It. 360 | OFV = 17571
-#> It. 365 | OFV = 17571
-#> It. 370 | OFV = 17571
-#> It. 375 | OFV = 17171
-#> It. 380 | OFV = 17171
-#> It. 385 | OFV = 17171
-#> It. 390 | OFV = 17171
-#> It. 395 | OFV = 17171
-#> It. 400 | OFV = 17171
-#>
-#> Total iterations: 400
-#> Elapsed time: 0.097 seconds.
-#>
-#> Final OFV = 17171
-#> Parameters: 1 19 18 5 11 7 20 12 9 14 2 8 17 16 15 13 6 3 4 10 21 1
-#>
-
-if (FALSE) {
- # plot of initial sequence
- # rotate for conventional orientation
- loc <- -cmdscale(eurodist, add = TRUE)$points
- x <- loc[,1]; y <- loc[,2]
- s <- seq_len(nrow(eurodistmat))
- tspinit <- loc[sq,]
-
- plot(x, y, type = "n", asp = 1, xlab = "", ylab = "",
- main = paste("Initial sequence of traveling salesman problem\n",
- "Distance =",distance(sq)), axes = FALSE)
- arrows(tspinit[s,1], tspinit[s,2], tspinit[s+1,1], tspinit[s+1,2],
- angle = 10, col = "green")
- text(x, y, labels(eurodist), cex = 0.8)
-
- # plot of final sequence from optim_ARS
- tspres <- loc[res3$par,]
- plot(x, y, type = "n", asp = 1, xlab = "", ylab = "",
- main = paste("optim_ARS() 'solving' traveling salesman problem\n",
- "Distance =",distance(c(1,res3$par,1))),axes = FALSE)
- arrows(tspres[s,1], tspres[s,2], tspres[s+1,1], tspres[s+1,2],
- angle = 10, col = "red")
- text(x, y, labels(eurodist), cex = 0.8)
-
- # using optim
- set.seed(123) # chosen to get a good soln relatively quickly
- (res4 <- optim(sq, distance, genseq, method = "SANN",
- control = list(maxit = 30000, temp = 2000, trace = TRUE,
- REPORT = 500)))
-
- tspres <- loc[res4$par,]
- plot(x, y, type = "n", asp = 1, xlab = "", ylab = "",
- main = paste("optim() 'solving' traveling salesman problem\n",
- "Distance =",distance(res4$par)),axes = FALSE)
- arrows(tspres[s,1], tspres[s,2], tspres[s+1,1], tspres[s+1,2],
- angle = 10, col = "red")
- text(x, y, labels(eurodist), cex = 0.8)
-}
-
-# one-dimensional function
-if (FALSE) {
- f <- function(x) abs(x)+cos(x)
- res5 <- optim_ARS(-20,f,lower=-20, upper=20)
-
- curve(f, -20, 20)
- abline(v = res5$par, lty = 4,col="green")
-}
-
-# one-dimensional function
-f <- function(x) (x^2+x)*cos(x) # -10 < x < 10
-res_max <- optim_ARS(0,f,lower=-10, upper=10,maximize=TRUE) # sometimes to local maxima
-#> Initial OFV = 0
-#> It. 5 | OFV = 1.08018
-#> It. 10 | OFV = 32.617
-#> It. 15 | OFV = 35.0597
-#> It. 20 | OFV = 35.0597
-#> It. 25 | OFV = 35.0597
-#> It. 30 | OFV = 35.0597
-#> It. 35 | OFV = 37.8576
-#> It. 40 | OFV = 37.8576
-#> It. 45 | OFV = 37.8576
-#> It. 50 | OFV = 40.0602
-#> It. 55 | OFV = 47.3821
-#> It. 60 | OFV = 47.3821
-#> It. 65 | OFV = 47.3821
-#> It. 70 | OFV = 47.3821
-#> It. 75 | OFV = 47.3821
-#> It. 80 | OFV = 47.6584
-#> It. 85 | OFV = 47.6584
-#> It. 90 | OFV = 47.6584
-#> It. 95 | OFV = 47.699
-#> It. 100 | OFV = 47.699
-#> It. 105 | OFV = 47.699
-#> It. 110 | OFV = 47.699
-#> It. 115 | OFV = 47.699
-#> It. 120 | OFV = 47.699
-#> It. 125 | OFV = 47.699
-#> It. 130 | OFV = 47.699
-#> It. 135 | OFV = 47.699
-#> It. 140 | OFV = 47.699
-#> It. 145 | OFV = 47.699
-#> It. 150 | OFV = 47.699
-#> It. 155 | OFV = 47.699
-#> It. 160 | OFV = 47.699
-#> It. 165 | OFV = 47.699
-#> It. 170 | OFV = 47.699
-#> It. 175 | OFV = 47.699
-#> It. 180 | OFV = 47.699
-#> It. 185 | OFV = 47.7055
-#> It. 190 | OFV = 47.7055
-#> It. 195 | OFV = 47.7055
-#> It. 200 | OFV = 47.7055
-#> It. 205 | OFV = 47.7055
-#> It. 210 | OFV = 47.7055
-#> It. 215 | OFV = 47.7055
-#> It. 220 | OFV = 47.7055
-#> It. 225 | OFV = 47.7055
-#> It. 230 | OFV = 47.7055
-#> It. 235 | OFV = 47.7055
-#> It. 240 | OFV = 47.7055
-#> It. 245 | OFV = 47.7055
-#> It. 250 | OFV = 47.7055
-#> It. 255 | OFV = 47.7055
-#> It. 260 | OFV = 47.7055
-#> It. 265 | OFV = 47.7055
-#> It. 270 | OFV = 47.7055
-#> It. 275 | OFV = 47.7055
-#> It. 280 | OFV = 47.7055
-#> It. 285 | OFV = 47.7055
-#> It. 290 | OFV = 47.7055
-#> It. 295 | OFV = 47.7055
-#> It. 300 | OFV = 47.7055
-#> It. 305 | OFV = 47.7055
-#> It. 310 | OFV = 47.7055
-#> It. 315 | OFV = 47.7055
-#> It. 320 | OFV = 47.7055
-#> It. 325 | OFV = 47.7055
-#> It. 330 | OFV = 47.7055
-#> It. 335 | OFV = 47.7055
-#> It. 340 | OFV = 47.7055
-#> It. 345 | OFV = 47.7055
-#> It. 350 | OFV = 47.7055
-#> It. 355 | OFV = 47.7055
-#> It. 360 | OFV = 47.7055
-#> It. 365 | OFV = 47.7055
-#> It. 370 | OFV = 47.7055
-#> It. 375 | OFV = 47.7055
-#> It. 380 | OFV = 47.7055
-#> Maximum number of identical optimal values reached (max_run=200), optimization stopped.
-#>
-#> Total iterations: 380
-#> Elapsed time: 0.083 seconds.
-#>
-#> Final OFV = 47.70545
-#> Parameters: 6.563052
-#>
-
-if (FALSE) {
- res_min <- optim_ARS(0,f,lower=-10, upper=10) # sometimes to local minima
-
- curve(f, -10, 10)
- abline(v = res_min$par, lty = 4,col="green")
- abline(v = res_max$par, lty = 4,col="red")
-}
-
-
-# two-dimensional Rastrigin function
-#It has a global minimum at f(x) = f(0) = 0.
-if (FALSE) {
- Rastrigin <- function(x1, x2){
- 20 + x1^2 + x2^2 - 10*(cos(2*pi*x1) + cos(2*pi*x2))
- }
-
-
- x1 <- x2 <- seq(-5.12, 5.12, by = 0.1)
- z <- outer(x1, x2, Rastrigin)
-
- res6 <- optim_ARS(c(-4,4),function(x) Rastrigin(x[1], x[2]),lower=-5.12, upper=5.12)
-
- # color scale
- nrz <- nrow(z)
- ncz <- ncol(z)
- jet.colors <-
- colorRampPalette(c("#00007F", "blue", "#007FFF", "cyan",
- "#7FFF7F", "yellow", "#FF7F00", "red", "#7F0000"))
- # Generate the desired number of colors from this palette
- nbcol <- 100
- color <- jet.colors(nbcol)
- # Compute the z-value at the facet centres
- zfacet <- z[-1, -1] + z[-1, -ncz] + z[-nrz, -1] + z[-nrz, -ncz]
- # Recode facet z-values into color indices
- facetcol <- cut(zfacet, nbcol)
- persp(x1, x2, z, col = color[facetcol], phi = 30, theta = 30)
- filled.contour(x1, x2, z, color.palette = jet.colors)
-}
-
-
-## Parallel computation
-## works better when each evaluation takes longer
-## here we have added extra time to the computations
-## just to show that it works
-if (FALSE) {
- res7 <- optim_ARS(c(-4,4),function(x){Sys.sleep(0.01); Rastrigin(x[1], x[2])},
- lower=-5.12, upper=5.12)
- res8 <- optim_ARS(c(-4,4),function(x){Sys.sleep(0.01); Rastrigin(x[1], x[2])},
- lower=-5.12, upper=5.12,parallel = T)
- res9 <- optim_ARS(c(-4,4),function(x){Sys.sleep(0.01); Rastrigin(x[1], x[2])},
- lower=-5.12, upper=5.12,parallel = T,parallel_type = "snow")
-}
-
optim_LS
performs sequential grid search optimization of an arbitrary function with respect
-to each of the parameters to be optimized over.
-The function works for both discrete and continuous optimization parameters
-and allows for box-constraints (by using the upper and lower function arguments) or sets of allowed values (by using the
-allowed_values function argument) for all parameters, or on a parameter per parameter basis.
optim_LS(
- par,
- fn,
- lower = NULL,
- upper = NULL,
- allowed_values = NULL,
- line_length = 50,
- trace = TRUE,
- maximize = F,
- parallel = F,
- parallel_type = NULL,
- num_cores = NULL,
- mrgsolve_model = NULL,
- seed = round(runif(1, 0, 1e+07)),
- allow_replicates = TRUE,
- replicates_index = seq(1, length(par)),
- ofv_initial = NULL,
- closed_bounds = TRUE,
- ...
-)
A vector of initial values for the parameters to be optimized over.
A function to be minimized (or maximized), -with first argument the vector of parameters over which minimization is to take place. -It should return a scalar result.
Lower bounds on the parameters. A vector.
Upper bounds on the parameters. A vector.
A list containing allowed values for each parameter list(par1=c(2,3,4,5,6),par2=c(5,6,7,8))
.
-A vector containing allowed values for all parameters is also allowed c(2,3,4,5,6)
.
The number of different parameter values per parameter to evaluate. The values are -selected as an evenly spaced grid between the upper and lower bounds.
Should the algorithm output results intermittently.
Should the function be maximized? Default is to minimize.
Should we use parallel computations?
Which type of parallelization should be used?
-Can be "snow" or "multicore". "snow" works on Linux-like systems & Windows. "multicore" works only on
-Linux-like systems. By default this is chosen for you depending on your operating system.
-See start_parallel
.
The number of cores to use in the parallelization. By default is set to the number
- output from
-parallel::detectCores()
.
-See start_parallel
.
If the computations require a mrgsolve model and you
-are using the "snow" method then you need to specify the name of the model
-object created by mread
or mcode
.
The random seed to use in the algorithm,
Should the algorithm allow parameters to have the same value?
A vector, the same length as the parameters. -If two values are the same in this vector then the parameters may not assume the same value in the optimization.
An initial objective function value (OFV). If not NULL then the initial design is not evaluated -and the OFV value is assumed to be this number.
Are the upper and lower limits open (boundaries not allowed) or closed (boundaries allowed) bounds?
Additional arguments passed to fn
and start_parallel
.
M. Foracchia, A.C. Hooker, P. Vicini and A. Ruggeri, "PopED, a software fir optimal -experimental design in population kinetics", Computer Methods and Programs in Biomedicine, 74, 2004.
J. Nyberg, S. Ueckert, E.A. Stroemberg, S. Hennig, M.O. Karlsson and A.C. Hooker, "PopED: An extended, -parallelized, nonlinear mixed effects models optimal design tool", -Computer Methods and Programs in Biomedicine, 108, 2012.
Other Optimize:
-Doptim()
,
-LEDoptim()
,
-RS_opt()
,
-a_line_search()
,
-bfgsb_min()
,
-calc_autofocus()
,
-calc_ofv_and_grad()
,
-mfea()
,
-optim_ARS()
,
-poped_optim_1()
,
-poped_optim_2()
,
-poped_optim_3()
,
-poped_optimize()
,
-poped_optim()
# "wild" function
-fw <- function(x) 10*sin(0.3*x)*sin(1.3*x^2) + 0.00001*x^4 + 0.2*x+80
-
-# Global minimum of 67.47 at about -15.81515
-(fw_min <- fw(-15.81515))
-#> [1] 67.46773
-
-if (interactive()){
- #plot of the function
- require(graphics)
- plot(fw, -50, 50, n = 10000, main = "Minimizing 'wild function'")
-
- # Known minimum
- points(-15.81515, fw_min, pch = 21, col = "red", cex = 1.5)
-}
-
-# optimization with fewer function evaluations
-# compared to SANN: see examples in '?optim'
-res1 <- optim_LS(50, fw,lower = -50, upper=50, line_length = 10000)
-#>
-#> Initial parameters: 50
-#> Initial OFV: 159.0012
-#>
-#> Searching parameter 1
-#> Changed from 50 to -15.8166 ; OFV = 67.485
-#>
-#> Elapsed time: 0.017 seconds.
-#>
-#> Final OFV = 67.48502
-#> Parameters: -15.81658
-#>
-
-if (interactive()){
- require(graphics)
- plot(fw, -20, 0, n = 10000, main = "Minimizing 'wild function'")
-
- # Known minimum
- points(-15.81515, fw_min, pch = 21, col = "red", cex = 1.5)
-
- #plot of the optimization
- points(res1$par, res1$ofv, pch = 16, col = "green", cex = 1)
-}
-
-# Upper and lower bounds and line_length should be considered carefully
-res2 <- optim_LS(50, fw, lower=-Inf,upper=Inf,line_length = 10000)
-#>
-#> Initial parameters: 50
-#> Initial OFV: 159.0012
-#>
-#> Searching parameter 1
-#> Changed from 50 to -5.0055 ; OFV = 69.8766
-#>
-#> Elapsed time: 0.018 seconds.
-#>
-#> Final OFV = 69.87659
-#> Parameters: -5.005501
-#>
-
-# Only integer values allowed
-res_int <- optim_LS(50, fw, allowed_values = seq(-50,50,by=1))
-#>
-#> Initial parameters: 50
-#> Initial OFV: 159.0012
-#>
-#> Searching parameter 1
-#> Changed from 50 to -17 ; OFV = 68.5368
-#>
-#> Elapsed time: 0 seconds.
-#>
-#> Final OFV = 68.53679
-#> Parameters: -17
-#>
-
-
-# Rosenbrock Banana function
-# f(x, y) = (a-x)^2 + b*(y-x^2)^2
-# global minimum at (x, y)=(a, a^2), where f(x, y)=0.
-# Usually a = 1 and b = 100 so x=1 and y=1
-if (interactive()){
- fr <- function(x,a=1,b=100) {
- x1 <- x[1]
- x2 <- x[2]
- b*(x2 - x1*x1)^2 + (a - x1)^2
- }
-
- res3 <- optim_LS(c(-1.2,1), fr,lower = -5, upper = 5, line_length = 1000)
-
- # plot the surface
- x <- seq(-50, 50, length= 30)
- y <- x
- f <- function(x,y){apply(cbind(x,y),1,fr)}
- z <- outer(x, y, f)
- persp(x, y, z, theta = 30, phi = 30, expand = 0.5, col = "lightblue", ticktype="detailed") -> res
- points(trans3d(1, 1, 0, pmat = res), col = 2, pch = 16,cex=2)
- points(trans3d(res3$par[1], res3$par[1], res3$ofv, pmat = res), col = "green", pch = 16,cex=1.5)
-}
-
-# box constraints
-flb <- function(x){
- p <- length(x)
- sum(c(1, rep(4, p-1)) * (x - c(1, x[-p])^2)^2)
-}
-
-## 25-dimensional box constrained
-if (interactive()){
- optim(rep(3, 25), flb,lower = rep(2, 25), upper = rep(4, 25),method = "L-BFGS-B")
-}
-res_box <- optim_LS(rep(3, 25), flb,
- lower = rep(2, 25),
- upper = rep(4, 25),
- line_length = 1000)
-#>
-#> Initial parameters: 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
-#> Initial OFV: 3460
-#>
-#> Searching parameter 13
-#> Changed from 3 to 2.14414 ; OFV = 3370.22
-#> Searching parameter 22
-#> Changed from 3 to 2.14414 ; OFV = 3280.43
-#> Searching parameter 12
-#> Changed from 3 to 2 ; OFV = 3158.2
-#> Searching parameter 9
-#> Changed from 3 to 2.14414 ; OFV = 3068.42
-#> Searching parameter 8
-#> Changed from 3 to 2 ; OFV = 2946.18
-#> Searching parameter 17
-#> Changed from 3 to 2.14414 ; OFV = 2856.4
-#> Searching parameter 24
-#> Changed from 3 to 2.14414 ; OFV = 2766.62
-#> Searching parameter 10
-#> Changed from 3 to 2 ; OFV = 2643.4
-#> Searching parameter 1
-#> Changed from 3 to 2 ; OFV = 2500.4
-#> Searching parameter 14
-#> Changed from 3 to 2 ; OFV = 2377.18
-#> Searching parameter 2
-#> Changed from 3 to 2 ; OFV = 2249.18
-#> Searching parameter 20
-#> Changed from 3 to 2.14414 ; OFV = 2159.39
-#> Searching parameter 21
-#> Changed from 3 to 2 ; OFV = 2001.94
-#> Searching parameter 4
-#> Changed from 3 to 2.14414 ; OFV = 1912.15
-#> Searching parameter 3
-#> Changed from 3 to 2 ; OFV = 1749.92
-#> Searching parameter 16
-#> Changed from 3 to 2 ; OFV = 1627.69
-#> Searching parameter 5
-#> Changed from 3 to 2 ; OFV = 1504.46
-#> Searching parameter 7
-#> Changed from 3 to 2 ; OFV = 1376.46
-#> Searching parameter 25
-#> Changed from 3 to 4 ; OFV = 1367.69
-#> Searching parameter 11
-#> Changed from 3 to 2 ; OFV = 1199.69
-#> Searching parameter 23
-#> Changed from 3 to 2 ; OFV = 1042.23
-#> Searching parameter 6
-#> Changed from 3 to 2 ; OFV = 874.23
-#> Searching parameter 19
-#> Changed from 3 to 2 ; OFV = 751.996
-#> Searching parameter 18
-#> Changed from 3 to 2 ; OFV = 588.775
-#> Searching parameter 15
-#> Changed from 3 to 2 ; OFV = 420.775
-#>
-#> Elapsed time: 0.071 seconds.
-#>
-#> Final OFV = 420.7749
-#> Parameters: 2 2 2 2.144144 2 2 2 2 2.144144 2 2 2 2.144144 2 2 2 2.144144 2 2 2.144144 2 2.144144 2 2.144144 4
-#>
-
-# one-dimensional function
-if (interactive()){
- f <- function(x) abs(x)+cos(x)
- res5 <- optim_LS(-20,f,lower=-20, upper=20, line_length = 500)
-
- curve(f, -20, 20)
- abline(v = res5$par, lty = 4,col="green")
-}
-
-# one-dimensional function
-f <- function(x) (x^2+x)*cos(x) # -10 < x < 10
-res_max <- optim_LS(0,f,lower=-10, upper=10,maximize=TRUE,line_length = 1000)
-#>
-#> Initial parameters: 0
-#> Initial OFV: 0
-#>
-#> Searching parameter 1
-#> Changed from 0 to 6.55656 ; OFV = 47.7052
-#>
-#> Elapsed time: 0.001 seconds.
-#>
-#> Final OFV = 47.7052
-#> Parameters: 6.556557
-#>
-
-if (interactive()){
- res_min <- optim_LS(0,f,lower=-10, upper=10, line_length = 1000)
-
- curve(f, -10, 10)
- abline(v = res_min$par, lty = 4,col="green")
- abline(v = res_max$par, lty = 4,col="red")
-}
-
-
-# two-dimensional Rastrigin function
-#It has a global minimum at f(x) = f(0) = 0.
-if (interactive()){
- Rastrigin <- function(x1, x2){
- 20 + x1^2 + x2^2 - 10*(cos(2*pi*x1) + cos(2*pi*x2))
- }
-
-
- x1 <- x2 <- seq(-5.12, 5.12, by = 0.1)
- z <- outer(x1, x2, Rastrigin)
-
- res6 <- optim_LS(c(-4,4),function(x) Rastrigin(x[1], x[2]),
- lower=-5.12, upper=5.12, line_length = 1000)
-
- # color scale
- nrz <- nrow(z)
- ncz <- ncol(z)
- jet.colors <-
- colorRampPalette(c("#00007F", "blue", "#007FFF", "cyan",
- "#7FFF7F", "yellow", "#FF7F00", "red", "#7F0000"))
- # Generate the desired number of colors from this palette
- nbcol <- 100
- color <- jet.colors(nbcol)
- # Compute the z-value at the facet centres
- zfacet <- z[-1, -1] + z[-1, -ncz] + z[-nrz, -1] + z[-nrz, -ncz]
- # Recode facet z-values into color indices
- facetcol <- cut(zfacet, nbcol)
- persp(x1, x2, z, col = color[facetcol], phi = 30, theta = 30)
- filled.contour(x1, x2, z, color.palette = jet.colors)
-}
-
-
-## Parallel computation
-## works better when each evaluation takes longer
-## here we have added extra time to the computations
-## just to show that it works
-if (interactive()){
- res7 <- optim_LS(c(-4,4),function(x){Sys.sleep(0.01); Rastrigin(x[1], x[2])},
- lower=-5.12, upper=5.12, line_length = 200)
- res8 <- optim_LS(c(-4,4),function(x){Sys.sleep(0.01); Rastrigin(x[1], x[2])},
- lower=-5.12, upper=5.12, line_length = 200, parallel = TRUE)
- res9 <- optim_LS(c(-4,4),function(x){Sys.sleep(0.01); Rastrigin(x[1], x[2])},
- lower=-5.12, upper=5.12, line_length = 200, parallel = TRUE,
- parallel_type = "snow")
-}
-
R/optimize_n.R
- optimize_groupsize.Rd
Title Optimize the proportion of individuals in the design groups
-A PopED database.
The proportions of individuals in each group -(relative to the total number of individuals) -to start the optimization from.
Should there be tracing of the optimization? Value can be integer values. -Larger numbers give more information.
A list of the initial objective function value, optimal proportions, -the objective function value with those proportions, -the optimal number of individuals in each group (with integer number of individuals), -and the objective function value with that number of individuals.
-# 2 design groups with either early or late samples
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
- },
- fError_fun=feps.add.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(0.01,0.25),
- xt=list(c(1,2,3),c(4,5,20,120)),
- groupsize=50,
- minxt=0.01,
- maxxt=120,
- a=70,
- mina=0.01,
- maxa=100)
-
-
-plot_model_prediction(poped.db)
-
-
-evaluate_design(poped.db)
-#> $ofv
-#> [1] 57.34239
-#>
-#> $fim
-#> CL V KA d_CL d_V d_KA
-#> CL 20100.83363 100.60318 57.19595 0.0000000 0.0000 0.0000000
-#> V 100.60318 47.77375 -18.43690 0.0000000 0.0000 0.0000000
-#> KA 57.19595 -18.43690 80.55401 0.0000000 0.0000 0.0000000
-#> d_CL 0.00000 0.00000 0.00000 2019.7601648 73.4525 0.6961553
-#> d_V 0.00000 0.00000 0.00000 73.4524996 48705.8108 117.2176533
-#> d_KA 0.00000 0.00000 0.00000 0.6961553 117.2177 51.8762750
-#> SIGMA[1,1] 0.00000 0.00000 0.00000 1428.9648684 31892.5113 417.9515723
-#> SIGMA[2,2] 0.00000 0.00000 0.00000 274.2990996 640.9862 10.3145690
-#> SIGMA[1,1] SIGMA[2,2]
-#> CL 0.0000 0.00000
-#> V 0.0000 0.00000
-#> KA 0.0000 0.00000
-#> d_CL 1428.9649 274.29910
-#> d_V 31892.5113 640.98623
-#> d_KA 417.9516 10.31457
-#> SIGMA[1,1] 353788.5599 6967.23365
-#> SIGMA[2,2] 6967.2337 236.40519
-#>
-#> $rse
-#> CL V KA d_CL d_V d_KA SIGMA[1,1]
-#> 4.742175 1.908239 11.706099 38.149149 23.388391 23.297863 28.859652
-#> SIGMA[2,2]
-#> 48.150485
-#>
-
-
-# what are the optimal proportions of
-# individuals in the two groups in the study?
-(n_opt <- optimize_groupsize(poped.db))
-#> Initial proportions:
-#> 0.5 0.5
-#>
-#> initial value -57.342391
-#> final value -57.747204
-#> converged
-#>
-#> Optimized proportions:
-#> 0.2984998 0.7015002
-#>
-#> Optimized number of individuals per group
-#> OFV: 57.74718
-#> 30 70
-#>
-#> $initial_props
-#> [1] 0.5 0.5
-#>
-#> $initial_ofv
-#> [1] 57.34239
-#>
-#> $opt_props
-#> [1] 0.2984998 0.7015002
-#>
-#> $opt_ofv_with_props
-#> [1] 57.7472
-#>
-#> $opt_n_per_group
-#> [1] 30 70
-#>
-#> $opt_ofv_with_n
-#> [1] 57.74718
-#>
-
-# How many individuals in the original design are needed to achieve an
-# efficiency of 1 compared to the optimized design with n=100?
-optimize_n_eff(poped.db,
- ofv_ref=n_opt$opt_ofv_with_n)
-#> [1] 105.19
-
-
-
-
R/optimize_n.R
- optimize_n_dist.Rd
Title Optimize the proportion of individuals in the design groups
-optimize_n_dist( - poped.db, - props = c(poped.db$design$groupsize/sum(poped.db$design$groupsize)), - ... -)- -
poped.db | -A PopED database. |
-
---|---|
props | -The proportions of individuals in each group -(relative to the total number of individuals) to start the optimization from. |
-
... | -- |
A list of the optimal proportions, the optimal number of individuals in each group, -and the initial and final objective function values.
- --poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL, - fg_fun=function(x,a,bpop,b,bocc){ - parameters=c(CL=bpop[1]*exp(b[1]), - V=bpop[2]*exp(b[2]), - KA=bpop[3]*exp(b[3]), - Favail=bpop[4], - DOSE=a[1]) - return(parameters) - }, - fError_fun=feps.add.prop, - bpop=c(CL=0.15, V=8, KA=1.0, Favail=1), - notfixed_bpop=c(1,1,1,0), - d=c(CL=0.07, V=0.02, KA=0.6), - sigma=c(PROP=0.01,ADD=0.25), - xt=list(c(1,2,3),c(4,5,20,120)), - groupsize=20, - minxt=0.01, - maxxt=120, - a=70, - mina=0.01, - maxa=100) - - - - -plot_model_prediction(poped.db)-(n_opt <- optimize_n_dist(poped.db))#> initial value -50.012065 -#> final value -50.416878 -#> converged#> $initial_props -#> [1] 0.5 0.5 -#> -#> $initial_ofv -#> [1] 50.01207 -#> -#> $opt_props -#> [1] 0.2984998 0.7015002 -#> -#> $opt_ofv -#> [1] 50.41688 -#> -#> $opt_n_per_group -#> [1] 11.93999 28.06001 -#>
optimize HOW MANY n there should be to achieve efficiency=1 compared to a reference OFV
-optimize_n_eff(poped.db, ofv_ref, norm_group_fim = NULL, ...)
A PopED database.
A reference OFV value to compare to.
The FIM per individual in each design group. If NULL
, then
-these are computed.
Arguments passed to evaluate.fim
and efficiency
.
The number of individuals needed.
-# 2 design groups with either early or late samples
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
- },
- fError_fun=feps.add.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(0.01,0.25),
- xt=list(c(1,2,3),c(4,5,20,120)),
- groupsize=50,
- minxt=0.01,
- maxxt=120,
- a=70,
- mina=0.01,
- maxa=100)
-
-
-plot_model_prediction(poped.db)
-
-
-evaluate_design(poped.db)
-#> $ofv
-#> [1] 57.34239
-#>
-#> $fim
-#> CL V KA d_CL d_V d_KA
-#> CL 20100.83363 100.60318 57.19595 0.0000000 0.0000 0.0000000
-#> V 100.60318 47.77375 -18.43690 0.0000000 0.0000 0.0000000
-#> KA 57.19595 -18.43690 80.55401 0.0000000 0.0000 0.0000000
-#> d_CL 0.00000 0.00000 0.00000 2019.7601648 73.4525 0.6961553
-#> d_V 0.00000 0.00000 0.00000 73.4524996 48705.8108 117.2176533
-#> d_KA 0.00000 0.00000 0.00000 0.6961553 117.2177 51.8762750
-#> SIGMA[1,1] 0.00000 0.00000 0.00000 1428.9648684 31892.5113 417.9515723
-#> SIGMA[2,2] 0.00000 0.00000 0.00000 274.2990996 640.9862 10.3145690
-#> SIGMA[1,1] SIGMA[2,2]
-#> CL 0.0000 0.00000
-#> V 0.0000 0.00000
-#> KA 0.0000 0.00000
-#> d_CL 1428.9649 274.29910
-#> d_V 31892.5113 640.98623
-#> d_KA 417.9516 10.31457
-#> SIGMA[1,1] 353788.5599 6967.23365
-#> SIGMA[2,2] 6967.2337 236.40519
-#>
-#> $rse
-#> CL V KA d_CL d_V d_KA SIGMA[1,1]
-#> 4.742175 1.908239 11.706099 38.149149 23.388391 23.297863 28.859652
-#> SIGMA[2,2]
-#> 48.150485
-#>
-
-
-# what are the optimal proportions of
-# individuals in the two groups in the study?
-(n_opt <- optimize_groupsize(poped.db))
-#> Initial proportions:
-#> 0.5 0.5
-#>
-#> initial value -57.342391
-#> final value -57.747204
-#> converged
-#>
-#> Optimized proportions:
-#> 0.2984998 0.7015002
-#>
-#> Optimized number of individuals per group
-#> OFV: 57.74718
-#> 30 70
-#>
-#> $initial_props
-#> [1] 0.5 0.5
-#>
-#> $initial_ofv
-#> [1] 57.34239
-#>
-#> $opt_props
-#> [1] 0.2984998 0.7015002
-#>
-#> $opt_ofv_with_props
-#> [1] 57.7472
-#>
-#> $opt_n_per_group
-#> [1] 30 70
-#>
-#> $opt_ofv_with_n
-#> [1] 57.74718
-#>
-
-# How many individuals in the original design are needed to achieve an
-# efficiency of 1 compared to the optimized design with n=100?
-optimize_n_eff(poped.db,
- ofv_ref=n_opt$opt_ofv_with_n)
-#> [1] 105.19
-
-
-
-
R/optimize_n.R
- optimize_n_rse.Rd
Optimize the number of subjects, -based on the current design and the desired uncertainty of a single parameter
-A PopED database.
The index number of the parameter, currently only bpop parameters are allowed.
The relative standard error (RSE) one would like to achieve (in percent, by default).
Should the RSE be represented as a percentage (T/F)?
A vector of the allowed total number of subjects in the study.
The total number of subjects needed and the RSE of the parameter.
-# 2 design groups with either early or late samples
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
- },
- fError_fun=feps.add.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(0.01,0.25),
- xt=list(c(1,2,3),c(4,5,20,120)),
- groupsize=50,
- minxt=0.01,
- maxxt=120,
- a=70,
- mina=0.01,
- maxa=100)
-
-# plot of the design
-plot_model_prediction(poped.db)
-
-
-# the current RSE values
-evaluate_design(poped.db)$rse
-#> CL V KA d_CL d_V d_KA SIGMA[1,1]
-#> 4.742175 1.908239 11.706099 38.149149 23.388391 23.297863 28.859652
-#> SIGMA[2,2]
-#> 48.150485
-
-# number of individuals if CL should have 10% RSE
-optimize_n_rse(poped.db,
- bpop_idx=1, # for CL
- need_rse=10) # the RSE you want
-#> $n
-#> [1] 24
-#>
-#> $par_rse
-#> CL
-#> 9.679923
-#>
-
-
-
Function generates random samples for a list of parameters
-pargen(par, user_dist_pointer, sample_size, bLHS, sample_number, poped.db)
A matrix describing the parameters. Each row is a parameter and -the matrix has three columns:
First column - Type of -distribution (0-fixed, 1-normal, 2-uniform, 3-user specified, 4-lognormal, -5-Truncated normal).
Second column - Mean of distribution.
Third -column - Variance or range of distribution.
A text string of the name of a function that -generates random samples from a user defined distribution.
The number of random samples per parameter to generate
Logical, indicating if Latin Hypercube Sampling should be used.
The sample number to extract from a user distribution.
A PopED database.
A matrix of random samples of size (sample_size x - number_of_parameters)
-library(PopED)
-
-############# START #################
-## Create PopED database
-## (warfarin example)
-#####################################
-
-## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define model, parameters, initial design
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(prop=0.01),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- a=c(DOSE=70))
-
-############# END ###################
-## Create PopED database
-## (warfarin example)
-#####################################
-
-
-# Adding 40% Uncertainty to fixed effects log-normal (not Favail)
-bpop_vals <- c(CL=0.15, V=8, KA=1.0, Favail=1)
-bpop_vals_ed_ln <- cbind(ones(length(bpop_vals),1)*4, # log-normal distribution
- bpop_vals,
- ones(length(bpop_vals),1)*(bpop_vals*0.4)^2) # 40% of bpop value
-bpop_vals_ed_ln["Favail",] <- c(0,1,0)
-
-pars.ln <- pargen(par=bpop_vals_ed_ln,
- user_dist_pointer=NULL,
- sample_size=1000,
- bLHS=1,
- sample_number=NULL,
- poped.db)
-
-
-# Adding 10% Uncertainty to fixed effects normal-distribution (not Favail)
-bpop_vals_ed_n <- cbind(ones(length(bpop_vals),1)*1, # log-normal distribution
- bpop_vals,
- ones(length(bpop_vals),1)*(bpop_vals*0.1)^2) # 10% of bpop value
-bpop_vals_ed_n["Favail",] <- c(0,1,0)
-
-pars.n <- pargen(par=bpop_vals_ed_n,
- user_dist_pointer=NULL,
- sample_size=1000,
- bLHS=1,
- sample_number=NULL,
- poped.db)
-
-
-# Adding 10% Uncertainty to fixed effects uniform-distribution (not Favail)
-bpop_vals_ed_u <- cbind(ones(length(bpop_vals),1)*2, # uniform distribution
- bpop_vals,
- ones(length(bpop_vals),1)*(bpop_vals*0.1)) # 10% of bpop value
-bpop_vals_ed_u["Favail",] <- c(0,1,0)
-
-pars.u <- pargen(par=bpop_vals_ed_u,
- user_dist_pointer=NULL,
- sample_size=1000,
- bLHS=1,
- sample_number=NULL,
- poped.db)
-
-
-# Adding user defined distributions
-bpop_vals_ed_ud <- cbind(ones(length(bpop_vals),1)*3, # user dfined distribution
- bpop_vals,
- bpop_vals*0.1) # 10% of bpop value
-bpop_vals_ed_ud["Favail",] <- c(0,1,0)
-
-# A normal distribution
-my_dist <- function(...){
- par_vec <- rnorm(c(1,1,1,1),mean=bpop_vals_ed_ud[,2],sd=bpop_vals_ed_ud[,3])
-}
-
-pars.ud <- pargen(par=bpop_vals_ed_ud,
- user_dist_pointer=my_dist,
- sample_size=1000,
- bLHS=1,
- sample_number=NULL,
- poped.db)
-
-
-
R/plot_efficiency_of_windows.R
- plot_efficiency_of_windows.Rd
Function plots the efficiency of windows around the sample time points.
-The function samples from a uniform distribution around the sample time
-points for each group (or each individual with deviate_by_id=TRUE
,
-with slower calculation times) and compares the results with the
-design defined in poped.db
. The maximal and minimal allowed values for all design variables as
-defined in poped.db are respected (e.g. poped.db$design_space$minxt and
-poped.db$design_space$maxxt).
plot_efficiency_of_windows(
- poped.db,
- xt_windows = NULL,
- xt_plus = xt_windows,
- xt_minus = xt_windows,
- iNumSimulations = 100,
- y_eff = TRUE,
- y_rse = TRUE,
- ofv_calc_type = poped.db$settings$ofv_calc_type,
- mean_line = TRUE,
- mean_color = "red",
- deviate_by_id = FALSE,
- parallel = F,
- seed = round(runif(1, 0, 1e+07)),
- ...
-)
A poped database
The distance on one direction from the optimal sample
-times. Can be a number or a matrix of the same size as the xt matrix found
-in poped.db$design$xt
.
The upper distance from the optimal sample times (xt +
-xt_plus). Can be a number or a matrix of the same size as the xt matrix
-found in poped.db$design$xt
.
The lower distance from the optimal sample times (xt -
-xt_minus). Can be a number or a matrix of the same size as the xt matrix
-found in poped.db$design$xt
.
The number of design simulations to make within the -specified windows.
Should one of the plots created have efficiency on the y-axis?
Should created plots include the relative standard error of each -parameter as a value on the y-axis?
OFV calculation type for FIM
1 = "D-optimality". Determinant of the FIM: det(FIM)
2 = "A-optimality". Inverse of the sum of the expected parameter variances: -1/trace_matrix(inv(FIM))
4 = "lnD-optimality". Natural logarithm of the determinant of the FIM: log(det(FIM))
6 = "Ds-optimality". Ratio of the Determinant of the FIM and the Determinant of the uninteresting -rows and columns of the FIM: det(FIM)/det(FIM_u)
7 = Inverse of the sum of the expected parameter RSE: 1/sum(get_rse(FIM,poped.db,use_percent=FALSE))
Should a mean value line be created?
The color of the mean value line.
Should the computations look at deviations per -individual instead of per group?
Should we use parallel computations (T/F)?
-Other options can be defined in this function and passed
-to start_parallel
. See especially
-the options dlls
and mrgsolve_model
from that function
-if you have a model defined with
-compiled code or are using mrgsolve.
The random seed to use.
Extra arguments passed to evaluate.fim
A ggplot object.
-Other evaluate_design:
-evaluate.fim()
,
-evaluate_design()
,
-evaluate_power()
,
-get_rse()
,
-model_prediction()
,
-plot_model_prediction()
Other Simulation:
-model_prediction()
,
-plot_model_prediction()
Other Graphics:
-plot_model_prediction()
library(PopED)
-
-############# START #################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## Optimization using an additive + proportional reidual error
-## to avoid sample times at very low concentrations (time 0 or very late samples).
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(prop=0.01,add=0.25),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0.01,
- maxxt=120,
- a=c(DOSE=70),
- mina=c(DOSE=0.01),
- maxa=c(DOSE=100))
-
-############# END ###################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-
-
-
-# Examine efficiency of sampling windows at plus/minus 0.5 hours from
-# sample points in the design
-plot_efficiency_of_windows(poped.db,xt_windows=0.5)
-
-
-
-if(interactive()){
-
- plot_efficiency_of_windows(poped.db,
- xt_plus=c( 0.5,1,2,1,2,3,7,1),
- xt_minus=c( 0.1,2,5,4,2,3,6,2))
-
- plot_efficiency_of_windows(poped.db,xt_windows=c( 0.5,1,2,1,2,3,7,1))
-
-
- plot_efficiency_of_windows(poped.db,
- xt_plus=c( 0.5,1,2,1,2,3,7,1),
- xt_minus=c( 0.1,2,5,4,2,3,6,2),
- y_rse=FALSE)
-
- plot_efficiency_of_windows(poped.db,
- xt_plus=c( 0.5,1,2,1,2,3,7,1),
- xt_minus=c( 0.1,2,5,4,2,3,6,2),
- y_eff=FALSE)
-}
-
-
Function plots model predictions for the typical value in the population, -individual predictions and data predictions.
-plot_model_prediction(
- poped.db,
- model_num_points = 100,
- groupsize_sim = 100,
- separate.groups = F,
- sample.times = T,
- sample.times.IPRED = F,
- sample.times.DV = F,
- PRED = T,
- IPRED = F,
- IPRED.lines = F,
- IPRED.lines.pctls = F,
- alpha.IPRED.lines = 0.1,
- alpha.IPRED = 0.3,
- sample.times.size = 4,
- DV = F,
- alpha.DV = 0.3,
- DV.lines = F,
- DV.points = F,
- alpha.DV.lines = 0.3,
- alpha.DV.points = 0.3,
- sample.times.DV.points = F,
- sample.times.DV.lines = F,
- alpha.sample.times.DV.points = 0.3,
- alpha.sample.times.DV.lines = 0.3,
- y_lab = "Model Predictions",
- facet_scales = "fixed",
- facet_label_names = T,
- model.names = NULL,
- DV.mean.sd = FALSE,
- PI = FALSE,
- PI_alpha = 0.3,
- ...
-)
A PopED database.
How many extra observation rows should be created in the data frame for each group or individual
-per model. If used then the points are placed evenly between model_minxt
and model_maxxt
. This option
-is used by plot_model_prediction
to simulate the response of the model on a finer grid then the defined design.
-If NULL
then only the input design is used. Can be a single value or a vector the same length as the number of models.
How many individuals per group should be -simulated when DV=TRUE or IPRED=TRUE to create prediction intervals?
Should there be separate plots for each group.
Should sample times be shown on the plots.
Should sample times be shown based on the IPRED y-values.
Should sample times be shown based on the DV y-values.
Should a PRED line be drawn.
Should we simulate individual predictions?
Should IPRED lines be drawn?
Should lines be drawn at the chosen percentiles of the IPRED values?
What should the transparency for the IPRED.lines be?
What should the transparency of the IPRED CI?
What should the size of the sample.times be?
should we simulate observations?
What should the transparency of the DV CI?
Should DV lines be drawn?
Should DV points be drawn?
What should the transparency for the DV.lines be?
What should the transparency for the DV.points be?
TRUE or FALSE.
TRUE or FALSE.
What should the transparency for the sample.times.DV.points be?
What should the transparency for the sample.times.DV.lines be?
The label of the y-axis.
Can be "free", "fixed", "free_x" or "free_y"
TRUE or FALSE
A vector of names of the response model/s (the length of the -vector should be equal to the number of response models). It is Null by default.
Plot the mean and standard deviation of simulated observations.
Plot prediction intervals for the expected data given the model.
-Predictions are based on first-order approximations to
-the model variance and a normality assumption of that variance. As such these computations are
-more approximate than using DV=T
and groupsize_sim = some large number
.
The transparency of the PI.
Additional arguments passed to the model_prediction
function.
A ggplot object. If you would like to further edit this plot don't
-forget to load the ggplot2 library using library(ggplot2)
.
Other evaluate_design:
-evaluate.fim()
,
-evaluate_design()
,
-evaluate_power()
,
-get_rse()
,
-model_prediction()
,
-plot_efficiency_of_windows()
Other Simulation:
-model_prediction()
,
-plot_efficiency_of_windows()
Other Graphics:
-plot_efficiency_of_windows()
## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-library(PopED)
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.md.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> N = floor(xt/TAU) + 1
-#> y = (DOSE * Favail/V) * (KA/(KA - CL/V)) * (exp(-CL/V *
-#> (xt - (N - 1) * TAU)) * (1 - exp(-N * CL/V * TAU))/(1 -
-#> exp(-CL/V * TAU)) - exp(-KA * (xt - (N - 1) * TAU)) *
-#> (1 - exp(-N * KA * TAU))/(1 - exp(-KA * TAU)))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1104c9b70>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_file="ff.PK.1.comp.oral.sd.CL",
- fg_file="sfg",
- fError_file="feps.prop",
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=0.01,
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0,
- maxxt=120,
- a=70)
-#> Warning: cannot open file 'sfg': No such file or directory
-#> Error in file(filename, "r", encoding = encoding): cannot open the connection
-
-## create plot of model without variability
-plot_model_prediction(poped.db)
-#> Error in eval(expr, envir, enclos): object 'poped.db' not found
-
-## create plot of model with variability by simulating from OMEGA and SIGMA
-plot_model_prediction(poped.db,IPRED=TRUE,DV=TRUE)
-#> Error in eval(expr, envir, enclos): object 'poped.db' not found
-
-## create plot of model with variability by
-## computing the expected variance (using an FO approximation)
-## and then computing a prediction interval
-## based on an assumption of normality
-## computation is faster but less accurate
-## compared to using DV=TRUE (and groupsize_sim = 500)
-plot_model_prediction(poped.db,PI=TRUE)
-#> Error in eval(expr, envir, enclos): object 'poped.db' not found
-
-##-- Model: One comp first order absorption + inhibitory imax
-## -- works for both mutiple and single dosing
-ff <- function(model_switch,xt,parameters,poped.db){
- with(as.list(parameters),{
-
- y=xt
- MS <- model_switch
-
- # PK model
- N = floor(xt/TAU)+1
- CONC=(DOSE*Favail/V)*(KA/(KA - CL/V)) *
- (exp(-CL/V * (xt - (N - 1) * TAU)) * (1 - exp(-N * CL/V * TAU))/(1 - exp(-CL/V * TAU)) -
- exp(-KA * (xt - (N - 1) * TAU)) * (1 - exp(-N * KA * TAU))/(1 - exp(-KA * TAU)))
-
- # PD model
- EFF = E0*(1 - CONC*IMAX/(IC50 + CONC))
-
- y[MS==1] = CONC[MS==1]
- y[MS==2] = EFF[MS==2]
-
- return(list( y= y,poped.db=poped.db))
- })
-}
-
-## -- parameter definition function
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c( V=bpop[1]*exp(b[1]),
- KA=bpop[2]*exp(b[2]),
- CL=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1],
- TAU = a[2],
- E0=bpop[5]*exp(b[4]),
- IMAX=bpop[6],
- IC50=bpop[7])
- return( parameters )
-}
-
-
-## -- Residual Error function
-feps <- function(model_switch,xt,parameters,epsi,poped.db){
- returnArgs <- ff(model_switch,xt,parameters,poped.db)
- y <- returnArgs[[1]]
- poped.db <- returnArgs[[2]]
-
- MS <- model_switch
-
- pk.dv <- y*(1+epsi[,1])+epsi[,2]
- pd.dv <- y*(1+epsi[,3])+epsi[,4]
-
- y[MS==1] = pk.dv[MS==1]
- y[MS==2] = pd.dv[MS==2]
-
- return(list( y= y,poped.db =poped.db ))
-}
-
-poped.db <-
- create.poped.database(
- ff_fun="ff",
- fError_fun="feps",
- fg_fun="sfg",
- groupsize=20,
- m=3,
- bpop=c(V=72.8,KA=0.25,CL=3.75,Favail=0.9,
- E0=1120,IMAX=0.807,IC50=0.0993),
- notfixed_bpop=c(1,1,1,0,1,1,1),
- d=c(V=0.09,KA=0.09,CL=0.25^2,E0=0.09),
- sigma=c(0.04,5e-6,0.09,100),
- notfixed_sigma=c(0,0,0,0),
- xt=c( 1,2,8,240,240,1,2,8,240,240),
- minxt=c(0,0,0,240,240,0,0,0,240,240),
- maxxt=c(10,10,10,248,248,10,10,10,248,248),
- discrete_xt = list(0:248),
- G_xt=c(1,2,3,4,5,1,2,3,4,5),
- bUseGrouped_xt=1,
- model_switch=c(1,1,1,1,1,2,2,2,2,2),
- a=list(c(DOSE=20,TAU=24),c(DOSE=40, TAU=24),c(DOSE=0, TAU=24)),
- maxa=c(DOSE=200,TAU=40),
- mina=c(DOSE=0,TAU=2),
- ourzero=0)
-#> Error in do.call(poped.db$model$fg_pointer, list(0, 0, 0, 0, zeros(poped.db$parameters$NumDocc, poped.db$parameters$NumOcc))): 'what' must be a function or character string
-
-## create plot of model and design
-plot_model_prediction(poped.db,facet_scales="free",
- model.names = c("PK","PD"))
-#> Error in eval(expr, envir, enclos): object 'poped.db' not found
-
-## create plot of model with variability by
-## computing the expected variance (using an FO approximation)
-## and then computing a prediction interval
-## based on an assumption of normality
-## computation is faster but less accurate
-## compared to using DV=TRUE (and groupsize_sim = 500)
-plot_model_prediction(poped.db,facet_scales="free",
- model.names = c("PK","PD"),
- PI=TRUE,
- separate.groups = TRUE)
-#> Error in eval(expr, envir, enclos): object 'poped.db' not found
-
-
-
Function chooses arg1
unless it is NULL
in which case arg2
is chosen.
poped.choose(arg1, arg2)
The first argument
The second argument
Other poped_input:
-convert_variables()
,
-create.poped.database()
,
-create_design_space()
,
-create_design()
,
-downsizing_general_design()
-poped.choose(2,5)
-#> [1] 2
-
-poped.choose("foo",66)
-#> [1] "foo"
-
-poped.choose(NULL,"hello")
-#> [1] "hello"
-
Run the graphical interface for PopED
-poped_gui()
Optimize a design defined in a PopED database using the objective function -described in the database (or in the arguments to this function). The -function works for both discrete and -continuous optimization variables.
-poped_optim(
- poped.db,
- opt_xt = poped.db$settings$optsw[2],
- opt_a = poped.db$settings$optsw[4],
- opt_x = poped.db$settings$optsw[3],
- opt_samps = poped.db$settings$optsw[1],
- opt_inds = poped.db$settings$optsw[5],
- method = c("ARS", "BFGS", "LS"),
- control = list(),
- trace = TRUE,
- fim.calc.type = poped.db$settings$iFIMCalculationType,
- ofv_calc_type = poped.db$settings$ofv_calc_type,
- ds_index = poped.db$parameters$ds_index,
- approx_type = poped.db$settings$iApproximationMethod,
- d_switch = poped.db$settings$d_switch,
- ED_samp_size = poped.db$settings$ED_samp_size,
- bLHS = poped.db$settings$bLHS,
- use_laplace = poped.db$settings$iEDCalculationType,
- out_file = "",
- parallel = F,
- parallel_type = NULL,
- num_cores = NULL,
- mrgsolve_model = NULL,
- loop_methods = ifelse(length(method) > 1, TRUE, FALSE),
- iter_max = 10,
- stop_crit_eff = 1.001,
- stop_crit_diff = NULL,
- stop_crit_rel = NULL,
- ofv_fun = poped.db$settings$ofv_fun,
- maximize = T,
- allow_replicates = TRUE,
- allow_replicates_xt = TRUE,
- allow_replicates_a = TRUE,
- ...
-)
A PopED database.
Should the sample times be optimized?
Should the continuous design variables be optimized?
Should the discrete design variables be optimized?
Are the number of sample times per group being optimized?
Are the number of individuals per group being optimized?
A vector of optimization methods to use in a sequential
-fashion. Options are c("ARS","BFGS","LS","GA")
. c("ARS")
is
-for Adaptive Random Search optim_ARS
. c("LS")
is for
-Line Search optim_LS
. c("BFGS")
is for Method
-"L-BFGS-B" from optim
. c("GA")
is for the
-genetic algorithm from ga
.
Contains control arguments for each method specified.
Should the algorithm output results intermittently.
The method used for calculating the FIM. Potential values:
0 = Full FIM. No assumption that fixed and random effects are uncorrelated.
1 = Reduced FIM. Assume that there is no correlation in the FIM between the fixed and random effects, and set these elements in -the FIM to zero.
2 = weighted models (placeholder).
3 = Not currently used.
4 = Reduced FIM and computing all derivatives with respect to the standard deviation of the residual unexplained variation (sqrt(SIGMA) in NONMEM). -This matches what is done in PFIM, and assumes that the standard deviation of the residual unexplained variation is the estimated parameter -(NOTE: NONMEM estimates the variance of the residual unexplained variation by default).
5 = Full FIM parameterized with A,B,C matrices & derivative of variance.
6 = Calculate one model switch at a time, good for large matrices.
7 = Reduced FIM parameterized with A,B,C matrices & derivative of variance.
OFV calculation type for FIM
1 = "D-optimality". Determinant of the FIM: det(FIM)
2 = "A-optimality". Inverse of the sum of the expected parameter variances: -1/trace_matrix(inv(FIM))
4 = "lnD-optimality". Natural logarithm of the determinant of the FIM: log(det(FIM))
6 = "Ds-optimality". Ratio of the Determinant of the FIM and the Determinant of the uninteresting -rows and columns of the FIM: det(FIM)/det(FIM_u)
7 = Inverse of the sum of the expected parameter RSE: 1/sum(get_rse(FIM,poped.db,use_percent=FALSE))
Ds_index is a vector set to 1 if a parameter is uninteresting, otherwise 0.
-size=(1,num unfixed parameters). First unfixed bpop, then unfixed d, then unfixed docc and last unfixed sigma.
-Default is the fixed effects being important, everything else not important. Used in conjunction with
-ofv_calc_type=6
.
Approximation method for model, 0=FO, 1=FOCE, 2=FOCEI, 3=FOI.
******START OF CRITERION SPECIFICATION OPTIONS**********
D-family design (1) or ED-family design (0) (with or without parameter uncertainty)
Sample size for E-family sampling
How to sample from distributions in E-family calculations. 0=Random Sampling, 1=LatinHyperCube --
Should the Laplace method be used in calculating the expectation of the OFV?
Save output from the optimization to a file.
Should we use parallel computations?
Which type of parallelization should be used?
-Can be "snow" or "multicore". "snow" works on Linux-like systems & Windows. "multicore" works only on
-Linux-like systems. By default this is chosen for you depending on your operating system.
-See start_parallel
.
The number of cores to use in the parallelization. By default is set to the number
- output from
-parallel::detectCores()
.
-See start_parallel
.
If the computations require a mrgsolve model and you
-are using the "snow" method then you need to specify the name of the model
-object created by mread
or mcode
.
Should the optimization methods be looped for
-iter_max
iterations, or until the efficiency of the design after the
-current series (compared to the start of the series) is less than, or equal to,
-stop_crit_eff
?
If line search is used then the algorithm tests if line
-search (always run at the end of the optimization iteration) changes the
-design in any way. If not, the algorithm stops. If yes, then a new
-iteration is run unless iter_max
iterations have already been run.
If loop_methods==TRUE
, the looping will stop if the
-efficiency of the design after the current series (compared to the start of
-the series) is less than, or equal to, stop_crit_eff
(if maximize==FALSE
then 1/stop_crit_eff is the cut
-off and the efficiency must be greater than or equal to this value to stop the looping).
If loop_methods==TRUE
, the looping will stop if the
-difference in criterion value of the design after the current series (compared to the start of
-the series) is less than, or equal to, stop_crit_diff
(if maximize==FALSE
then -stop_crit_diff is the cut
-off and the difference in criterion value must be greater than or equal to this value to stop the looping).
If loop_methods==TRUE
, the looping will stop if the
-relative difference in criterion value of the design after the current series (compared to the start of
-the series) is less than, or equal to, stop_crit_rel
(if maximize==FALSE
then -stop_crit_rel is the cut
-off and the relative difference in criterion value must be greater than or equal to this value to stop the looping).
User defined function used to compute the objective function. The function must have a poped database object as its first -argument and have "..." in its argument list. Can be referenced as a function or as a file name where the function defined in the file has the same name as the file. -e.g. "cost.txt" has a function named "cost" in it.
Should the objective function be maximized or minimized?
Should the algorithm allow optimized design components to have the same value? If FALSE then
-all discrete optimizations will not allow replicates within variable types
-(equivalent to allow_replicates_xt=FALSE
and allow_replicates_a=FALSE
).
Should the algorithm allow optimized xt
design components to have the same value? If FALSE then
-all discrete optimizations will not allow replicates.
Should the algorithm allow optimized a
design components to have the same value? If FALSE then
-all discrete optimizations will not allow replicates.
arguments passed to other functions.
This function takes information from the PopED database supplied as an -argument. The PopED database supplies information about the the model, -parameters, design and methods to use. Some of the arguments coming from the -PopED database can be overwritten; if they are supplied then they are used -instead of the arguments from the PopED database.
-If more than one optimization method is
-specified then the methods are run in series. If loop_methods=TRUE
-then the series of optimization methods will be run for iter_max
-iterations, or until the efficiency of the design after the current series
-(compared to the start of the series) is less than stop_crit_eff
.
M. Foracchia, A.C. Hooker, P. Vicini and A. - Ruggeri, "PopED, a software fir optimal experimental design in population - kinetics", Computer Methods and Programs in Biomedicine, 74, 2004.
J. - Nyberg, S. Ueckert, E.A. Stroemberg, S. Hennig, M.O. Karlsson and A.C. - Hooker, "PopED: An extended, parallelized, nonlinear mixed effects models - optimal design tool", Computer Methods and Programs in Biomedicine, 108, - 2012.
Other Optimize:
-Doptim()
,
-LEDoptim()
,
-RS_opt()
,
-a_line_search()
,
-bfgsb_min()
,
-calc_autofocus()
,
-calc_ofv_and_grad()
,
-mfea()
,
-optim_ARS()
,
-optim_LS()
,
-poped_optim_1()
,
-poped_optim_2()
,
-poped_optim_3()
,
-poped_optimize()
library(PopED)
-
-############# START #################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## Optimization using an additive + proportional reidual error
-## to avoid sample times at very low concentrations (time 0 or very late samples).
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(prop=0.01,add=0.25),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0.01,
- maxxt=120,
- a=c(DOSE=70),
- mina=c(DOSE=0.01),
- maxa=c(DOSE=100))
-
-############# END ###################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-##############
-# D-family Optimization
-##############
-
-# below are a number of ways to optimize the problem
-
-
-# ARS+BFGS+LS optimization of dose
-# optimization with just a few iterations
-# only to check that things are working
-out_1 <- poped_optim(poped.db,opt_a =TRUE,
- control = list(ARS=list(iter=2),
- BFGS=list(maxit=2),
- LS=list(line_length=2)),
- iter_max = 1)
-#> ===============================================================================
-#> Initial design evaluation
-#>
-#> Initial OFV = 55.3964
-#>
-#> Initial design
-#> expected relative standard error
-#> (%RSE, rounded to nearest integer)
-#> Parameter Values RSE_0
-#> CL 0.15 5
-#> V 8 3
-#> KA 1 14
-#> d_CL 0.07 30
-#> d_V 0.02 37
-#> d_KA 0.6 27
-#> sig_prop 0.01 32
-#> sig_add 0.25 26
-#>
-#> ==============================================================================
-#> Optimization of design parameters
-#>
-#> * Optimize Covariates
-#>
-#> ************* Iteration 1 for all optimization methods***********************
-#>
-#> *******************************************
-#> Running Adaptive Random Search Optimization
-#> *******************************************
-#> Initial OFV = 55.3964
-#>
-#> Total iterations: 2
-#> Elapsed time: 0.011 seconds.
-#>
-#> Final OFV = 55.39645
-#> Parameters: 70
-#>
-#> *******************************************
-#> Running BFGS Optimization
-#> *******************************************
-#> initial value -55.396450
-#> final value -55.766379
-#> stopped after 2 iterations
-#>
-#> *******************************************
-#> Running Line Search Optimization
-#> *******************************************
-#>
-#> Initial parameters: 83.20112
-#> Initial OFV: 55.76638
-#>
-#> Searching parameter 1
-#> Changed from 83.2011 to 100 ; OFV = 56.032
-#>
-#> Elapsed time: 0.01 seconds.
-#>
-#> Final OFV = 56.03204
-#> Parameters: 100
-#>
-#> *******************************************
-#> Stopping criteria testing
-#> (Compare between start of iteration and end of iteration)
-#> *******************************************
-#> Difference in OFV: 0.636
-#> Relative difference in OFV: 1.15%
-#> Efficiency:
-#> ((exp(ofv_final) / exp(ofv_init))^(1/n_parameters)) = 1.0827
-#>
-#> Efficiency stopping criteria:
-#> Is (1.0827 <= 1.001)? No.
-#> Stopping criteria NOT achieved.
-#>
-#> Stopping criteria NOT achieved.
-#>
-#> ===============================================================================
-#> FINAL RESULTS
-#>
-#> Optimized Covariates:
-#> Group 1: 100
-#>
-#> OFV = 56.032
-#>
-#> Efficiency:
-#> ((exp(ofv_final) / exp(ofv_init))^(1/n_parameters)) = 1.0827
-#>
-#> Expected relative standard error
-#> (%RSE, rounded to nearest integer):
-#> Parameter Values RSE_0 RSE
-#> CL 0.15 5 5
-#> V 8 3 3
-#> KA 1 14 14
-#> d_CL 0.07 30 28
-#> d_V 0.02 37 34
-#> d_KA 0.6 27 26
-#> sig_prop 0.01 32 23
-#> sig_add 0.25 26 30
-#>
-#> Total running time: 0.122 seconds
-
-
-# cost function
-# PRED at 120 hours
-crit_fcn <- function(poped.db,...){
- pred_df <- model_prediction(poped.db)
- return(pred_df[pred_df$Time==120,"PRED"])
-}
-
-# maximize cost function
-out_2 <- poped_optim(poped.db,opt_a =TRUE,
- ofv_fun=crit_fcn,
- control = list(ARS=list(iter=2),
- BFGS=list(maxit=2),
- LS=list(line_length=2)),
- iter_max = 2)
-#> ===============================================================================
-#> Initial design evaluation
-#>
-#> Initial OFV = 0.939866
-#>
-#> Initial design
-#> expected relative standard error
-#> (%RSE, rounded to nearest integer)
-#> Parameter Values RSE_0
-#> CL 0.15 5
-#> V 8 3
-#> KA 1 14
-#> d_CL 0.07 30
-#> d_V 0.02 37
-#> d_KA 0.6 27
-#> sig_prop 0.01 32
-#> sig_add 0.25 26
-#>
-#> ==============================================================================
-#> Optimization of design parameters
-#>
-#> * Optimize Covariates
-#>
-#> ************* Iteration 1 for all optimization methods***********************
-#>
-#> *******************************************
-#> Running Adaptive Random Search Optimization
-#> *******************************************
-#> Initial OFV = 0.939866
-#>
-#> Total iterations: 2
-#> Elapsed time: 0.003 seconds.
-#>
-#> Final OFV = 0.9398657
-#> Parameters: 70
-#>
-#> *******************************************
-#> Running BFGS Optimization
-#> *******************************************
-#> initial value -0.939866
-#> final value -1.014649
-#> stopped after 2 iterations
-#>
-#> *******************************************
-#> Running Line Search Optimization
-#> *******************************************
-#>
-#> Initial parameters: 75.56977
-#> Initial OFV: 1.014649
-#>
-#> Searching parameter 1
-#> Changed from 75.5698 to 100 ; OFV = 1.34267
-#>
-#> Elapsed time: 0.007 seconds.
-#>
-#> Final OFV = 1.342665
-#> Parameters: 100
-#>
-#> *******************************************
-#> Stopping criteria testing
-#> (Compare between start of iteration and end of iteration)
-#> *******************************************
-#> Difference in OFV: 0.403
-#> Relative difference in OFV: 42.9%
-#> Efficiency:
-#> (ofv_final / ofv_init) = 1.4286
-#>
-#> Efficiency stopping criteria:
-#> Is (1.4286 <= 1.001)? No.
-#> Stopping criteria NOT achieved.
-#>
-#> Stopping criteria NOT achieved.
-#>
-#> ************* Iteration 2 for all optimization methods***********************
-#>
-#> *******************************************
-#> Running Adaptive Random Search Optimization
-#> *******************************************
-#> Initial OFV = 1.34267
-#>
-#> Total iterations: 2
-#> Elapsed time: 0.003 seconds.
-#>
-#> Final OFV = 1.342665
-#> Parameters: 100
-#>
-#> *******************************************
-#> Running BFGS Optimization
-#> *******************************************
-#> initial value -1.342665
-#> final value -1.342665
-#> converged
-#>
-#> *******************************************
-#> Running Line Search Optimization
-#> *******************************************
-#>
-#> Initial parameters: 100
-#> Initial OFV: 1.342665
-#>
-#> Searching parameter 1
-#> Changed from 100 to 100 ; OFV = 1.34267
-#>
-#> Elapsed time: 0.004 seconds.
-#>
-#> Final OFV = 1.342665
-#> Parameters: 100
-#>
-#> *******************************************
-#> Stopping criteria testing
-#> (Compare between start of iteration and end of iteration)
-#> *******************************************
-#> Difference in OFV: 0
-#> Relative difference in OFV: 0%
-#> Efficiency:
-#> (ofv_final / ofv_init) = 1
-#>
-#> Efficiency stopping criteria:
-#> Is (1 <= 1.001)? Yes.
-#> Stopping criteria achieved.
-#>
-#> Stopping criteria achieved.
-#>
-#> ===============================================================================
-#> FINAL RESULTS
-#>
-#> Optimized Covariates:
-#> Group 1: 100
-#>
-#> OFV = 1.34267
-#>
-#> Efficiency:
-#> (ofv_final / ofv_init) = 1.4286
-#>
-#> Expected relative standard error
-#> (%RSE, rounded to nearest integer):
-#> Parameter Values RSE_0 RSE
-#> CL 0.15 5 5
-#> V 8 3 3
-#> KA 1 14 14
-#> d_CL 0.07 30 28
-#> d_V 0.02 37 34
-#> d_KA 0.6 27 26
-#> sig_prop 0.01 32 23
-#> sig_add 0.25 26 30
-#>
-#> Total running time: 0.182 seconds
-
-# minimize the cost function
-out_3 <- poped_optim(poped.db,opt_a =TRUE,
- ofv_fun=crit_fcn,
- control = list(ARS=list(iter=2),
- BFGS=list(maxit=2),
- LS=list(line_length=2)),
- iter_max = 2,
- maximize = FALSE,
- evaluate_fim = FALSE)
-#> ===============================================================================
-#> Initial design evaluation
-#>
-#> Initial OFV = 0.939866
-#> ==============================================================================
-#> Optimization of design parameters
-#>
-#> * Optimize Covariates
-#>
-#> ************* Iteration 1 for all optimization methods***********************
-#>
-#> *******************************************
-#> Running Adaptive Random Search Optimization
-#> *******************************************
-#> Initial OFV = 0.939866
-#>
-#> Total iterations: 2
-#> Elapsed time: 0.003 seconds.
-#>
-#> Final OFV = 0.8123613
-#> Parameters: 60.50363
-#>
-#> *******************************************
-#> Running BFGS Optimization
-#> *******************************************
-#> initial value 0.812361
-#> final value 0.706775
-#> stopped after 2 iterations
-#>
-#> *******************************************
-#> Running Line Search Optimization
-#> *******************************************
-#>
-#> Initial parameters: 52.63973
-#> Initial OFV: 0.7067753
-#>
-#> Searching parameter 1
-#> Changed from 52.6397 to 0.01 ; OFV = 0.000134267
-#>
-#> Elapsed time: 0.005 seconds.
-#>
-#> Final OFV = 0.0001342665
-#> Parameters: 0.01
-#>
-#> *******************************************
-#> Stopping criteria testing
-#> (Compare between start of iteration and end of iteration)
-#> *******************************************
-#> Difference in OFV: -0.94
-#> Relative difference in OFV: -100%
-#> Efficiency:
-#> (ofv_final / ofv_init) = 0.00014286
-#>
-#> Efficiency stopping criteria:
-#> Is (0.00014286 >= 0.999)? No.
-#> Stopping criteria NOT achieved.
-#>
-#> Stopping criteria NOT achieved.
-#>
-#> ************* Iteration 2 for all optimization methods***********************
-#>
-#> *******************************************
-#> Running Adaptive Random Search Optimization
-#> *******************************************
-#> Initial OFV = 0.000134267
-#>
-#> Total iterations: 2
-#> Elapsed time: 0.003 seconds.
-#>
-#> Final OFV = 0.0001342665
-#> Parameters: 0.01
-#>
-#> *******************************************
-#> Running BFGS Optimization
-#> *******************************************
-#> initial value 0.000134
-#> final value 0.000134
-#> converged
-#>
-#> *******************************************
-#> Running Line Search Optimization
-#> *******************************************
-#>
-#> Initial parameters: 0.01000001
-#> Initial OFV: 0.0001342667
-#>
-#> Searching parameter 1
-#> Changed from 0.01 to 0.01 ; OFV = 0.000134267
-#>
-#> Elapsed time: 0.004 seconds.
-#>
-#> Final OFV = 0.0001342665
-#> Parameters: 0.01
-#>
-#> *******************************************
-#> Stopping criteria testing
-#> (Compare between start of iteration and end of iteration)
-#> *******************************************
-#> Difference in OFV: 0
-#> Relative difference in OFV: 0%
-#> Efficiency:
-#> (ofv_final / ofv_init) = 1
-#>
-#> Efficiency stopping criteria:
-#> Is (1 >= 0.999)? Yes.
-#> Stopping criteria achieved.
-#>
-#> Stopping criteria achieved.
-#>
-#> ===============================================================================
-#> FINAL RESULTS
-#>
-#> Optimized Covariates:
-#> Group 1: 0.01
-#>
-#> OFV = 0.000134267
-#>
-#> Efficiency:
-#> (ofv_final / ofv_init) = 0.00014286
-#>
-#> Total running time: 0.188 seconds
-
-
-if (FALSE) {
-
- # RS+BFGS+LS optimization of sample times
- # (longer run time than above but more likely to reach a maximum)
- output <- poped_optim(poped.db,opt_xt=T,parallel = TRUE)
-
- get_rse(output$FIM,output$poped.db)
- plot_model_prediction(output$poped.db)
-
- # optimization with only integer times allowed
- poped.db.2 <- poped.db
- poped.db.2$design_space$xt_space <- matrix(list(seq(1,120)),1,8)
- output_2 <- poped_optim(poped.db.2,opt_xt=T,parallel = TRUE)
-
- get_rse(output_2$FIM,output_2$poped.db)
- plot_model_prediction(output_2$poped.db)
-
- # Examine efficiency of sampling windows
- plot_efficiency_of_windows(output_2$poped.db,xt_windows=0.5)
- plot_efficiency_of_windows(output_2$poped.db,xt_windows=1)
-
- # Adaptive Random Search (ARS, just a few samples here)
- rs.output <- poped_optim(poped.db,opt_xt=T,method = "ARS",
- control = list(ARS=list(iter=5)))
-
- get_rse(rs.output$FIM,rs.output$poped.db)
-
- # line search, DOSE and sample time optimization
- ls.output <- poped_optim(poped.db,opt_xt=T,opt_a=T,method = "LS",
- control = list(LS=list(line_length=5)))
-
- # Adaptive random search,
- # DOSE and sample time optimization
- ars.output <- poped_optim(poped.db,opt_xt=T,opt_a=T,method = "ARS",
- control = list(ARS=list(iter=5)))
-
- # BFGS gradient search from the stats::optim() function,
- # DOSE and sample time optimization
- bfgs.output <- poped_optim(poped.db,opt_xt=T,opt_a=T,method = "BFGS",
- control = list(BFGS=list(maxit=5)))
-
-
- # genetic algorithm from the GA::ga() function,
- # DOSE and sample time optimization
- ga.output <- poped_optim(poped.db,opt_xt=T,opt_a=F,method = "GA",parallel=T)
-
- # cost function with GA
- # maximize
- out_2 <- poped_optim(poped.db,opt_a =TRUE,
- ofv_fun=crit_fcn,
- parallel = T,
- method=c("GA"))
-
- # cost function with GA
- # minimize
- out_2 <- poped_optim(poped.db,opt_a =TRUE,
- ofv_fun=crit_fcn,
- parallel = T,
- method=c("GA"),
- iter_max = 1,
- maximize = F,
- evaluate_fim = F)
-
- # optimize distribution of individuals in 3 groups
- poped_db_2 <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(prop=0.01,add=0.25),
- groupsize=32,
- m=3,
- xt=list(c( 0.5,1,2,6,8),c(36,72,120),
- c(10,12,14,16,18,20,22,24)),
- minxt=0.01,
- maxxt=120,
- a=c(DOSE=70),
- mina=c(DOSE=0.01),
- maxa=c(DOSE=100))
-
- opt_xt_inds <-
- poped_optim(poped_db_2,
- opt_a =TRUE,
- opt_inds = TRUE,
- control = list(ARS=list(iter=2),
- BFGS=list(maxit=2),
- LS=list(line_length=2)),
- iter_max = 1)
-
-
-
- ##############
- # E-family Optimization
- ##############
-
- # Adding 10% log-normal Uncertainty to fixed effects (not Favail)
- bpop_vals <- c(CL=0.15, V=8, KA=1.0, Favail=1)
- bpop_vals_ed_ln <- cbind(ones(length(bpop_vals),1)*4, # log-normal distribution
- bpop_vals,
- ones(length(bpop_vals),1)*(bpop_vals*0.1)^2) # 10% of bpop value
- bpop_vals_ed_ln["Favail",] <- c(0,1,0)
- bpop_vals_ed_ln
-
- ## -- Define initial design and design space
- poped.db <- create.poped.database(ff_file="ff.PK.1.comp.oral.sd.CL",
- fg_file="sfg",
- fError_file="feps.add.prop",
- bpop=bpop_vals_ed_ln,
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(0.01,0.25),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0,
- maxxt=120,
- a=70,
- mina=0,
- maxa=100)
-
-
- # E_ln(D) optimization using Random search (just a few samples here)
- output <- poped_optim(poped.db,opt_xt=TRUE,opt_a=TRUE,d_switch=0,
- method = c("ARS","LS"),
- control = list(ARS=list(iter=2),
- LS=list(line_length=2)),
- iter_max = 1)
- get_rse(output$FIM,output$poped.db)
-
- # ED with laplace approximation,
- # optimization using Random search (just a few iterations here)
- ars.output <- poped_optim(poped.db,opt_xt=T,opt_a=T,method = "ARS",
- d_switch=0,use_laplace=TRUE,#laplace.fim=TRUE,
- parallel=T,
- control = list(ARS=list(iter=5)))
-
-}
-
loop_methods=TRUE
-then the series of optimization methods will be run for iter_max
-iterations, or until the efficiency of the design after the current series
-(compared to the start of the series) is less than stop_crit_eff
.R/poped_optim_1.R
- poped_optim_1.Rd
This function takes information from the PopED database supplied as an -argument. The PopED database supplies information about the the model, -parameters, design and methods to use. Some of the arguments coming from the -PopED database can be overwritten; if they are supplied then they are used -instead of the arguments from the PopED database.
-poped_optim_1(
- poped.db,
- opt_xt = poped.db$settings$optsw[2],
- opt_a = poped.db$settings$optsw[4],
- opt_x = poped.db$settings$optsw[3],
- opt_samps = poped.db$settings$optsw[1],
- opt_inds = poped.db$settings$optsw[5],
- method = c("ARS", "BFGS", "LS"),
- control = list(),
- trace = TRUE,
- fim.calc.type = poped.db$settings$iFIMCalculationType,
- ofv_calc_type = poped.db$settings$ofv_calc_type,
- approx_type = poped.db$settings$iApproximationMethod,
- d_switch = poped.db$settings$d_switch,
- ED_samp_size = poped.db$settings$ED_samp_size,
- bLHS = poped.db$settings$bLHS,
- use_laplace = poped.db$settings$iEDCalculationType,
- out_file = "",
- parallel = F,
- parallel_type = NULL,
- num_cores = NULL,
- loop_methods = ifelse(length(method) > 1, TRUE, FALSE),
- iter_max = 10,
- stop_crit_eff = 1.001,
- stop_crit_diff = NULL,
- stop_crit_rel = NULL,
- ofv_fun = poped.db$settings$ofv_fun,
- maximize = T,
- ...
-)
A PopED database.
Should the sample times be optimized?
Should the continuous design variables be optimized?
Should the discrete design variables be optimized?
Are the number of sample times per group being optimized?
Are the number of individuals per group being optimized?
A vector of optimization methods to use in a sequential
-fashion. Options are c("ARS","BFGS","LS","GA")
. c("ARS")
is
-for Adaptive Random Search optim_ARS
. c("LS")
is for
-Line Search optim_LS
. c("BFGS")
is for Method
-"L-BFGS-B" from optim
. c("GA")
is for the
-genetic algorithm from ga
.
Contains control arguments for each method specified.
Should the algorithm output results intermittently.
The method used for calculating the FIM. Potential values:
0 = Full FIM. No assumption that fixed and random effects are uncorrelated.
1 = Reduced FIM. Assume that there is no correlation in the FIM between the fixed and random effects, and set these elements in -the FIM to zero.
2 = weighted models (placeholder).
3 = Not currently used.
4 = Reduced FIM and computing all derivatives with respect to the standard deviation of the residual unexplained variation (sqrt(SIGMA) in NONMEM). -This matches what is done in PFIM, and assumes that the standard deviation of the residual unexplained variation is the estimated parameter -(NOTE: NONMEM estimates the variance of the residual unexplained variation by default).
5 = Full FIM parameterized with A,B,C matrices & derivative of variance.
6 = Calculate one model switch at a time, good for large matrices.
7 = Reduced FIM parameterized with A,B,C matrices & derivative of variance.
OFV calculation type for FIM
1 = "D-optimality". Determinant of the FIM: det(FIM)
2 = "A-optimality". Inverse of the sum of the expected parameter variances: -1/trace_matrix(inv(FIM))
4 = "lnD-optimality". Natural logarithm of the determinant of the FIM: log(det(FIM))
6 = "Ds-optimality". Ratio of the Determinant of the FIM and the Determinant of the uninteresting -rows and columns of the FIM: det(FIM)/det(FIM_u)
7 = Inverse of the sum of the expected parameter RSE: 1/sum(get_rse(FIM,poped.db,use_percent=FALSE))
Approximation method for model, 0=FO, 1=FOCE, 2=FOCEI, 3=FOI.
******START OF CRITERION SPECIFICATION OPTIONS**********
D-family design (1) or ED-family design (0) (with or without parameter uncertainty)
Sample size for E-family sampling
How to sample from distributions in E-family calculations. 0=Random Sampling, 1=LatinHyperCube --
Should the Laplace method be used in calculating the expectation of the OFV?
Save output from the optimization to a file.
Should we use parallel computations?
Which type of parallelization should be used?
-Can be "snow" or "multicore". "snow" works on Linux-like systems & Windows. "multicore" works only on
-Linux-like systems. By default this is chosen for you depending on your operating system.
-See start_parallel
.
The number of cores to use in the parallelization. By default is set to the number
- output from
-parallel::detectCores()
.
-See start_parallel
.
Should the optimization methods be looped for
-iter_max
iterations, or until the efficiency of the design after the
-current series (compared to the start of the series) is less than, or equal to,
-stop_crit_eff
?
If line search is used then the algorithm tests if line
-search (always run at the end of the optimization iteration) changes the
-design in any way. If not, the algorithm stops. If yes, then a new
-iteration is run unless iter_max
iterations have already been run.
If loop_methods==TRUE
, the looping will stop if the
-efficiency of the design after the current series (compared to the start of
-the series) is less than, or equal to, stop_crit_eff
(if maximize==FALSE
then 1/stop_crit_eff is the cut
-off and the efficiency must be greater than or equal to this value to stop the looping).
If loop_methods==TRUE
, the looping will stop if the
-difference in criterion value of the design after the current series (compared to the start of
-the series) is less than, or equal to, stop_crit_diff
(if maximize==FALSE
then -stop_crit_diff is the cut
-off and the difference in criterion value must be greater than or equal to this value to stop the looping).
If loop_methods==TRUE
, the looping will stop if the
-relative difference in criterion value of the design after the current series (compared to the start of
-the series) is less than, or equal to, stop_crit_rel
(if maximize==FALSE
then -stop_crit_rel is the cut
-off and the relative difference in criterion value must be greater than or equal to this value to stop the looping).
User defined function used to compute the objective function. The function must have a poped database object as its first -argument and have "..." in its argument list. Can be referenced as a function or as a file name where the function defined in the file has the same name as the file. -e.g. "cost.txt" has a function named "cost" in it.
Should the objective function be maximized or minimized?
arguments passed to other functions.
M. Foracchia, A.C. Hooker, P. Vicini and A. - Ruggeri, "PopED, a software fir optimal experimental design in population - kinetics", Computer Methods and Programs in Biomedicine, 74, 2004.
J. - Nyberg, S. Ueckert, E.A. Stroemberg, S. Hennig, M.O. Karlsson and A.C. - Hooker, "PopED: An extended, parallelized, nonlinear mixed effects models - optimal design tool", Computer Methods and Programs in Biomedicine, 108, - 2012.
Other Optimize:
-Doptim()
,
-LEDoptim()
,
-RS_opt()
,
-a_line_search()
,
-bfgsb_min()
,
-calc_autofocus()
,
-calc_ofv_and_grad()
,
-mfea()
,
-optim_ARS()
,
-optim_LS()
,
-poped_optim_2()
,
-poped_optim_3()
,
-poped_optimize()
,
-poped_optim()
Optimize the objective function. The function works for both discrete and
-continuous optimization variables. If more than one optimization method is
-specified then the methods are run in series. If loop_methods=TRUE
-then the series of optimization methods will be run for iter_max
-iterations, or until the efficiency of the design after the current series
-(compared to the start of the series) is less than stop_crit_eff
.
poped_optim_2(
- poped.db,
- opt_xt = poped.db$settings$optsw[2],
- opt_a = poped.db$settings$optsw[4],
- opt_x = poped.db$settings$optsw[3],
- opt_samps = poped.db$settings$optsw[1],
- opt_inds = poped.db$settings$optsw[5],
- method = c("ARS", "BFGS", "LS"),
- control = list(),
- trace = TRUE,
- fim.calc.type = poped.db$settings$iFIMCalculationType,
- ofv_calc_type = poped.db$settings$ofv_calc_type,
- approx_type = poped.db$settings$iApproximationMethod,
- d_switch = poped.db$settings$d_switch,
- ED_samp_size = poped.db$settings$ED_samp_size,
- bLHS = poped.db$settings$bLHS,
- use_laplace = poped.db$settings$iEDCalculationType,
- out_file = "",
- parallel = F,
- parallel_type = NULL,
- num_cores = NULL,
- loop_methods = ifelse(length(method) > 1, TRUE, FALSE),
- iter_max = 10,
- stop_crit_eff = 1.001,
- stop_crit_diff = NULL,
- stop_crit_rel = NULL,
- ofv_fun = poped.db$settings$ofv_fun,
- maximize = T,
- transform_parameters = F,
- ...
-)
A PopED database.
Should the sample times be optimized?
Should the continuous design variables be optimized?
Should the discrete design variables be optimized?
Are the number of sample times per group being optimized?
Are the number of individuals per group being optimized?
A vector of optimization methods to use in a sequential
-fashion. Options are c("ARS","BFGS","LS","GA")
. c("ARS")
is
-for Adaptive Random Search optim_ARS
. c("LS")
is for
-Line Search optim_LS
. c("BFGS")
is for Method
-"L-BFGS-B" from optim
. c("GA")
is for the
-genetic algorithm from ga
.
Contains control arguments for each method specified.
Should the algorithm output results intermittently.
The method used for calculating the FIM. Potential values:
0 = Full FIM. No assumption that fixed and random effects are uncorrelated.
1 = Reduced FIM. Assume that there is no correlation in the FIM between the fixed and random effects, and set these elements in -the FIM to zero.
2 = weighted models (placeholder).
3 = Not currently used.
4 = Reduced FIM and computing all derivatives with respect to the standard deviation of the residual unexplained variation (sqrt(SIGMA) in NONMEM). -This matches what is done in PFIM, and assumes that the standard deviation of the residual unexplained variation is the estimated parameter -(NOTE: NONMEM estimates the variance of the residual unexplained variation by default).
5 = Full FIM parameterized with A,B,C matrices & derivative of variance.
6 = Calculate one model switch at a time, good for large matrices.
7 = Reduced FIM parameterized with A,B,C matrices & derivative of variance.
OFV calculation type for FIM
1 = "D-optimality". Determinant of the FIM: det(FIM)
2 = "A-optimality". Inverse of the sum of the expected parameter variances: -1/trace_matrix(inv(FIM))
4 = "lnD-optimality". Natural logarithm of the determinant of the FIM: log(det(FIM))
6 = "Ds-optimality". Ratio of the Determinant of the FIM and the Determinant of the uninteresting -rows and columns of the FIM: det(FIM)/det(FIM_u)
7 = Inverse of the sum of the expected parameter RSE: 1/sum(get_rse(FIM,poped.db,use_percent=FALSE))
Approximation method for model, 0=FO, 1=FOCE, 2=FOCEI, 3=FOI.
******START OF CRITERION SPECIFICATION OPTIONS**********
D-family design (1) or ED-family design (0) (with or without parameter uncertainty)
Sample size for E-family sampling
How to sample from distributions in E-family calculations. 0=Random Sampling, 1=LatinHyperCube --
Should the Laplace method be used in calculating the expectation of the OFV?
Save output from the optimization to a file.
Should we use parallel computations?
Which type of parallelization should be used?
-Can be "snow" or "multicore". "snow" works on Linux-like systems & Windows. "multicore" works only on
-Linux-like systems. By default this is chosen for you depending on your operating system.
-See start_parallel
.
The number of cores to use in the parallelization. By default is set to the number
- output from
-parallel::detectCores()
.
-See start_parallel
.
Should the optimization methods be looped for
-iter_max
iterations, or until the efficiency of the design after the
-current series (compared to the start of the series) is less than, or equal to,
-stop_crit_eff
?
If line search is used then the algorithm tests if line
-search (always run at the end of the optimization iteration) changes the
-design in any way. If not, the algorithm stops. If yes, then a new
-iteration is run unless iter_max
iterations have already been run.
If loop_methods==TRUE
, the looping will stop if the
-efficiency of the design after the current series (compared to the start of
-the series) is less than, or equal to, stop_crit_eff
(if maximize==FALSE
then 1/stop_crit_eff is the cut
-off and the efficiency must be greater than or equal to this value to stop the looping).
If loop_methods==TRUE
, the looping will stop if the
-difference in criterion value of the design after the current series (compared to the start of
-the series) is less than, or equal to, stop_crit_diff
(if maximize==FALSE
then -stop_crit_diff is the cut
-off and the difference in criterion value must be greater than or equal to this value to stop the looping).
If loop_methods==TRUE
, the looping will stop if the
-relative difference in criterion value of the design after the current series (compared to the start of
-the series) is less than, or equal to, stop_crit_rel
(if maximize==FALSE
then -stop_crit_rel is the cut
-off and the relative difference in criterion value must be greater than or equal to this value to stop the looping).
User defined function used to compute the objective function. The function must have a poped database object as its first -argument and have "..." in its argument list. Can be referenced as a function or as a file name where the function defined in the file has the same name as the file. -e.g. "cost.txt" has a function named "cost" in it.
Should the objective function be maximized or minimized?
Should we transform the parameters before optimization?
arguments passed to other functions.
This function takes information from the PopED database supplied as an -argument. The PopED database supplies information about the the model, -parameters, design and methods to use. Some of the arguments coming from the -PopED database can be overwritten; if they are supplied then they are used -instead of the arguments from the PopED database.
-M. Foracchia, A.C. Hooker, P. Vicini and A. - Ruggeri, "PopED, a software fir optimal experimental design in population - kinetics", Computer Methods and Programs in Biomedicine, 74, 2004.
J. - Nyberg, S. Ueckert, E.A. Stroemberg, S. Hennig, M.O. Karlsson and A.C. - Hooker, "PopED: An extended, parallelized, nonlinear mixed effects models - optimal design tool", Computer Methods and Programs in Biomedicine, 108, - 2012.
Other Optimize:
-Doptim()
,
-LEDoptim()
,
-RS_opt()
,
-a_line_search()
,
-bfgsb_min()
,
-calc_autofocus()
,
-calc_ofv_and_grad()
,
-mfea()
,
-optim_ARS()
,
-optim_LS()
,
-poped_optim_1()
,
-poped_optim_3()
,
-poped_optimize()
,
-poped_optim()
Optimize the objective function. The function works for both discrete and
-continuous optimization variables. If more than one optimization method is
-specified then the methods are run in series. If loop_methods=TRUE
-then the series of optimization methods will be run for iter_max
-iterations, or until the efficiency of the design after the current series
-(compared to the start of the series) is less than stop_crit_eff
.
poped_optim_3(
- poped.db,
- opt_xt = poped.db$settings$optsw[2],
- opt_a = poped.db$settings$optsw[4],
- opt_x = poped.db$settings$optsw[3],
- opt_samps = poped.db$settings$optsw[1],
- opt_inds = poped.db$settings$optsw[5],
- method = c("ARS", "BFGS", "LS"),
- control = list(),
- trace = TRUE,
- fim.calc.type = poped.db$settings$iFIMCalculationType,
- ofv_calc_type = poped.db$settings$ofv_calc_type,
- ds_index = poped.db$parameters$ds_index,
- approx_type = poped.db$settings$iApproximationMethod,
- d_switch = poped.db$settings$d_switch,
- ED_samp_size = poped.db$settings$ED_samp_size,
- bLHS = poped.db$settings$bLHS,
- use_laplace = poped.db$settings$iEDCalculationType,
- out_file = "",
- parallel = F,
- parallel_type = NULL,
- num_cores = NULL,
- loop_methods = ifelse(length(method) > 1, TRUE, FALSE),
- iter_max = 10,
- stop_crit_eff = 1.001,
- stop_crit_diff = NULL,
- stop_crit_rel = NULL,
- ofv_fun = poped.db$settings$ofv_fun,
- maximize = T,
- allow_replicates = TRUE,
- allow_replicates_xt = TRUE,
- allow_replicates_a = TRUE,
- ...
-)
A PopED database.
Should the sample times be optimized?
Should the continuous design variables be optimized?
Should the discrete design variables be optimized?
Are the number of sample times per group being optimized?
Are the number of individuals per group being optimized?
A vector of optimization methods to use in a sequential
-fashion. Options are c("ARS","BFGS","LS","GA")
. c("ARS")
is
-for Adaptive Random Search optim_ARS
. c("LS")
is for
-Line Search optim_LS
. c("BFGS")
is for Method
-"L-BFGS-B" from optim
. c("GA")
is for the
-genetic algorithm from ga
. If opt_inds=TRUE
then
-this optimization is always added to the end of the sequential optimization.
Contains control arguments specified for each method separately.
Should the algorithm output results intermittently.
The method used for calculating the FIM. Potential values:
0 = Full FIM. No assumption that fixed and random effects are uncorrelated.
1 = Reduced FIM. Assume that there is no correlation in the FIM between the fixed and random effects, and set these elements in -the FIM to zero.
2 = weighted models (placeholder).
3 = Not currently used.
4 = Reduced FIM and computing all derivatives with respect to the standard deviation of the residual unexplained variation (sqrt(SIGMA) in NONMEM). -This matches what is done in PFIM, and assumes that the standard deviation of the residual unexplained variation is the estimated parameter -(NOTE: NONMEM estimates the variance of the residual unexplained variation by default).
5 = Full FIM parameterized with A,B,C matrices & derivative of variance.
6 = Calculate one model switch at a time, good for large matrices.
7 = Reduced FIM parameterized with A,B,C matrices & derivative of variance.
OFV calculation type for FIM
1 = "D-optimality". Determinant of the FIM: det(FIM)
2 = "A-optimality". Inverse of the sum of the expected parameter variances: -1/trace_matrix(inv(FIM))
4 = "lnD-optimality". Natural logarithm of the determinant of the FIM: log(det(FIM))
6 = "Ds-optimality". Ratio of the Determinant of the FIM and the Determinant of the uninteresting -rows and columns of the FIM: det(FIM)/det(FIM_u)
7 = Inverse of the sum of the expected parameter RSE: 1/sum(get_rse(FIM,poped.db,use_percent=FALSE))
Ds_index is a vector set to 1 if a parameter is uninteresting, otherwise 0.
-size=(1,num unfixed parameters). First unfixed bpop, then unfixed d, then unfixed docc and last unfixed sigma.
-Default is the fixed effects being important, everything else not important. Used in conjunction with
-ofv_calc_type=6
.
Approximation method for model, 0=FO, 1=FOCE, 2=FOCEI, 3=FOI.
******START OF CRITERION SPECIFICATION OPTIONS**********
D-family design (1) or ED-family design (0) (with or without parameter uncertainty)
Sample size for E-family sampling
How to sample from distributions in E-family calculations. 0=Random Sampling, 1=LatinHyperCube --
Should the Laplace method be used in calculating the expectation of the OFV?
Save output from the optimization to a file.
Should we use parallel computations?
Which type of parallelization should be used?
-Can be "snow" or "multicore". "snow" works on Linux-like systems & Windows. "multicore" works only on
-Linux-like systems. By default this is chosen for you depending on your operating system.
-See start_parallel
.
The number of cores to use in the parallelization. By default is set to the number
- output from
-parallel::detectCores()
.
-See start_parallel
.
Should the optimization methods be looped for
-iter_max
iterations, or until the efficiency of the design after the
-current series (compared to the start of the series) is less than, or equal to,
-stop_crit_eff
?
If line search is used then the algorithm tests if line
-search (always run at the end of the optimization iteration) changes the
-design in any way. If not, the algorithm stops. If yes, then a new
-iteration is run unless iter_max
iterations have already been run.
If loop_methods==TRUE
, the looping will stop if the
-efficiency of the design after the current series (compared to the start of
-the series) is less than, or equal to, stop_crit_eff
(if maximize==FALSE
then 1/stop_crit_eff is the cut
-off and the efficiency must be greater than or equal to this value to stop the looping).
If loop_methods==TRUE
, the looping will stop if the
-difference in criterion value of the design after the current series (compared to the start of
-the series) is less than, or equal to, stop_crit_diff
(if maximize==FALSE
then -stop_crit_diff is the cut
-off and the difference in criterion value must be greater than or equal to this value to stop the looping).
If loop_methods==TRUE
, the looping will stop if the
-relative difference in criterion value of the design after the current series (compared to the start of
-the series) is less than, or equal to, stop_crit_rel
(if maximize==FALSE
then -stop_crit_rel is the cut
-off and the relative difference in criterion value must be greater than or equal to this value to stop the looping).
User defined function used to compute the objective function. The function must have a poped database object as its first -argument and have "..." in its argument list. Can be referenced as a function or as a file name where the function defined in the file has the same name as the file. -e.g. "cost.txt" has a function named "cost" in it.
Should the objective function be maximized or minimized?
Should the algorithm allow parameters to have the same value?
arguments passed to other functions.
This function takes information from the PopED database supplied as an -argument. The PopED database supplies information about the the model, -parameters, design and methods to use. Some of the arguments coming from the -PopED database can be overwritten; if they are supplied then they are used -instead of the arguments from the PopED database.
-M. Foracchia, A.C. Hooker, P. Vicini and A. - Ruggeri, "PopED, a software fir optimal experimental design in population - kinetics", Computer Methods and Programs in Biomedicine, 74, 2004.
J. - Nyberg, S. Ueckert, E.A. Stroemberg, S. Hennig, M.O. Karlsson and A.C. - Hooker, "PopED: An extended, parallelized, nonlinear mixed effects models - optimal design tool", Computer Methods and Programs in Biomedicine, 108, - 2012.
Other Optimize:
-Doptim()
,
-LEDoptim()
,
-RS_opt()
,
-a_line_search()
,
-bfgsb_min()
,
-calc_autofocus()
,
-calc_ofv_and_grad()
,
-mfea()
,
-optim_ARS()
,
-optim_LS()
,
-poped_optim_1()
,
-poped_optim_2()
,
-poped_optimize()
,
-poped_optim()
This function is an older version of poped_optim
. Please use poped_optim
-unless you have a specific reason to use this function instead.
poped_optimize(
- poped.db,
- ni = NULL,
- xt = NULL,
- model_switch = NULL,
- x = NULL,
- a = NULL,
- bpop = NULL,
- d = NULL,
- maxxt = NULL,
- minxt = NULL,
- maxa = NULL,
- mina = NULL,
- fmf = 0,
- dmf = 0,
- trflag = TRUE,
- opt_xt = poped.db$settings$optsw[2],
- opt_a = poped.db$settings$optsw[4],
- opt_x = poped.db$settings$optsw[3],
- opt_samps = poped.db$settings$optsw[1],
- opt_inds = poped.db$settings$optsw[5],
- cfaxt = poped.db$settings$cfaxt,
- cfaa = poped.db$settings$cfaa,
- rsit = poped.db$settings$rsit,
- rsit_output = poped.db$settings$rsit_output,
- fim.calc.type = poped.db$settings$iFIMCalculationType,
- ofv_calc_type = poped.db$settings$ofv_calc_type,
- approx_type = poped.db$settings$iApproximationMethod,
- bUseExchangeAlgorithm = poped.db$settings$bUseExchangeAlgorithm,
- iter = 1,
- d_switch = poped.db$settings$d_switch,
- ED_samp_size = poped.db$settings$ED_samp_size,
- bLHS = poped.db$settings$bLHS,
- use_laplace = poped.db$settings$iEDCalculationType,
- ...
-)
A PopED database.
A vector of the number of samples in each group.
A matrix of sample times. Each row is a vector of sample times for a group.
A matrix that is the same size as xt, specifying which model each sample belongs to.
A matrix for the discrete design variables. Each row is a group.
A matrix of covariates. Each row is a group.
Matrix defining the fixed effects, per row (row number = parameter_number) we should have:
column 1 the type of the distribution for E-family designs (0 = Fixed, 1 = Normal, 2 = Uniform, - 3 = User Defined Distribution, 4 = lognormal and 5 = truncated normal)
column 2 defines the mean.
column 3 defines the variance of the distribution (or length of uniform distribution).
Can also just supply the parameter values as a vector c()
if no uncertainty around the
-parameter value is to be used. The parameter order of 'bpop' is defined in the 'fg_fun' or 'fg_file'. If you use named
-arguments in 'bpop' then the order will be worked out automatically.
Matrix defining the diagonals of the IIV (same logic as for the fixed effects
-matrix bpop to define uncertainty). One can also just supply the parameter values as a c()
.
-The parameter order of 'd' is defined in the 'fg_fun' or 'fg_file'. If you use named
-arguments in 'd' then the order will be worked out automatically.
Matrix or single value defining the maximum value for each xt sample. If a single value is -supplied then all xt values are given the same maximum value.
Matrix or single value defining the minimum value for each xt sample. If a single value is -supplied then all xt values are given the same minimum value
Vector defining the max value for each covariate. If a single value is supplied then -all a values are given the same max value
Vector defining the min value for each covariate. If a single value is supplied then -all a values are given the same max value
The initial value of the FIM. If set to zero then it is computed.
The initial OFV. If set to zero then it is computed.
Should the optimization be output to the screen and to a file?
Should the sample times be optimized?
Should the continuous design variables be optimized?
Should the discrete design variables be optimized?
Are the number of sample times per group being optimized?
Are the number of individuals per group being optimized?
First step factor for sample times
Stochastic Gradient search first step factor for covariates
Number of Random search iterations
Number of iterations in random search between screen output
The method used for calculating the FIM. Potential values:
0 = Full FIM. No assumption that fixed and random effects are uncorrelated.
1 = Reduced FIM. Assume that there is no correlation in the FIM between the fixed and random effects, and set these elements in -the FIM to zero.
2 = weighted models (placeholder).
3 = Not currently used.
4 = Reduced FIM and computing all derivatives with respect to the standard deviation of the residual unexplained variation (sqrt(SIGMA) in NONMEM). -This matches what is done in PFIM, and assumes that the standard deviation of the residual unexplained variation is the estimated parameter -(NOTE: NONMEM estimates the variance of the residual unexplained variation by default).
5 = Full FIM parameterized with A,B,C matrices & derivative of variance.
6 = Calculate one model switch at a time, good for large matrices.
7 = Reduced FIM parameterized with A,B,C matrices & derivative of variance.
OFV calculation type for FIM
1 = "D-optimality". Determinant of the FIM: det(FIM)
2 = "A-optimality". Inverse of the sum of the expected parameter variances: -1/trace_matrix(inv(FIM))
4 = "lnD-optimality". Natural logarithm of the determinant of the FIM: log(det(FIM))
6 = "Ds-optimality". Ratio of the Determinant of the FIM and the Determinant of the uninteresting -rows and columns of the FIM: det(FIM)/det(FIM_u)
7 = Inverse of the sum of the expected parameter RSE: 1/sum(get_rse(FIM,poped.db,use_percent=FALSE))
Approximation method for model, 0=FO, 1=FOCE, 2=FOCEI, 3=FOI.
Use Exchange algorithm (1=TRUE, 0=FALSE)
The number of iterations entered into the blockheader_2
function.
******START OF CRITERION SPECIFICATION OPTIONS**********
D-family design (1) or ED-family design (0) (with or without parameter uncertainty)
Sample size for E-family sampling
How to sample from distributions in E-family calculations. 0=Random Sampling, 1=LatinHyperCube --
Should the Laplace method be used in calculating the expectation of the OFV?
arguments passed to other functions. See Doptim
.
This function optimized the objective function. -The function works for both discrete and continuous optimization variables. -This function takes information from the PopED database supplied as an argument. -The PopED database supplies information about the the model, parameters, design and methods to use. -Some of the arguments coming from the PopED database can be overwritten; -if they are supplied then they are used instead of the arguments from the PopED database.
-M. Foracchia, A.C. Hooker, P. Vicini and A. Ruggeri, "PopED, a software fir optimal -experimental design in population kinetics", Computer Methods and Programs in Biomedicine, 74, 2004.
J. Nyberg, S. Ueckert, E.A. Stroemberg, S. Hennig, M.O. Karlsson and A.C. Hooker, "PopED: An extended, -parallelized, nonlinear mixed effects models optimal design tool", -Computer Methods and Programs in Biomedicine, 108, 2012.
Other Optimize:
-Doptim()
,
-LEDoptim()
,
-RS_opt()
,
-a_line_search()
,
-bfgsb_min()
,
-calc_autofocus()
,
-calc_ofv_and_grad()
,
-mfea()
,
-optim_ARS()
,
-optim_LS()
,
-poped_optim_1()
,
-poped_optim_2()
,
-poped_optim_3()
,
-poped_optim()
library(PopED)
-
-############# START #################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## Optimization using an additive + proportional reidual error
-## to avoid sample times at very low concentrations (time 0 or very late samples).
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(prop=0.01,add=0.25),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0.01,
- maxxt=120,
- a=c(DOSE=70),
- mina=c(DOSE=0.01),
- maxa=c(DOSE=100))
-
-############# END ###################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-
-##############
-# D-family Optimization
-##############
-
-# below are a number of ways to optimize the problem
-
-# RS+SG+LS optimization of DOSE and sample times
-# optimization with just a few iterations
-# only to check that things are working
-out_1 <- poped_optimize(poped.db,opt_a=TRUE,opt_xt=TRUE,
- rsit=2,sgit=2,ls_step_size=2,
- iter_max=1,out_file = "")
-#> ===============================================================================
-#> Initial design evaluation
-#>
-#> Initial OFV = 55.3964
-#>
-#> Initial design
-#> expected relative standard error
-#> (%RSE, rounded to nearest integer)
-#> Parameter Values RSE_0
-#> CL 0.15 5
-#> V 8 3
-#> KA 1 14
-#> d_CL 0.07 30
-#> d_V 0.02 37
-#> d_KA 0.6 27
-#> sig_prop 0.01 32
-#> sig_add 0.25 26
-#>
-#> ==============================================================================
-#> Optimization of design parameters
-#>
-#> * Optimize Sampling Schedule
-#> * Optimize Covariates
-#>
-#> *******************************
-#> Initial Value
-#> OFV(mf) = 55.3964
-#> *******************************
-#>
-#> RS - It. : 2 OFV : 55.3964
-#>
-#> *******************************
-#> RS Results
-#> OFV(mf) = 55.3964
-#>
-#> Optimized Sampling Schedule
-#> Group 1: 0.5 1 2 6 24 36 72 120
-#>
-#> Optimized Covariates:
-#> Group 1: 70
-#>
-#> *********************************
-#>
-#> Run time for random search: 0.012 seconds
-#>
-#> SG - It. : 1 OFV : 55.45 Diff. : 1
-#> SG - It. : 2 OFV : 55.61 Diff. : 0.002799
-#>
-#> SG - Iteration 2 --------- FINAL -------------------------
-#> Normalized gradient: Grad_xt(OFV)/OFV
-#> -0.00262405731976996
-#> -0.000132025613933461
-#> 0.00495628830027523
-#> -0.000109893298136573
-#> -0.000341253151812552
-#> 2.72645778558773e-05
-#> 0.000160461624573026
-#> 3.06020413801048e-05
-#> xt opt:
-#> 0.210318514650852
-#> 0.950298514650852
-#> 2.28968148534915
-#> 5.71031851465085
-#> 23.7103185146509
-#> 36.2896814853491
-#> 72.2896814853491
-#> 120
-#> Normalized gradient: Grad_a(OFV)/OFV
-#> 6.312896e-04
-#> aopt:
-#> 7.024140e+01
-#> OFV(mf) : 55.6095
-#> diff : 0.00279928
-#> *************************************************************
-#> Stochastic gradient run time: 0.189 seconds
-#>
-#> *****************************
-#> Line Search
-#>
-#> Searching xt8 on group 1
-#> Searching xt3 on group 1
-#> Searching xt6 on group 1
-#> group 1 -- xt[6] changed from 36.2897 to 0.01
-#> OFV(MF) changed from 55.6095 to 55.7789
-#> group 1 -- xt[6] changed from 0.01 to 120
-#> OFV(MF) changed from 55.7789 to 55.8761
-#> Searching xt4 on group 1
-#> Searching xt5 on group 1
-#> Searching xt1 on group 1
-#> group 1 -- xt[1] changed from 0.210319 to 0.01
-#> OFV(MF) changed from 55.8761 to 55.9642
-#> group 1 -- xt[1] changed from 0.01 to 120
-#> OFV(MF) changed from 55.9642 to 56.0271
-#> Searching xt7 on group 1
-#> group 1 -- xt[7] changed from 72.2897 to 120
-#> OFV(MF) changed from 56.0271 to 56.0561
-#> Searching xt2 on group 1
-#> OFV(MF): 56.0561
-#>
-#> Best value for OFV(MF) = 56.0561
-#>
-#> Best value for xt:
-#> Group 1: 0.9503 2.29 5.71 23.71 120 120 120 120
-#>
-#> Searching a1 on individual/group 1
-#> group 1 -- a[1] changed from 70.2414 to 100
-#> OFV(MF) changed from 56.0561 to 56.8149
-#> OFV(MF): 56.8149
-#> Best value for OFV(MF) = 56.8149
-#>
-#> Best value for a:
-#> Group 1: 100 [0.01,100]
-#>
-#>
-#> Line search run time: 0.108 seconds
-#> ***************************
-#>
-#> ===============================================================================
-#> FINAL RESULTS
-#> Optimized Sampling Schedule
-#> Group 1: 0.9503 2.29 5.71 23.71 120 120 120 120
-#>
-#> Optimized Covariates:
-#> Group 1: 100
-#>
-#> OFV = 56.8149
-#>
-#> Efficiency:
-#> ((exp(ofv_final) / exp(ofv_init))^(1/n_parameters)) = 1.194
-#>
-#> Expected relative standard error
-#> (%RSE, rounded to nearest integer):
-#> Parameter Values RSE_0 RSE
-#> CL 0.15 5 5
-#> V 8 3 3
-#> KA 1 14 14
-#> d_CL 0.07 0 0
-#> d_V 0.02 37 34
-#> d_KA 0.6 0 0
-#> sig_prop 0.01 32 24
-#> sig_add 0.25 26 16
-#>
-#> Total running time: 0.31 seconds
-
-if (FALSE) {
-
- # RS+SG+LS optimization of sample times
- # (longer run time than above but more likely to reach a maximum)
- output <- poped_optimize(poped.db,opt_xt=T)
- get_rse(output$fmf,output$poped.db)
- plot_model_prediction(output$poped.db)
-
- # MFEA optimization with only integer times allowed
- mfea.output <- poped_optimize(poped.db,opt_xt=1,
- bUseExchangeAlgorithm=1,
- EAStepSize=1)
- get_rse(mfea.output$fmf,mfea.output$poped.db)
- plot_model_prediction(mfea.output$poped.db)
-
- # Examine efficiency of sampling windows
- plot_efficiency_of_windows(mfea.output$poped.db,xt_windows=0.5)
- plot_efficiency_of_windows(mfea.output$poped.db,xt_windows=1)
-
- # Random search (just a few samples here)
- rs.output <- poped_optimize(poped.db,opt_xt=1,opt_a=1,rsit=20,
- bUseRandomSearch= 1,
- bUseStochasticGradient = 0,
- bUseBFGSMinimizer = 0,
- bUseLineSearch = 0)
- get_rse(rs.output$fmf,rs.output$poped.db)
-
- # line search, DOSE and sample time optimization
- ls.output <- poped_optimize(poped.db,opt_xt=1,opt_a=1,
- bUseRandomSearch= 0,
- bUseStochasticGradient = 0,
- bUseBFGSMinimizer = 0,
- bUseLineSearch = 1,
- ls_step_size=10)
-
- # Stochastic gradient search, DOSE and sample time optimization
- sg.output <- poped_optimize(poped.db,opt_xt=1,opt_a=1,
- bUseRandomSearch= 0,
- bUseStochasticGradient = 1,
- bUseBFGSMinimizer = 0,
- bUseLineSearch = 0,
- sgit=20)
-
- # BFGS search, DOSE and sample time optimization
- bfgs.output <- poped_optimize(poped.db,opt_xt=1,opt_a=1,
- bUseRandomSearch= 0,
- bUseStochasticGradient = 0,
- bUseBFGSMinimizer = 1,
- bUseLineSearch = 0)
-
- ##############
- # E-family Optimization
- ##############
-
- # Adding 10% log-normal Uncertainty to fixed effects (not Favail)
- bpop_vals <- c(CL=0.15, V=8, KA=1.0, Favail=1)
- bpop_vals_ed_ln <- cbind(ones(length(bpop_vals),1)*4, # log-normal distribution
- bpop_vals,
- ones(length(bpop_vals),1)*(bpop_vals*0.1)^2) # 10% of bpop value
- bpop_vals_ed_ln["Favail",] <- c(0,1,0)
- bpop_vals_ed_ln
-
- ## -- Define initial design and design space
- poped.db <- create.poped.database(ff_file="ff.PK.1.comp.oral.sd.CL",
- fg_file="sfg",
- fError_file="feps.add.prop",
- bpop=bpop_vals_ed_ln,
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(0.01,0.25),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0,
- maxxt=120,
- a=70,
- mina=0,
- maxa=100)
-
- # ED optimization using Random search (just a few samples here)
- output <- poped_optimize(poped.db,opt_xt=1,opt_a=1,rsit=10,d_switch=0)
- get_rse(output$fmf,output$poped.db)
-
- # ED with laplace approximation,
- # optimization using Random search (just a few samples here)
- output <- poped_optimize(poped.db,opt_xt=1,opt_a=1,rsit=10,
- d_switch=0,use_laplace=TRUE,laplace.fim=TRUE)
- get_rse(output$fmf,output$poped.db)
-
-
-}
-
Generate random samples from a uniform distribution [0,1] and return in matrix form
-rand(dim1, dim2 = NULL)
The dimension of the matrix (if square), otherwise the number of rows.
The number of columns, if different from the number of rows.
Matrix of random generated samples.
-
-rand(2,3)
-#> [,1] [,2] [,3]
-#> [1,] 0.8447178 0.2868302 0.2885822
-#> [2,] 0.8602158 0.6164877 0.9087107
-
-rand(5)
-#> [,1] [,2] [,3] [,4] [,5]
-#> [1,] 0.9049117 0.5940931 0.24494388 0.5344482 0.1869131
-#> [2,] 0.1723104 0.3337554 0.24043885 0.2955405 0.9123031
-#> [3,] 0.7052867 0.3833964 0.07207165 0.5733157 0.2817364
-#> [4,] 0.2017357 0.4239477 0.63541968 0.8786657 0.1743530
-#> [5,] 0.8945690 0.6280580 0.82835438 0.2438678 0.1254093
-
Generate random samples from a standardized normal distribution and return in matrix form.
-randn(dim1, dim2 = NULL)
The dimension of the matrix (if square), otherwise the number of rows.
The number of columns, if different from the number of rows.
Matrix of random generated samples.
-
-randn(2,3)
-#> [,1] [,2] [,3]
-#> [1,] 0.1815624 -0.1510503 -1.9365325
-#> [2,] 0.7038866 -0.8166760 0.2953898
-
-randn(5)
-#> [,1] [,2] [,3] [,4] [,5]
-#> [1,] 0.3087733 -0.7993793 1.0554095 -0.84689349 1.3576308
-#> [2,] -0.2202427 2.0292053 0.2182924 -0.04316951 -0.3313580
-#> [3,] 1.0525170 1.0148143 -0.1949883 0.14934471 1.1190877
-#> [4,] -1.1703753 0.1793560 1.3504137 -0.19473851 -0.7110720
-#> [5,] 1.9194861 0.2573688 -0.6135336 -0.92924791 0.6451075
-
randperm.Rd
A wrapper for the sample
function.
randperm(num)- -
num | -Either a vector of one or more elements from which to choose, or a positive integer. |
-
---|
See sample
Other MATLAB: cell
,
- diag_matlab
, feval
,
- fileparts
, isempty
,
- ones
, randn
,
- rand
, size
,
- tic
, toc
, zeros
--randperm(c(2,3,4,5,6))#> [1] 3 2 6 5 4-randperm(10)#> [1] 2 5 9 8 3 10 1 7 4 6
R/shrinkage.R
- shrinkage.Rd
Predict shrinkage of empirical Bayes estimates (EBEs) in a population model
-shrinkage(poped.db, use_mc = FALSE, num_sim_ids = 1000, use_purrr = FALSE)
A PopED database
Should the calculation be based on monte-carlo simulations. If -not then then a first order approximation is used
If use_mc=TRUE
, how many individuals should be
-simulated to make the computations.
If use_mc=TRUE
then should the method use the package
-purrr in calculations? This may speed up computations (potentially).
The shrinkage computed in variance units, standard deviation units - and the relative standard errors of the EBEs.
-Combes, F. P., Retout, S., - Frey, N., & Mentre, F. (2013). Prediction of shrinkage of individual - parameters using the Bayesian information matrix in non-linear mixed effect - models with evaluation in pharmacokinetics. Pharmaceutical Research, 30(9), - 2355-67. doi:10.1007/s11095-013-1079-3 -.
Hennig, S., Nyberg, J., Fanta, S., Backman, J. - T., Hoppu, K., Hooker, A. C., & Karlsson, M. O. (2012). Application of the - optimal design approach to improve a pretransplant drug dose finding design - for ciclosporin. Journal of Clinical Pharmacology, 52(3), 347-360. - doi:10.1177/0091270010397731 -.
library(PopED)
-
-############# START #################
-## Create PopED database
-## (warfarin example)
-#####################################
-
-## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define model, parameters, initial design
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(prop=0.01),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- a=c(DOSE=70))
-
-############# END ###################
-## Create PopED database
-## (warfarin example)
-#####################################
-
-shrinkage(poped.db)
-#> # A tibble: 3 × 5
-#> d_CL d_V d_KA type group
-#> <dbl> <dbl> <dbl> <chr> <chr>
-#> 1 0.0244 0.174 0.0301 shrink_var grp_1
-#> 2 0.0123 0.0910 0.0152 shrink_sd grp_1
-#> 3 0.0413 0.0590 0.134 se grp_1
-
-
-
Function written to match MATLAB's size function
-size(obj, dimension.index = NULL)
An object you want to know the various dimensions of. Typically a matrix.
Which dimension you are interested in.
The dimensions of the object or specific dimension you are interested in.
-This tool chooses the type of parallelization process to use based on the -computer OS being used. For windows the default is "snow" and for Linux-like -systems the default is "multicore"
-start_parallel(
- parallel = TRUE,
- num_cores = NULL,
- parallel_type = NULL,
- seed = NULL,
- dlls = NULL,
- mrgsolve_model = NULL,
- ...
-)
Should the parallel functionality start up?
How many cores to use. Default is
-parallel::detectCores()
. See detectCores
for more information.
Which type of parallelization should be used? Can be -"snow" or "multicore". "snow" works on Linux-like systems & Windows. -"multicore" works only on Linux-like systems. By default this is chosen -for you depending on your operating system.
The random seed to use.
If the computations require compiled code (DLL's) and you are
-using the "snow" method then you need to specify the name of the DLL's without
-the extension as a text vector c("this_file","that_file")
.
If the computations require a mrgsolve model and you
-are using the "snow" method" then you need to specify the name of the model
-object created by mread
or mcode
Arguments passed to makeCluster
An atomic vector (TRUE or FALSE) with two attributes: "type" and "cores".
-R/summary.poped_optim.R
- summary.poped_optim.Rd
Display a summary of output from poped_optim
-# S3 method for poped_optim
-summary(object, ...)
An object returned from poped_optim
to summarize.
Additional arguments. Passed to blockfinal
.
library(PopED)
-
-############# START #################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-## Warfarin example from software comparison in:
-## Nyberg et al., "Methods and software tools for design evaluation
-## for population pharmacokinetics-pharmacodynamics studies",
-## Br. J. Clin. Pharm., 2014.
-
-## Optimization using an additive + proportional reidual error
-## to avoid sample times at very low concentrations (time 0 or very late samples).
-
-## find the parameters that are needed to define from the structural model
-ff.PK.1.comp.oral.sd.CL
-#> function (model_switch, xt, parameters, poped.db)
-#> {
-#> with(as.list(parameters), {
-#> y = xt
-#> y = (DOSE * Favail * KA/(V * (KA - CL/V))) * (exp(-CL/V *
-#> xt) - exp(-KA * xt))
-#> return(list(y = y, poped.db = poped.db))
-#> })
-#> }
-#> <bytecode: 0x1205aa458>
-#> <environment: namespace:PopED>
-
-## -- parameter definition function
-## -- names match parameters in function ff
-sfg <- function(x,a,bpop,b,bocc){
- parameters=c(CL=bpop[1]*exp(b[1]),
- V=bpop[2]*exp(b[2]),
- KA=bpop[3]*exp(b[3]),
- Favail=bpop[4],
- DOSE=a[1])
- return(parameters)
-}
-
-## -- Define initial design and design space
-poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL,
- fg_fun=sfg,
- fError_fun=feps.add.prop,
- bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
- notfixed_bpop=c(1,1,1,0),
- d=c(CL=0.07, V=0.02, KA=0.6),
- sigma=c(prop=0.01,add=0.25),
- groupsize=32,
- xt=c( 0.5,1,2,6,24,36,72,120),
- minxt=0.01,
- maxxt=120,
- a=c(DOSE=70),
- mina=c(DOSE=0.01),
- maxa=c(DOSE=100))
-
-############# END ###################
-## Create PopED database
-## (warfarin model for optimization)
-#####################################
-
-##############
-# D-family Optimization
-##############
-
-
-# ARS+BFGS+LS optimization of dose
-# optimization with just a few iterations
-# only to check that things are working
-out_1 <- poped_optim(poped.db,opt_a =TRUE,
- control = list(ARS=list(iter=2),
- BFGS=list(maxit=2),
- LS=list(line_length=2)),
- iter_max = 1)
-#> ===============================================================================
-#> Initial design evaluation
-#>
-#> Initial OFV = 55.3964
-#>
-#> Initial design
-#> expected relative standard error
-#> (%RSE, rounded to nearest integer)
-#> Parameter Values RSE_0
-#> CL 0.15 5
-#> V 8 3
-#> KA 1 14
-#> d_CL 0.07 30
-#> d_V 0.02 37
-#> d_KA 0.6 27
-#> sig_prop 0.01 32
-#> sig_add 0.25 26
-#>
-#> ==============================================================================
-#> Optimization of design parameters
-#>
-#> * Optimize Covariates
-#>
-#> ************* Iteration 1 for all optimization methods***********************
-#>
-#> *******************************************
-#> Running Adaptive Random Search Optimization
-#> *******************************************
-#> Initial OFV = 55.3964
-#>
-#> Total iterations: 2
-#> Elapsed time: 0.007 seconds.
-#>
-#> Final OFV = 55.39645
-#> Parameters: 70
-#>
-#> *******************************************
-#> Running BFGS Optimization
-#> *******************************************
-#> initial value -55.396450
-#> final value -55.766379
-#> stopped after 2 iterations
-#>
-#> *******************************************
-#> Running Line Search Optimization
-#> *******************************************
-#>
-#> Initial parameters: 83.20112
-#> Initial OFV: 55.76638
-#>
-#> Searching parameter 1
-#> Changed from 83.2011 to 100 ; OFV = 56.032
-#>
-#> Elapsed time: 0.015 seconds.
-#>
-#> Final OFV = 56.03204
-#> Parameters: 100
-#>
-#> *******************************************
-#> Stopping criteria testing
-#> (Compare between start of iteration and end of iteration)
-#> *******************************************
-#> Difference in OFV: 0.636
-#> Relative difference in OFV: 1.15%
-#> Efficiency:
-#> ((exp(ofv_final) / exp(ofv_init))^(1/n_parameters)) = 1.0827
-#>
-#> Efficiency stopping criteria:
-#> Is (1.0827 <= 1.001)? No.
-#> Stopping criteria NOT achieved.
-#>
-#> Stopping criteria NOT achieved.
-#>
-#> ===============================================================================
-#> FINAL RESULTS
-#>
-#> Optimized Covariates:
-#> Group 1: 100
-#>
-#> OFV = 56.032
-#>
-#> Efficiency:
-#> ((exp(ofv_final) / exp(ofv_init))^(1/n_parameters)) = 1.0827
-#>
-#> Expected relative standard error
-#> (%RSE, rounded to nearest integer):
-#> Parameter Values RSE_0 RSE
-#> CL 0.15 5 5
-#> V 8 3 3
-#> KA 1 14 14
-#> d_CL 0.07 30 28
-#> d_V 0.02 37 34
-#> d_KA 0.6 27 26
-#> sig_prop 0.01 32 23
-#> sig_add 0.25 26 30
-#>
-#> Total running time: 0.131 seconds
-
-
-summary(out_1)
-#> ===============================================================================
-#> FINAL RESULTS
-#>
-#> Optimized Covariates:
-#> Group 1: 100
-#>
-#> OFV = 56.032
-#>
-#> Efficiency:
-#> ((exp(ofv_final) / exp(ofv_init))^(1/n_parameters)) = 1.0827
-#>
-#> Expected relative standard error
-#> (%RSE, rounded to nearest integer):
-#> Parameter Values RSE_0 RSE
-#> CL 0.15 5 5
-#> V 8 3 3
-#> KA 1 14 14
-#> d_CL 0.07 30 28
-#> d_V 0.02 37 34
-#> d_KA 0.6 27 26
-#> sig_prop 0.01 32 23
-#> sig_add 0.25 26 30
-#>
-#> Total running time: 0.131 seconds
-
Function tests is any matrix element is above a maximum value. For those elements -the function sets those values to the maximum value.
- - -test_for_max(mat, max_mat)- -
A matrix
- -Other matrix_manipulation: diag_matlab
,
- test_for_min
, test_for_zeros
--test_for_max(cbind(2,3,4,5,6),cbind(4,4,4,4,4))#> [,1] [,2] [,3] [,4] [,5] -#> [1,] 2 3 4 4 4#> [,1] [,2] [,3] [,4] [,5] [,6] -#> [1,] 40 40 40 40 40 40 -#> [2,] 40 40 40 40 40 40 -#> [3,] 40 40 40 40 40 40 -#> [4,] 40 40 40 40 40 40 -#> [5,] 40 40 40 40 40 40 -#> [6,] 40 40 40 40 40 40- - -
Function tests is any matrix element is above a minimum value. For those elements -the function sets those values to the minimum value.
- - -test_for_min(mat, min_mat)- -
A matrix
- -Other matrix_manipulation: diag_matlab
,
- test_for_max
, test_for_zeros
--test_for_min(cbind(2,3,4,5,6),cbind(4,4,4,4,4))#> [,1] [,2] [,3] [,4] [,5] -#> [1,] 4 4 4 5 6#> [,1] [,2] [,3] [,4] [,5] [,6] -#> [1,] 45 45 45 45 45 45 -#> [2,] 45 45 45 45 45 45 -#> [3,] 45 45 45 45 45 45 -#> [4,] 45 45 45 45 45 45 -#> [5,] 45 45 45 45 45 45 -#> [6,] 45 45 45 45 45 45- - - -
test_for_zeros.Rd
Function tests is any matrix element is zero. For those elements -the function sets those values to the minimum value allowed (not zero). -This is used to avoid numerical problems in the FIM calculation.
- -test_for_zeros(mat, ourzero)- -
mat | -A matrix. |
-
---|---|
ourzero | -A matrix the same size as mat with the value that zero should be reassigned to. |
-
A matrix
- -Other matrix_manipulation: diag_matlab
--test_for_zeros(cbind(2,3,0,5,6),1e-18)#> [,1] [,2] [,3] [,4] [,5] -#> [1,] 2 3 1e-18 5 6#> [,1] [,2] [,3] [,4] [,5] [,6] -#> [1,] 1e-07 1e-07 1e-07 1e-07 1e-07 1e-07 -#> [2,] 1e-07 1e-07 1e-07 1e-07 1e-07 1e-07 -#> [3,] 1e-07 1e-07 1e-07 1e-07 1e-07 1e-07 -#> [4,] 1e-07 1e-07 1e-07 1e-07 1e-07 1e-07 -#> [5,] 1e-07 1e-07 1e-07 1e-07 1e-07 1e-07 -#> [6,] 1e-07 1e-07 1e-07 1e-07 1e-07 1e-07-test_for_zeros(cbind(1,2,3,NA,0),1e-5)#> [,1] [,2] [,3] [,4] [,5] -#> [1,] 1 2 3 NA 1e-05- - -
R/test_mat_size.R
- test_mat_size.Rd
Test to make sure that matricies are the right size
-test_mat_size(correct_size, mat, name)
the correct size of a matrix
The matrix to test.
The name of the matrix as a string.
Function to start a timer. Stop with toc().
-tic(gcFirst = FALSE, name = ".poped_savedTime")
Perform garbage collection?
The saved name of the time object.
This is a modified version of the same function in the matlab R-package.
-Function to stop a timer. Start with tic().
-toc(echo = TRUE, name = ".poped_savedTime")
Print time to screen?
The saved name of the time object.
This is a modified version of the same function in the matlab R-package.
-Catch *and* save both errors and warnings, and in the case of -a warning, also keep the computed result.
-tryCatch.W.E(expr)
an R expression to evaluate
a list with 'value' and 'warning', where - 'value' may be an error caught.
-Create a matrix of zeros of size (dim1 x dim2).
-zeros(dim1, dim2 = NULL)
The dimension of the matrix (if square) or the number of rows.
The number of columns
A matrix of zeros.
-
-zeros(3)
-#> [,1] [,2] [,3]
-#> [1,] 0 0 0
-#> [2,] 0 0 0
-#> [3,] 0 0 0
-zeros(0,3)
-#> [,1] [,2] [,3]
-zeros(4,7)
-#> [,1] [,2] [,3] [,4] [,5] [,6] [,7]
-#> [1,] 0 0 0 0 0 0 0
-#> [2,] 0 0 0 0 0 0 0
-#> [3,] 0 0 0 0 0 0 0
-#> [4,] 0 0 0 0 0 0 0
-zeros(1,4)
-#> [,1] [,2] [,3] [,4]
-#> [1,] 0 0 0 0
-