diff --git a/docs/404.html b/docs/404.html index e159e26..c9fabb4 100644 --- a/docs/404.html +++ b/docs/404.html @@ -1,74 +1,34 @@ - - - - + + + + - Page not found (404) • PopED - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + - - - - -
-
- + +
+ + + - - -
+
+
-
+ + - - diff --git a/docs/LICENSE.html b/docs/LICENSE.html index 6aa4e69..a5d41f3 100644 --- a/docs/LICENSE.html +++ b/docs/LICENSE.html @@ -1,74 +1,12 @@ - - - - - - - -NA • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -NA • PopED - - - - + + -
-
- -
- -
+
+
-
- - + + diff --git a/docs/articles/examples.html b/docs/articles/examples.html index f3a9237..b51eddc 100644 --- a/docs/articles/examples.html +++ b/docs/articles/examples.html @@ -26,6 +26,8 @@ + +
+
-
-

-Introduction

-

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:

+
+

Introduction +

+

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

+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.

+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.

++++++++++++++++++ @@ -524,328 +553,389 @@

Features Ex1
-

Note: All features are available in PopED but some are not demonstrated in the supplied examples.

+

Note: All features are available in PopED but some are not +demonstrated in the supplied examples.

-
-

-Analytic solution of PKPD model, multiple study arms

-

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).

+
+

Analytic solution of PKPD model, multiple study arms +

+

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))
-  })
-}
+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.

+## -- 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.

+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")) 
+plot_model_prediction( + poped.db,PI=TRUE, + facet_scales="free", + separate.groups=TRUE, + model.names=c("PK","PD"))

-
-

-ODE solution of PK model, multiple dosing

-

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).

+
+

ODE solution of PK model, multiple dosing +

+

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

+library(deSolve)
+

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.

+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.

+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

+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)
+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.

+

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.

+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.

+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.

+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: 3.535 seconds.
-tic(); eval <- evaluate_design(poped.db.Rcpp); toc()
-#> Elapsed time: 1.899 seconds.
-

The difference is noticeable and gets larger for more complex ODE models.

+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.

-
-

-ODE solution of TMDD model with 2 outputs, Multiple arms, different dose routes, different number of sample times per arm

-

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.

+
+

ODE solution of TMDD model with 2 outputs, Multiple arms, different +dose routes, different number of sample times per arm +

+

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))
-  })
-}
+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.

+

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.

+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.

+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")
+plot_model_prediction(poped.db.2,facet_scales="free")

-eval_2 <- evaluate_design(poped.db.2)
-round(eval_2$rse) # in percent
+eval_2 <- evaluate_design(poped.db.2) +round(eval_2$rse) # in percent @@ -943,105 +1033,122 @@

-
-

-Model with continuous covariates

-

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.

+
+

Model with continuous covariates +

+

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)).

+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

+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)
+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)).

+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))
-  )
+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
+ev <- evaluate_design(poped_db_2) +round(ev$ofv,1) +#> [1] 42.4
-round(ev$rse)
+round(ev$rse) @@ -1058,11 +1165,11 @@

- + - + @@ -1078,32 +1185,36 @@

WT_CL3028
WT_V2321
d_CL
-

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.

+

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))
+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)) @@ -1120,9 +1231,9 @@

- - - + + + @@ -1130,8 +1241,8 @@

- - + + @@ -1140,8 +1251,8 @@

- - + + @@ -1150,128 +1261,147 @@

- - + + - - - - + + + + - +
0% 3.25 3.3225.2519.3821.0223.7418.1921.03 21.95 10.06
25% 3.25 3.3228.3321.7127.1120.79 21.03 21.95 10.0750% 3.26 3.3329.8022.8429.9622.96 21.03 21.96 10.0775% 3.29 3.3631.9524.4932.9225.23 21.03 21.96 10.07
100%3.583.6636.2927.803.423.4936.9528.31 21.0321.9721.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).

+

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).

-
-

-Model with discrete covariates

-

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.

+
+

Model with discrete covariates +

+

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.

-
-

-Model with Inter-Occasion Variability (IOV)

-

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.

+
+

Model with Inter-Occasion Variability (IOV) +

+

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).

+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.

+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.

+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")
+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:

+

We can also see that the design is relatively poor for estimating the +IOV parameter:

-ev <- evaluate_design(poped.db)
-round(ev$rse)
+ev <- evaluate_design(poped.db) +round(ev$rse) @@ -1309,55 +1439,61 @@

-
-

-Full omega matrix

-

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).

+
+

Full omega matrix +

+

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
-  )
+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.

+(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)
+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)
+ev1 <- evaluate_design(poped.db) +ev2 <- evaluate_design(poped.db_with)
-round(ev1$rse)
-round(ev2$rse)
+round(ev1$rse) +round(ev2$rse) @@ -1417,14 +1553,17 @@

-

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)

+

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)
+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) @@ -1485,410 +1624,471 @@

-
-

-Include a prior FIM, compute power to identify a parameter

-

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.

+
+

Include a prior FIM, compute power to identify a parameter +

+

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.

+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))
-  )
+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)
+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):

+(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.

+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))
-  )
+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)
+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
+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).

+

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).

+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\)).

+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\)).

-
-

-Design evaluation including uncertainty in the model parameters (robust design)

-

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:

+
+

Design evaluation including uncertainty in the model parameters +(robust design) +

+

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.

+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:

+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.264 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.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.272 seconds.
+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. -
-

-Design evaluation for a subset of model parameters of interest (Ds optimality)

-

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.

+
+

Design evaluation for a subset of model parameters of interest (Ds +optimality) +

+

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
+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
+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
-
-

-Shrinkage

-

The full code for this example is available in “ex.13.shrinkage.R”.

+
+

Shrinkage +

+

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().

+

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 x 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.

+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.

-
-

-Further examples

+
+

Further examples +

Available in PopED, but not shown in examples:

@@ -1897,11 +2097,19 @@

  • Symbolic differentiation
  • -
    +

      -
    1. 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↩︎

    2. -
    3. 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↩︎

    4. +
    5. 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↩︎

    6. +
    7. 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↩︎

    @@ -1917,11 +2125,13 @@

    @@ -1930,5 +2140,7 @@

    + + diff --git a/docs/articles/examples_files/figure-html/simulate_IOV_with_IIV-1.png b/docs/articles/examples_files/figure-html/simulate_IOV_with_IIV-1.png index a7a4e85..e2610f0 100644 Binary files a/docs/articles/examples_files/figure-html/simulate_IOV_with_IIV-1.png and b/docs/articles/examples_files/figure-html/simulate_IOV_with_IIV-1.png differ diff --git a/docs/articles/examples_files/figure-html/simulate_ODE_model-1.png b/docs/articles/examples_files/figure-html/simulate_ODE_model-1.png index 2ce5cdf..27e3fb0 100644 Binary files a/docs/articles/examples_files/figure-html/simulate_ODE_model-1.png and b/docs/articles/examples_files/figure-html/simulate_ODE_model-1.png differ diff --git a/docs/articles/examples_files/figure-html/simulate_adult-1.png b/docs/articles/examples_files/figure-html/simulate_adult-1.png index 7fa6951..bb9e44b 100644 Binary files a/docs/articles/examples_files/figure-html/simulate_adult-1.png and b/docs/articles/examples_files/figure-html/simulate_adult-1.png differ diff --git a/docs/articles/examples_files/figure-html/simulate_different_dose_regimen-1.png b/docs/articles/examples_files/figure-html/simulate_different_dose_regimen-1.png index bb86657..6f89bfd 100644 Binary files a/docs/articles/examples_files/figure-html/simulate_different_dose_regimen-1.png and b/docs/articles/examples_files/figure-html/simulate_different_dose_regimen-1.png differ diff --git a/docs/articles/examples_files/figure-html/simulate_multi-response_model-1.png b/docs/articles/examples_files/figure-html/simulate_multi-response_model-1.png index 5636a40..ed55be5 100644 Binary files a/docs/articles/examples_files/figure-html/simulate_multi-response_model-1.png and b/docs/articles/examples_files/figure-html/simulate_multi-response_model-1.png differ diff --git a/docs/articles/examples_files/figure-html/simulate_pediatrics-1.png b/docs/articles/examples_files/figure-html/simulate_pediatrics-1.png index f2994aa..2922876 100644 Binary files a/docs/articles/examples_files/figure-html/simulate_pediatrics-1.png and b/docs/articles/examples_files/figure-html/simulate_pediatrics-1.png differ diff --git a/docs/articles/examples_files/figure-html/simulate_with_cov_matrix-1.png b/docs/articles/examples_files/figure-html/simulate_with_cov_matrix-1.png index 8ac6f9d..cc91110 100644 Binary files a/docs/articles/examples_files/figure-html/simulate_with_cov_matrix-1.png and b/docs/articles/examples_files/figure-html/simulate_with_cov_matrix-1.png differ diff --git a/docs/articles/examples_files/figure-html/unnamed-chunk-24-1.png b/docs/articles/examples_files/figure-html/unnamed-chunk-24-1.png index bffb1d8..472b39d 100644 Binary files a/docs/articles/examples_files/figure-html/unnamed-chunk-24-1.png and b/docs/articles/examples_files/figure-html/unnamed-chunk-24-1.png differ diff --git a/docs/articles/examples_files/figure-html/unnamed-chunk-61-1.png b/docs/articles/examples_files/figure-html/unnamed-chunk-61-1.png index 5b8be77..be38fd2 100644 Binary files a/docs/articles/examples_files/figure-html/unnamed-chunk-61-1.png and b/docs/articles/examples_files/figure-html/unnamed-chunk-61-1.png differ diff --git a/docs/articles/handling_LOQ.html b/docs/articles/handling_LOQ.html index 8af6ef8..de413d8 100644 --- a/docs/articles/handling_LOQ.html +++ b/docs/articles/handling_LOQ.html @@ -26,6 +26,8 @@ + +
    +
    @@ -114,69 +118,82 @@

    21 May, 2021

    -library(PopED)
    -packageVersion("PopED")
    -#> [1] '0.6.0'
    -
    -

    -Define a model

    -

    Here we define, as an example, a one-compartment pharmacokinetic model with linear absorption (analytic solution) in PopED (Nyberg et al. 2012).

    +library(PopED) +packageVersion("PopED") +#> [1] '0.6.0.9002'
    +
    +

    Define a model +

    +

    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. DOSEis defined as a covariate (in vector a) so that we can optimize the value later.

    +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. DOSEis +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.

    +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.

    -
    -

    -Define an initial design and design space

    -

    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.

    +
    +

    Define an initial design and design space +

    +

    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)
    -                                
    +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) +
    -
    -

    -Simulation

    -

    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:

    +
    +

    Simulation +

    +

    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)
    +plot_model_prediction(poped_db, model_num_points = 500,facet_scales = "free",PI=T)

    -
    -

    -Design evaluation

    -

    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.

    +
    +

    Design evaluation +

    +

    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)
    - +eval_full <- evaluate_design(poped_db) +
    @@ -255,55 +272,76 @@

    Expected parameter RSE (in %) for the initial design.
    -
    -

    -LOQ handling

    +
    +

    LOQ handling +

    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")
    +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).

    +

    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.367 
    -#> D2 evaluation time:  0.135
    +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.

    - +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.

    +
    -RSE (in %) for the initial design using different methods of handling LOQ. +RSE (in %) for the initial design using different methods of handling +LOQ.
    @@ -434,31 +472,34 @@

    -
    -

    -ULOQ handling

    -

    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:

    +
    +

    ULOQ handling +

    +

    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")
    +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.
    - +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. +
    -RSE (in %) for the initial design using different methods of handling LOQ and ULOQ. +RSE (in %) for the initial design using different methods of handling +LOQ and ULOQ.
    @@ -645,42 +686,49 @@

    -
    -

    -Design optimization

    -

    We can then optimize the design using the different methods of computing the FIM. Here we optimize only using lower LOQ.

    +
    +

    Design optimization +

    +

    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)
    -All designs together in one plot show how the different handling of BLQ data results in different optimal designs. +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)
    +All designs together in one plot show how the different handling of BLQ +data results in different optimal designs.
    Design points for the apraoch ignoring LOQ, using the D2 method, and using the D6 method

    -Design points for the apraoch ignoring LOQ, using the D2 method, and using the D6 method +Design points for the apraoch ignoring LOQ, using the D2 method, and +using the D6 method

    -

    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.

    +

    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))
    - +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)) +
    @@ -814,62 +862,79 @@

    RSE (in %) for the optimized designs evaluated using the D6 method.
    -
    -

    -Version information

    +
    +

    Version information +

    -sessionInfo()
    -#> R version 4.1.0 (2021-05-18)
    -#> Platform: x86_64-apple-darwin17.0 (64-bit)
    -#> Running under: macOS Big Sur 10.16
    -#> 
    -#> Matrix products: default
    -#> BLAS:   /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRblas.dylib
    -#> LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib
    -#> 
    -#> locale:
    -#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
    -#> 
    -#> attached base packages:
    -#> [1] stats     graphics  grDevices utils     datasets  methods   base     
    -#> 
    -#> other attached packages:
    -#> [1] kableExtra_1.3.4 knitr_1.33       ggplot2_3.3.3    PopED_0.6.0     
    -#> [5] testthat_3.0.2  
    -#> 
    -#> loaded via a namespace (and not attached):
    -#>  [1] svglite_2.0.0     mvtnorm_1.1-1     prettyunits_1.1.1 ps_1.6.0         
    -#>  [5] gtools_3.8.2      assertthat_0.2.1  rprojroot_2.0.2   digest_0.6.27    
    -#>  [9] utf8_1.2.1        R6_2.5.0          evaluate_0.14     highr_0.9        
    -#> [13] httr_1.4.2        pillar_1.6.1      rlang_0.4.11      rstudioapi_0.13  
    -#> [17] callr_3.7.0       jquerylib_0.1.4   rmarkdown_2.8     pkgdown_1.6.1    
    -#> [21] labeling_0.4.2    textshaping_0.3.4 desc_1.3.0        devtools_2.4.1   
    -#> [25] webshot_0.5.2     stringr_1.4.0     munsell_0.5.0     compiler_4.1.0   
    -#> [29] xfun_0.23         pkgconfig_2.0.3   systemfonts_1.0.2 pkgbuild_1.2.0   
    -#> [33] htmltools_0.5.1.1 tidyselect_1.1.1  tibble_3.1.2      bookdown_0.22    
    -#> [37] codetools_0.2-18  viridisLite_0.4.0 fansi_0.4.2       crayon_1.4.1     
    -#> [41] dplyr_1.0.6       withr_2.4.2       MASS_7.3-54       grid_4.1.0       
    -#> [45] jsonlite_1.7.2    gtable_0.3.0      lifecycle_1.0.0   DBI_1.1.1        
    -#> [49] magrittr_2.0.1    scales_1.1.1      cli_2.5.0         stringi_1.6.2    
    -#> [53] cachem_1.0.5      farver_2.1.0      fs_1.5.0          remotes_2.3.0    
    -#> [57] xml2_1.3.2        bslib_0.2.5.1     ellipsis_0.3.2    ragg_1.1.2       
    -#> [61] vctrs_0.3.8       generics_0.1.0    boot_1.3-28       tools_4.1.0      
    -#> [65] glue_1.4.2        purrr_0.3.4       processx_3.5.2    pkgload_1.2.1    
    -#> [69] fastmap_1.1.0     yaml_2.2.1        colorspace_2.0-1  sessioninfo_1.1.1
    -#> [73] rvest_1.0.0       memoise_2.0.0     sass_0.4.0        usethis_2.0.1
    +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
    -
    -

    -References

    +
    +

    References +

    -Nyberg, Joakim, Caroline Bazzoli, Kay Ogungbenro, Alexander Aliev, Sergei Leonov, Stephen Duffull, Andrew C Hooker, and France Mentré. 2015. Methods and software tools for design evaluation in population pharmacokinetics-pharmacodynamics studies.” British Journal of Clinical Pharmacology 79 (1): 6–17. https://doi.org/10.1111/bcp.12352. +Nyberg, Joakim, Caroline Bazzoli, Kay Ogungbenro, Alexander Aliev, +Sergei Leonov, Stephen Duffull, Andrew C Hooker, and France Mentré. +2015. Methods and software tools for design +evaluation in population pharmacokinetics-pharmacodynamics +studies.” British Journal of Clinical +Pharmacology 79 (1): 6–17. https://doi.org/10.1111/bcp.12352.
    -Nyberg, Joakim, Sebastian Ueckert, Eric A. Strömberg, Stefanie Hennig, Mats O. Karlsson, and Andrew C. Hooker. 2012. PopED: An extended, parallelized, nonlinear mixed effects models optimal design tool.” Computer Methods and Programs in Biomedicine 108 (2): 789–805. https://doi.org/10.1016/j.cmpb.2012.05.005. +Nyberg, Joakim, Sebastian Ueckert, Eric A. Strömberg, Stefanie Hennig, +Mats O. Karlsson, and Andrew C. Hooker. 2012. PopED: An extended, parallelized, nonlinear mixed effects +models optimal design tool.” Computer Methods and +Programs in Biomedicine 108 (2): 789–805. https://doi.org/10.1016/j.cmpb.2012.05.005.
    -Vong, Camille, Sebastian Ueckert, Joakim Nyberg, and Andrew C. Hooker. 2012. “Handling Below Limit of Quantification Data in Optimal Trial Design.” PAGE, Abstracts of the Annual Meeting of the Population Approach Group in Europe. https://www.page-meeting.org/?abstract=2578. +Vong, Camille, Sebastian Ueckert, Joakim Nyberg, and Andrew C. Hooker. +2012. “Handling Below Limit of Quantification Data in Optimal +Trial Design.” PAGE, Abstracts of the Annual Meeting of the +Population Approach Group in Europe. https://www.page-meeting.org/?abstract=2578.
    @@ -886,11 +951,13 @@

    @@ -899,5 +966,7 @@

    + + diff --git a/docs/articles/handling_LOQ_files/figure-html/simulate_without_BSV-1.png b/docs/articles/handling_LOQ_files/figure-html/simulate_without_BSV-1.png index d03721d..436b749 100644 Binary files a/docs/articles/handling_LOQ_files/figure-html/simulate_without_BSV-1.png and b/docs/articles/handling_LOQ_files/figure-html/simulate_without_BSV-1.png differ diff --git a/docs/articles/handling_LOQ_files/figure-html/unnamed-chunk-10-1.png b/docs/articles/handling_LOQ_files/figure-html/unnamed-chunk-10-1.png index 2dbb0c4..842e160 100644 Binary files a/docs/articles/handling_LOQ_files/figure-html/unnamed-chunk-10-1.png and b/docs/articles/handling_LOQ_files/figure-html/unnamed-chunk-10-1.png differ diff --git a/docs/articles/handling_LOQ_files/figure-html/unnamed-chunk-16-1.png b/docs/articles/handling_LOQ_files/figure-html/unnamed-chunk-16-1.png index b5c72f1..3f89bc5 100644 Binary files a/docs/articles/handling_LOQ_files/figure-html/unnamed-chunk-16-1.png and b/docs/articles/handling_LOQ_files/figure-html/unnamed-chunk-16-1.png differ diff --git a/docs/articles/handling_LOQ_files/figure-html/unnamed-chunk-6-1.png b/docs/articles/handling_LOQ_files/figure-html/unnamed-chunk-6-1.png index 96bcbe5..0fd0689 100644 Binary files a/docs/articles/handling_LOQ_files/figure-html/unnamed-chunk-6-1.png and b/docs/articles/handling_LOQ_files/figure-html/unnamed-chunk-6-1.png differ diff --git a/docs/articles/index.html b/docs/articles/index.html index adedc76..1ed8510 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -1,74 +1,12 @@ - - - - - - - -Articles • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Articles • PopED - - + + - - -
    -
    - -
    - - -
    - - + + diff --git a/docs/articles/intro-poped.html b/docs/articles/intro-poped.html index 262a24b..def7670 100644 --- a/docs/articles/intro-poped.html +++ b/docs/articles/intro-poped.html @@ -26,6 +26,8 @@ + +
    +
    -

    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).

    +

    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. See ?poped for more information.

    -

    Below is an example to introduce the package. This example and several other examples, are available as r-scripts in the “examples” folder in the PopED installation directory located at:

    +

    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")
    +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, the code found in this vignette) using the following code

    +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.

    -
    -

    -Define a model

    -

    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).

    +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.

    +
    +

    Define a model +

    +

    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'
    +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.

    +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.

    +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)) 
    -}
    +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)) +}

    -
    -

    -Create a PopED database

    -

    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).

    +
    +

    Create a PopED database +

    +

    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)
    +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)
    -
    -

    -Design simulation

    -

    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:

    +
    +

    Design simulation +

    +

    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)
    +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.

    +

    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)
    +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
    +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

    -
    -

    -Design evaluation

    +
    +

    Design evaluation +

    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.

    -
    -

    -Evaluate alternative design

    -

    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:

    +(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.

    +
    +

    Evaluate alternative design +

    +

    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)
    +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
    +(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
    -
    -

    -Comparison of designs

    -

    The precision on CL is similar with the alternative design but the other parameters are less well estimated.

    +
    +

    Comparison of designs +

    +

    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_eval <- round(data.frame("Design 1"=ds1$rse,"Design 2"=ds2$rse)))
    @@ -373,157 +428,189 @@

    -

    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).

    +

    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)"
    +efficiency(ds2$ofv,ds1$ofv,poped.db) +#> [1] 3.965919 +#> attr(,"description") +#> [1] "(exp(ofv_final) / exp(ofv_init))^(1/n_parameters)"
    -
    -

    -Design optimization

    -

    Now we can optimize the sample times of the original design by maximizing the OFV1.

    +
    +

    Design optimization +

    +

    Now we can optimize the sample times of the original design by +maximizing the OFV1.

    -output <- poped_optim(poped.db, opt_xt=TRUE)
    +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: 23.15 seconds
    -plot_model_prediction(output$poped.db)
    +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.

    -
    -

    -Examine efficiency of sampling windows

    -

    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).

    +

    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.

    +
    +

    Examine efficiency of sampling windows +

    +

    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)
    +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.

    +

    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.

    -
    -

    -Optimize over a discrete design space

    -

    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.

    +
    +

    Optimize over a discrete design space +

    +

    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)
    +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: 13.47 seconds
    -plot_model_prediction(output_discrete$poped.db, model_num_points = 300)
    +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.

    +

    Here we see that the optimization ran somewhat quicker, but gave a +less efficient design.

    -
    -

    -Optimize ‘Other’ design variables

    -

    One could also optimize over dose, to see if a different dose could help in parameter estimation .

    +
    +

    Optimize ‘Other’ design variables +

    +

    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).

    +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).

    -
    -

    -Cost function to optimize dose

    -

    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.

    +
    +

    Cost function to optimize dose +

    +

    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
    +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)
    +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: 4.739 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:

    +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))
    +library(ggplot2) +plot_model_prediction(output_cost$poped.db, model_num_points = 300)+ + coord_cartesian(xlim=c(230,250))

    -
    +

      -
    1. Tip: to make the optimization run faster use the option parallel = TRUE in the poped_optim command.↩︎

    2. +
    3. Tip: to make the optimization run faster use the option +parallel = TRUE in the poped_optim command.↩︎

    @@ -539,11 +626,13 @@

    @@ -552,5 +641,7 @@

    + + diff --git a/docs/articles/intro-poped_files/figure-html/simulate_discrete_optimization-1.png b/docs/articles/intro-poped_files/figure-html/simulate_discrete_optimization-1.png index 376c9a2..50cb5a7 100644 Binary files a/docs/articles/intro-poped_files/figure-html/simulate_discrete_optimization-1.png and b/docs/articles/intro-poped_files/figure-html/simulate_discrete_optimization-1.png differ diff --git a/docs/articles/intro-poped_files/figure-html/simulate_efficiency_windows-1.png b/docs/articles/intro-poped_files/figure-html/simulate_efficiency_windows-1.png index e261722..3401bdb 100644 Binary files a/docs/articles/intro-poped_files/figure-html/simulate_efficiency_windows-1.png and b/docs/articles/intro-poped_files/figure-html/simulate_efficiency_windows-1.png differ diff --git a/docs/articles/intro-poped_files/figure-html/simulate_optimal_design-1.png b/docs/articles/intro-poped_files/figure-html/simulate_optimal_design-1.png index 52bca0c..0b22983 100644 Binary files a/docs/articles/intro-poped_files/figure-html/simulate_optimal_design-1.png and b/docs/articles/intro-poped_files/figure-html/simulate_optimal_design-1.png differ diff --git a/docs/articles/intro-poped_files/figure-html/simulate_with_BSV-1.png b/docs/articles/intro-poped_files/figure-html/simulate_with_BSV-1.png index b595448..7eb8541 100644 Binary files a/docs/articles/intro-poped_files/figure-html/simulate_with_BSV-1.png and b/docs/articles/intro-poped_files/figure-html/simulate_with_BSV-1.png differ diff --git a/docs/articles/intro-poped_files/figure-html/simulate_without_BSV-1.png b/docs/articles/intro-poped_files/figure-html/simulate_without_BSV-1.png index 28b4a21..d70e92c 100644 Binary files a/docs/articles/intro-poped_files/figure-html/simulate_without_BSV-1.png and b/docs/articles/intro-poped_files/figure-html/simulate_without_BSV-1.png differ diff --git a/docs/articles/intro-poped_files/figure-html/unnamed-chunk-16-1.png b/docs/articles/intro-poped_files/figure-html/unnamed-chunk-16-1.png index 802dd6a..ac7e4f3 100644 Binary files a/docs/articles/intro-poped_files/figure-html/unnamed-chunk-16-1.png and b/docs/articles/intro-poped_files/figure-html/unnamed-chunk-16-1.png differ diff --git a/docs/articles/model_def_other_pkgs.html b/docs/articles/model_def_other_pkgs.html index 7397984..8102843 100644 --- a/docs/articles/model_def_other_pkgs.html +++ b/docs/articles/model_def_other_pkgs.html @@ -26,6 +26,8 @@ + +
    +
    -
    -

    -Introduction

    -

    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 hierarchical, ordinary differential equation (ODE) based models. In this document you will see how to couple PopED to models, defined with ODEs, implemented using:

    +
    +

    Introduction +

    +

    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:

    • deSolve (with native R ODE models)
    • deSolve (with compiled C ODE models)
    • deSolve (with compiled C++ ODE models using Rcpp)
    • PKPDsim
    • mrgsolve
    • -
    • RxODE
    • +
    • rxode2
    -

    For the future we will also show how to use

    -
      -
    • PKPDmodels
    • -
    • dMod
    • -
    +library(PopED) +library(PKPDsim) +library(mrgsolve) +library(deSolve) +library(Rcpp) +library(rxode2)
    + + +
    -
    -

    -The model

    -

    In this example we will use a one-compartment linear absorption model

    -

    - - +
    +

    The model +

    +

    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} @@ -153,33 +160,36 @@

    \frac{dA_{1}}{dt} &=-(CL/V_1)\cdot A_1 + k_{a} \cdot A_{0} \\ f(t) &= A_1/V_1 \end{split} - (\#eq:ode) \]

    -

    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

    +

    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} + 0, &\text{otherwise} \end{cases} - (\#eq:input) \]

    Parameter values are defined as:

    \[ \begin{split} - k_a &= \theta_1 \cdot e^{\eta_1} \\ - CL &= \theta_2 \cdot e^{\eta_2} \\ - V_1 &= \theta_3 \cdot e^{\eta_3} \\ + 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} - (\#eq:par) -\] 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

    +\] 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 = A_1/V_1 \cdot (1+\varepsilon_1) + \varepsilon_2 - (\#eq:ruv) + 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 shown in Table @ref(tab:values).
    +

    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: + +
    @@ -259,595 +269,648 @@

    Model parameter values.

    -
    -

    -Model implementation

    -

    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.).

    -
    -

    -Analytic solution

    -

    First we implement an analytic solution to the model in a function that could be used in PopED.

    +
    +

    Model implementation +

    +

    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.).

    +
    +

    Analytic solution +

    +

    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 <- function(model_switch,xt,parameters,poped.db){
    -  with(as.list(parameters),{
    -    y=xt
    -    N = floor(xt/TAU)+1
    -    y=(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( y=y,poped.db=poped.db))
    -  })
    -}
    +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)) + }) +}
    -
    -

    -ODE solution using deSolve

    -

    Model using ODEs defined in deSolve

    +
    +

    ODE solution using deSolve +

    +

    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)))
    -  })
    -}
    +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 integration
    -    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"]),]
    +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))
    +  })
    +}
    +
    +
    +

    ODE solution using deSolve and compiled C code +

    +

    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)
    +{
         
    -    y = out[,"A2"]/V
    +  if (ip[0] <1) error("nout should be at least 1");
         
    -    y=cbind(y) # must be a column matrix 
    -    return(list(y=y,poped.db=poped.db))
    -  })
    -}
    -
    -
    -

    -ODE solution using deSolve and compiled C code

    -

    Model using ODEs defined in deSolve with compiled code

    -
    -cat(readChar(system.file("examples/one_comp_oral_CL.c", package="PopED"), 1e5))
    -#> /* file tmdd_qss_one_target.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 tmdd_qss_one_target.c */
    + 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 = ""))
    +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 start of integration
    -    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))
    -  })
    -}
    +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)) + }) +}
    -
    -

    -ODE solution using deSolve and compiled C++ code (via Rcpp)

    +
    +

    ODE solution using deSolve and compiled C++ code (via Rcpp) +

    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);
    -}')
    +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))
    -}
    +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)) +}
    -
    -

    -ODE solution using PKPDsim

    +
    +

    ODE solution using PKPDsim +

    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))
    -}
    +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)) +}
    -
    -

    -ODE solution using mrgsolve

    +
    +

    ODE solution using mrgsolve +

    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
    -'
    +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.
    +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))
    -  
    -}
    +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)) + +}
    -
    -

    -ODE solution using RxODE

    +
    +

    ODE solution using RxODE +

    The model written for RxODE:

    -modrx <- RxODE({
    -  d/dt(DEPOT) = -KA*DEPOT;
    -  d/dt(CENT) = KA*DEPOT - (CL/V)*CENT;
    -  CP=CENT/V;
    -})
    +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))
    -  
    -}
    +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)) + +}
    -
    -

    -Common model elements

    +
    +

    Common model elements +

    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){
    -  y <- do.call(poped.db$model$ff_pointer,list(model_switch,xt,parameters,poped.db))[[1]]
    -  y = y*(1+epsi[,1])+epsi[,2]
    -  return(list(y=y,poped.db=poped.db)) 
    -}
    + +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)) +}
    -
    -

    -Create PopED databases

    -

    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.

    +
    +

    Create PopED databases +

    +

    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,
    -                                  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)
    +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)
    -
    -

    -Model predictions

    -

    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:

    +
    +

    Model predictions +

    +

    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) 
    +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).

    +

    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: 3.593837e-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
    +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
    -
    -

    -Evaluate the design

    -

    Here we compare the computation of the Fisher Information Matrix (FIM). By comparing the \(ln(det(FIM))\) (the lnD-objective function value, or ofv).

    +
    +

    Evaluate the design +

    +

    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
    +(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: 2.493735e-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: 2.493735e-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: 2.493735e-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.361616e-08"
    +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"
    -
    -

    -Speed of FIM computation

    -

    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, in previous work (http://pkpdsim.ronkeizer.com/speed.html), 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.

    +
    +

    Speed of FIM computation +

    +

    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)
    +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)

    -
    -

    -Version information

    +
    +

    Version information +

    -devtools::session_info()
    -#> ─ Session info ───────────────────────────────────────────────────────────────
    -#>  setting  value                       
    -#>  version  R version 4.1.0 (2021-05-18)
    -#>  os       macOS Big Sur 10.16         
    -#>  system   x86_64, darwin17.0          
    -#>  ui       X11                         
    -#>  language (EN)                        
    -#>  collate  en_US.UTF-8                 
    -#>  ctype    en_US.UTF-8                 
    -#>  tz       Europe/Stockholm            
    -#>  date     2021-05-21                  
    -#> 
    -#> ─ Packages ───────────────────────────────────────────────────────────────────
    -#>  ! package       * version  date       lib source                            
    -#>    assertthat      0.2.1    2019-03-21 [2] CRAN (R 4.1.0)                    
    -#>    backports       1.2.1    2020-12-09 [2] CRAN (R 4.1.0)                    
    -#>    BH              1.75.0-0 2021-01-11 [2] CRAN (R 4.1.0)                    
    -#>    bookdown        0.22     2021-04-22 [2] CRAN (R 4.1.0)                    
    -#>    boot            1.3-28   2021-05-03 [2] CRAN (R 4.1.0)                    
    -#>    bslib           0.2.5.1  2021-05-18 [2] CRAN (R 4.1.0)                    
    -#>    cachem          1.0.5    2021-05-15 [2] CRAN (R 4.1.0)                    
    -#>    callr           3.7.0    2021-04-20 [2] CRAN (R 4.1.0)                    
    -#>    checkmate       2.0.0    2020-02-06 [2] CRAN (R 4.1.0)                    
    -#>    cli             2.5.0    2021-04-26 [2] CRAN (R 4.1.0)                    
    -#>    codetools       0.2-18   2020-11-04 [2] CRAN (R 4.1.0)                    
    -#>    colorspace      2.0-1    2021-05-04 [2] CRAN (R 4.1.0)                    
    -#>    crayon          1.4.1    2021-02-08 [2] CRAN (R 4.1.0)                    
    -#>    data.table      1.14.0   2021-02-21 [2] CRAN (R 4.1.0)                    
    -#>    DBI             1.1.1    2021-01-15 [2] CRAN (R 4.1.0)                    
    -#>    desc            1.3.0    2021-03-05 [2] CRAN (R 4.1.0)                    
    -#>    deSolve       * 1.28     2020-03-08 [2] CRAN (R 4.1.0)                    
    -#>    devtools        2.4.1    2021-05-05 [2] CRAN (R 4.1.0)                    
    -#>    digest          0.6.27   2020-10-24 [2] CRAN (R 4.1.0)                    
    -#>    dparser         1.3.1-4  2021-04-07 [2] CRAN (R 4.1.0)                    
    -#>    dplyr           1.0.6    2021-05-05 [2] CRAN (R 4.1.0)                    
    -#>    ellipsis        0.3.2    2021-04-29 [2] CRAN (R 4.1.0)                    
    -#>    evaluate        0.14     2019-05-28 [2] CRAN (R 4.1.0)                    
    -#>    fansi           0.4.2    2021-01-15 [2] CRAN (R 4.1.0)                    
    -#>    farver          2.1.0    2021-02-28 [2] CRAN (R 4.1.0)                    
    -#>    fastmap         1.1.0    2021-01-25 [2] CRAN (R 4.1.0)                    
    -#>    fs              1.5.0    2020-07-31 [2] CRAN (R 4.1.0)                    
    -#>    generics        0.1.0    2020-10-31 [2] CRAN (R 4.1.0)                    
    -#>    ggplot2         3.3.3    2020-12-30 [2] CRAN (R 4.1.0)                    
    -#>    glue            1.4.2    2020-08-27 [2] CRAN (R 4.1.0)                    
    -#>    gtable          0.3.0    2019-03-25 [2] CRAN (R 4.1.0)                    
    -#>    gtools          3.8.2    2020-03-31 [2] CRAN (R 4.1.0)                    
    -#>    highr           0.9      2021-04-16 [2] CRAN (R 4.1.0)                    
    -#>    htmltools       0.5.1.1  2021-01-22 [2] CRAN (R 4.1.0)                    
    -#>    httr            1.4.2    2020-07-20 [2] CRAN (R 4.1.0)                    
    -#>    jquerylib       0.1.4    2021-04-26 [2] CRAN (R 4.1.0)                    
    -#>    jsonlite        1.7.2    2020-12-09 [2] CRAN (R 4.1.0)                    
    -#>    kableExtra    * 1.3.4    2021-02-20 [2] CRAN (R 4.1.0)                    
    -#>    knitr         * 1.33     2021-04-24 [2] CRAN (R 4.1.0)                    
    -#>    labeling        0.4.2    2020-10-20 [2] CRAN (R 4.1.0)                    
    -#>    lifecycle       1.0.0    2021-02-15 [2] CRAN (R 4.1.0)                    
    -#>    lotri           0.3.1    2021-01-05 [2] CRAN (R 4.1.0)                    
    -#>    lubridate       1.7.10   2021-02-26 [2] CRAN (R 4.1.0)                    
    -#>    magrittr        2.0.1    2020-11-17 [2] CRAN (R 4.1.0)                    
    -#>    MASS            7.3-54   2021-05-03 [2] CRAN (R 4.1.0)                    
    -#>    memoise         2.0.0    2021-01-26 [2] CRAN (R 4.1.0)                    
    -#>    mrgsolve      * 0.11.1   2021-05-10 [2] CRAN (R 4.1.0)                    
    -#>    munsell         0.5.0    2018-06-12 [2] CRAN (R 4.1.0)                    
    -#>    mvtnorm         1.1-1    2020-06-09 [2] CRAN (R 4.1.0)                    
    -#>    pillar          1.6.1    2021-05-16 [2] CRAN (R 4.1.0)                    
    -#>    pkgbuild        1.2.0    2020-12-15 [2] CRAN (R 4.1.0)                    
    -#>    pkgconfig       2.0.3    2019-09-22 [2] CRAN (R 4.1.0)                    
    -#>    pkgdown         1.6.1    2020-09-12 [2] CRAN (R 4.1.0)                    
    -#>    pkgload         1.2.1    2021-04-06 [2] CRAN (R 4.1.0)                    
    -#>    PKPDsim       * 1.0.7    2021-05-21 [2] Github (InsightRX/PKPDsim@bd9b9e4)
    -#>  P PopED         * 0.6.0    2021-05-21 [?] local                             
    -#>    PreciseSums     0.4      2020-07-10 [2] CRAN (R 4.1.0)                    
    -#>    prettyunits     1.1.1    2020-01-24 [2] CRAN (R 4.1.0)                    
    -#>    processx        3.5.2    2021-04-30 [2] CRAN (R 4.1.0)                    
    -#>    ps              1.6.0    2021-02-28 [2] CRAN (R 4.1.0)                    
    -#>    purrr           0.3.4    2020-04-17 [2] CRAN (R 4.1.0)                    
    -#>    qs              0.24.1   2021-03-07 [2] CRAN (R 4.1.0)                    
    -#>    R6              2.5.0    2020-10-28 [2] CRAN (R 4.1.0)                    
    -#>    ragg            1.1.2    2021-03-17 [2] CRAN (R 4.1.0)                    
    -#>    RApiSerialize   0.1.0    2014-04-19 [2] CRAN (R 4.1.0)                    
    -#>    Rcpp          * 1.0.6    2021-01-15 [2] CRAN (R 4.1.0)                    
    -#>    RcppParallel    5.1.4    2021-05-04 [2] CRAN (R 4.1.0)                    
    -#>    remotes         2.3.0    2021-04-01 [2] CRAN (R 4.1.0)                    
    -#>    rlang           0.4.11   2021-04-30 [2] CRAN (R 4.1.0)                    
    -#>    rmarkdown       2.8      2021-05-07 [2] CRAN (R 4.1.0)                    
    -#>    rprojroot       2.0.2    2020-11-15 [2] CRAN (R 4.1.0)                    
    -#>    rstudioapi      0.13     2020-11-12 [2] CRAN (R 4.1.0)                    
    -#>    rvest           1.0.0    2021-03-09 [2] CRAN (R 4.1.0)                    
    -#>    RxODE         * 1.0.9    2021-05-11 [2] CRAN (R 4.1.0)                    
    -#>    sass            0.4.0    2021-05-12 [2] CRAN (R 4.1.0)                    
    -#>    scales          1.1.1    2020-05-11 [2] CRAN (R 4.1.0)                    
    -#>    sessioninfo     1.1.1    2018-11-05 [2] CRAN (R 4.1.0)                    
    -#>    stringfish      0.15.1   2021-03-16 [2] CRAN (R 4.1.0)                    
    -#>    stringi         1.6.2    2021-05-17 [2] CRAN (R 4.1.0)                    
    -#>    stringr         1.4.0    2019-02-10 [2] CRAN (R 4.1.0)                    
    -#>    svglite         2.0.0    2021-02-20 [2] CRAN (R 4.1.0)                    
    -#>    sys             3.4      2020-07-23 [2] CRAN (R 4.1.0)                    
    -#>    systemfonts     1.0.2    2021-05-11 [2] CRAN (R 4.1.0)                    
    -#>    testthat      * 3.0.2    2021-02-14 [2] CRAN (R 4.1.0)                    
    -#>    textshaping     0.3.4    2021-05-11 [2] CRAN (R 4.1.0)                    
    -#>    tibble          3.1.2    2021-05-16 [2] CRAN (R 4.1.0)                    
    -#>    tidyselect      1.1.1    2021-04-30 [2] CRAN (R 4.1.0)                    
    -#>    usethis         2.0.1    2021-02-10 [2] CRAN (R 4.1.0)                    
    -#>    utf8            1.2.1    2021-03-12 [2] CRAN (R 4.1.0)                    
    -#>    vctrs           0.3.8    2021-04-29 [2] CRAN (R 4.1.0)                    
    -#>    viridisLite     0.4.0    2021-04-13 [2] CRAN (R 4.1.0)                    
    -#>    webshot         0.5.2    2019-11-22 [2] CRAN (R 4.1.0)                    
    -#>    withr           2.4.2    2021-04-18 [2] CRAN (R 4.1.0)                    
    -#>    xfun            0.23     2021-05-15 [2] CRAN (R 4.1.0)                    
    -#>    xml2            1.3.2    2020-04-23 [2] CRAN (R 4.1.0)                    
    -#>    yaml            2.2.1    2020-02-01 [2] CRAN (R 4.1.0)                    
    -#> 
    -#> [1] /private/var/folders/g6/mk9zc6552f7g93c457xzgvfc0000gp/T/Rtmp2dRrIZ/temp_libpath7ebb50981b8f
    -#> [2] /Library/Frameworks/R.framework/Versions/4.1/Resources/library
    -#> 
    -#>  P ── Loaded and on-disk path mismatch.
    -#sessionInfo()
    +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()
    @@ -863,11 +926,13 @@

    @@ -876,5 +941,7 @@

    + + diff --git a/docs/articles/model_def_other_pkgs_compare_speed.png b/docs/articles/model_def_other_pkgs_compare_speed.png index e0179da..b5a3e09 100644 Binary files a/docs/articles/model_def_other_pkgs_compare_speed.png and b/docs/articles/model_def_other_pkgs_compare_speed.png differ diff --git a/docs/articles/model_def_other_pkgs_files/figure-html/unnamed-chunk-14-1.png b/docs/articles/model_def_other_pkgs_files/figure-html/unnamed-chunk-14-1.png index 7449dff..309a1d8 100644 Binary files a/docs/articles/model_def_other_pkgs_files/figure-html/unnamed-chunk-14-1.png and b/docs/articles/model_def_other_pkgs_files/figure-html/unnamed-chunk-14-1.png differ diff --git a/docs/authors.html b/docs/authors.html index f057252..ab34aa6 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -1,74 +1,12 @@ - - - - - - - -Citation and Authors • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Authors and Citation • PopED - - + + - - -
    -
    - -
    - -
    +
    -
    -
    - - + + diff --git a/docs/index.html b/docs/index.html index 89d218b..e4af7c1 100644 --- a/docs/index.html +++ b/docs/index.html @@ -32,6 +32,8 @@ + +
    -
    - - - + + diff --git a/docs/reference/Dtrace.html b/docs/reference/Dtrace.html index dcbdb94..0548e48 100644 --- a/docs/reference/Dtrace.html +++ b/docs/reference/Dtrace.html @@ -1,75 +1,12 @@ - - - - - - - -Trace optimization routines — Dtrace • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Trace optimization routines — Dtrace • PopED - - + + - - -
    -
    - -
    - -
    +
    @@ -150,328 +78,331 @@

    Trace optimization routines

    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
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    fn

    A file to output information to. Can also be the screen if ''.

    it

    the iteration number.

    ni

    A vector of the number of samples in each group.

    xtopt

    The matrix defining current best sampling schedule.

    xopt

    The cell structure defining the current best discrete design variables.

    aopt

    The matrix defining the current best continuous design variables.

    gxt

    The matrix defining the current gradient of the xt vector.

    ga

    The matrix defining the current gradient for the continuous design variables.

    dmf

    The current OFV.

    diff

    The difference from the previous iteration.

    ixt

    If xt Gradient Inversion occurred or not.

    ia

    If a Gradient Inversion occurred or not.

    itvector

    The iteration vector. Not currently used.

    dmfvector

    The dmf vector. Not currently used.

    poped.db

    A PopED database.

    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?

    opt_samps

    Are the number of sample times per group being optimized?

    opt_inds

    Are the number of individuals per group being optimized?

    rsit

    Number of Random search iterations

    convergence_eps

    Stochastic Gradient convergence value, -(difference in OFV for D-optimal, difference in gradient for ED-optimal)

    - - -

    Examples

    -
    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: 0x7fe20a979808> -#> <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 -#> *************************************************************
    -
    +
    +
    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
    +)
    +
    + +
    +

    Arguments

    +
    fn
    +

    A file to output information to. Can also be the screen if ''.

    + + +
    it
    +

    the iteration number.

    + + +
    ni
    +

    A vector of the number of samples in each group.

    + + +
    xtopt
    +

    The matrix defining current best sampling schedule.

    + + +
    xopt
    +

    The cell structure defining the current best discrete design variables.

    + + +
    aopt
    +

    The matrix defining the current best continuous design variables.

    + + +
    gxt
    +

    The matrix defining the current gradient of the xt vector.

    + + +
    ga
    +

    The matrix defining the current gradient for the continuous design variables.

    + + +
    dmf
    +

    The current OFV.

    + + +
    diff
    +

    The difference from the previous iteration.

    + + +
    ixt
    +

    If xt Gradient Inversion occurred or not.

    + + +
    ia
    +

    If a Gradient Inversion occurred or not.

    + + +
    itvector
    +

    The iteration vector. Not currently used.

    + + +
    dmfvector
    +

    The dmf vector. Not currently used.

    + + +
    poped.db
    +

    A PopED database.

    + + +
    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?

    + + +
    opt_samps
    +

    Are the number of sample times per group being optimized?

    + + +
    opt_inds
    +

    Are the number of individuals per group being optimized?

    + + +
    rsit
    +

    Number of Random search iterations

    + + +
    convergence_eps
    +

    Stochastic Gradient convergence value, +(difference in OFV for D-optimal, difference in gradient for ED-optimal)

    + +
    + +
    +

    Examples

    +
    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
    +#> *************************************************************
    +
    +
    +
    +
    -
    - - + + diff --git a/docs/reference/LEDoptim.html b/docs/reference/LEDoptim.html index dddaa2e..b09ffdf 100644 --- a/docs/reference/LEDoptim.html +++ b/docs/reference/LEDoptim.html @@ -1,82 +1,19 @@ - - - - - - - -Optimization function for D-family, E-family and Laplace approximated ED designs — LEDoptim • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Optimization function for D-family, E-family and Laplace approximated ED designs — LEDoptim • PopED - - - - - - - - - - - - + + - - -
    -
    - -
    - -
    +

    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

      -
    1. Adaptive random search. See RS_opt.

    2. +function

      1. 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,
    -  ...
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    poped.db

    A PopED database.

    model_switch

    A matrix that is the same size as xt, specifying which model each sample belongs to.

    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.

    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:

      -
    • column 1 the type of the +

      +
      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,
      +  ...
      +)
      +
      + +
      +

      Arguments

      +
      poped.db
      +

      A PopED database.

      + + +
      model_switch
      +

      A matrix that is the same size as xt, specifying which model each sample belongs to.

      + + +
      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.

      + + +
      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:

      • 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).

      • -
    ddescr

    Matrix defining the diagonals of the IIV (same logic as for -the bpopdescr).

    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

    ofv_init

    The initial OFV. If set to zero then it is computed.

    fim_init

    The initial value of the FIM. If set to zero then it is computed.

    trflag

    Should the optimization be output to the screen and to a file?

    header_flag

    Should the header text be printed out?

    footer_flag

    Should the footer text be printed out?

    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?

    out_file

    Which file should the output be directed to? A string, a file handle using -file or "" will output to the screen.

    d_switch
      -
    • ******START OF CRITERION SPECIFICATION OPTIONS**********

    • -

    D-family design (1) or ED-family 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 using the standard MC integration technique, so can be slow.

    use_RS

    should the function use a random search algorithm?

    ...

    arguments passed to evaluate.fim and ofv_fim.

    - -

    See also

    - - - -

    Examples

    -
    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: 0x7fe20a979808> -#> <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) + + + +
    ddescr
    +

    Matrix defining the diagonals of the IIV (same logic as for +the bpopdescr).

    + + +
    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

    + + +
    ofv_init
    +

    The initial OFV. If set to zero then it is computed.

    + + +
    fim_init
    +

    The initial value of the FIM. If set to zero then it is computed.

    + + +
    trflag
    +

    Should the optimization be output to the screen and to a file?

    - 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="") -} -
    +
    header_flag
    +

    Should the header text be printed out?

    + + +
    footer_flag
    +

    Should the footer text be printed out?

    + + +
    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?

    + + +
    out_file
    +

    Which file should the output be directed to? A string, a file handle using +file or "" will output to the screen.

    + + +
    d_switch
    +
    • ******START OF CRITERION SPECIFICATION OPTIONS**********

    • +

    D-family design (1) or ED-family 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 using the standard MC integration technique, so can be slow.

    + + +
    use_RS
    +

    should the function use a random search algorithm?

    + + +
    ...
    +

    arguments passed to evaluate.fim and ofv_fim.

    + +
    +
    +

    See also

    + +
    + +
    +

    Examples

    +
    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="") 
    +
    +}
    +
    +
    +
    -
    - - + + diff --git a/docs/reference/LinMatrixH.html b/docs/reference/LinMatrixH.html index a9b900b..9289632 100644 --- a/docs/reference/LinMatrixH.html +++ b/docs/reference/LinMatrixH.html @@ -1,76 +1,13 @@ - - - - - - - -Model linearization with respect to epsilon. — LinMatrixH • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Model linearization with respect to epsilon. — LinMatrixH • PopED - - + + - - -
    -
    - -
    - -
    +
    @@ -152,91 +80,90 @@

    Model linearization with respect to epsilon.

    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)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    model_switch

    A matrix that is the same size as xt, specifying which model each sample belongs to.

    xt_ind

    A vector of the individual/group sample times

    x

    A matrix for the discrete design variables. Each row is a group.

    a

    A matrix of covariates. Each row is a group.

    bpop

    The fixed effects parameter values. Supplied as a vector.

    b_ind

    vector of individual realization of the BSV terms b

    bocc_ind

    Vector of individual realizations of the BOV terms bocc

    poped.db

    A PopED database.

    - -

    Value

    - -

    A matrix of size (samples per individual x number of epsilons)

    -

    See also

    - - +
    +
    LinMatrixH(model_switch, xt_ind, x, a, bpop, b_ind, bocc_ind, poped.db)
    +
    + +
    +

    Arguments

    +
    model_switch
    +

    A matrix that is the same size as xt, specifying which model each sample belongs to.

    + + +
    xt_ind
    +

    A vector of the individual/group sample times

    + + +
    x
    +

    A matrix for the discrete design variables. Each row is a group.

    + + +
    a
    +

    A matrix of covariates. Each row is a group.

    + + +
    bpop
    +

    The fixed effects parameter values. Supplied as a vector.

    + + +
    b_ind
    +

    vector of individual realization of the BSV terms b

    + + +
    bocc_ind
    +

    Vector of individual realizations of the BOV terms bocc

    + + +
    poped.db
    +

    A PopED database.

    + +
    +
    +

    Value

    + + +

    A matrix of size (samples per individual x number of epsilons)

    +
    +
    +

    See also

    + +
    +
    -
    - - + + diff --git a/docs/reference/LinMatrixL.html b/docs/reference/LinMatrixL.html index 02c6ca6..c88add2 100644 --- a/docs/reference/LinMatrixL.html +++ b/docs/reference/LinMatrixL.html @@ -1,78 +1,15 @@ - - - - - - - -The linearized matrix L — LinMatrixL • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -The linearized matrix L — LinMatrixL • PopED - - - - - - - - - - - + + - - - -
    -
    - -
    - -
    +
    @@ -156,157 +84,162 @@

    The linearized matrix L

    (b_ind and bocc_ind).

    -
    LinMatrixL(model_switch, xt_ind, x, a, bpop, b_ind, bocc_ind, poped.db)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    model_switch

    A vector that is the same size as xt, specifying which model each sample belongs to.

    x

    A vector for the discrete design variables.

    a

    A vector of covariates.

    bpop

    The fixed effects parameter values. Supplied as a vector.

    b_ind

    The point at which to evaluate the derivative

    bocc_ind

    The point at which to evaluate the derivative

    poped.db

    A PopED database.

    - -

    Value

    - -

    As a list:

    -
    y

    A matrix of size (samples per individual x number of random effects)

    -
    poped.db

    A PopED database

    - - -

    Examples

    -
    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: 0x7fe20a979808> -#> <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 -#>
    -
    +
    +
    LinMatrixL(model_switch, xt_ind, x, a, bpop, b_ind, bocc_ind, poped.db)
    +
    + +
    +

    Arguments

    +
    model_switch
    +

    A vector that is the same size as xt, specifying which model each sample belongs to.

    + + +
    x
    +

    A vector for the discrete design variables.

    + + +
    a
    +

    A vector of covariates.

    + + +
    bpop
    +

    The fixed effects parameter values. Supplied as a vector.

    + + +
    b_ind
    +

    The point at which to evaluate the derivative

    + + +
    bocc_ind
    +

    The point at which to evaluate the derivative

    + + +
    poped.db
    +

    A PopED database.

    + +
    +
    +

    Value

    + + +

    As a list:

    +
    y
    +

    A matrix of size (samples per individual x number of random effects)

    + +
    poped.db
    +

    A PopED database

    + +
    + +
    +

    Examples

    +
    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
    +#> 
    +
    +
    +
    +
    -
    - - + + diff --git a/docs/reference/LinMatrixLH.html b/docs/reference/LinMatrixLH.html index f262d82..bcded63 100644 --- a/docs/reference/LinMatrixLH.html +++ b/docs/reference/LinMatrixLH.html @@ -1,77 +1,14 @@ - - - - - - - -Model linearization with respect to epsilon and eta. — LinMatrixLH • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Model linearization with respect to epsilon and eta. — LinMatrixLH • PopED - - - - - - - - - - - - + + - - -
    -
    - -
    - -
    +
    @@ -154,193 +82,196 @@

    Model linearization with respect to epsilon and eta.

    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
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    model_switch

    A matrix that is the same size as xt, specifying which model each sample belongs to.

    xt_ind

    A vector of the individual/group sample times

    x

    A matrix for the discrete design variables. Each row is a group.

    a

    A matrix of covariates. Each row is a group.

    bpop

    The fixed effects parameter values. Supplied as a vector.

    b_ind

    vector of individual realization of the BSV terms b

    bocc_ind

    Vector of individual realizations of the BOV terms bocc

    NumEPS

    The number of eps() terms in the model.

    poped.db

    A PopED database.

    - -

    Value

    - -

    A matrix of size (samples per individual x (number of sigma x number of omega))

    -

    See also

    - - - -

    Examples

    -
    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: 0x7fe20a979808> -#> <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 -#>
    - -
    +
    +
    LinMatrixLH(
    +  model_switch,
    +  xt_ind,
    +  x,
    +  a,
    +  bpop,
    +  b_ind,
    +  bocc_ind,
    +  NumEPS,
    +  poped.db
    +)
    +
    + +
    +

    Arguments

    +
    model_switch
    +

    A matrix that is the same size as xt, specifying which model each sample belongs to.

    + + +
    xt_ind
    +

    A vector of the individual/group sample times

    + + +
    x
    +

    A matrix for the discrete design variables. Each row is a group.

    + + +
    a
    +

    A matrix of covariates. Each row is a group.

    + + +
    bpop
    +

    The fixed effects parameter values. Supplied as a vector.

    + + +
    b_ind
    +

    vector of individual realization of the BSV terms b

    + + +
    bocc_ind
    +

    Vector of individual realizations of the BOV terms bocc

    + + +
    NumEPS
    +

    The number of eps() terms in the model.

    + + +
    poped.db
    +

    A PopED database.

    + +
    +
    +

    Value

    + + +

    A matrix of size (samples per individual x (number of sigma x number of omega))

    +
    +
    +

    See also

    + +
    + +
    +

    Examples

    +
    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
    +#> 
    +
    +  
    +
    +
    +
    -
    - - + + diff --git a/docs/reference/LinMatrixL_occ.html b/docs/reference/LinMatrixL_occ.html index b6dfe44..4c776b1 100644 --- a/docs/reference/LinMatrixL_occ.html +++ b/docs/reference/LinMatrixL_occ.html @@ -1,76 +1,13 @@ - - - - - - - -Model linearization with respect to occasion variability parameters. — LinMatrixL_occ • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Model linearization with respect to occasion variability parameters. — LinMatrixL_occ • PopED - + + - - - -
    -
    - -
    - -
    +
    @@ -152,184 +80,187 @@

    Model linearization with respect to occasion variability parameters.

    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
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    model_switch

    A matrix that is the same size as xt, specifying which model each sample belongs to.

    xt_ind

    A vector of the individual/group sample times

    x

    A matrix for the discrete design variables. Each row is a group.

    a

    A matrix of covariates. Each row is a group.

    bpop

    The fixed effects parameter values. Supplied as a vector.

    b_ind

    vector of individual realization of the BSV terms b

    bocc_ind

    Vector of individual realizations of the BOV terms bocc

    iCurrentOcc

    The current occasion.

    poped.db

    A PopED database.

    - -

    Value

    - -

    A matrix of size (samples per individual x number of iovs)

    -

    See also

    - - - -

    Examples

    -
    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: 0x7fe20a979808> -#> <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 -#>
    -
    +
    +
    LinMatrixL_occ(
    +  model_switch,
    +  xt_ind,
    +  x,
    +  a,
    +  bpop,
    +  b_ind,
    +  bocc_ind,
    +  iCurrentOcc,
    +  poped.db
    +)
    +
    + +
    +

    Arguments

    +
    model_switch
    +

    A matrix that is the same size as xt, specifying which model each sample belongs to.

    + + +
    xt_ind
    +

    A vector of the individual/group sample times

    + + +
    x
    +

    A matrix for the discrete design variables. Each row is a group.

    + + +
    a
    +

    A matrix of covariates. Each row is a group.

    + + +
    bpop
    +

    The fixed effects parameter values. Supplied as a vector.

    + + +
    b_ind
    +

    vector of individual realization of the BSV terms b

    + + +
    bocc_ind
    +

    Vector of individual realizations of the BOV terms bocc

    + + +
    iCurrentOcc
    +

    The current occasion.

    + + +
    poped.db
    +

    A PopED database.

    + +
    +
    +

    Value

    + + +

    A matrix of size (samples per individual x number of iovs)

    +
    +
    +

    See also

    + +
    + +
    +

    Examples

    +
    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
    +#> 
    +
    +
    +
    +
    -
    - - + + diff --git a/docs/reference/PopED-1.png b/docs/reference/PopED-1.png index 679a551..a6c8b54 100644 Binary files a/docs/reference/PopED-1.png and b/docs/reference/PopED-1.png differ diff --git a/docs/reference/PopED.html b/docs/reference/PopED.html index ed0201c..060c1db 100644 --- a/docs/reference/PopED.html +++ b/docs/reference/PopED.html @@ -1,77 +1,14 @@ - - - - - - - -PopED - Population (and individual) optimal Experimental Design. — PopED • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -PopED - Population (and individual) optimal Experimental Design. — PopED • PopED - - - - - - - - - - - - - - + + -
    -
    - -
    - -
    +
    @@ -155,11 +83,9 @@

    PopED - Population (and individual) optimal Experimental D<

    - -

    Details

    - -

    To get started you need to define

      -
    1. A model.

    2. +
      +

      Details

      +

      To get started you need to define

      1. A model.

      2. An initial design (and design space if you want to optimize).

      3. The tasks to perform.

      There are a number of functions to help you with these tasks. The user-level functions defined below are @@ -168,210 +94,209 @@

      Details 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.

      +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.

      +feps.add.prop, +feps.add, +feps.prop.

      Create an initial study design (and design space): -create.poped.database.

      +create.poped.database.

      Evaluate the model and/or design through simulation and graphics: -plot_model_prediction, -model_prediction, -plot_efficiency_of_windows.

      +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.

      +evaluate_design, +evaluate.fim, +evaluate.e.ofv.fim, +ofv_fim, +get_rse.

      Optimize the design (evaluate afterwards using the above functions): -poped_optim,

      +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").

      -

      References

      - +

      system.file("examples", package="PopED").

      +
      +
      +

      References

      -
        -
      1. J. Nyberg, S. Ueckert, E.A. Stroemberg, S. Hennig, M.O. Karlsson and A.C. Hooker, "PopED: An extended, +

        1. 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.

        2. 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.

        3. -
        4. https://andrewhooker.github.io/PopED/

        5. -
        - - -

        Examples

        -
        -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) - -} -
        +
      2. https://andrewhooker.github.io/PopED/

      3. +
      + +
      +

      Examples

      +
      
      +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)
      +  
      +}
      +
      +
    +
    - - - + + diff --git a/docs/reference/RS_opt.html b/docs/reference/RS_opt.html index bae47b9..9d4b145 100644 --- a/docs/reference/RS_opt.html +++ b/docs/reference/RS_opt.html @@ -1,82 +1,19 @@ - - - - - - - -Optimize the objective function using an adaptive random search algorithm for D-family and E-family designs. — RS_opt • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Optimize the objective function using an adaptive random search algorithm for D-family and E-family designs. — RS_opt • PopED - - - - - - - - - - - - - - + + -
    -
    - -
    - -
    +
    @@ -164,150 +92,148 @@

    Optimize the objective function using an adaptive random search algorithm fo 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,
    -  ...
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    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:

      -
    • column 1 the type of the +

      +
      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,
      +  ...
      +)
      +
      + +
      +

      Arguments

      +
      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:

      • 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).

      • -
    ddescr

    Matrix defining the diagonals of the IIV (same logic as for -the bpopdescr).

    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 initial 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:

      -
    • 0 = Full FIM. No assumption that fixed and random effects are uncorrelated.

    • +
    + + +
    ddescr
    +

    Matrix defining the diagonals of the IIV (same logic as for +the bpopdescr).

    + + +
    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 initial 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:

    • 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).

    • @@ -318,278 +244,276 @@

      Arg
    • 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.

    • -

    approx_type

    Approximation method for model, 0=FO, 1=FOCE, 2=FOCEI, 3=FOI.

    iter

    The number of iterations entered into the blockheader_2 function.

    d_switch
      -
    • ******START OF CRITERION SPECIFICATION OPTIONS**********

    • -

    D-family design (1) or ED-family 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 + + + +

    approx_type
    +

    Approximation method for model, 0=FO, 1=FOCE, 2=FOCEI, 3=FOI.

    + + +
    iter
    +

    The number of iterations entered into the blockheader_2 function.

    + + +
    d_switch
    +
    • ******START OF CRITERION SPECIFICATION OPTIONS**********

    • +

    D-family design (1) or ED-family 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 using 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 -file or "" will output to the screen.

    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 evaluate.fim and ofv_fim.

    - -

    References

    +is done using 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 +file or "" will output to the screen.

    + +
    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 evaluate.fim and ofv_fim.

    + +
    +
    +

    References

    -
      -
    1. M. Foracchia, A.C. Hooker, P. Vicini and A. Ruggeri, "PopED, a software fir optimal +

      1. 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.

      2. 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.

      3. -
      - -

      See also

      - - - -

      Examples

      -
      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: 0x7fe20a979808> -#> <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.043 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="") - -} -
      +
    + + +
    +

    Examples

    +
    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="") 
    +
    +}
    +
    +
    +
    - - - + + diff --git a/docs/reference/Rplot002.png b/docs/reference/Rplot002.png index f5c5b1b..77b068a 100644 Binary files a/docs/reference/Rplot002.png and b/docs/reference/Rplot002.png differ diff --git a/docs/reference/a_line_search.html b/docs/reference/a_line_search.html index 2e8ea6c..979d12e 100644 --- a/docs/reference/a_line_search.html +++ b/docs/reference/a_line_search.html @@ -1,76 +1,13 @@ - - - - - - - -Optimize using line search — a_line_search • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Optimize using line search — a_line_search • PopED - - + + - - -
    -
    - -
    - -
    +
    @@ -152,255 +80,269 @@

    Optimize using line search

    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
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    poped.db

    A PopED database.

    out_file

    The output file to write to.

    bED

    If the algorithm should use E-family methods. Logical.

    diff

    The OFV difference that is deemed significant for changing a design. If, +

    +
    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
    +)
    +
    + +
    +

    Arguments

    +
    poped.db
    +

    A PopED database.

    + + +
    out_file
    +

    The output file to write to.

    + + +
    bED
    +

    If the algorithm should use E-family methods. Logical.

    + + +
    diff
    +

    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.

    fmf_initial

    The initial value of the FIM. If 0 then the FIM is calculated from poped.db.

    dmf_initial

    The initial value of the objective function value (OFV). -If 0 then the OFV is calculated from poped.db.

    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?

    opt_samps

    Are the number of sample times per group being optimized?

    opt_inds

    Are the number of individuals per group being optimized?

    ls_step_size

    Number of grid points in the line search.

    - -

    Value

    - -

    A list containing:

    -
    fmf

    The FIM.

    -
    dmf

    The final value of the objective function value.

    -
    best_changed

    If the algorithm has found a better design than the starting design.

    -
    xt

    A matrix of sample times. Each row is a vector of sample times for a group.

    -
    x

    A matrix for the discrete design variables. Each row is a group.

    -
    a

    A matrix of covariates. Each row is a group.

    -
    poped.db

    A PopED database.

    - -

    See also

    - - - -

    Examples

    -
    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: 0x7fe20a979808> -#> <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 xt1 on group 1 -#> group 1 -- xt[1] changed from 0.5 to 0.01 -#> OFV(MF) changed from 55.3964 to 55.7394 -#> group 1 -- xt[1] changed from 0.01 to 90.0025 -#> OFV(MF) changed from 55.7394 to 55.7436 -#> group 1 -- xt[1] changed from 90.0025 to 120 -#> OFV(MF) changed from 55.7436 to 55.8023 -#> Searching xt6 on group 1 -#> group 1 -- xt[6] changed from 36 to 0.01 -#> OFV(MF) changed from 55.8023 to 55.8666 -#> group 1 -- xt[6] changed from 0.01 to 90.0025 -#> OFV(MF) changed from 55.8666 to 55.9043 -#> group 1 -- xt[6] changed from 90.0025 to 120 -#> OFV(MF) changed from 55.9043 to 55.9321 -#> Searching xt2 on group 1 -#> Searching xt3 on group 1 -#> Searching xt7 on group 1 -#> group 1 -- xt[7] changed from 72 to 30.0075 -#> OFV(MF) changed from 55.9321 to 55.9484 -#> group 1 -- xt[7] changed from 30.0075 to 90.0025 -#> OFV(MF) changed from 55.9484 to 55.9661 -#> Searching xt8 on group 1 -#> Searching xt5 on group 1 -#> Searching xt4 on group 1 -#> OFV(MF): 55.9661 -#> -#> Best value for OFV(MF) = 55.9661 -#> -#> Best value for xt: -#> Group 1: 1 2 6 24 90 120 120 120 -#> -#> Searching a1 on individual/group 1 -#> group 1 -- a[1] changed from 70 to 75.0025 -#> OFV(MF) changed from 55.9661 to 56.1502 -#> group 1 -- a[1] changed from 75.0025 to 100 -#> OFV(MF) changed from 56.1502 to 56.7067 -#> OFV(MF): 56.7067 -#> Best value for OFV(MF) = 56.7067 -#> -#> Best value for a: -#> Group 1: 100 [0.01,100] -#> -#> -#> Line search run time: 0.424 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") - -} +the change is not made.

    + + +
    fmf_initial
    +

    The initial value of the FIM. If 0 then the FIM is calculated from poped.db.

    + + +
    dmf_initial
    +

    The initial value of the objective function value (OFV). +If 0 then the OFV is calculated from poped.db.

    + + +
    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?

    + + +
    opt_samps
    +

    Are the number of sample times per group being optimized?

    + -
    +
    opt_inds
    +

    Are the number of individuals per group being optimized?

    + + +
    ls_step_size
    +

    Number of grid points in the line search.

    + +
    +
    +

    Value

    + + +

    A list containing:

    +
    fmf
    +

    The FIM.

    + +
    dmf
    +

    The final value of the objective function value.

    + +
    best_changed
    +

    If the algorithm has found a better design than the starting design.

    + +
    xt
    +

    A matrix of sample times. Each row is a vector of sample times for a group.

    + +
    x
    +

    A matrix for the discrete design variables. Each row is a group.

    + +
    a
    +

    A matrix of covariates. Each row is a group.

    + +
    poped.db
    +

    A PopED database.

    + +
    +
    +

    See also

    + +
    + +
    +

    Examples

    +
    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")
    +  
    +}
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/bfgsb_min.html b/docs/reference/bfgsb_min.html index 47424e9..bd64a47 100644 --- a/docs/reference/bfgsb_min.html +++ b/docs/reference/bfgsb_min.html @@ -1,76 +1,13 @@ - - - - - - - -Nonlinear minimization using BFGS with box constraints — bfgsb_min • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Nonlinear minimization using BFGS with box constraints — bfgsb_min • PopED - - + + - - -
    -
    - -
    - -
    +
    @@ -152,190 +80,197 @@

    Nonlinear minimization using BFGS with box constraints

    method for nonlinear minimization with box constraints.

    -
    bfgsb_min(f_name, f_options, x0, l, u, options = list())
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - -
    f_name

    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.

    f_options

    Options for the f_name argument.

    x0

    the initial values to optimize

    l

    the lower bounds

    u

    the upper bounds

    options

    a list of additional settings arguments

    - -

    Value

    - -

    A list containing:

    -
    x_k

    The objective function.

    -
    f_k

    The gradient.

    -
    B_k

    The hessian.

    - -

    See also

    - - - -

    Examples

    -
    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: 0x7fe20a979808> -#> <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) - -} +
    +
    bfgsb_min(f_name, f_options, x0, l, u, options = list())
    +
    + +
    +

    Arguments

    +
    f_name
    +

    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.

    + + +
    f_options
    +

    Options for the f_name argument.

    + + +
    x0
    +

    the initial values to optimize

    + + +
    l
    +

    the lower bounds

    -
    + +
    u
    +

    the upper bounds

    + + +
    options
    +

    a list of additional settings arguments

    + +
    +
    +

    Value

    + + +

    A list containing:

    +
    x_k
    +

    The objective function.

    + +
    f_k
    +

    The gradient.

    + +
    B_k
    +

    The hessian.

    + +
    +
    +

    See also

    + +
    + +
    +

    Examples

    +
    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) 
    +  
    +}
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/blockexp.html b/docs/reference/blockexp.html index b8fcdba..280565b 100644 --- a/docs/reference/blockexp.html +++ b/docs/reference/blockexp.html @@ -1,76 +1,13 @@ - - - - - - - -Summarize your experiment for optimization routines — blockexp • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Summarize your experiment for optimization routines — blockexp • PopED - - + + - - -
    -
    - -
    - -
    +
    @@ -152,206 +80,231 @@

    Summarize your experiment for optimization routines

    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]
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    fn

    The file handle to write to.

    poped.db

    A PopED database.

    e_flag

    Should output be with uncertainty around parameters?

    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?

    opt_samps

    Are the number of sample times per group being optimized?

    opt_inds

    Are the number of individuals per group being optimized?

    - -

    See also

    - -

    Other Helper: -blockfinal(), -blockheader(), -blockopt()

    - -

    Examples

    -
    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: 0x7fe20a979808> -#> <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
    -
    +
    +
    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]
    +)
    +
    + +
    +

    Arguments

    +
    fn
    +

    The file handle to write to.

    + + +
    poped.db
    +

    A PopED database.

    + + +
    e_flag
    +

    Should output be with uncertainty around parameters?

    + + +
    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?

    + + +
    opt_samps
    +

    Are the number of sample times per group being optimized?

    + + +
    opt_inds
    +

    Are the number of individuals per group being optimized?

    + +
    +
    +

    See also

    +

    Other Helper: +blockfinal(), +blockheader(), +blockopt()

    +
    + +
    +

    Examples

    +
    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
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/blockfinal.html b/docs/reference/blockfinal.html index f542dc3..ca80565 100644 --- a/docs/reference/blockfinal.html +++ b/docs/reference/blockfinal.html @@ -1,75 +1,12 @@ - - - - - - - -Result function for optimization routines — blockfinal • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Result function for optimization routines — blockfinal • PopED - - + + - - -
    -
    - -
    - -
    +
    @@ -150,297 +78,296 @@

    Result function for optimization routines

    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,
    -  ...
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    fn

    The file handle to write to.

    fmf

    The initial value of the FIM. If set to zero then it is computed.

    dmf

    The initial OFV. If set to zero then it is computed.

    groupsize

    A vector of the number of individuals in each group.

    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.

    x

    A matrix for the discrete design variables. Each row is a group.

    a

    A matrix of covariates. Each row is a group.

    model_switch

    A matrix that is the same size as xt, specifying which model each sample belongs to.

    bpop

    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, +

      +
      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,
      +  ...
      +)
      +
      + +
      +

      Arguments

      +
      fn
      +

      The file handle to write to.

      + + +
      fmf
      +

      The initial value of the FIM. If set to zero then it is computed.

      + + +
      dmf
      +

      The initial OFV. If set to zero then it is computed.

      + + +
      groupsize
      +

      A vector of the number of individuals in each group.

      + + +
      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.

      + + +
      x
      +

      A matrix for the discrete design variables. Each row is a group.

      + + +
      a
      +

      A matrix of covariates. Each row is a group.

      + + +
      model_switch
      +

      A matrix that is the same size as xt, specifying which model each sample belongs to.

      + + +
      bpop
      +

      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 +

    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.

    d

    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(). +arguments in 'bpop' then the order will be worked out automatically.

    + + +
    d
    +

    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.

    docc

    Matrix defining the IOV, the IOV variances and the IOV distribution as for d and bpop.

    sigma

    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().

    poped.db

    A PopED database.

    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?

    opt_inds

    Are the number of individuals per group being optimized?

    fmf_init

    Initial FIM.

    dmf_init

    Initial OFV.

    param_cvs_init

    The initial design parameter RSE values in percent.

    compute_inv

    should the inverse of the FIM be used to compute expected RSE values? Often not needed -except for diagnostic purposes.

    out_file

    Which file should the output be directed to? A string, a file handle using -file or "" will output to the screen.

    trflag

    Should the optimization be output to the screen and to a file?

    footer_flag

    Should the footer text be printed out?

    ...

    arguments passed to evaluate.fim and ofv_fim.

    - -

    See also

    - -

    Other Helper: -blockexp(), -blockheader(), -blockopt()

    - -

    Examples

    -
    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: 0x7fe20a979808> -#> <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.799 seconds
    - -
    +arguments in 'd' then the order will be worked out automatically.

    + + +
    docc
    +

    Matrix defining the IOV, the IOV variances and the IOV distribution as for d and bpop.

    + + +
    sigma
    +

    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().

    + + +
    poped.db
    +

    A PopED database.

    + + +
    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?

    + + +
    opt_inds
    +

    Are the number of individuals per group being optimized?

    + + +
    fmf_init
    +

    Initial FIM.

    + + +
    dmf_init
    +

    Initial OFV.

    + + +
    param_cvs_init
    +

    The initial design parameter RSE values in percent.

    + + +
    compute_inv
    +

    should the inverse of the FIM be used to compute expected RSE values? Often not needed +except for diagnostic purposes.

    + + +
    out_file
    +

    Which file should the output be directed to? A string, a file handle using +file or "" will output to the screen.

    + + +
    trflag
    +

    Should the optimization be output to the screen and to a file?

    + + +
    footer_flag
    +

    Should the footer text be printed out?

    + + +
    ...
    +

    arguments passed to evaluate.fim and ofv_fim.

    + +
    +
    +

    See also

    +

    Other Helper: +blockexp(), +blockheader(), +blockopt()

    +
    + +
    +

    Examples

    +
    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
    +
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/blockheader.html b/docs/reference/blockheader.html index 27214cf..96c4525 100644 --- a/docs/reference/blockheader.html +++ b/docs/reference/blockheader.html @@ -1,75 +1,12 @@ - - - - - - - -Header function for optimization routines — blockheader • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Header function for optimization routines — blockheader • PopED - + + - - - -
    -
    - -
    - -
    +
    @@ -150,344 +78,357 @@

    Header function for optimization routines

    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,
    -  ...
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    poped.db

    A PopED database.

    name

    The name used for the output file. Combined with name_header and iter. -If "" then output is to the screen.

    iter

    The last number in the name printed to the output file, combined with name.

    e_flag

    Should output be with uncertainty around parameters?

    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?

    opt_samps

    Are the number of sample times per group being optimized?

    opt_inds

    Are the number of individuals per group being optimized?

    fmf

    The initial value of the FIM. If set to zero then it is computed.

    dmf

    The initial OFV. If set to zero then it is computed.

    bpop

    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, +

      +
      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,
      +  ...
      +)
      +
      + +
      +

      Arguments

      +
      poped.db
      +

      A PopED database.

      + + +
      name
      +

      The name used for the output file. Combined with name_header and iter. +If "" then output is to the screen.

      + + +
      iter
      +

      The last number in the name printed to the output file, combined with name.

      + + +
      e_flag
      +

      Should output be with uncertainty around parameters?

      + + +
      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?

      + + +
      opt_samps
      +

      Are the number of sample times per group being optimized?

      + + +
      opt_inds
      +

      Are the number of individuals per group being optimized?

      + + +
      fmf
      +

      The initial value of the FIM. If set to zero then it is computed.

      + + +
      dmf
      +

      The initial OFV. If set to zero then it is computed.

      + + +
      bpop
      +

      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 +

    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.

    d

    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(). +arguments in 'bpop' then the order will be worked out automatically.

    + + +
    d
    +

    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.

    docc

    Matrix defining the IOV, the IOV variances and the IOV distribution as for d and bpop.

    sigma

    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().

    name_header

    The initial portion of the file name.

    file_path

    The path to where the file should be created.

    out_file

    Which file should the output be directed to? A string, a file handle using -file or "" will output to the screen.

    compute_inv

    should the inverse of the FIM be used to compute expected RSE values? Often not needed -except for diagnostic purposes.

    trflag

    Should the optimization be output to the screen and to a file?

    header_flag

    Should the header text be printed out?

    ...

    Additional arguments passed to further functions.

    - -

    Value

    - -

    fn A file handle (or '' if name='')

    -

    See also

    - -

    Other Helper: -blockexp(), -blockfinal(), -blockopt()

    - -

    Examples

    -
    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: 0x7fe20a979808> -#> <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 sprintf(...): object 'poped.db.1' not found
    - -
    +arguments in 'd' then the order will be worked out automatically.

    + + +
    docc
    +

    Matrix defining the IOV, the IOV variances and the IOV distribution as for d and bpop.

    + + +
    sigma
    +

    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().

    + + +
    name_header
    +

    The initial portion of the file name.

    + + +
    file_path
    +

    The path to where the file should be created.

    + + +
    out_file
    +

    Which file should the output be directed to? A string, a file handle using +file or "" will output to the screen.

    + + +
    compute_inv
    +

    should the inverse of the FIM be used to compute expected RSE values? Often not needed +except for diagnostic purposes.

    + + +
    trflag
    +

    Should the optimization be output to the screen and to a file?

    + + +
    header_flag
    +

    Should the header text be printed out?

    + + +
    ...
    +

    Additional arguments passed to further functions.

    + +
    +
    +

    Value

    + + +

    fn A file handle (or '' if name='')

    +
    +
    +

    See also

    +

    Other Helper: +blockexp(), +blockfinal(), +blockopt()

    +
    + +
    +

    Examples

    +
    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
    +
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/blockopt.html b/docs/reference/blockopt.html index 361f8d4..db40b4c 100644 --- a/docs/reference/blockopt.html +++ b/docs/reference/blockopt.html @@ -1,76 +1,13 @@ - - - - - - - -Summarize your optimization settings for optimization routines — blockopt • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Summarize your optimization settings for optimization routines — blockopt • PopED - - + + - - -
    -
    - -
    - -
    +
    @@ -152,145 +80,150 @@

    Summarize your optimization settings for optimization routines

    you will use to optimize.

    -
    blockopt(fn, poped.db, opt_method = "")
    - -

    Arguments

    - - - - - - - - - - - - - - -
    fn

    The file handle to write to.

    poped.db

    A PopED database.

    opt_method

    If "RS" (random search), "SG" (stochastic gradient) or "DO" (discrete optimization) then specific output is produced.

    - -

    See also

    - -

    Other Helper: -blockexp(), -blockfinal(), -blockheader()

    - -

    Examples

    -
    library(PopED) - -############# START ################# -## Create PopED database -## (warfarin model for optimization) -##################################### +
    +
    blockopt(fn, poped.db, opt_method = "")
    +
    -## 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. +
    +

    Arguments

    +
    fn
    +

    The file handle to write to.

    -## 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: 0x7fe20a979808> -#> <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) -} +
    poped.db
    +

    A PopED database.

    -## -- 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) -##################################### +
    opt_method
    +

    If "RS" (random search), "SG" (stochastic gradient) or "DO" (discrete optimization) then specific output is produced.

    +
    +
    +

    See also

    +

    Other Helper: +blockexp(), +blockfinal(), +blockheader()

    +
    -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
    +
    +

    Examples

    +
    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
    +
    +
    +
    - - - + + diff --git a/docs/reference/build_sfg.html b/docs/reference/build_sfg.html index 92b1d9f..684889a 100644 --- a/docs/reference/build_sfg.html +++ b/docs/reference/build_sfg.html @@ -1,75 +1,12 @@ - - - - - - - -Build PopED parameter function from a model function — build_sfg • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Build PopED parameter function from a model function — build_sfg • PopED - - + + - - -
    -
    - -
    - -
    +
    @@ -150,89 +78,91 @@

    Build PopED parameter function from a model function

    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()
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - -
    model

    A string of text describing the model function name

    covariates

    A list of covariate names to be filtered out of the model

    par_names

    A list of parameter names in the model file. If not supplied then +

    +
    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()
    +)
    +
    + +
    +

    Arguments

    +
    model
    +

    A string of text describing the model function name

    + + +
    covariates
    +

    A list of covariate names to be filtered out of the model

    + + +
    par_names
    +

    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.

    etas

    Can be "exp", "prop", "add" or "none". Either one value for all parameters or -a list defining the model per parameter.

    no_etas

    Parameters that should not have etas associated with them.

    env

    The environment to create the function in.

    - -

    Value

    - -

    A parameter model function to be used as input to PopED calculations.

    - -

    Examples

    -
    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: 0x7fe20d5952a8>
    -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: 0x7fe20d5952a8>
    +filtered out of that list.

    + + +
    etas
    +

    Can be "exp", "prop", "add" or "none". Either one value for all parameters or +a list defining the model per parameter.

    + + +
    no_etas
    +

    Parameters that should not have etas associated with them.

    + + +
    env
    +

    The environment to create the function in.

    + +
    +
    +

    Value

    + + +

    A parameter model function to be used as input to PopED calculations.

    +
    + +
    +

    Examples

    +
    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>
    +
    +
    +
    - - - + + diff --git a/docs/reference/calc_autofocus.html b/docs/reference/calc_autofocus.html index ad2781c..a1543bb 100644 --- a/docs/reference/calc_autofocus.html +++ b/docs/reference/calc_autofocus.html @@ -1,75 +1,12 @@ - - - - - - - -Compute the autofocus portion of the stochastic gradient routine — calc_autofocus • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Compute the autofocus portion of the stochastic gradient routine — calc_autofocus • PopED - - - - + + -
    -
    - -
    - -
    +
    @@ -150,253 +78,257 @@

    Compute the autofocus portion of the stochastic gradient routine

    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
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    m

    Number of groups in the study. Each individual in a group will have the same design.

    ni_var

    The ni_var.

    dmf

    The initial OFV. If set to zero then it is computed.

    varopt

    The varopt.

    varopto

    The varopto.

    maxvar

    The maxvar.

    minvar

    The minvar.

    gradvar

    The gradvar.

    normgvar

    The normgvar.

    avar

    The avar.

    model_switch

    A matrix that is the same size as xt, specifying which model each sample belongs to.

    groupsize

    A vector of the number of individuals in each group.

    xtopt

    The optimal sampling times matrix.

    xopt

    The optimal discrete design variables matrix.

    aopt

    The optimal continuous design variables matrix.

    ni

    A vector of the number of samples in each group.

    bpop

    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, +

      +
      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
      +)
      +
      + +
      +

      Arguments

      +
      m
      +

      Number of groups in the study. Each individual in a group will have the same design.

      + + +
      ni_var
      +

      The ni_var.

      + + +
      dmf
      +

      The initial OFV. If set to zero then it is computed.

      + + +
      varopt
      +

      The varopt.

      + + +
      varopto
      +

      The varopto.

      + + +
      maxvar
      +

      The maxvar.

      + + +
      minvar
      +

      The minvar.

      + + +
      gradvar
      +

      The gradvar.

      + + +
      normgvar
      +

      The normgvar.

      + + +
      avar
      +

      The avar.

      + + +
      model_switch
      +

      A matrix that is the same size as xt, specifying which model each sample belongs to.

      + + +
      groupsize
      +

      A vector of the number of individuals in each group.

      + + +
      xtopt
      +

      The optimal sampling times matrix.

      + + +
      xopt
      +

      The optimal discrete design variables matrix.

      + + +
      aopt
      +

      The optimal continuous design variables matrix.

      + + +
      ni
      +

      A vector of the number of samples in each group.

      + + +
      bpop
      +

      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 +

    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.

    d

    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(). +arguments in 'bpop' then the order will be worked out automatically.

    + + +
    d
    +

    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.

    sigma

    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().

    docc

    Matrix defining the IOV, the IOV variances and the IOV distribution as for d and bpop.

    poped.db

    A PopED database.

    - -

    Value

    - -

    A list containing:

    -
    navar

    The autofocus parameter.

    -
    poped.db

    PopED database.

    - -

    See also

    - - - -

    Examples

    -
    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: 0x7fe20a979808> -#> <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) - -} -
    +arguments in 'd' then the order will be worked out automatically.

    + + +
    sigma
    +

    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().

    + + +
    docc
    +

    Matrix defining the IOV, the IOV variances and the IOV distribution as for d and bpop.

    + + +
    poped.db
    +

    A PopED database.

    + +
    +
    +

    Value

    + + +

    A list containing:

    +
    navar
    +

    The autofocus parameter.

    + +
    poped.db
    +

    PopED database.

    + +
    +
    +

    See also

    + +
    + +
    +

    Examples

    +
    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)
    +
    +}
    +
    +
    +
    - - - + + diff --git a/docs/reference/calc_ofv_and_fim.html b/docs/reference/calc_ofv_and_fim.html index 106feb4..7de90cb 100644 --- a/docs/reference/calc_ofv_and_fim.html +++ b/docs/reference/calc_ofv_and_fim.html @@ -1,78 +1,15 @@ - - - - - - - -Calculate the Fisher Information Matrix (FIM) and the OFV(FIM) for either point values or parameters or distributions. — calc_ofv_and_fim • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Calculate the Fisher Information Matrix (FIM) and the OFV(FIM) for either point values or parameters or distributions. — calc_ofv_and_fim • PopED - - - - - - - - - - + + - - - - -
    -
    - -
    - -
    +
    @@ -156,114 +84,110 @@

    Calculate the Fisher Information Matrix (FIM) and the OFV(FIM) for either po 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,
    -  ...
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    poped.db

    A PopED database.

    ofv

    The current ofv. If other than zero then this values is simply returned unchanged.

    fim

    The current FIM. If other than zero then this values is simply returned unchanged.

    d_switch
      -
    • ******START OF CRITERION SPECIFICATION OPTIONS**********

    • -

    D-family design (1) or ED-family design (0) (with or without parameter uncertainty)

    bpopdescr

    Matrix defining the fixed effects, per row (row number = -parameter_number) we should have:

      -
    • column 1 the type of the +

      +
      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,
      +  ...
      +)
      +
      + +
      +

      Arguments

      +
      poped.db
      +

      A PopED database.

      + + +
      ofv
      +

      The current ofv. If other than zero then this value is simply returned unchanged.

      + + +
      fim
      +

      The current FIM. If other than zero then this value is simply returned unchanged.

      + + +
      d_switch
      +
      • ******START OF CRITERION SPECIFICATION OPTIONS**********

      • +

      D-family design (1) or ED-family design (0) (with or without parameter uncertainty)

      + + +
      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).

      • -
    ddescr

    Matrix defining the diagonals of the IIV (same logic as for -the bpopdescr).

    bpop

    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, +

    + + +
    ddescr
    +

    Matrix defining the diagonals of the IIV (same logic as for +the bpopdescr).

    + + +
    bpop
    +

    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 +

    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.

    d

    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(). +arguments in 'bpop' then the order will be worked out automatically.

    + + +
    d
    +

    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.

    docc_full

    A between occasion variability matrix.

    model_switch

    A matrix that is the same size as xt, specifying which model each sample belongs to.

    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.

    x

    A matrix for the discrete design variables. Each row is a group.

    a

    A matrix of covariates. Each row is a group.

    fim.calc.type

    The method used for calculating the FIM. Potential values:

      -
    • 0 = Full FIM. No assumption that fixed and random effects are uncorrelated.

    • +arguments in 'd' then the order will be worked out automatically.

      + + +
      docc_full
      +

      A between occasion variability matrix.

      + + +
      model_switch
      +

      A matrix that is the same size as xt, specifying which model each sample belongs to.

      + + +
      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.

      + + +
      x
      +

      A matrix for the discrete design variables. Each row is a group.

      + + +
      a
      +

      A matrix of covariates. Each row is a group.

      + + +
      fim.calc.type
      +

      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).

      • @@ -274,196 +198,200 @@

        Arg
      • 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.

      • -

    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 + + + +

    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 using the standard MC integration technique, so can be slow.

    ofv_fun

    User defined function used to compute the objective function. The function must have a poped database object as its first +is done using the standard MC integration technique, so can be slow.

    + + +
    ofv_fun
    +

    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.

    evaluate_fim

    Should the FIM be calculated?

    ...

    Other arguments passed to the function.

    - -

    Value

    - -

    A list containing the FIM and OFV(FIM) or the E(FIM) and E(OFV(FIM)) according to the function arguments.

    -

    See also

    - -

    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()

    +e.g. "cost.txt" has a function named "cost" in it.

    + + +
    evaluate_fim
    +

    Should the FIM be calculated?

    + + +
    ...
    +

    Other arguments passed to the function.

    + +
    +
    +

    Value

    + + +

    A list containing the FIM and OFV(FIM) or the E(FIM) and E(OFV(FIM)) according to the function arguments.

    +
    +
    +

    See also

    + - -

    Examples

    -
    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: 0x7fe20a979808> -#> <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) +evaluate.e.ofv.fim(), +evaluate.fim(), +ofv_fim()

    +
    -} -
    +
    +

    Examples

    +
    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)
    +
    +}
    +
    +
    +
    - - - + + diff --git a/docs/reference/calc_ofv_and_grad.html b/docs/reference/calc_ofv_and_grad.html index c4b8c76..ed76388 100644 --- a/docs/reference/calc_ofv_and_grad.html +++ b/docs/reference/calc_ofv_and_grad.html @@ -1,77 +1,14 @@ - - - - - - - -Compute an objective function and gradient — calc_ofv_and_grad • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Compute an objective function and gradient — calc_ofv_and_grad • PopED - - - - - - - - - - - - - - + + -
    -
    - -
    - -
    +

    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.

    +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
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    x

    A matrix for the discrete design variables. Each row is a group.

    optxt

    If sampling times are optimized

    opta

    If continuous design variables are optimized

    model_switch

    A matrix that is the same size as xt, specifying which model each sample belongs to.

    aa

    The aa value

    axt

    the axt value

    groupsize

    A vector of the number of individuals in each group.

    ni

    A vector of the number of samples in each group.

    xtopto

    the xtopto value

    xopto

    the xopto value

    aopto

    the aopto value

    bpop

    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, +

      +
      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
      +)
      +
      + +
      +

      Arguments

      +
      x
      +

      A matrix for the discrete design variables. Each row is a group.

      + + +
      optxt
      +

      If sampling times are optimized

      + + +
      opta
      +

      If continuous design variables are optimized

      + + +
      model_switch
      +

      A matrix that is the same size as xt, specifying which model each sample belongs to.

      + + +
      aa
      +

      The aa value

      + + +
      axt
      +

      the axt value

      + + +
      groupsize
      +

      A vector of the number of individuals in each group.

      + + +
      ni
      +

      A vector of the number of samples in each group.

      + + +
      xtopto
      +

      the xtopto value

      + + +
      xopto
      +

      the xopto value

      + + +
      aopto
      +

      the aopto value

      + + +
      bpop
      +

      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 +

    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.

    d

    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(). +arguments in 'bpop' then the order will be worked out automatically.

    + + +
    d
    +

    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.

    sigma

    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().

    docc_full

    A between occasion variability matrix.

    poped.db

    A PopED database.

    only_fim

    Should the gradient be calculated?

    - -

    Value

    - -

    A list containing:

    -
    f

    The objective function.

    -
    g

    The gradient.

    - -

    See also

    - - - -

    Examples

    -
    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: 0x7fe20a979808> -#> <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.079631592 -#> [2,] -0.025697632 -#> [3,] -0.312973640 -#> [4,] 0.009484126 -#> [5,] 0.019485344 -#> [6,] -0.001675732 -#> [7,] -0.009543726 -#> [8,] -0.001929126 -#> [9,] -0.035843401 -#>
    -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) - -} +arguments in 'd' then the order will be worked out automatically.

    + + +
    sigma
    +

    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().

    + + +
    docc_full
    +

    A between occasion variability matrix.

    + +
    poped.db
    +

    A PopED database.

    +
    only_fim
    +

    Should the gradient be calculated?

    -
    +
    +
    +

    Value

    + + +

    A list containing:

    +
    f
    +

    The objective function.

    + +
    g
    +

    The gradient.

    + +
    +
    +

    See also

    + +
    + +
    +

    Examples

    +
    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)
    +  
    +}
    +
    +
    +
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/cell.html b/docs/reference/cell.html index 753d745..01126bd 100644 --- a/docs/reference/cell.html +++ b/docs/reference/cell.html @@ -1,75 +1,12 @@ - - - - - - - -Create a cell array (a matrix of lists) — cell • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Create a cell array (a matrix of lists) — cell • PopED - - + + - - -
    -
    - -
    - -
    +
    @@ -150,87 +78,94 @@

    Create a cell array (a matrix of lists)

    Create a cell array as in MATLAB.

    -
    cell(...)
    - -

    Arguments

    - - - - - - -
    ...

    Dimensions for the cell array.

    +
    +
    cell(...)
    +
    -

    Value

    +
    +

    Arguments

    +
    ...
    +

    Dimensions for the cell array.

    -

    A list of empty lists.

    -

    Note

    +
    +
    +

    Value

    + +

    A list of empty lists.

    +
    +
    +

    Note

    This is a modified version of the same function in the matlab R-package.

    -

    See also

    - -

    Other MATLAB: -diag_matlab(), -feval(), -fileparts(), -isempty(), -ones(), -randn(), -rand(), -size(), -tic(), -toc(), -zeros()

    - -

    Examples

    -
    -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 -#>
    +
    +
    +

    See also

    +

    Other MATLAB: +diag_matlab(), +feval(), +fileparts(), +isempty(), +ones(), +randn(), +rand(), +size(), +tic(), +toc(), +zeros()

    +
    + +
    +

    Examples

    +
    
    +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
    +#> 
    +
    +
    +
    - - - + + diff --git a/docs/reference/convert_variables.html b/docs/reference/convert_variables.html index 4e79fff..d265d59 100644 --- a/docs/reference/convert_variables.html +++ b/docs/reference/convert_variables.html @@ -1,78 +1,15 @@ - - - - - - - -Create global variables in the PopED database — convert_variables • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Create global variables in the PopED database — convert_variables • PopED - - - - - - - - - - - + + - - - -
    -
    - -
    - -
    +
    @@ -153,57 +81,56 @@

    Create global variables in the PopED database

    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.

    +use the function create.poped.database.

    -
    convert_variables(poped.db)
    - -

    Arguments

    - - - - - - -
    poped.db

    A PopED database

    +
    +
    convert_variables(poped.db)
    +
    -

    Value

    +
    +

    Arguments

    +
    poped.db
    +

    A PopED database

    -

    A PopED database

    -

    See also

    +
    +
    +

    Value

    + - +

    A PopED database

    +
    +
    +
    - - - + + diff --git a/docs/reference/create.poped.database.html b/docs/reference/create.poped.database.html index 27a48a8..db8dd9a 100644 --- a/docs/reference/create.poped.database.html +++ b/docs/reference/create.poped.database.html @@ -1,80 +1,17 @@ - - - - - - - -Create a PopED database — create.poped.database • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Create a PopED database — create.poped.database • PopED - - - - - - - - - - - + + - - - -
    -
    - -
    - -
    +
    @@ -160,367 +88,353 @@

    Create a PopED database

    (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)
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    popedInput

    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).

    ff_file
      -
    • ******START OF MODEL DEFINITION OPTIONS**********

    • +
      +
      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)
      +)
      +
      + +
      +

      Arguments

      +
      popedInput
      +

      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).

      + + +
      ff_file
      +
      • ******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"

    ff_fun

    Function describing the structural model. e.g. ff.PK.1.comp.oral.md.KE.

    fg_file

    A string giving the function name or filename and path of the +e.g. "ff.PK.1.comp.oral.md.KE"

    + + +
    ff_fun
    +

    Function describing the structural model. e.g. ff.PK.1.comp.oral.md.KE.

    + + +
    fg_file
    +

    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"

    fg_fun

    Function describing the parameter model. e.g. parameter.model.

    fError_file

    A string giving the function name or filename and path of the +e.g. "parameter.model"

    + + +
    fg_fun
    +

    Function describing the parameter model. e.g. parameter.model.

    + + +
    fError_file
    +

    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".

    fError_fun

    Function describing the residual error model. e.g. feps.prop.

    optsw
      -
    • ******WHAT TO OPTIMIZE**********

    • +e.g. "feps.prop".

      + + +
      fError_fun
      +

      Function describing the residual error model. e.g. feps.prop.

      + + +
      optsw
      +
      • ******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

    xt
      -
    • ******START OF INITIAL DESIGN OPTIONS**********

    • +All elements set to zero => only calculate the FIM with current design

      + + +
      xt
      +
      • ******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.

    m

    Number of groups in the study. Each individual in a group will have the same design.

    x

    A matrix defining the initial discrete values for the model -Each row is a group/individual.

    nx

    Number of discrete design variables.

    a

    Matrix defining the initial continuous covariate values. + If only one vector is supplied, e.g. c(1,2,3,4), then all groups will +have the same initial design.

    + + +
    m
    +

    Number of groups in the study. Each individual in a group will have the same design.

    + + +
    x
    +

    A matrix defining the initial discrete values for the model +Each row is a group/individual.

    + + +
    nx
    +

    Number of discrete design variables.

    + + +
    a
    +

    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.

    groupsize

    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.

    ni

    Vector defining the number of samples for each group.

    model_switch

    Matrix defining which response a certain sampling time belongs to.

    maxni
      -
    • ******START OF DESIGN SPACE OPTIONS**********

    • -

    Max number of samples per group/individual

    minni

    Min number of samples per group/individual

    maxtotni

    Number defining the maximum number of samples allowed in the experiment.

    mintotni

    Number defining the minimum number of samples allowed in the experiment.

    maxgroupsize

    Vector defining the max size of the different groups (max number of individuals in each group)

    mingroupsize

    Vector defining the min size of the different groups (min num individuals in each group) --

    maxtotgroupsize

    The total maximal groupsize over all groups

    mintotgroupsize

    The total minimal groupsize over all groups

    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

    discrete_xt

    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.

    discrete_x

    Cell array defining the discrete variables for each x value. -See examples in create_design_space.

    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

    discrete_a

    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.

    bUseGrouped_xt

    Use grouped time points (1=TRUE, 0=FALSE).

    G_xt

    Matrix defining the grouping of sample points. Matching integers mean that the points are matched.

    bUseGrouped_a

    Use grouped covariates (1=TRUE, 0=FALSE)

    G_a

    Matrix defining the grouping of covariates. Matching integers mean that the points are matched.

    bUseGrouped_x

    Use grouped discrete design variables (1=TRUE, 0=FALSE).

    G_x

    Matrix defining the grouping of discrete design variables. Matching integers mean that the points are matched.

    iFIMCalculationType
      -
    • ******START OF FIM CALCULATION OPTIONS**********

    • -

    Fisher Information Matrix type

      -
    • 0=Full FIM

    • +same values.

      + + +
      groupsize
      +

      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.

      + + +
      ni
      +

      Vector defining the number of samples for each group.

      + + +
      model_switch
      +

      Matrix defining which response a certain sampling time belongs to.

      + + +
      maxni
      +
      • ******START OF DESIGN SPACE OPTIONS**********

      • +

      Max number of samples per group/individual

      + + +
      minni
      +

      Min number of samples per group/individual

      + + +
      maxtotni
      +

      Number defining the maximum number of samples allowed in the experiment.

      + + +
      mintotni
      +

      Number defining the minimum number of samples allowed in the experiment.

      + + +
      maxgroupsize
      +

      Vector defining the max size of the different groups (max number of individuals in each group)

      + + +
      mingroupsize
      +

      Vector defining the min size of the different groups (min num individuals in each group) --

      + + +
      maxtotgroupsize
      +

      The total maximal groupsize over all groups

      + + +
      mintotgroupsize
      +

      The total minimal groupsize over all groups

      + + +
      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

      + + +
      discrete_xt
      +

      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.

      + + +
      discrete_x
      +

      Cell array defining the discrete variables for each x value. +See examples in create_design_space.

      + + +
      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

      + + +
      discrete_a
      +

      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.

      + + +
      bUseGrouped_xt
      +

      Use grouped time points (1=TRUE, 0=FALSE).

      + + +
      G_xt
      +

      Matrix defining the grouping of sample points. Matching integers mean that the points are matched.

      + + +
      bUseGrouped_a
      +

      Use grouped covariates (1=TRUE, 0=FALSE)

      + + +
      G_a
      +

      Matrix defining the grouping of covariates. Matching integers mean that the points are matched.

      + + +
      bUseGrouped_x
      +

      Use grouped discrete design variables (1=TRUE, 0=FALSE).

      + + +
      G_x
      +

      Matrix defining the grouping of discrete design variables. Matching integers mean that the points are matched.

      + + +
      iFIMCalculationType
      +
      • ******START OF FIM CALCULATION OPTIONS**********

      • +

      Fisher Information Matrix type

      • 0=Full FIM

      • 1=Reduced FIM

      • 2=weighted models

      • 3=Loc models

      • @@ -528,579 +442,574 @@

        Arg
      • 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

      • -

    iApproximationMethod

    Approximation method for model, 0=FO, 1=FOCE, 2=FOCEI, 3=FOI

    iFOCENumInd

    Num individuals in each step of FOCE

    prior_fim

    The prior FIM (added to calculated FIM)

    strAutoCorrelationFile

    Filename and path, or function name, for the Autocorrelation function, -empty string means no autocorrelation.

    d_switch
      -
    • ******START OF CRITERION SPECIFICATION OPTIONS**********

    • -

    D-family design (1) or ED-family design (0) (with or without parameter uncertainty)

    ofv_calc_type

    OFV calculation type for FIM

      -
    • 1 = "D-optimality". Determinant of the FIM: det(FIM)

    • +
    + + +
    iApproximationMethod
    +

    Approximation method for model, 0=FO, 1=FOCE, 2=FOCEI, 3=FOI

    + + +
    iFOCENumInd
    +

    Num individuals in each step of FOCE

    + + +
    prior_fim
    +

    The prior FIM (added to calculated FIM)

    + + +
    strAutoCorrelationFile
    +

    Filename and path, or function name, for the Autocorrelation function, +empty string means no autocorrelation.

    + + +
    d_switch
    +
    • ******START OF CRITERION SPECIFICATION OPTIONS**********

    • +

    D-family design (1) or ED-family design (0) (with or without parameter uncertainty)

    + + +
    ofv_calc_type
    +

    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

    Ds_index is a vector set to 1 if a parameter is uninteresting, otherwise 0. + + + +

    ds_index
    +

    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.

    strEDPenaltyFile

    Penalty function name or path and filename, empty string means no penalty. -User defined criterion can be defined this way.

    ofv_fun

    User defined function used to compute the objective function. The function must have a poped database object as its first +ofv_calc_type=6.

    + + +
    strEDPenaltyFile
    +

    Penalty function name or path and filename, empty string means no penalty. +User defined criterion can be defined this way.

    + + +
    ofv_fun
    +

    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.

    iEDCalculationType
      -
    • ******START OF E-FAMILY CRITERION SPECIFICATION OPTIONS**********

    • -

    ED Integral Calculation, 0=Monte-Carlo-Integration, 1=Laplace Approximation, 2=BFGS Laplace Approximation -- --

    ED_samp_size

    Sample size for E-family sampling

    bLHS

    How to sample from distributions in E-family calculations. 0=Random Sampling, 1=LatinHyperCube --

    strUserDistributionFile

    Filename and path, or function name, for user defined distributions for E-family designs

    nbpop
      -
    • ******START OF Model parameters SPECIFICATION OPTIONS**********

    • -

    Number of typical values

    NumRanEff

    Number of IIV parameters. Typically can be computed from other values and not supplied.

    NumDocc

    Number of IOV variance parameters. Typically can be computed from other values and not supplied.

    NumOcc

    Number of occasions. Typically can be computed from other values and not supplied.

    bpop

    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, +e.g. "cost.txt" has a function named "cost" in it.

      + + +
      iEDCalculationType
      +
      • ******START OF E-FAMILY CRITERION SPECIFICATION OPTIONS**********

      • +

      ED Integral Calculation, 0=Monte-Carlo-Integration, 1=Laplace Approximation, 2=BFGS Laplace Approximation -- --

      + + +
      ED_samp_size
      +

      Sample size for E-family sampling

      + + +
      bLHS
      +

      How to sample from distributions in E-family calculations. 0=Random Sampling, 1=LatinHyperCube --

      + + +
      strUserDistributionFile
      +

      Filename and path, or function name, for user defined distributions for E-family designs

      + + +
      nbpop
      +
      • ******START OF Model parameters SPECIFICATION OPTIONS**********

      • +

      Number of typical values

      + + +
      NumRanEff
      +

      Number of IIV parameters. Typically can be computed from other values and not supplied.

      + + +
      NumDocc
      +

      Number of IOV variance parameters. Typically can be computed from other values and not supplied.

      + + +
      NumOcc
      +

      Number of occasions. Typically can be computed from other values and not supplied.

      + + +
      bpop
      +

      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 +

    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.

    d

    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(). +arguments in 'bpop' then the order will be worked out automatically.

    + + +
    d
    +

    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.

    covd

    Column major vector defining the covariances of the IIV variances. -That is, from your full IIV matrix covd <- IIV[lower.tri(IIV)].

    sigma

    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().

    docc

    Matrix defining the IOV, the IOV variances and the IOV distribution as for d and bpop.

    covdocc

    Column major vector defining the covariance of the IOV, as in covd.

    notfixed_bpop
      -
    • ******START OF Model parameters fixed or not SPECIFICATION OPTIONS**********

    • +arguments in 'd' then the order will be worked out automatically.

      + + +
      covd
      +

      Column major vector defining the covariances of the IIV variances. +That is, from your full IIV matrix covd <- IIV[lower.tri(IIV)].

      + + +
      sigma
      +

      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().

      + + +
      docc
      +

      Matrix defining the IOV, the IOV variances and the IOV distribution as for d and bpop.

      + + +
      covdocc
      +

      Column major vector defining the covariance of the IOV, as in covd.

      + + +
      notfixed_bpop
      +
      • ******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.

    notfixed_d

    Vector defining if a IIV is fixed or not (1=not fixed, 0=fixed). +arguments in 'notfixed_bpop' then the order will be worked out automatically.

    + + +
    notfixed_d
    +

    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.

    notfixed_covd

    Vector defining if a covariance IIV is fixed or not (1=not fixed, 0=fixed)

    notfixed_docc

    Vector defining if an IOV variance is fixed or not (1=not fixed, 0=fixed)

    notfixed_covdocc

    Vector row major order for lower triangular matrix defining if a covariance IOV is fixed or not (1=not fixed, 0=fixed)

    notfixed_sigma

    Vector defining if a residual error parameter is fixed or not (1=not fixed, 0=fixed)

    notfixed_covsigma

    Vector defining if a covariance residual error parameter is fixed or not (1=not fixed, 0=fixed). -Default is fixed.

    bUseRandomSearch
      -
    • ******START OF Optimization algorithm SPECIFICATION OPTIONS**********

    • -

    Use random search (1=TRUE, 0=FALSE)

    bUseStochasticGradient

    Use Stochastic Gradient search (1=TRUE, 0=FALSE)

    bUseLineSearch

    Use Line search (1=TRUE, 0=FALSE)

    bUseExchangeAlgorithm

    Use Exchange algorithm (1=TRUE, 0=FALSE)

    bUseBFGSMinimizer

    Use BFGS Minimizer (1=TRUE, 0=FALSE)

    EACriteria

    Exchange Algorithm Criteria, 1 = Modified, 2 = Fedorov

    strRunFile

    Filename and path, or function name, for a run file that is used instead of the regular PopED call.

    poped_version
      -
    • ******START OF Labeling and file names SPECIFICATION OPTIONS**********

    • -

    The current PopED version

    modtit

    The model title

    output_file

    Filename and path of the output file during search

    output_function_file

    Filename suffix of the result function file

    strIterationFileName

    Filename and path for storage of current optimal design

    user_data
      -
    • ******START OF Miscellaneous SPECIFICATION OPTIONS**********

    • -

    User defined data structure that, for example could be used to send in data to the model

    ourzero

    Value to interpret as zero in design

    dSeed

    The seed number used for optimization and sampling -- integer or -1 which creates a random seed as.integer(Sys.time()) or NULL.

    line_opta

    Vector for line search on continuous design variables (1=TRUE,0=FALSE)

    line_optx

    Vector for line search on discrete design variables (1=TRUE,0=FALSE)

    bShowGraphs

    Use graph output during search

    use_logfile

    If a log file should be used (0=FALSE, 1=TRUE)

    m1_switch

    Method used to calculate M1 -(0=Complex difference, 1=Central difference, 20=Analytic derivative, 30=Automatic differentiation)

    m2_switch

    Method used to calculate M2 -(0=Central difference, 1=Central difference, 20=Analytic derivative, 30=Automatic differentiation)

    hle_switch

    Method used to calculate linearization of residual error -(0=Complex difference, 1=Central difference, 30=Automatic differentiation)

    gradff_switch

    Method used to calculate the gradient of the model -(0=Complex difference, 1=Central difference, 20=Analytic derivative, 30=Automatic differentiation)

    gradfg_switch

    Method used to calculate the gradient of the parameter vector g -(0=Complex difference, 1=Central difference, 20=Analytic derivative, 30=Automatic differentiation)

    grad_all_switch

    Method used to calculate all the gradients -(0=Complex difference, 1=Central difference)

    rsit_output

    Number of iterations in random search between screen output

    sgit_output

    Number of iterations in stochastic gradient search between screen output

    hm1

    Step length of derivative of linearized model w.r.t. typical values

    hlf

    Step length of derivative of model w.r.t. g

    hlg

    Step length of derivative of g w.r.t. b

    hm2

    Step length of derivative of variance w.r.t. typical values

    hgd

    Step length of derivative of OFV w.r.t. time

    hle

    Step length of derivative of model w.r.t. sigma

    AbsTol

    The absolute tolerance for the diff equation solver

    RelTol

    The relative tolerance for the diff equation solver

    iDiffSolverMethod

    The diff equation solver method, NULL as default.

    bUseMemorySolver

    If the differential equation results should be stored in memory (1) or not (0)

    rsit

    Number of Random search iterations

    sgit

    Number of stochastic gradient iterations

    intrsit

    Number of Random search iterations with discrete optimization.

    intsgit

    Number of Stochastic Gradient search iterations with discrete optimization

    maxrsnullit

    Iterations until adaptive narrowing in random search

    convergence_eps

    Stochastic Gradient convergence value, -(difference in OFV for D-optimal, difference in gradient for ED-optimal)

    rslxt

    Random search locality factor for sample times

    rsla

    Random search locality factor for covariates

    cfaxt

    Stochastic Gradient search first step factor for sample times

    cfaa

    Stochastic Gradient search first step factor for covariates

    bGreedyGroupOpt

    Use greedy algorithm for group assignment optimization

    EAStepSize

    Exchange Algorithm StepSize

    EANumPoints

    Exchange Algorithm NumPoints

    EAConvergenceCriteria

    Exchange Algorithm Convergence Limit/Criteria

    bEANoReplicates

    Avoid replicate samples when using Exchange Algorithm

    BFGSConvergenceCriteriaMinStep

    BFGS Minimizer Convergence Criteria Minimum Step

    BFGSProjectedGradientTol

    BFGS Minimizer Convergence Criteria Normalized Projected Gradient Tolerance

    BFGSTolerancef

    BFGS Minimizer Line Search Tolerance f

    BFGSToleranceg

    BFGS Minimizer Line Search Tolerance g

    BFGSTolerancex

    BFGS Minimizer Line Search Tolerance x

    ED_diff_it

    Number of iterations in ED-optimal design to calculate convergence criteria

    ED_diff_percent

    ED-optimal design convergence criteria in percent

    line_search_it

    Number of grid points in the line search

    Doptim_iter

    Number of iterations of full Random search and full Stochastic Gradient if line search is not used

    iCompileOption

    ******START OF PARALLEL OPTIONS********** Compile options for PopED

      -
    • -1 = No compilation,

    • +arguments in 'notfixed_d' then the order will be worked out automatically.

      + + +
      notfixed_covd
      +

      Vector defining if a covariance IIV is fixed or not (1=not fixed, 0=fixed)

      + + +
      notfixed_docc
      +

      Vector defining if an IOV variance is fixed or not (1=not fixed, 0=fixed)

      + + +
      notfixed_covdocc
      +

      Vector row major order for lower triangular matrix defining if a covariance IOV is fixed or not (1=not fixed, 0=fixed)

      + + +
      notfixed_sigma
      +

      Vector defining if a residual error parameter is fixed or not (1=not fixed, 0=fixed)

      + + +
      notfixed_covsigma
      +

      Vector defining if a covariance residual error parameter is fixed or not (1=not fixed, 0=fixed). +Default is fixed.

      + + +
      bUseRandomSearch
      +
      • ******START OF Optimization algorithm SPECIFICATION OPTIONS**********

      • +

      Use random search (1=TRUE, 0=FALSE)

      + + +
      bUseStochasticGradient
      +

      Use Stochastic Gradient search (1=TRUE, 0=FALSE)

      + + +
      bUseLineSearch
      +

      Use Line search (1=TRUE, 0=FALSE)

      + + +
      bUseExchangeAlgorithm
      +

      Use Exchange algorithm (1=TRUE, 0=FALSE)

      + + +
      bUseBFGSMinimizer
      +

      Use BFGS Minimizer (1=TRUE, 0=FALSE)

      + + +
      EACriteria
      +

      Exchange Algorithm Criteria, 1 = Modified, 2 = Fedorov

      + + +
      strRunFile
      +

      Filename and path, or function name, for a run file that is used instead of the regular PopED call.

      + + +
      poped_version
      +
      • ******START OF Labeling and file names SPECIFICATION OPTIONS**********

      • +

      The current PopED version

      + + +
      modtit
      +

      The model title

      + + +
      output_file
      +

      Filename and path of the output file during search

      + + +
      output_function_file
      +

      Filename suffix of the result function file

      + + +
      strIterationFileName
      +

      Filename and path for storage of current optimal design

      + + +
      user_data
      +
      • ******START OF Miscellaneous SPECIFICATION OPTIONS**********

      • +

      User defined data structure that, for example could be used to send in data to the model

      + + +
      ourzero
      +

      Value to interpret as zero in design

      + + +
      dSeed
      +

      The seed number used for optimization and sampling -- integer or -1 which creates a random seed as.integer(Sys.time()) or NULL.

      + + +
      line_opta
      +

      Vector for line search on continuous design variables (1=TRUE,0=FALSE)

      + + +
      line_optx
      +

      Vector for line search on discrete design variables (1=TRUE,0=FALSE)

      + + +
      bShowGraphs
      +

      Use graph output during search

      + + +
      use_logfile
      +

      If a log file should be used (0=FALSE, 1=TRUE)

      + + +
      m1_switch
      +

      Method used to calculate M1 +(0=Complex difference, 1=Central difference, 20=Analytic derivative, 30=Automatic differentiation)

      + + +
      m2_switch
      +

      Method used to calculate M2 +(0=Central difference, 1=Central difference, 20=Analytic derivative, 30=Automatic differentiation)

      + + +
      hle_switch
      +

      Method used to calculate linearization of residual error +(0=Complex difference, 1=Central difference, 30=Automatic differentiation)

      + + +
      gradff_switch
      +

      Method used to calculate the gradient of the model +(0=Complex difference, 1=Central difference, 20=Analytic derivative, 30=Automatic differentiation)

      + + +
      gradfg_switch
      +

      Method used to calculate the gradient of the parameter vector g +(0=Complex difference, 1=Central difference, 20=Analytic derivative, 30=Automatic differentiation)

      + + +
      grad_all_switch
      +

      Method used to calculate all the gradients +(0=Complex difference, 1=Central difference)

      + + +
      rsit_output
      +

      Number of iterations in random search between screen output

      + + +
      sgit_output
      +

      Number of iterations in stochastic gradient search between screen output

      + + +
      hm1
      +

      Step length of derivative of linearized model w.r.t. typical values

      + + +
      hlf
      +

      Step length of derivative of model w.r.t. g

      + + +
      hlg
      +

      Step length of derivative of g w.r.t. b

      + + +
      hm2
      +

      Step length of derivative of variance w.r.t. typical values

      + + +
      hgd
      +

      Step length of derivative of OFV w.r.t. time

      + + +
      hle
      +

      Step length of derivative of model w.r.t. sigma

      + + +
      AbsTol
      +

      The absolute tolerance for the diff equation solver

      + + +
      RelTol
      +

      The relative tolerance for the diff equation solver

      + + +
      iDiffSolverMethod
      +

      The diff equation solver method, NULL as default.

      + + +
      bUseMemorySolver
      +

      If the differential equation results should be stored in memory (1) or not (0)

      + + +
      rsit
      +

      Number of Random search iterations

      + + +
      sgit
      +

      Number of stochastic gradient iterations

      + + +
      intrsit
      +

      Number of Random search iterations with discrete optimization.

      + + +
      intsgit
      +

      Number of Stochastic Gradient search iterations with discrete optimization

      + + +
      maxrsnullit
      +

      Iterations until adaptive narrowing in random search

      + + +
      convergence_eps
      +

      Stochastic Gradient convergence value, +(difference in OFV for D-optimal, difference in gradient for ED-optimal)

      + + +
      rslxt
      +

      Random search locality factor for sample times

      + + +
      rsla
      +

      Random search locality factor for covariates

      + + +
      cfaxt
      +

      Stochastic Gradient search first step factor for sample times

      + + +
      cfaa
      +

      Stochastic Gradient search first step factor for covariates

      + + +
      bGreedyGroupOpt
      +

      Use greedy algorithm for group assignment optimization

      + + +
      EAStepSize
      +

      Exchange Algorithm StepSize

      + + +
      EANumPoints
      +

      Exchange Algorithm NumPoints

      + + +
      EAConvergenceCriteria
      +

      Exchange Algorithm Convergence Limit/Criteria

      + + +
      bEANoReplicates
      +

      Avoid replicate samples when using Exchange Algorithm

      + + +
      BFGSConvergenceCriteriaMinStep
      +

      BFGS Minimizer Convergence Criteria Minimum Step

      + + +
      BFGSProjectedGradientTol
      +

      BFGS Minimizer Convergence Criteria Normalized Projected Gradient Tolerance

      + + +
      BFGSTolerancef
      +

      BFGS Minimizer Line Search Tolerance f

      + + +
      BFGSToleranceg
      +

      BFGS Minimizer Line Search Tolerance g

      + + +
      BFGSTolerancex
      +

      BFGS Minimizer Line Search Tolerance x

      + + +
      ED_diff_it
      +

      Number of iterations in ED-optimal design to calculate convergence criteria

      + + +
      ED_diff_percent
      +

      ED-optimal design convergence criteria in percent

      + + +
      line_search_it
      +

      Number of grid points in the line search

      + + +
      Doptim_iter
      +

      Number of iterations of full Random search and full Stochastic Gradient if line search is not used

      + + +
      iCompileOption
      +

      ******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

      • -
    iUseParallelMethod

    Parallel method to use (0 = Matlab PCT, 1 = MPI)

    MCC_Dep

    Additional dependencies used in MCC compilation (mat-files), if several space separated

    strExecuteName

    Compilation output executable name

    iNumProcesses

    Number of processes to use when running in parallel (e.g. 3 = 2 workers, 1 job manager)

    iNumChunkDesignEvals

    Number of design evaluations that should be evaluated in each process before getting new work from job manager

    Mat_Out_Pre

    The prefix of the output mat file to communicate with the executable

    strExtraRunOptions

    Extra options send to e$g. the MPI executable or a batch script, see execute_parallel$m for more information and options

    dPollResultTime

    Polling time to check if the parallel execution is finished

    strFunctionInputName

    The file containing the popedInput structure that should be used to evaluate the designs

    bParallelRS

    If the random search is going to be executed in parallel

    bParallelSG

    If the stochastic gradient search is going to be executed in parallel

    bParallelMFEA

    If the modified exchange algorithm is going to be executed in parallel

    bParallelLS

    If the line search is going to be executed in parallel

    - -

    Value

    - -

    A PopED database

    -

    See also

    - - - -

    Examples

    -
    ## 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: 0x7fe25cadfcb0> -#> <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 calc_ofv_and_fim(poped.db, ...): object 'poped.db' not found
    + + + +
    iUseParallelMethod
    +

    Parallel method to use (0 = Matlab PCT, 1 = MPI)

    + + +
    MCC_Dep
    +

    Additional dependencies used in MCC compilation (mat-files), if several space separated

    + + +
    strExecuteName
    +

    Compilation output executable name

    + + +
    iNumProcesses
    +

    Number of processes to use when running in parallel (e.g. 3 = 2 workers, 1 job manager)

    + + +
    iNumChunkDesignEvals
    +

    Number of design evaluations that should be evaluated in each process before getting new work from job manager

    + + +
    Mat_Out_Pre
    +

    The prefix of the output mat file to communicate with the executable

    + + +
    strExtraRunOptions
    +

    Extra options send to e$g. the MPI executable or a batch script, see execute_parallel$m for more information and options

    + + +
    dPollResultTime
    +

    Polling time to check if the parallel execution is finished

    + + +
    strFunctionInputName
    +

    The file containing the popedInput structure that should be used to evaluate the designs

    + + +
    bParallelRS
    +

    If the random search is going to be executed in parallel

    + + +
    bParallelSG
    +

    If the stochastic gradient search is going to be executed in parallel

    + + +
    bParallelMFEA
    +

    If the modified exchange algorithm is going to be executed in parallel

    + + +
    bParallelLS
    +

    If the line search is going to be executed in parallel

    + +
    +
    +

    Value

    + + +

    A PopED database

    +
    +
    +

    See also

    + +
    + +
    +

    Examples

    +
    ## 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
    +
    +
    +
    - - - + + diff --git a/docs/reference/create_design.html b/docs/reference/create_design.html index f861d33..1ab7100 100644 --- a/docs/reference/create_design.html +++ b/docs/reference/create_design.html @@ -1,79 +1,16 @@ - - - - - - - -Create design variables for a full description of a design. — create_design • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Create design variables for a full description of a design. — create_design • PopED - - - - - - - - - - - + + - - - -
    -
    - -
    - -
    +
    @@ -158,134 +86,133 @@

    Create design variables for a full description of a design.

    Returns a list of matricies compatible with PopED.

    -
    create_design(
    -  xt,
    -  groupsize,
    -  m = NULL,
    -  x = NULL,
    -  a = NULL,
    -  ni = NULL,
    -  model_switch = NULL
    -)
    +
    +
    create_design(
    +  xt,
    +  groupsize,
    +  m = NULL,
    +  x = NULL,
    +  a = NULL,
    +  ni = NULL,
    +  model_switch = NULL
    +)
    +
    -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    xt

    Matrix defining the sampling schedule. -Each row is a group.

    groupsize

    Vector defining the size of the different groups (number of individuals in each group).

    m

    A number defining the number of groups. Computed from xt if not defined.

    x

    A matrix defining the discrete design variables for the model -Each row is a group.

    a

    Matrix defining the continuous design variables. Each row is a group.

    ni

    Vector defining the number of samples for each group, computed as all elements of xt for each group by default.

    model_switch

    Matrix defining which response a certain sampling time belongs to. Defaults to one for all elements of xt.

    +
    +

    Arguments

    +
    xt
    +

    Matrix defining the sampling schedule. +Each row is a group.

    -

    Details

    -

    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.

    -

    See also

    +
    groupsize
    +

    Vector defining the size of the different groups (number of individuals in each group).

    - -

    Examples

    -
    library(PopED) +
    m
    +

    A number defining the number of groups. Computed from xt if not defined.

    -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) +
    x
    +

    A matrix defining the discrete design variables for the model +Each row is a group.

    -design_5 <- create_design(xt=xt3,groupsize=20,m=3) -design_6 <- create_design(xt=xt1,groupsize=20,model_switch=ones(2,4)) +
    a
    +

    Matrix defining the continuous design variables. Each row is a group.

    -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)) +
    ni
    +

    Vector defining the number of samples for each group, computed as all elements of xt for each group by default.

    -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) +
    model_switch
    +

    Matrix defining which response a certain sampling time belongs to. Defaults to one for all elements of xt.

    -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))) +
    +
    +

    Details

    +

    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.

    +
    + -
    +
    +

    Examples

    +
    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)))
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/create_design_space.html b/docs/reference/create_design_space.html index dde5fc2..ba1d487 100644 --- a/docs/reference/create_design_space.html +++ b/docs/reference/create_design_space.html @@ -1,81 +1,18 @@ - - - - - - - -Create design variables and a design space for a full description of an optimization problem. — create_design_space • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Create design variables and a design space for a full description of an optimization problem. — create_design_space • PopED - - - - - - - - - - + + - - - - -
    -
    - -
    - -
    +
    @@ -162,260 +90,259 @@

    Create design variables and a design space for a full description of an opti 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
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    design

    The output from a call to create_design.

    maxni

    Vector defining the maximum number of samples per group.

    minni

    Vector defining the minimum number of samples per group.

    maxtotni

    Number defining the maximum number of samples allowed in the experiment.

    mintotni

    Number defining the minimum number of samples allowed in the experiment.

    maxgroupsize

    Vector defining the maximum size of the different groups (maximum number of individuals in each group)

    mingroupsize

    Vector defining the minimum size of the different groups (minimum num individuals in each group)

    maxtotgroupsize

    The total maximal groupsize over all groups

    mintotgroupsize

    The total minimal groupsize over all groups

    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

    xt_space

    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).

    maxa

    Vector defining the maximum value for each covariate. IF a single value is supplied then -all a values are given the same maximum value

    mina

    Vector defining the minimum value for each covariate. IF a single value is supplied then -all a values are given the same minimum value

    a_space

    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).

    x_space

    Cell array cell defining the discrete variables for each x value.

    use_grouped_xt

    Group sampling times between groups so that each group has the same values (TRUE or FALSE).

    grouped_xt

    Matrix defining the grouping of sample points. Matching integers mean that the points are matched. -Allows for finer control than use_grouped_xt

    use_grouped_a

    Group continuous design variables between groups so that each group has the same values (TRUE or FALSE).

    grouped_a

    Matrix defining the grouping of continuous design variables. Matching integers mean that the values are matched. -Allows for finer control than use_grouped_a.

    use_grouped_x

    Group discrete design variables between groups so that each group has the same values (TRUE or FALSE).

    grouped_x

    Matrix defining the grouping of discrete design variables. Matching integers mean that the values are matched. -Allows for finer control than use_grouped_x.

    our_zero

    Value to interpret as zero in design.

    - -

    Details

    +
    +
    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
    +)
    +
    -

    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.

    -

    See also

    +
    +

    Arguments

    +
    design
    +

    The output from a call to create_design.

    - -

    Examples

    -
    library(PopED) +
    maxni
    +

    Vector defining the maximum number of samples per group.

    -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) +
    minni
    +

    Vector defining the minimum number of samples per group.

    -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) +
    maxtotni
    +

    Number defining the maximum number of samples allowed in the experiment.

    -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)) +
    mintotni
    +

    Number defining the minimum number of samples allowed in the experiment.

    -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))) +
    maxgroupsize
    +

    Vector defining the maximum size of the different groups (maximum number of individuals in each group)

    -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))) +
    mingroupsize
    +

    Vector defining the minimum size of the different groups (minimum num individuals in each group)

    -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) +
    maxtotgroupsize
    +

    The total maximal groupsize over all groups

    -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) +
    mintotgroupsize
    +

    The total minimal groupsize over all groups

    -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) +
    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.

    -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)) +
    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

    -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) +
    xt_space
    +

    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).

    -ds_17 <- create_design_space(design_1,a_space = list(1:100,seq(1000,100000,by=1000))) -
    +
    maxa
    +

    Vector defining the maximum value for each covariate. IF a single value is supplied then +all a values are given the same maximum value

    + + +
    mina
    +

    Vector defining the minimum value for each covariate. IF a single value is supplied then +all a values are given the same minimum value

    + + +
    a_space
    +

    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).

    + + +
    x_space
    +

    Cell array cell defining the discrete variables for each x value.

    + + +
    use_grouped_xt
    +

    Group sampling times between groups so that each group has the same values (TRUE or FALSE).

    + + +
    grouped_xt
    +

    Matrix defining the grouping of sample points. Matching integers mean that the points are matched. +Allows for finer control than use_grouped_xt

    + + +
    use_grouped_a
    +

    Group continuous design variables between groups so that each group has the same values (TRUE or FALSE).

    + + +
    grouped_a
    +

    Matrix defining the grouping of continuous design variables. Matching integers mean that the values are matched. +Allows for finer control than use_grouped_a.

    + + +
    use_grouped_x
    +

    Group discrete design variables between groups so that each group has the same values (TRUE or FALSE).

    + + +
    grouped_x
    +

    Matrix defining the grouping of discrete design variables. Matching integers mean that the values are matched. +Allows for finer control than use_grouped_x.

    + + +
    our_zero
    +

    Value to interpret as zero in design.

    + +
    +
    +

    Details

    +

    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.

    +
    +
    +

    See also

    + +
    + +
    +

    Examples

    +
    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)))
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/design_summary.html b/docs/reference/design_summary.html index b59dd80..a204edb 100644 --- a/docs/reference/design_summary.html +++ b/docs/reference/design_summary.html @@ -1,75 +1,12 @@ - - - - - - - -Display a summary of output from poped_db — design_summary • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Display a summary of output from poped_db — design_summary • PopED - - - - + + -
    -
    - -
    - -
    +
    @@ -150,51 +78,46 @@

    Display a summary of output from poped_db

    Display a summary of output from poped_db

    -
    design_summary(poped_db, file = "", ...)
    - -

    Arguments

    - - - - - - - - - - - - - - -
    poped_db

    An object returned from create.poped.database to summarize.

    file

    A file handle to write to. Default is to the R console.

    ...

    Additional arguments. Passed to blockfinal.

    +
    +
    design_summary(poped_db, file = "", ...)
    +
    + +
    +

    Arguments

    +
    poped_db
    +

    An object returned from create.poped.database to summarize.

    + + +
    file
    +

    A file handle to write to. Default is to the R console.

    +
    ...
    +

    Additional arguments. Passed to blockfinal.

    + +
    +
    +
    - - - + + diff --git a/docs/reference/diag_matlab.html b/docs/reference/diag_matlab.html index d4e538c..fc00e85 100644 --- a/docs/reference/diag_matlab.html +++ b/docs/reference/diag_matlab.html @@ -1,80 +1,17 @@ - - - - - - - -Function written to match MATLAB's diag function — diag_matlab • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Function written to match MATLAB's diag function — diag_matlab • PopED - - - - - - - - - - - - + + - - -
    -
    - -
    - -
    +

    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 +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)
    - -

    Arguments

    - - - - - - -
    mat

    Either a vector to make into a diagonal matrix or a matrix you -want to extract the diagonal from

    - -

    Value

    - -

    Either a diagonal matrix or the diagonal of a matrix.

    -

    See also

    - -

    Other MATLAB: -cell(), -feval(), -fileparts(), -isempty(), -ones(), -randn(), -rand(), -size(), -tic(), -toc(), -zeros()

    - -

    Examples

    -
    -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
    -
    +
    +
    diag_matlab(mat)
    +
    + +
    +

    Arguments

    +
    mat
    +

    Either a vector to make into a diagonal matrix or a matrix you +want to extract the diagonal from

    + +
    +
    +

    Value

    + + +

    Either a diagonal matrix or the diagonal of a matrix.

    +
    +
    +

    See also

    +

    Other MATLAB: +cell(), +feval(), +fileparts(), +isempty(), +ones(), +randn(), +rand(), +size(), +tic(), +toc(), +zeros()

    +
    + +
    +

    Examples

    +
    
    +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
    +
    +
    +
    +
    -
    - - + + diff --git a/docs/reference/downsizing_general_design.html b/docs/reference/downsizing_general_design.html index 46e3f4f..a0d7e4f 100644 --- a/docs/reference/downsizing_general_design.html +++ b/docs/reference/downsizing_general_design.html @@ -1,76 +1,13 @@ - - - - - - - -Downsize a general design to a specific design — downsizing_general_design • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Downsize a general design to a specific design — downsizing_general_design • PopED - - - - + + -
    -
    - -
    - -
    +

    Function takes a design with potentially empty design -variables and rescues the design so that a FIM can be calculated using mftot.

    +variables and rescues the design so that a FIM can be calculated using mftot.

    -
    downsizing_general_design(poped.db)
    +
    +
    downsizing_general_design(poped.db)
    +
    + +
    +

    Arguments

    +
    poped.db
    +

    A PopED database

    + +
    +
    +

    Value

    + + +

    A list containing:

    +
    ni
    +

    A vector of the number of samples in each group.

    -

    Arguments

    - - - - - - -
    poped.db

    A PopED database

    +
    xt
    +

    A matrix of sample times. Each row is a vector of sample times for a group.

    -

    Value

    +
    model_switch
    +

    A matrix that is the same size as xt, specifying which model each sample belongs to.

    -

    A list containing:

    -
    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.

    -
    bpop

    A matrix of fixed effect parameter values.

    +
    x
    +

    A matrix for the discrete design variables. Each row is a group.

    -

    See also

    +
    a
    +

    A matrix of covariates. Each row is a group.

    - +
    bpop
    +

    A matrix of fixed effect parameter values.

    + +
    +
    +

    See also

    + +
    +
    -
    - - + + diff --git a/docs/reference/ed_laplace_ofv.html b/docs/reference/ed_laplace_ofv.html index ef36c0d..c0f8bc4 100644 --- a/docs/reference/ed_laplace_ofv.html +++ b/docs/reference/ed_laplace_ofv.html @@ -1,80 +1,17 @@ - - - - - - - -Evaluate the expectation of determinant the Fisher Information Matrix (FIM) -using the Laplace approximation. — ed_laplace_ofv • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Evaluate the expectation of determinant the Fisher Information Matrix (FIM) +using the Laplace approximation. — ed_laplace_ofv • PopED - - - - - - - - - - - - - - + + -
    -
    - -
    - -
    +
    -

    Compute the expectation of the det(FIM) using the Laplace +

    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(),
    -  ...
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    model_switch

    A matrix that is the same size as xt, specifying which model each sample belongs to.

    groupsize

    A vector of the number of individuals in each group.

    ni

    A vector of the number of samples in each group.

    xtopto

    the sampling times

    xopto

    the discrete design variables

    aopto

    the continuous design variables

    bpopdescr

    Matrix defining the fixed effects, per row (row number = -parameter_number) we should have:

      -
    • column 1 the type of the +

      +
      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(),
      +  ...
      +)
      +
      + +
      +

      Arguments

      +
      model_switch
      +

      A matrix that is the same size as xt, specifying which model each sample belongs to.

      + + +
      groupsize
      +

      A vector of the number of individuals in each group.

      + + +
      ni
      +

      A vector of the number of samples in each group.

      + + +
      xtopto
      +

      the sampling times

      + + +
      xopto
      +

      the discrete design variables

      + + +
      aopto
      +

      the continuous design variables

      + + +
      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).

      • -
    ddescr

    Matrix defining the diagonals of the IIV (same logic as for -the bpopdescr).

    covd

    Column major vector defining the covariances of the IIV variances. -That is, from your full IIV matrix covd <- IIV[lower.tri(IIV)].

    sigma

    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().

    docc

    Matrix defining the IOV, the IOV variances and the IOV distribution as for d and bpop.

    poped.db

    A PopED database.

    method

    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 + + + +

    ddescr
    +

    Matrix defining the diagonals of the IIV (same logic as for +the bpopdescr).

    + + +
    covd
    +

    Column major vector defining the covariances of the IIV variances. +That is, from your full IIV matrix covd <- IIV[lower.tri(IIV)].

    + + +
    sigma
    +

    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().

    + + +
    docc
    +

    Matrix defining the IOV, the IOV variances and the IOV distribution as for d and bpop.

    + + +
    poped.db
    +

    A PopED database.

    + + +
    method
    +

    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.

    return_gradient

    Should the gradient be returned.

    optxt

    If sampling times are optimized

    opta

    If continuous design variables are optimized

    x

    The design parameters to compute the gradient on.

    ...

    Arguments passed through from other functions, does not pass anything to another function.

    - -

    Value

    - -

    The FIM and the hessian of the FIM.

    -

    Details

    +to compute the hessian.

    + + +
    return_gradient
    +

    Should the gradient be returned.

    + +
    optxt
    +

    If sampling times are optimized

    + + +
    opta
    +

    If continuous design variables are optimized

    + + +
    x
    +

    The design parameters to compute the gradient on.

    + + +
    ...
    +

    Arguments passed through from other functions, does not pass anything to another function.

    + +
    +
    +

    Value

    + + +

    The FIM and the hessian of the FIM.

    +
    +
    +

    Details

    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.

    -

    See also

    - -

    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()

    +

    Typically this function will not be run by the user. Instead use evaluate.e.ofv.fim.

    +
    +
    +

    See also

    + - -

    Examples

    -
    ## 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: 0x7fe20a979808> -#> <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 poped.db$settings$iEDCalculationType <- use_laplace: object 'poped.db.n' not found
    #> Elapsed time: 0.002 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) - - - - -} +calc_ofv_and_fim(), +ed_mftot(), +evaluate.e.ofv.fim()

    +
    -
    +
    +

    Examples

    +
    ## 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)
    +  
    +  
    +  
    +  
    +}
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/ed_mftot.html b/docs/reference/ed_mftot.html index b35a412..2341a15 100644 --- a/docs/reference/ed_mftot.html +++ b/docs/reference/ed_mftot.html @@ -1,76 +1,13 @@ - - - - - - - -Evaluate the expectation of the Fisher Information Matrix (FIM) and the expectation of the OFV(FIM). — ed_mftot • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Evaluate the expectation of the Fisher Information Matrix (FIM) and the expectation of the OFV(FIM). — ed_mftot • PopED - + + - - - -
    -
    - -
    - -
    +
    @@ -152,240 +80,243 @@

    Evaluate the expectation of the Fisher Information Matrix (FIM) and the expe PopED database.

    -
    ed_mftot(
    -  model_switch,
    -  groupsize,
    -  ni,
    -  xtoptn,
    -  xoptn,
    -  aoptn,
    -  bpopdescr,
    -  ddescr,
    -  covd,
    -  sigma,
    -  docc,
    -  poped.db,
    -  calc_fim = TRUE,
    -  ...
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    model_switch

    A matrix that is the same size as xt, specifying which model each sample belongs to.

    groupsize

    A vector of the number of individuals in each group.

    ni

    A vector of the number of samples in each group.

    xtoptn

    The xtoptn value

    xoptn

    The xoptn

    aoptn

    The aoptn value

    bpopdescr

    Matrix defining the fixed effects, per row (row number = -parameter_number) we should have:

      -
    • column 1 the type of the +

      +
      ed_mftot(
      +  model_switch,
      +  groupsize,
      +  ni,
      +  xtoptn,
      +  xoptn,
      +  aoptn,
      +  bpopdescr,
      +  ddescr,
      +  covd,
      +  sigma,
      +  docc,
      +  poped.db,
      +  calc_fim = TRUE,
      +  ...
      +)
      +
      + +
      +

      Arguments

      +
      model_switch
      +

      A matrix that is the same size as xt, specifying which model each sample belongs to.

      + + +
      groupsize
      +

      A vector of the number of individuals in each group.

      + + +
      ni
      +

      A vector of the number of samples in each group.

      + + +
      xtoptn
      +

      The xtoptn value

      + + +
      xoptn
      +

      The xoptn

      + + +
      aoptn
      +

      The aoptn value

      + + +
      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).

      • -
    ddescr

    Matrix defining the diagonals of the IIV (same logic as for -the bpopdescr).

    covd

    Column major vector defining the covariances of the IIV variances. -That is, from your full IIV matrix covd <- IIV[lower.tri(IIV)].

    sigma

    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().

    docc

    Matrix defining the IOV, the IOV variances and the IOV distribution as for d and bpop.

    poped.db

    A PopED database.

    calc_fim

    Should the FIM be calculated or should we just use the user defined ed_penalty_pointer.

    ...

    Other arguments passed to the function.

    - -

    Value

    - -

    A list containing the E(FIM) and E(OFV(FIM)) and the a poped.db.

    -

    See also

    - -

    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()

    + + + +
    ddescr
    +

    Matrix defining the diagonals of the IIV (same logic as for +the bpopdescr).

    + + +
    covd
    +

    Column major vector defining the covariances of the IIV variances. +That is, from your full IIV matrix covd <- IIV[lower.tri(IIV)].

    + + +
    sigma
    +

    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().

    + + +
    docc
    +

    Matrix defining the IOV, the IOV variances and the IOV distribution as for d and bpop.

    + + +
    poped.db
    +

    A PopED database.

    + + +
    calc_fim
    +

    Should the FIM be calculated or should we just use the user defined ed_penalty_pointer.

    + + +
    ...
    +

    Other arguments passed to the function.

    + +
    +
    +

    Value

    + + +

    A list containing the E(FIM) and E(OFV(FIM)) and the a poped.db.

    +
    +
    +

    See also

    + - -

    Examples

    -
    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: 0x7fe20a979808> -#> <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.36459 -#>
    - -
    +calc_ofv_and_fim(), +ed_laplace_ofv(), +evaluate.e.ofv.fim()

    +
    + +
    +

    Examples

    +
    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
    +#> 
    +
    +  
    +
    +
    +
    - - - + + diff --git a/docs/reference/efficiency.html b/docs/reference/efficiency.html index c29d3fb..a45e0ca 100644 --- a/docs/reference/efficiency.html +++ b/docs/reference/efficiency.html @@ -1,75 +1,12 @@ - - - - - - - -Compute efficiency. — efficiency • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Compute efficiency. — efficiency • PopED + + - - - - -
    -
    - -
    - -
    +
    @@ -150,113 +78,113 @@

    Compute efficiency.

    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,
    -  ...
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ofv_init

    An initial objective function

    ofv_final

    A final objective function.

    poped_db

    a poped database

    npar

    The number of parameters to use for normalization.

    ofv_calc_type

    OFV calculation type for FIM

      -
    • 1 = "D-optimality". Determinant of the FIM: det(FIM)

    • +
      +
      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,
      +  ...
      +)
      +
      + +
      +

      Arguments

      +
      ofv_init
      +

      An initial objective function

      + + +
      ofv_final
      +

      A final objective function.

      + + +
      poped_db
      +

      a poped database

      + + +
      npar
      +

      The number of parameters to use for normalization.

      + + +
      ofv_calc_type
      +

      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

    Ds_index is a vector set to 1 if a parameter is uninteresting, otherwise 0. + + + +

    ds_index
    +

    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.

    use_log

    Are the `ofv` arguments in the log space?

    ...

    arguments passed to evaluate.fim and ofv_fim.

    - -

    Value

    - -

    The specified efficiency value depending on the ofv_calc_type. +ofv_calc_type=6.

    + + +
    use_log
    +

    Are the `ofv` arguments in the log space?

    + + +
    ...
    +

    arguments passed to evaluate.fim and ofv_fim.

    + +
    +
    +

    Value

    + + +

    The specified efficiency value depending on the ofv_calc_type. The attribute "description" tells you how the calculation was made -attr(return_vale,"description")

    -

    See also

    - - +attr(return_vale,"description")

    + + +
    +
    +

    See also

    + +
    +
    - - - + + diff --git a/docs/reference/evaluate.e.ofv.fim.html b/docs/reference/evaluate.e.ofv.fim.html index 6c01fd7..a92fa9b 100644 --- a/docs/reference/evaluate.e.ofv.fim.html +++ b/docs/reference/evaluate.e.ofv.fim.html @@ -1,78 +1,15 @@ - - - - - - - -Evaluate the expectation of the Fisher Information Matrix (FIM) and the expectation of the OFV(FIM). — evaluate.e.ofv.fim • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Evaluate the expectation of the Fisher Information Matrix (FIM) and the expectation of the OFV(FIM). — evaluate.e.ofv.fim • PopED - - - - - - - - - - + + - - - - -
    -
    - -
    - -
    +
    @@ -156,40 +84,39 @@

    Evaluate the expectation of the Fisher Information Matrix (FIM) and the expe 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,
    -  ...
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    poped.db

    A PopED database.

    fim.calc.type

    The method used for calculating the FIM. Potential values:

      -
    • 0 = Full FIM. No assumption that fixed and random effects are uncorrelated.

    • +
      +
      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,
      +  ...
      +)
      +
      + +
      +

      Arguments

      +
      poped.db
      +

      A PopED database.

      + + +
      fim.calc.type
      +

      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).

      • @@ -200,272 +127,276 @@

        Arg
      • 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.

      • -

    bpop

    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, +

    + + +
    bpop
    +

    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 +

    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.

    d

    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(). +arguments in 'bpop' then the order will be worked out automatically.

    + + +
    d
    +

    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.

    covd

    Column major vector defining the covariances of the IIV variances. -That is, from your full IIV matrix covd <- IIV[lower.tri(IIV)].

    docc

    Matrix defining the IOV, the IOV variances and the IOV distribution as for d and bpop.

    sigma

    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().

    model_switch

    A matrix that is the same size as xt, specifying which model each sample belongs to.

    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.

    x

    A matrix for the discrete design variables. Each row is a group.

    a

    A matrix of covariates. Each row is a group.

    groupsize

    A vector of the number of individuals in each group.

    deriv.type

    A number indicating the type of derivative to use:

      -
    • 0=Complex difference

    • +arguments in 'd' then the order will be worked out automatically.

      + + +
      covd
      +

      Column major vector defining the covariances of the IIV variances. +That is, from your full IIV matrix covd <- IIV[lower.tri(IIV)].

      + + +
      docc
      +

      Matrix defining the IOV, the IOV variances and the IOV distribution as for d and bpop.

      + + +
      sigma
      +

      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().

      + + +
      model_switch
      +

      A matrix that is the same size as xt, specifying which model each sample belongs to.

      + + +
      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.

      + + +
      x
      +

      A matrix for the discrete design variables. Each row is a group.

      + + +
      a
      +

      A matrix of covariates. Each row is a group.

      + + +
      groupsize
      +

      A vector of the number of individuals in each group.

      + + +
      deriv.type
      +

      A number indicating the type of derivative to use:

      • 0=Complex difference

      • 1=Central difference

      • 20=Analytic derivative (placeholder)

      • 30=Automatic differentiation (placeholder)

      • -
    bLHS

    How to sample from distributions in E-family calculations. 0=Random Sampling, 1=LatinHyperCube --

    ofv_calc_type

    OFV calculation type for FIM

      -
    • 1 = "D-optimality". Determinant of the FIM: det(FIM)

    • +
    + + +
    bLHS
    +

    How to sample from distributions in E-family calculations. 0=Random Sampling, 1=LatinHyperCube --

    + + +
    ofv_calc_type
    +

    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))

    • -
    ED_samp_size

    Sample size for E-family sampling

    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 + + + +

    ED_samp_size
    +

    Sample size for E-family sampling

    + + +
    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 using the standard MC integration technique, so can be slow.

    ...

    Other arguments passed to the function.

    - -

    Value

    - -

    A list containing the E(FIM) and E(OFV(FIM)) and the a poped.db updated according to the function arguments.

    -

    See also

    - -

    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()

    +is done using the standard MC integration technique, so can be slow.

    + + +
    ...
    +

    Other arguments passed to the function.

    + +
    +
    +

    Value

    + + +

    A list containing the E(FIM) and E(OFV(FIM)) and the a poped.db updated according to the function arguments.

    +
    +
    +

    See also

    + - -

    Examples

    -
    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: 0x7fe20a979808> -#> <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.45214
    -## 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.46088
    -## ED evaluate using Laplace approximation -tic() -output <- evaluate.e.ofv.fim(poped.db,use_laplace=TRUE) -toc() -
    #> Elapsed time: 1.3 seconds.
    output$E_ofv -
    #> [1] 1.302806e+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 - - +calc_ofv_and_fim(), +evaluate.fim(), +ofv_fim()

    +
    -} -
    +
    +

    Examples

    +
    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
    +  
    + 
    +
    +}
    +
    +
    +
    - - - + + diff --git a/docs/reference/evaluate.fim.html b/docs/reference/evaluate.fim.html index fadfd79..d78404e 100644 --- a/docs/reference/evaluate.fim.html +++ b/docs/reference/evaluate.fim.html @@ -1,78 +1,15 @@ - - - - - - - -Evaluate the Fisher Information Matrix (FIM) — evaluate.fim • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Evaluate the Fisher Information Matrix (FIM) — evaluate.fim • PopED - - - - - - - - - - - - + + - - -
    -
    - -
    - -
    +
    @@ -156,36 +84,35 @@

    Evaluate the Fisher Information Matrix (FIM)

    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,
    -  ...
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    poped.db

    A PopED database.

    fim.calc.type

    The method used for calculating the FIM. Potential values:

      -
    • 0 = Full FIM. No assumption that fixed and random effects are uncorrelated.

    • +
      +
      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,
      +  ...
      +)
      +
      + +
      +

      Arguments

      +
      poped.db
      +

      A PopED database.

      + + +
      fim.calc.type
      +

      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).

      • @@ -196,303 +123,323 @@

        Arg
      • 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.

      • -

    approx.method

    Approximation method for model, 0=FO, 1=FOCE, 2=FOCEI, 3=FOI

    FOCE.num

    Number individuals in each step of FOCE approximation method

    bpop.val

    The fixed effects parameter values. Supplied as a vector.

    d_full

    A between subject variability matrix (OMEGA in NONMEM).

    docc_full

    A between occasion variability matrix.

    sigma_full

    A residual unexplained variability matrix (SIGMA in NONMEM).

    model_switch

    A matrix that is the same size as xt, specifying which model each sample belongs to.

    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.

    x

    A matrix for the discrete design variables. Each row is a group.

    a

    A matrix of covariates. Each row is a group.

    groupsize

    A vector of the number of individuals in each group.

    deriv.type

    A number indicating the type of derivative to use:

      -
    • 0=Complex difference

    • +
    + + +
    approx.method
    +

    Approximation method for model, 0=FO, 1=FOCE, 2=FOCEI, 3=FOI

    + + +
    FOCE.num
    +

    Number individuals in each step of FOCE approximation method

    + + +
    bpop.val
    +

    The fixed effects parameter values. Supplied as a vector.

    + + +
    d_full
    +

    A between subject variability matrix (OMEGA in NONMEM).

    + + +
    docc_full
    +

    A between occasion variability matrix.

    + + +
    sigma_full
    +

    A residual unexplained variability matrix (SIGMA in NONMEM).

    + + +
    model_switch
    +

    A matrix that is the same size as xt, specifying which model each sample belongs to.

    + + +
    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.

    + + +
    x
    +

    A matrix for the discrete design variables. Each row is a group.

    + + +
    a
    +

    A matrix of covariates. Each row is a group.

    + + +
    groupsize
    +

    A vector of the number of individuals in each group.

    + + +
    deriv.type
    +

    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.

    - -

    Value

    - -

    The FIM.

    -

    See also

    - -

    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 arguments passed to the function.

    + +
    +
    +

    Value

    + + +

    The FIM.

    +
    +
    +

    See also

    + - -

    Examples

    -
    ## 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: 0x7fe25cadfcb0> -#> <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.08763896 -#> [,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.92423 -#> [4,] 0.02613561 521.54030 -#> [5,] 3.26560786 11214.21071 -#> [6,] 41.81083599 71.08764 -#> [7,] 71.08763896 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.21752779 -#> [,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.92423 -#> [4,] 0.02613561 521.54030 -#> [5,] 3.26560786 11214.21071 -#> [6,] 41.81083599 71.08764 -#> [7,] 71.08763896 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.08763896 -#> [,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
    +calc_ofv_and_fim(), +evaluate.e.ofv.fim(), +ofv_fim()

    +
    + +
    +

    Examples

    +
    ## 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 
    +
    +
    +
    - - - + + diff --git a/docs/reference/evaluate_design.html b/docs/reference/evaluate_design.html index 2613079..99a2e66 100644 --- a/docs/reference/evaluate_design.html +++ b/docs/reference/evaluate_design.html @@ -1,75 +1,12 @@ - - - - - - - -Evaluate a design — evaluate_design • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Evaluate a design — evaluate_design • PopED + + - - - - -
    -
    - -
    - -
    +
    @@ -150,141 +78,144 @@

    Evaluate a design

    This function evaluates the design defined in a poped database.

    -
    evaluate_design(poped.db, ...)
    - -

    Arguments

    - - - - - - - - - - -
    poped.db

    A poped database

    ...

    Extra parameters passed to calc_ofv_and_fim and get_rse

    - -

    Value

    - -

    A list of elements evaluating the current design.

    -

    See also

    - - - -

    Examples

    -
    library(PopED) - -############# START ################# -## Create PopED database -## (warfarin example) -##################################### +
    +
    evaluate_design(poped.db, ...)
    +
    -## 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. +
    +

    Arguments

    +
    poped.db
    +

    A poped database

    -## 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: 0x7fe20a979808> -#> <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)) +
    ...
    +

    Extra parameters passed to calc_ofv_and_fim and get_rse

    -############# END ################### -## Create PopED database -## (warfarin example) -##################################### +
    +
    +

    Value

    + -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.08763896 -#> 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 -#>
    +

    A list of elements evaluating the current design.

    +
    +
    +

    See also

    + +
    -
    +
    +

    Examples

    +
    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 
    +#> 
    +
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/evaluate_fim_map.html b/docs/reference/evaluate_fim_map.html index a20c86a..36149b7 100644 --- a/docs/reference/evaluate_fim_map.html +++ b/docs/reference/evaluate_fim_map.html @@ -1,77 +1,14 @@ - - - - - - - -Compute the Bayesian Fisher information matrix — evaluate_fim_map • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Compute the Bayesian Fisher information matrix — evaluate_fim_map • PopED - - - - - - - - - - - - - - + + -
    -
    - -
    - -
    +
    @@ -154,154 +82,154 @@

    Compute the Bayesian Fisher information matrix

    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
    -)
    +
    +
    evaluate_fim_map(
    +  poped.db,
    +  use_mc = FALSE,
    +  num_sim_ids = 1000,
    +  use_purrr = FALSE,
    +  shrink_mat = F
    +)
    +
    + +
    +

    Arguments

    +
    poped.db
    +

    A PopED database

    -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - -
    poped.db

    A PopED database

    use_mc

    Should the calculation be based on monte-carlo simulations. If -not then then a first order approximation is used

    num_sim_ids

    If use_mc=TRUE, how many individuals should be -simulated to make the computations.

    use_purrr

    If use_mc=TRUE then should the method use the package -purrr in calculations? This may speed up computations (potentially).

    shrink_mat

    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).

    -

    Value

    +
    use_mc
    +

    Should the calculation be based on monte-carlo simulations. If +not then then a first order approximation is used

    + + +
    num_sim_ids
    +

    If use_mc=TRUE, how many individuals should be +simulated to make the computations.

    + -

    The Bayesian Fisher information matrix for each design group

    -

    References

    +
    use_purrr
    +

    If use_mc=TRUE then should the method use the package +purrr in calculations? This may speed up computations (potentially).

    + +
    shrink_mat
    +

    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).

    + +
    +
    +

    Value

    + + +

    The Bayesian Fisher information matrix for each design group

    +
    +
    +

    References

    -
      -
    1. Combes, F. P., Retout, S., +

      1. 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 + 2355-67. doi:10.1007/s11095-013-1079-3 .

      2. 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 + doi:10.1177/0091270010397731 .

      3. -
      - - -

      Examples

      -
      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: 0x7fe20a979808> -#> <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 x 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
      - -
      +
    + +
    +

    Examples

    +
    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
    +
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/evaluate_power-1.png b/docs/reference/evaluate_power-1.png index c57ad86..64b8bb1 100644 Binary files a/docs/reference/evaluate_power-1.png and b/docs/reference/evaluate_power-1.png differ diff --git a/docs/reference/evaluate_power-2.png b/docs/reference/evaluate_power-2.png index 03e8b9d..97a6efe 100644 Binary files a/docs/reference/evaluate_power-2.png and b/docs/reference/evaluate_power-2.png differ diff --git a/docs/reference/evaluate_power.html b/docs/reference/evaluate_power.html index bddbae7..9b07ac2 100644 --- a/docs/reference/evaluate_power.html +++ b/docs/reference/evaluate_power.html @@ -1,77 +1,14 @@ - - - - - - - -Power of a design to estimate a parameter. — evaluate_power • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Power of a design to estimate a parameter. — evaluate_power • PopED - - - - - - - - - - - - - - + + -
    -
    - -
    - -
    +
    @@ -154,277 +82,281 @@

    Power of a design to estimate a parameter.

    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,
    -  ...
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    poped.db

    A poped database

    bpop_idx

    Index for an unfixed population parameter (bpop) for +

    +
    evaluate_power(
    +  poped.db,
    +  bpop_idx,
    +  h0 = 0,
    +  alpha = 0.05,
    +  power = 0.8,
    +  twoSided = TRUE,
    +  find_min_n = TRUE,
    +  fim = NULL,
    +  out = NULL,
    +  ...
    +)
    +
    + +
    +

    Arguments

    +
    poped.db
    +

    A poped database

    + + +
    bpop_idx
    +

    Index for an unfixed population parameter (bpop) for which the power should be -evaluated for being different than the null hypothesis (h0).

    h0

    The null hypothesized value for the parameter.

    alpha

    Type 1 error.

    power

    Targeted power.

    twoSided

    Is this a two-sided test.

    find_min_n

    Should the function compute the minimum n needed (given the -current design) to achieve the desired power?

    fim

    Provide the FIM from a previous calculation

    out

    provide output from a previous calculation (e.g., -calc_ofv_and_fim, ...)

    ...

    Extra parameters passed to calc_ofv_and_fim and -get_rse

    - -

    Value

    - -

    A list of elements evaluating the current design including the power.

    -

    References

    +evaluated for being different than the null hypothesis (h0).

    + +
    h0
    +

    The null hypothesized value for the parameter.

    + + +
    alpha
    +

    Type 1 error.

    + + +
    power
    +

    Targeted power.

    + + +
    twoSided
    +

    Is this a two-sided test.

    + + +
    find_min_n
    +

    Should the function compute the minimum n needed (given the +current design) to achieve the desired power?

    + + +
    fim
    +

    Provide the FIM from a previous calculation

    + + +
    out
    +

    provide output from a previous calculation (e.g., +calc_ofv_and_fim, ...)

    + + +
    ...
    +

    Extra parameters passed to calc_ofv_and_fim and +get_rse

    + +
    +
    +

    Value

    -
      -
    1. Retout, S., Comets, E., Samson, A., and Mentre, + +

      A list of elements evaluating the current design including the power.

      +
    +
    +

    References

    + +
    1. 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 + doi:10.1002/sim.2910 .

    2. 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 + doi:10.1007/s10928-013-9331-3 .

    3. -
    - -

    See also

    - - - -

    Examples

    -
    # 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) -} - +
    +
    +

    See also

    + +
    -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.3770635 1889.1721996 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.8965834 2004.8718636 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.8965834 2004.8718636 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 -#>
    +
    +

    Examples

    +
    # 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
    +#> 
    +
    +
    +
    - - - + + diff --git a/docs/reference/extract_norm_group_fim.html b/docs/reference/extract_norm_group_fim.html index 65594c1..59f87be 100644 --- a/docs/reference/extract_norm_group_fim.html +++ b/docs/reference/extract_norm_group_fim.html @@ -1,75 +1,12 @@ - - - - - - - -Extract a normalized group FIM — extract_norm_group_fim • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Extract a normalized group FIM — extract_norm_group_fim • PopED - + + - - - -
    -
    - -
    - -
    +
    @@ -150,50 +78,48 @@

    Extract a normalized group FIM

    Extract an individual FIM for each group in a design

    -
    extract_norm_group_fim(poped.db, ...)
    +
    +
    extract_norm_group_fim(poped.db, ...)
    +
    + +
    +

    Arguments

    +
    poped.db
    +

    A PopED database

    -

    Arguments

    - - - - - - - - - - -
    poped.db

    A PopED database

    ...

    Arguments passed to evaluate.fim

    -

    Value

    +
    ...
    +

    Arguments passed to evaluate.fim

    -

    A list of FIMs, one for each group in a design.

    +
    +
    +

    Value

    + + +

    A list of FIMs, one for each group in a design.

    +
    +
    - - - + + diff --git a/docs/reference/feps.add-1.png b/docs/reference/feps.add-1.png index 5e16348..6f2d439 100644 Binary files a/docs/reference/feps.add-1.png and b/docs/reference/feps.add-1.png differ diff --git a/docs/reference/feps.add.html b/docs/reference/feps.add.html index 46583ec..f943e1b 100644 --- a/docs/reference/feps.add.html +++ b/docs/reference/feps.add.html @@ -1,79 +1,16 @@ - - - - - - - -RUV model: -Additive . — feps.add • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -RUV model: +Additive . — feps.add • PopED - - - - - - - - - - + + - - - - -
    -
    - -
    - -
    +

    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 +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)
    +
    +
    feps.add(model_switch, xt, parameters, epsi, poped.db)
    +
    -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - -
    model_switch

    a vector of values, the same size as xt, identifying which model +

    +

    Arguments

    +
    model_switch
    +

    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.

    xt

    a vector of independent variable values (often time).

    parameters

    A named list of parameter values.

    epsi

    A matrix with the same number of rows as the xt vector, columns match the numbers defined in this -function.

    poped.db

    a poped database. This can be used to extract information that may be needed in the model file.

    +corresponding xt value. Used for multiple response models.

    -

    Value

    -

    A list consisting of:

      -
    1. y the values of the model at the specified points.

    2. -
    3. poped.db A (potentially modified) poped database.

    4. -
    +
    xt
    +

    a vector of independent variable values (often time).

    -

    See also

    - +
    parameters
    +

    A named list of parameter values.

    -

    Examples

    -
    -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: 0x7fe24aba5148> -#> <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) -} +
    epsi
    +

    A matrix with the same number of rows as the xt vector, columns match the numbers defined in this +function.

    -## -- 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
    -
    +
    poped.db
    +

    a poped database. This can be used to extract information that may be needed in the model file.

    + +
    +
    +

    Value

    + + +

    A list consisting of:

    1. y the values of the model at the specified points.

    2. +
    3. poped.db A (potentially modified) poped database.

    4. +
    + + +
    +

    Examples

    +
    
    +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 
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/feps.add.prop-1.png b/docs/reference/feps.add.prop-1.png index 1a8e638..ddf2e54 100644 Binary files a/docs/reference/feps.add.prop-1.png and b/docs/reference/feps.add.prop-1.png differ diff --git a/docs/reference/feps.add.prop.html b/docs/reference/feps.add.prop.html index a69083a..5be0ba0 100644 --- a/docs/reference/feps.add.prop.html +++ b/docs/reference/feps.add.prop.html @@ -1,79 +1,16 @@ - - - - - - - -RUV model: -Additive and Proportional. — feps.add.prop • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -RUV model: +Additive and Proportional. — feps.add.prop • PopED - - - - - - - - - - + + - - - - -
    -
    - -
    - -
    +

    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 +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)
    +
    +
    feps.add.prop(model_switch, xt, parameters, epsi, poped.db)
    +
    -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - -
    model_switch

    a vector of values, the same size as xt, identifying which model +

    +

    Arguments

    +
    model_switch
    +

    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.

    xt

    a vector of independent variable values (often time).

    parameters

    A named list of parameter values.

    epsi

    A matrix with the same number of rows as the xt vector, columns match the numbers defined in this -function.

    poped.db

    a poped database. This can be used to extract information that may be needed in the model file.

    +corresponding xt value. Used for multiple response models.

    -

    Value

    -

    A list consisting of:

      -
    1. y the values of the model at the specified points.

    2. -
    3. poped.db A (potentially modified) poped database.

    4. -
    +
    xt
    +

    a vector of independent variable values (often time).

    -

    See also

    - +
    parameters
    +

    A named list of parameter values.

    -

    Examples

    -
    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: 0x7fe25cadfcb0> -#> <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 ) -} +
    epsi
    +

    A matrix with the same number of rows as the xt vector, columns match the numbers defined in this +function.

    -## -- 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
    -
    +
    poped.db
    +

    a poped database. This can be used to extract information that may be needed in the model file.

    + +
    +
    +

    Value

    + + +

    A list consisting of:

    1. y the values of the model at the specified points.

    2. +
    3. poped.db A (potentially modified) poped database.

    4. +
    + + +
    +

    Examples

    +
    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 
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/feps.prop-1.png b/docs/reference/feps.prop-1.png index b16a20d..00f7fe3 100644 Binary files a/docs/reference/feps.prop-1.png and b/docs/reference/feps.prop-1.png differ diff --git a/docs/reference/feps.prop.html b/docs/reference/feps.prop.html index 19ad7e9..376495e 100644 --- a/docs/reference/feps.prop.html +++ b/docs/reference/feps.prop.html @@ -1,79 +1,16 @@ - - - - - - - -RUV model: -Proportional. — feps.prop • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -RUV model: +Proportional. — feps.prop • PopED - - - - - - - - - - - - + + - - -
    -
    - -
    - -
    +

    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 +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)
    +
    +
    feps.prop(model_switch, xt, parameters, epsi, poped.db)
    +
    -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - -
    model_switch

    a vector of values, the same size as xt, identifying which model +

    +

    Arguments

    +
    model_switch
    +

    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.

    xt

    a vector of independent variable values (often time).

    parameters

    A named list of parameter values.

    epsi

    A matrix with the same number of rows as the xt vector, columns match the numbers defined in this -function.

    poped.db

    a poped database. This can be used to extract information that may be needed in the model file.

    +corresponding xt value. Used for multiple response models.

    -

    Value

    -

    A list consisting of:

      -
    1. y the values of the model at the specified points.

    2. -
    3. poped.db A (potentially modified) poped database.

    4. -
    - -

    See also

    +
    xt
    +

    a vector of independent variable values (often time).

    - -

    Examples

    -
    library(PopED) +
    parameters
    +

    A named list of parameter values.

    -############# 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. +
    epsi
    +

    A matrix with the same number of rows as the xt vector, columns match the numbers defined in this +function.

    -## 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: 0x7fe20a979808> -#> <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)) +
    poped.db
    +

    a poped database. This can be used to extract information that may be needed in the model file.

    -############# END ################### -## Create PopED database -## (warfarin example) -##################################### +
    +
    +

    Value

    + +

    A list consisting of:

    1. y the values of the model at the specified points.

    2. +
    3. poped.db A (potentially modified) poped database.

    4. +
    + -## 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.08763896 -#> [,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
    -
    +
    +

    Examples

    +
    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 
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/feval.html b/docs/reference/feval.html index 0988184..13fe9c7 100644 --- a/docs/reference/feval.html +++ b/docs/reference/feval.html @@ -1,75 +1,12 @@ - - - - - - - -MATLAB feval function — feval • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -MATLAB feval function — feval • PopED + + - - - - -
    -
    - -
    - -
    +
    -

    This is just a wrapper for the do.call function to behave like the feval function in MATLAB.

    +

    This is just a wrapper for the do.call function to behave like the feval function in MATLAB.

    -
    feval(file.name, ...)
    - -

    Arguments

    - - - - - - - - - - -
    file.name

    A function or a string that is the name of a function.

    ...

    Arguments for the function. Multiple arguments separated by a comma.

    - -

    Value

    - -

    Output from the defined function.

    -

    See also

    - -

    Other MATLAB: -cell(), -diag_matlab(), -fileparts(), -isempty(), -ones(), -randn(), -rand(), -size(), -tic(), -toc(), -zeros()

    - -

    Examples

    -
    -feval("sin",pi/2) -
    #> [1] 1
    -
    +
    +
    feval(file.name, ...)
    +
    + +
    +

    Arguments

    +
    file.name
    +

    A function or a string that is the name of a function.

    + + +
    ...
    +

    Arguments for the function. Multiple arguments separated by a comma.

    + +
    +
    +

    Value

    + + +

    Output from the defined function.

    +
    +
    +

    See also

    +

    Other MATLAB: +cell(), +diag_matlab(), +fileparts(), +isempty(), +ones(), +randn(), +rand(), +size(), +tic(), +toc(), +zeros()

    +
    + +
    +

    Examples

    +
    
    +feval("sin",pi/2)
    +#> [1] 1
    +
    +
    +
    +
    -
    - - + + diff --git a/docs/reference/ff.PK.1.comp.oral.md.CL-1.png b/docs/reference/ff.PK.1.comp.oral.md.CL-1.png index 1a8e638..ddf2e54 100644 Binary files a/docs/reference/ff.PK.1.comp.oral.md.CL-1.png and b/docs/reference/ff.PK.1.comp.oral.md.CL-1.png differ diff --git a/docs/reference/ff.PK.1.comp.oral.md.CL.html b/docs/reference/ff.PK.1.comp.oral.md.CL.html index 70b1bfd..2c28128 100644 --- a/docs/reference/ff.PK.1.comp.oral.md.CL.html +++ b/docs/reference/ff.PK.1.comp.oral.md.CL.html @@ -1,78 +1,15 @@ - - - - - - - -Structural model: one-compartment, oral absorption, multiple bolus dose, parameterized using CL. — ff.PK.1.comp.oral.md.CL • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Structural model: one-compartment, oral absorption, multiple bolus dose, parameterized using CL. — ff.PK.1.comp.oral.md.CL • PopED - - - - - - - - - - - - + + - - -
    -
    - -
    - -
    +

    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 +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)
    +
    +
    ff.PK.1.comp.oral.md.CL(model_switch, xt, parameters, poped.db)
    +
    -

    Arguments

    - - - - - - - - - - - - - - - - - - -
    model_switch

    a vector of values, the same size as xt, identifying which model +

    +

    Arguments

    +
    model_switch
    +

    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.

    xt

    a vector of independent variable values (often time).

    parameters

    A named list of parameter values.

    poped.db

    a poped database. This can be used to extract information that may be needed in the model file.

    +corresponding xt value. Used for multiple response models.

    -

    Value

    -

    A list consisting of:

      -
    1. y the values of the model at the specified points.

    2. -
    3. poped.db A (potentially modified) poped database.

    4. -
    +
    xt
    +

    a vector of independent variable values (often time).

    -

    See also

    - +
    parameters
    +

    A named list of parameter values.

    -

    Examples

    -
    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: 0x7fe25cadfcb0> -#> <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 ) -} +
    poped.db
    +

    a poped database. This can be used to extract information that may be needed in the model file.

    -## -- 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)) +
    +
    +

    Value

    + -## 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
    -
    +

    A list consisting of:

    1. y the values of the model at the specified points.

    2. +
    3. poped.db A (potentially modified) poped database.

    4. +
    + + +
    +

    Examples

    +
    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 
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/ff.PK.1.comp.oral.md.KE-1.png b/docs/reference/ff.PK.1.comp.oral.md.KE-1.png index 1a8e638..ddf2e54 100644 Binary files a/docs/reference/ff.PK.1.comp.oral.md.KE-1.png and b/docs/reference/ff.PK.1.comp.oral.md.KE-1.png differ diff --git a/docs/reference/ff.PK.1.comp.oral.md.KE.html b/docs/reference/ff.PK.1.comp.oral.md.KE.html index fbaaf83..a970783 100644 --- a/docs/reference/ff.PK.1.comp.oral.md.KE.html +++ b/docs/reference/ff.PK.1.comp.oral.md.KE.html @@ -1,78 +1,15 @@ - - - - - - - -Structural model: one-compartment, oral absorption, multiple bolus dose, parameterized using KE. — ff.PK.1.comp.oral.md.KE • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Structural model: one-compartment, oral absorption, multiple bolus dose, parameterized using KE. — ff.PK.1.comp.oral.md.KE • PopED - - - - - - - - - - - - + + - - -
    -
    - -
    - -
    +

    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 +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)
    +
    +
    ff.PK.1.comp.oral.md.KE(model_switch, xt, parameters, poped.db)
    +
    -

    Arguments

    - - - - - - - - - - - - - - - - - - -
    model_switch

    a vector of values, the same size as xt, identifying which model +

    +

    Arguments

    +
    model_switch
    +

    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.

    xt

    a vector of independent variable values (often time).

    parameters

    A named list of parameter values.

    poped.db

    a poped database. This can be used to extract information that may be needed in the model file.

    +corresponding xt value. Used for multiple response models.

    -

    Value

    -

    A list consisting of:

      -
    1. y the values of the model at the specified points.

    2. -
    3. poped.db A (potentially modified) poped database.

    4. -
    +
    xt
    +

    a vector of independent variable values (often time).

    -

    See also

    - +
    parameters
    +

    A named list of parameter values.

    -

    Examples

    -
    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: 0x7fe20d7bf9d0> -#> <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 ) -} +
    poped.db
    +

    a poped database. This can be used to extract information that may be needed in the model file.

    -## -- 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)) +
    +
    +

    Value

    + -## 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
    -
    +

    A list consisting of:

    1. y the values of the model at the specified points.

    2. +
    3. poped.db A (potentially modified) poped database.

    4. +
    + + +
    +

    Examples

    +
    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 
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/ff.PK.1.comp.oral.sd.CL-1.png b/docs/reference/ff.PK.1.comp.oral.sd.CL-1.png index b16a20d..00f7fe3 100644 Binary files a/docs/reference/ff.PK.1.comp.oral.sd.CL-1.png and b/docs/reference/ff.PK.1.comp.oral.sd.CL-1.png differ diff --git a/docs/reference/ff.PK.1.comp.oral.sd.CL.html b/docs/reference/ff.PK.1.comp.oral.sd.CL.html index 2936c69..76aa98b 100644 --- a/docs/reference/ff.PK.1.comp.oral.sd.CL.html +++ b/docs/reference/ff.PK.1.comp.oral.sd.CL.html @@ -1,78 +1,15 @@ - - - - - - - -Structural model: one-compartment, oral absorption, single bolus dose, parameterized using CL. — ff.PK.1.comp.oral.sd.CL • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Structural model: one-compartment, oral absorption, single bolus dose, parameterized using CL. — ff.PK.1.comp.oral.sd.CL • PopED - - - - - - - - - - + + - - - - -
    -
    - -
    - -
    +

    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 +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)
    +
    +
    ff.PK.1.comp.oral.sd.CL(model_switch, xt, parameters, poped.db)
    +
    -

    Arguments

    - - - - - - - - - - - - - - - - - - -
    model_switch

    a vector of values, the same size as xt, identifying which model +

    +

    Arguments

    +
    model_switch
    +

    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.

    xt

    a vector of independent variable values (often time).

    parameters

    A named list of parameter values.

    poped.db

    a poped database. This can be used to extract information that may be needed in the model file.

    +corresponding xt value. Used for multiple response models.

    -

    Value

    -

    A list consisting of:

      -
    1. y the values of the model at the specified points.

    2. -
    3. poped.db A (potentially modified) poped database.

    4. -
    +
    xt
    +

    a vector of independent variable values (often time).

    -

    See also

    - +
    parameters
    +

    A named list of parameter values.

    -

    Examples

    -
    library(PopED) -############# START ################# -## Create PopED database -## (warfarin example) -##################################### +
    poped.db
    +

    a poped database. This can be used to extract information that may be needed in the model file.

    -## 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: 0x7fe20a979808> -#> <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) -##################################### +
    +
    +

    Value

    + +

    A list consisting of:

    1. y the values of the model at the specified points.

    2. +
    3. poped.db A (potentially modified) poped database.

    4. +
    + -## 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.08763896 -#> [,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
    -
    +
    +

    Examples

    +
    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 
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/ff.PK.1.comp.oral.sd.KE-1.png b/docs/reference/ff.PK.1.comp.oral.sd.KE-1.png index 5e16348..6f2d439 100644 Binary files a/docs/reference/ff.PK.1.comp.oral.sd.KE-1.png and b/docs/reference/ff.PK.1.comp.oral.sd.KE-1.png differ diff --git a/docs/reference/ff.PK.1.comp.oral.sd.KE.html b/docs/reference/ff.PK.1.comp.oral.sd.KE.html index 3b5c6ae..10fd312 100644 --- a/docs/reference/ff.PK.1.comp.oral.sd.KE.html +++ b/docs/reference/ff.PK.1.comp.oral.sd.KE.html @@ -1,78 +1,15 @@ - - - - - - - -Structural model: one-compartment, oral absorption, single bolus dose, parameterized using KE. — ff.PK.1.comp.oral.sd.KE • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Structural model: one-compartment, oral absorption, single bolus dose, parameterized using KE. — ff.PK.1.comp.oral.sd.KE • PopED - - - - - - - - - - - - + + - - -
    -
    - -
    - -
    +

    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 +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)
    +
    +
    ff.PK.1.comp.oral.sd.KE(model_switch, xt, parameters, poped.db)
    +
    -

    Arguments

    - - - - - - - - - - - - - - - - - - -
    model_switch

    a vector of values, the same size as xt, identifying which model +

    +

    Arguments

    +
    model_switch
    +

    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.

    xt

    a vector of independent variable values (often time).

    parameters

    A named list of parameter values.

    poped.db

    a poped database. This can be used to extract information that may be needed in the model file.

    +corresponding xt value. Used for multiple response models.

    -

    Value

    -

    A list consisting of:

      -
    1. y the values of the model at the specified points.

    2. -
    3. poped.db A (potentially modified) poped database.

    4. -
    +
    xt
    +

    a vector of independent variable values (often time).

    -

    See also

    - +
    parameters
    +

    A named list of parameter values.

    -

    Examples

    -
    -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: 0x7fe24aba5148> -#> <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) -} +
    poped.db
    +

    a poped database. This can be used to extract information that may be needed in the model file.

    -## -- 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) +
    +
    +

    Value

    + -## 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.2206816 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
    -
    +

    A list consisting of:

    1. y the values of the model at the specified points.

    2. +
    3. poped.db A (potentially modified) poped database.

    4. +
    + + +
    +

    Examples

    +
    
    +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 
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/ff.PKPD.1.comp.oral.md.CL.imax-1.png b/docs/reference/ff.PKPD.1.comp.oral.md.CL.imax-1.png index 24cc7a3..6e06daa 100644 Binary files a/docs/reference/ff.PKPD.1.comp.oral.md.CL.imax-1.png and b/docs/reference/ff.PKPD.1.comp.oral.md.CL.imax-1.png differ diff --git a/docs/reference/ff.PKPD.1.comp.oral.md.CL.imax.html b/docs/reference/ff.PKPD.1.comp.oral.md.CL.imax.html index 9e70b80..04cb6a5 100644 --- a/docs/reference/ff.PKPD.1.comp.oral.md.CL.imax.html +++ b/docs/reference/ff.PKPD.1.comp.oral.md.CL.imax.html @@ -1,79 +1,16 @@ - - - - - - - -Structural model: one-compartment, oral absorption, multiple bolus dose, -parameterized using CL driving an inhibitory IMAX model with a direct effect. — ff.PKPD.1.comp.oral.md.CL.imax • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Structural model: one-compartment, oral absorption, multiple bolus dose, +parameterized using CL driving an inhibitory IMAX model with a direct effect. — ff.PKPD.1.comp.oral.md.CL.imax • PopED - - - - - - - - - - - - - - + + -
    -
    - -
    - -
    +

    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 +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)
    +
    +
    ff.PKPD.1.comp.oral.md.CL.imax(model_switch, xt, parameters, poped.db)
    +
    -

    Arguments

    - - - - - - - - - - - - - - - - - - -
    model_switch

    a vector of values, the same size as xt, identifying which model +

    +

    Arguments

    +
    model_switch
    +

    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.

    xt

    a vector of independent variable values (often time).

    parameters

    A named list of parameter values.

    poped.db

    a poped database. This can be used to extract information that may be needed in the model file.

    +corresponding xt value. Used for multiple response models.

    -

    Value

    -

    A list consisting of:

      -
    1. y the values of the model at the specified points.

    2. -
    3. poped.db A (potentially modified) poped database.

    4. -
    +
    xt
    +

    a vector of independent variable values (often time).

    -

    See also

    - - -

    Examples

    -
    -library(PopED) +
    parameters
    +

    A named list of parameter values.

    -## 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: 0x7fe1fae1c9e0> -#> <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: 0x7fe25cadfcb0> -#> <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 ) -} +
    poped.db
    +

    a poped database. This can be used to extract information that may be needed in the model file.

    +
    +
    +

    Value

    + -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)) - +

    A list consisting of:

    1. y the values of the model at the specified points.

    2. +
    3. poped.db A (potentially modified) poped database.

    4. +
    + -## 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
    -
    +
    +

    Examples

    +
    
    +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 
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/ff.PKPD.1.comp.sd.CL.emax-1.png b/docs/reference/ff.PKPD.1.comp.sd.CL.emax-1.png index e6d25ca..9a9bed2 100644 Binary files a/docs/reference/ff.PKPD.1.comp.sd.CL.emax-1.png and b/docs/reference/ff.PKPD.1.comp.sd.CL.emax-1.png differ diff --git a/docs/reference/ff.PKPD.1.comp.sd.CL.emax.html b/docs/reference/ff.PKPD.1.comp.sd.CL.emax.html index b656fa3..5af0537 100644 --- a/docs/reference/ff.PKPD.1.comp.sd.CL.emax.html +++ b/docs/reference/ff.PKPD.1.comp.sd.CL.emax.html @@ -1,77 +1,14 @@ - - - - - - - -Structural model: one-compartment, single bolus IV dose, parameterized using CL driving an EMAX model with a direct effect. — ff.PKPD.1.comp.sd.CL.emax • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Structural model: one-compartment, single bolus IV dose, parameterized using CL driving an EMAX model with a direct effect. — ff.PKPD.1.comp.sd.CL.emax • PopED - - - - - - - - - - - + + - - - -
    -
    - -
    - -
    +

    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 +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)
    +
    +
    ff.PKPD.1.comp.sd.CL.emax(model_switch, xt, parameters, poped.db)
    +
    -

    Arguments

    - - - - - - - - - - - - - - - - - - -
    model_switch

    a vector of values, the same size as xt, identifying which model +

    +

    Arguments

    +
    model_switch
    +

    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.

    xt

    a vector of independent variable values (often time).

    parameters

    A named list of parameter values.

    poped.db

    a poped database. This can be used to extract information that may be needed in the model file.

    +corresponding xt value. Used for multiple response models.

    -

    Value

    -

    A list consisting of:

      -
    1. y the values of the model at the specified points.

    2. -
    3. poped.db A (potentially modified) poped database.

    4. -
    +
    xt
    +

    a vector of independent variable values (often time).

    -

    See also

    - - -

    Examples

    -
    -library(PopED) +
    parameters
    +

    A named list of parameter values.

    -## 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: 0x7fe1fd8e6ea8> -#> <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 )) -} +
    poped.db
    +

    a poped database. This can be used to extract information that may be needed in the model file.

    -## -- 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) +
    +
    +

    Value

    + +

    A list consisting of:

    1. y the values of the model at the specified points.

    2. +
    3. poped.db A (potentially modified) poped database.

    4. +
    + -## 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
    -
    +
    +

    Examples

    +
    
    +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 
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/fileparts.html b/docs/reference/fileparts.html index 2b98dae..086c0bd 100644 --- a/docs/reference/fileparts.html +++ b/docs/reference/fileparts.html @@ -1,75 +1,12 @@ - - - - - - - -MATLAB fileparts function — fileparts • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -MATLAB fileparts function — fileparts • PopED - - - - + + -
    -
    - -
    - -
    +
    @@ -150,80 +78,88 @@

    MATLAB fileparts function

    Get the various parts of a file with path string.

    -
    fileparts(filename.with.path)
    +
    +
    fileparts(filename.with.path)
    +
    + +
    +

    Arguments

    +
    filename.with.path
    +

    A string of a filename with a path

    -

    Arguments

    - - - - - - -
    filename.with.path

    A string of a filename with a path

    +
    +
    +

    Value

    + -

    Value

    +

    A list with the following components:

    +
    pathname
    +

    The path name

    -

    A list with the following components:

    -
    pathname

    The path name

    -
    filename

    The file name

    -
    fileext

    The file extension

    +
    filename
    +

    The file name

    -

    Note

    +
    fileext
    +

    The file extension

    +
    +
    +

    Note

    This is a modified version of the same function in the matlab R-package.

    -

    See also

    - -

    Other MATLAB: -cell(), -diag_matlab(), -feval(), -isempty(), -ones(), -randn(), -rand(), -size(), -tic(), -toc(), -zeros()

    - -

    Examples

    -
    -fileparts("ggg/ttt/lll.R") -
    #> $pathname -#> [1] "ggg/ttt" -#> -#> $filename -#> [1] "lll" -#> -#> $fileext -#> [1] ".R" -#>
    -
    +
    +
    +

    See also

    +

    Other MATLAB: +cell(), +diag_matlab(), +feval(), +isempty(), +ones(), +randn(), +rand(), +size(), +tic(), +toc(), +zeros()

    +
    + +
    +

    Examples

    +
    
    +fileparts("ggg/ttt/lll.R")
    +#> $pathname
    +#> [1] "ggg/ttt"
    +#> 
    +#> $filename
    +#> [1] "lll"
    +#> 
    +#> $fileext
    +#> [1] ".R"
    +#> 
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/getTruncatedNormal.html b/docs/reference/getTruncatedNormal.html index 1ad6ad7..5a1064a 100644 --- a/docs/reference/getTruncatedNormal.html +++ b/docs/reference/getTruncatedNormal.html @@ -1,75 +1,12 @@ - - - - - - - -Generate a random sample from a truncated normal distribution. — getTruncatedNormal • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Generate a random sample from a truncated normal distribution. — getTruncatedNormal • PopED - + + - - - -
    -
    - -
    - -
    +
    @@ -150,57 +78,58 @@

    Generate a random sample from a truncated normal distribution.

    Generate a random sample from a truncated normal distribution.

    -
    getTruncatedNormal(mean, variance)
    +
    +
    getTruncatedNormal(mean, variance)
    +
    + +
    +

    Arguments

    +
    mean
    +

    the mean of the normal distribution

    -

    Arguments

    - - - - - - - - - - -
    mean

    the mean of the normal distribution

    variance

    The variance of the normal distribution

    -

    Value

    +
    variance
    +

    The variance of the normal distribution

    -

    A random sample from the specified truncated normal distribution

    +
    +
    +

    Value

    + -

    Examples

    -
    -getTruncatedNormal(mean=3,variance=100) -
    #> [,1] -#> [1,] 7.909153
    +

    A random sample from the specified truncated normal distribution

    +
    -
    +
    +

    Examples

    +
    
    +getTruncatedNormal(mean=3,variance=100)
    +#>          [,1]
    +#> [1,] 5.223929
    +
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/get_all_params.html b/docs/reference/get_all_params.html index 5c2464c..1b1335c 100644 --- a/docs/reference/get_all_params.html +++ b/docs/reference/get_all_params.html @@ -1,75 +1,12 @@ - - - - - - - -Extract all model parameters from the PopED database. — get_all_params • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Extract all model parameters from the PopED database. — get_all_params • PopED - - + + - - -
    -
    - -
    - -
    +
    @@ -150,158 +78,175 @@

    Extract all model parameters from the PopED database.

    Extract all model parameters from the PopED database.

    -
    get_all_params(poped.db)
    - -

    Arguments

    - - - - - - -
    poped.db

    A PopED database.

    - -

    Value

    - -

    A list containing:

    -
    bpop

    A vector of fixed effect parameter values.

    -
    d

    A vector of between subject variability parameters

    -
    covd

    A vector of the covariances of the between subject variability parameters. Row major format of the lower triangular portion of the D (OMEGA) matrix

    -
    docc

    A vector of the between occasion variability (BOV) terms in the model

    -
    covdocc

    A vector of the covariances between the BOV terms. Row major of the lower triangular portion of the BOV matrix.

    -
    sigma

    A vector of the residual unexplained variances (RUV)

    -
    covsigma

    A vector of the covariances between the RUV terms

    -
    all

    A vector with all of the above, in the order of this list.

    - - -

    Examples

    -
    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: 0x7fe20a979808> -#> <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 -#>
    +
    +
    get_all_params(poped.db)
    +
    -
    +
    +

    Arguments

    +
    poped.db
    +

    A PopED database.

    + +
    +
    +

    Value

    + + +

    A list containing:

    +
    bpop
    +

    A vector of fixed effect parameter values.

    + +
    d
    +

    A vector of between subject variability parameters

    + +
    covd
    +

    A vector of the covariances of the between subject variability parameters. Row major format of the lower triangular portion of the D (OMEGA) matrix

    + +
    docc
    +

    A vector of the between occasion variability (BOV) terms in the model

    + +
    covdocc
    +

    A vector of the covariances between the BOV terms. Row major of the lower triangular portion of the BOV matrix.

    + +
    sigma
    +

    A vector of the residual unexplained variances (RUV)

    + +
    covsigma
    +

    A vector of the covariances between the RUV terms

    + +
    all
    +

    A vector with all of the above, in the order of this list.

    + +
    + +
    +

    Examples

    +
    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
    +#> 
    +
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/get_rse.html b/docs/reference/get_rse.html index b0eb765..629b963 100644 --- a/docs/reference/get_rse.html +++ b/docs/reference/get_rse.html @@ -1,76 +1,13 @@ - - - - - - - -Compute the expected parameter relative standard errors — get_rse • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Compute the expected parameter relative standard errors — get_rse • PopED - - + + - - -
    -
    - -
    - -
    +
    @@ -152,55 +80,54 @@

    Compute the expected parameter relative standard errors

    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,
    -  ...
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    fim

    A Fisher Information Matrix (FIM).

    poped.db

    A PopED database.

    bpop

    A vector containing the values of the fixed effects used to compute the fim.

    d

    A vector containing the values of the diagonals of the between subject variability matrix.

    docc

    Matrix defining the IOV, the IOV variances and the IOV distribution as for d and bpop.

    sigma

    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().

    use_percent

    Should RSE be reported as percent?

    fim.calc.type

    The method used for calculating the FIM. Potential values:

      -
    • 0 = Full FIM. No assumption that fixed and random effects are uncorrelated.

    • +
      +
      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,
      +  ...
      +)
      +
      + +
      +

      Arguments

      +
      fim
      +

      A Fisher Information Matrix (FIM).

      + + +
      poped.db
      +

      A PopED database.

      + + +
      bpop
      +

      A vector containing the values of the fixed effects used to compute the fim.

      + + +
      d
      +

      A vector containing the values of the diagonals of the between subject variability matrix.

      + + +
      docc
      +

      Matrix defining the IOV, the IOV variances and the IOV distribution as for d and bpop.

      + + +
      sigma
      +

      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().

      + + +
      use_percent
      +

      Should RSE be reported as percent?

      + + +
      fim.calc.type
      +

      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).

      • @@ -211,232 +138,253 @@

        Arg
      • 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.

      • -

    prior_fim

    A prior FIM to be added to the fim. Should be the same size as the fim.

    ...

    Additional arguments passed to inv.

    - -

    Value

    - -

    A named list of RSE values. If the estimated parameter is assumed to be zero then for that + + + +

    prior_fim
    +

    A prior FIM to be added to the fim. Should be the same size as the fim.

    + + +
    ...
    +

    Additional arguments passed to inv.

    + +
    +
    +

    Value

    + + +

    A named list of RSE values. If the estimated parameter is assumed to be zero then for that parameter the standard error is returned.

    -

    See also

    - - - -

    Examples

    -
    ## 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: 0x7fe25cadfcb0> -#> <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.08763896 -#> [,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.92423 -#> [4,] 0.02613561 521.54030 -#> [5,] 3.26560786 11214.21071 -#> [6,] 41.81083599 71.08764 -#> [7,] 71.08763896 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.21752779 -#> [,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.92423 -#> [4,] 0.02613561 521.54030 -#> [5,] 3.26560786 11214.21071 -#> [6,] 41.81083599 71.08764 -#> [7,] 71.08763896 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.08763896 -#> [,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
    +
    + + +
    +

    Examples

    +
    ## 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 
    +
    +
    +
    - - - + + diff --git a/docs/reference/get_unfixed_params.html b/docs/reference/get_unfixed_params.html index c5afa63..9001dbc 100644 --- a/docs/reference/get_unfixed_params.html +++ b/docs/reference/get_unfixed_params.html @@ -1,78 +1,15 @@ - - - - - - - -Return all the unfixed parameters — get_unfixed_params • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Return all the unfixed parameters — get_unfixed_params • PopED - - - - - - - - - - - + + - - - -
    -
    - -
    - -
    +

    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 +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)
    +
    +
    get_unfixed_params(poped.db, params = NULL)
    +
    + +
    +

    Arguments

    +
    poped.db
    +

    a PopED database.

    -

    Arguments

    - - - - - - - - - - -
    poped.db

    a PopED database.

    params

    If params is supplied then the parameters are taken from this vector.

    -

    Value

    +
    params
    +

    If params is supplied then the parameters are taken from this vector.

    -

    A list with the parameters. All unfixed parameters are also +

    +
    +

    Value

    + + +

    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.

    +
    +
    -
    - - + + diff --git a/docs/reference/getfulld.html b/docs/reference/getfulld.html index 2b1088d..9a39fbe 100644 --- a/docs/reference/getfulld.html +++ b/docs/reference/getfulld.html @@ -1,78 +1,15 @@ - - - - - - - -Create a full D (between subject variability) matrix given a vector of variances and covariances. -Note, this does not test matching vector lengths. — getfulld • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Create a full D (between subject variability) matrix given a vector of variances and covariances. +Note, this does not test matching vector lengths. — getfulld • PopED + + - - - - -
    -
    - -
    - -
    +
    @@ -155,64 +83,66 @@

    Create a full D (between subject variability) matrix given a vector of varia Note, this does not test matching vector lengths.

    -
    getfulld(variance_vector, covariance_vector = NULL)
    - -

    Arguments

    - - - - - - - - - - -
    variance_vector

    The vector of the variances.

    covariance_vector

    A vector of the covariances. Written in column major -order for the lower triangular matrix.

    - -

    Value

    - -

    The full matrix of variances for the between subject variances

    - -

    Examples

    -
    -getfulld(c(1,2,3)) -
    #> [,1] [,2] [,3] -#> [1,] 1 0 0 -#> [2,] 0 2 0 -#> [3,] 0 0 3
    -getfulld(c(1,2,3),c(7,6,5)) -
    #> [,1] [,2] [,3] -#> [1,] 1 7 6 -#> [2,] 7 2 5 -#> [3,] 6 5 3
    -
    +
    +
    getfulld(variance_vector, covariance_vector = NULL)
    +
    + +
    +

    Arguments

    +
    variance_vector
    +

    The vector of the variances.

    + + +
    covariance_vector
    +

    A vector of the covariances. Written in column major +order for the lower triangular matrix.

    + +
    +
    +

    Value

    + + +

    The full matrix of variances for the between subject variances

    +
    + +
    +

    Examples

    +
    
    +getfulld(c(1,2,3))
    +#>      [,1] [,2] [,3]
    +#> [1,]    1    0    0
    +#> [2,]    0    2    0
    +#> [3,]    0    0    3
    +
    +getfulld(c(1,2,3),c(7,6,5))
    +#>      [,1] [,2] [,3]
    +#> [1,]    1    7    6
    +#> [2,]    7    2    5
    +#> [3,]    6    5    3
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/gradf_eps.html b/docs/reference/gradf_eps.html index 15bdf73..23c9633 100644 --- a/docs/reference/gradf_eps.html +++ b/docs/reference/gradf_eps.html @@ -1,76 +1,13 @@ - - - - - - - -Model linearization with respect to epsilon. — gradf_eps • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Model linearization with respect to epsilon. — gradf_eps • PopED - + + - - - -
    -
    - -
    - -
    +
    @@ -152,179 +80,182 @@

    Model linearization with respect to epsilon.

    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)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    model_switch

    A matrix that is the same size as xt, specifying which model each sample belongs to.

    xt_ind

    A vector of the individual/group sample times

    x

    A matrix for the discrete design variables. Each row is a group.

    a

    A matrix of covariates. Each row is a group.

    bpop

    The fixed effects parameter values. Supplied as a vector.

    b_ind

    vector of individual realization of the BSV terms b

    bocc_ind

    Vector of individual realizations of the BOV terms bocc

    num_eps

    The number of eps() in the model.

    poped.db

    A PopED database.

    - -

    Value

    - -

    A matrix of size (samples per individual x number of epsilons)

    -

    See also

    - - - -

    Examples

    -
    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: 0x7fe20a979808> -#> <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 -#>
    +
    +
    gradf_eps(model_switch, xt_ind, x, a, bpop, b_ind, bocc_ind, num_eps, poped.db)
    +
    + +
    +

    Arguments

    +
    model_switch
    +

    A matrix that is the same size as xt, specifying which model each sample belongs to.

    + + +
    xt_ind
    +

    A vector of the individual/group sample times

    + + +
    x
    +

    A matrix for the discrete design variables. Each row is a group.

    + + +
    a
    +

    A matrix of covariates. Each row is a group.

    + + +
    bpop
    +

    The fixed effects parameter values. Supplied as a vector.

    + + +
    b_ind
    +

    vector of individual realization of the BSV terms b

    + + +
    bocc_ind
    +

    Vector of individual realizations of the BOV terms bocc

    + + +
    num_eps
    +

    The number of eps() in the model.

    + + +
    poped.db
    +

    A PopED database.

    + +
    +
    +

    Value

    + + +

    A matrix of size (samples per individual x number of epsilons)

    +
    +
    +

    See also

    + +
    + +
    +

    Examples

    +
    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
    +#> 
    +
    +
    +
    - - - + + diff --git a/docs/reference/index.html b/docs/reference/index.html index 8adb6aa..0ed95dd 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -1,74 +1,12 @@ - - - - - - - -Function reference • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Function reference • PopED - - + + - - -
    -
    - -
    - -
    +
    - - - - - - - - - - -
    -

    General information

    + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    +

    General information

    -

    PopED

    +
    +

    PopED poped PopED-package

    PopED - Population (and individual) optimal Experimental Design.

    -

    Predefined structural models

    +
    +

    Predefined structural models

    +

    ff.PK.1.comp.oral.md.CL()

    Structural model: one-compartment, oral absorption, multiple bolus dose, parameterized using CL.

    +

    ff.PK.1.comp.oral.md.KE()

    Structural model: one-compartment, oral absorption, multiple bolus dose, parameterized using KE.

    +

    ff.PK.1.comp.oral.sd.CL()

    Structural model: one-compartment, oral absorption, single bolus dose, parameterized using CL.

    +

    ff.PK.1.comp.oral.sd.KE()

    Structural model: one-compartment, oral absorption, single bolus dose, parameterized using KE.

    +

    ff.PKPD.1.comp.oral.md.CL.imax()

    Structural model: one-compartment, oral absorption, multiple bolus dose, parameterized using CL driving an inhibitory IMAX model with a direct effect.

    +

    ff.PKPD.1.comp.sd.CL.emax()

    Structural model: one-compartment, single bolus IV dose, parameterized using CL driving an EMAX model with a direct effect.

    -

    Between subject variability models

    +
    +

    Between subject variability models

    +

    build_sfg()

    Build PopED parameter function from a model function

    -

    Predefined residual error models

    -

    Define a residual unexplained variability (RUV) model.

    +
    +

    Predefined residual error models

    +

    Define a residual unexplained variability (RUV) model.

    +

    feps.add()

    RUV model: Additive .

    +

    feps.add.prop()

    RUV model: Additive and Proportional.

    +

    feps.prop()

    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 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.poped.database()

    Create a PopED database

    +

    create_design()

    Create design variables for a full description of a design.

    +

    create_design_space()

    Create design variables and a design space for a full description of an optimization problem.

    -

    Simulate from the model and design

    +
    +

    Simulate from the model and design

    +

    plot_model_prediction()

    Plot model predictions

    +

    model_prediction()

    Model predictions

    -

    Evaluate or summarize the design(s)

    +
    +

    Evaluate or summarize the design(s)

    +

    evaluate.e.ofv.fim()

    Evaluate the expectation of the Fisher Information Matrix (FIM) and the expectation of the OFV(FIM).

    +

    evaluate.fim()

    Evaluate the Fisher Information Matrix (FIM)

    +

    evaluate_design()

    Evaluate a design

    +

    evaluate_fim_map()

    Compute the Bayesian Fisher information matrix

    +

    evaluate_power()

    Power of a design to estimate a parameter.

    +

    shrinkage()

    Predict shrinkage of empirical Bayes estimates (EBEs) in a population model

    +

    calc_ofv_and_fim()

    Calculate the Fisher Information Matrix (FIM) and the OFV(FIM) for either point values or parameters or distributions.

    +

    ofv_fim()

    Evaluate a criterion of the Fisher Information Matrix (FIM)

    +

    ofv_criterion()

    Normalize an objective function by the size of the FIM matrix

    +

    get_rse()

    Compute the expected parameter relative standard errors

    +

    plot_efficiency_of_windows()

    Plot the efficiency of windows

    +

    efficiency()

    Compute efficiency.

    +

    design_summary()

    Display a summary of output from poped_db

    -

    Optimize a design

    -

    Optimize a design given a model, design and design space.

    +
    +

    Optimize a design

    +

    Optimize a design given a model, design and design space.

    +

    poped_optim()

    Optimize a design defined in a PopED database

    +

    summary(<poped_optim>)

    Display a summary of output from poped_optim

    +

    optim_ARS()

    Optimize a function using adaptive random search.

    +

    optim_LS()

    Optimize a function using a line search algorithm.

    +

    optimize_groupsize()

    Title Optimize the proportion of individuals in the design groups

    +

    optimize_n_eff()

    Translate efficiency to number of subjects

    +

    optimize_n_rse()

    Optimize the number of subjects based on desired uncertainty of a parameter.

    +

    LEDoptim()

    Optimization function for D-family, E-family and Laplace approximated ED designs

    +

    RS_opt()

    Optimize the objective function using an adaptive random search algorithm for D-family and E-family designs.

    +

    a_line_search()

    Optimize using line search

    +

    poped_optimize()

    Retired optimization module for PopED

    -

    Miscellaneous

    +
    +

    Miscellaneous

    +

    cell()

    Create a cell array (a matrix of lists)

    +

    mc_mean()

    Compute the monte-carlo mean of a function

    +

    median_hilow_poped()

    Wrap summary functions from Hmisc and ggplot to work with stat_summary in ggplot

    +

    ones()

    Create a matrix of ones

    +

    pargen()

    Parameter simulation

    +

    poped_gui()

    Run the graphical interface for PopED

    +

    size()

    Function written to match MATLAB's size function

    +

    start_parallel()

    Start parallel computational processes

    +

    tic()

    Timer function (as in MATLAB)

    +

    toc()

    Timer function (as in MATLAB)

    +

    zeros()

    Create a matrix of zeros.

    - +
    +
    -
    - - + + diff --git a/docs/reference/inv.html b/docs/reference/inv.html index 22c35ae..6cf01a3 100644 --- a/docs/reference/inv.html +++ b/docs/reference/inv.html @@ -1,75 +1,12 @@ - - - - - - - -Compute the inverse of a matrix — inv • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Compute the inverse of a matrix — inv • PopED - - + + - - -
    -
    - -
    - -
    +
    @@ -150,63 +78,61 @@

    Compute the inverse of a matrix

    Function computes the inverse of a matrix.

    -
    inv(mat, method = 1, tol = .Machine$double.eps, pseudo_on_fail = TRUE, ...)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - -
    mat

    A matrix

    method

    Which method to use. 1 is Cholesky chol2inv(chol(mat), -2 is using solve(mat) and 3 is the Moore-Penrose generalized inverse (pseudoinverse).

    tol

    The tolerance at which we should identify a singular value as zero (used in pseudoinverse calculation).

    pseudo_on_fail

    If another method fails should the Moore-Penrose generalized inverse (pseudoinverse) be used?

    ...

    Not used.

    - -

    Value

    - -

    The inverse matrix

    +
    +
    inv(mat, method = 1, tol = .Machine$double.eps, pseudo_on_fail = TRUE, ...)
    +
    + +
    +

    Arguments

    +
    mat
    +

    A matrix

    + + +
    method
    +

    Which method to use. 1 is Cholesky chol2inv(chol(mat), +2 is using solve(mat) and 3 is the Moore-Penrose generalized inverse (pseudoinverse).

    + + +
    tol
    +

    The tolerance at which we should identify a singular value as zero (used in pseudoinverse calculation).

    + + +
    pseudo_on_fail
    +

    If another method fails should the Moore-Penrose generalized inverse (pseudoinverse) be used?

    + + +
    ...
    +

    Not used.

    + +
    +
    +

    Value

    + + +

    The inverse matrix

    +
    +
    - - - + + diff --git a/docs/reference/isempty.html b/docs/reference/isempty.html index bf801d2..d533c0c 100644 --- a/docs/reference/isempty.html +++ b/docs/reference/isempty.html @@ -1,75 +1,12 @@ - - - - - - - -Function written to match MATLAB's isempty function — isempty • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Function written to match MATLAB's isempty function — isempty • PopED - - + + - - -
    -
    - -
    - -
    +
    @@ -150,69 +78,73 @@

    Function written to match MATLAB's isempty function

    Function written to match MATLAB's isempty function

    -
    isempty(...)
    - -

    Arguments

    - - - - - - -
    ...

    arguments to pass to the function. Typically a matrix.

    - -

    Value

    - -

    Logical. True if the passed object has any dimension that is zero.

    -

    See also

    - -

    Other MATLAB: -cell(), -diag_matlab(), -feval(), -fileparts(), -ones(), -randn(), -rand(), -size(), -tic(), -toc(), -zeros()

    - -

    Examples

    -
    -isempty(zeros(2,3)) -
    #> [1] FALSE
    -isempty(zeros(2,0)) -
    #> [1] TRUE
    -isempty(c(1,2,3)) -
    #> [1] FALSE
    -
    +
    +
    isempty(...)
    +
    + +
    +

    Arguments

    +
    ...
    +

    arguments to pass to the function. Typically a matrix.

    + +
    +
    +

    Value

    + + +

    Logical. True if the passed object has any dimension that is zero.

    +
    +
    +

    See also

    +

    Other MATLAB: +cell(), +diag_matlab(), +feval(), +fileparts(), +ones(), +randn(), +rand(), +size(), +tic(), +toc(), +zeros()

    +
    + +
    +

    Examples

    +
    
    +isempty(zeros(2,3))
    +#> [1] FALSE
    +
    +isempty(zeros(2,0))
    +#> [1] TRUE
    +
    +isempty(c(1,2,3))
    +#> [1] FALSE
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/log_prior_pdf.html b/docs/reference/log_prior_pdf.html index de07b96..0101cb5 100644 --- a/docs/reference/log_prior_pdf.html +++ b/docs/reference/log_prior_pdf.html @@ -1,75 +1,12 @@ - - - - - - - -Compute the natural log of the PDF for the parameters in an E-family design — log_prior_pdf • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Compute the natural log of the PDF for the parameters in an E-family design — log_prior_pdf • PopED + + - - - - -
    -
    - -
    - -
    +
    @@ -150,74 +78,68 @@

    Compute the natural log of the PDF for the parameters in an E-family design<

    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
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - -
    alpha

    A parameter vector.

    bpopdescr

    Matrix defining the fixed effects, per row (row number = -parameter_number) we should have:

      -
    • column 1 the type of the +

      +
      log_prior_pdf(
      +  alpha,
      +  bpopdescr,
      +  ddescr,
      +  return_gradient = F,
      +  return_hessian = F
      +)
      +
      + +
      +

      Arguments

      +
      alpha
      +

      A parameter vector.

      + + +
      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).

      • -
    ddescr

    Matrix defining the diagonals of the IIV (same logic as for -the bpopdescr).

    return_gradient

    Should the gradient be returned.

    return_hessian

    Should the hessian be returned?

    + + + +
    ddescr
    +

    Matrix defining the diagonals of the IIV (same logic as for +the bpopdescr).

    + + +
    return_gradient
    +

    Should the gradient be returned.

    +
    return_hessian
    +

    Should the hessian be returned?

    + +
    +
    +
    - - - + + diff --git a/docs/reference/mc_mean.html b/docs/reference/mc_mean.html index ff6ddb4..fbdb2aa 100644 --- a/docs/reference/mc_mean.html +++ b/docs/reference/mc_mean.html @@ -1,75 +1,12 @@ - - - - - - - -Compute the monte-carlo mean of a function — mc_mean • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Compute the monte-carlo mean of a function — mc_mean • PopED + + - - - - -
    -
    - -
    - -
    +
    @@ -150,103 +78,99 @@

    Compute the monte-carlo mean of a function

    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,
    -  ...
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ofv_fcn

    A function with poped.db as the first input

    poped.db

    A PopED database.

    bpopdescr

    Matrix defining the fixed effects, per row (row number = -parameter_number) we should have:

      -
    • column 1 the type of the +

      +
      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,
      +  ...
      +)
      +
      + +
      +

      Arguments

      +
      ofv_fcn
      +

      A function with poped.db as the first input

      + + +
      poped.db
      +

      A PopED database.

      + + +
      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).

      • -
    ddescr

    Matrix defining the diagonals of the IIV (same logic as for -the bpopdescr).

    doccdescr

    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, +

    + + +
    ddescr
    +

    Matrix defining the diagonals of the IIV (same logic as for +the bpopdescr).

    + + +
    doccdescr
    +

    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).

    • -
    user_distribution_pointer

    Function name for user defined distributions for E-family designs

    ED_samp_size

    Sample size for E-family sampling

    bLHS

    How to sample from distributions in E-family calculations. 0=Random Sampling, 1=LatinHyperCube --

    ...

    Other arguments passed to the function.

    - -

    Value

    - -

    The mean of the function evaluated at different parameter values.

    + + + +
    user_distribution_pointer
    +

    Function name for user defined distributions for E-family designs

    + + +
    ED_samp_size
    +

    Sample size for E-family sampling

    + + +
    bLHS
    +

    How to sample from distributions in E-family calculations. 0=Random Sampling, 1=LatinHyperCube --

    + + +
    ...
    +

    Other arguments passed to the function.

    + +
    +
    +

    Value

    + + +

    The mean of the function evaluated at different parameter values.

    +
    +
    - - - + + diff --git a/docs/reference/median_hilow_poped.html b/docs/reference/median_hilow_poped.html index bab40a4..8db016e 100644 --- a/docs/reference/median_hilow_poped.html +++ b/docs/reference/median_hilow_poped.html @@ -1,76 +1,13 @@ - - - - - - - -Wrap summary functions from Hmisc and ggplot to work with stat_summary in ggplot — median_hilow_poped • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Wrap summary functions from Hmisc and ggplot to work with stat_summary in ggplot — median_hilow_poped • PopED - + + - - - -
    -
    - -
    - -
    +
    @@ -152,48 +80,43 @@

    Wrap summary functions from Hmisc and ggplot to work with stat_summary in gg PopED does not have to load ggplot when started.

    -
    median_hilow_poped(x, ...)
    +
    +
    median_hilow_poped(x, ...)
    +
    + +
    +

    Arguments

    +
    x
    +

    A numeric vector

    -

    Arguments

    - - - - - - - - - - -
    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.

    +
    ...
    +

    Additional arguments passed to Hmisc's smedian.hilow function or +ggplot2's median_hilow function, depending on your version of ggplot.

    + +
    +
    - - - + + diff --git a/docs/reference/mf3.html b/docs/reference/mf3.html index ed3d21e..6c9afb3 100644 --- a/docs/reference/mf3.html +++ b/docs/reference/mf3.html @@ -1,75 +1,12 @@ - - - - - - - -The Fisher Information Matrix (FIM) for one individual — mf3 • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -The Fisher Information Matrix (FIM) for one individual — mf3 • PopED - + + - - - -
    -
    - -
    - -
    +
    @@ -150,98 +78,100 @@

    The Fisher Information Matrix (FIM) for one individual

    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)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    model_switch

    A vector that is the same size as xt, specifying which model each sample belongs to.

    xt

    A vector of sample times.

    x

    A vector for the discrete design variables.

    a

    A vector of covariates.

    bpop

    The fixed effects parameter values. Supplied as a vector.

    d

    A between subject variability matrix (OMEGA in NONMEM).

    sigma

    A residual unexplained variability matrix (SIGMA in NONMEM).

    docc

    A between occasion variability matrix.

    poped.db

    A PopED database.

    - -

    Value

    - -

    As a list:

    -
    ret

    The FIM for one individual

    -
    poped.db

    A PopED database

    - -

    See also

    - - +
    +
    mf3(model_switch, xt, x, a, bpop, d, sigma, docc, poped.db)
    +
    + +
    +

    Arguments

    +
    model_switch
    +

    A vector that is the same size as xt, specifying which model each sample belongs to.

    + + +
    xt
    +

    A vector of sample times.

    + + +
    x
    +

    A vector for the discrete design variables.

    + + +
    a
    +

    A vector of covariates.

    + + +
    bpop
    +

    The fixed effects parameter values. Supplied as a vector.

    + + +
    d
    +

    A between subject variability matrix (OMEGA in NONMEM).

    + + +
    sigma
    +

    A residual unexplained variability matrix (SIGMA in NONMEM).

    + + +
    docc
    +

    A between occasion variability matrix.

    + + +
    poped.db
    +

    A PopED database.

    + +
    +
    +

    Value

    + + +

    As a list:

    +
    ret
    +

    The FIM for one individual

    + +
    poped.db
    +

    A PopED database

    + +
    +
    +
    - - - + + diff --git a/docs/reference/mf7.html b/docs/reference/mf7.html index f6bdc2e..5939a5d 100644 --- a/docs/reference/mf7.html +++ b/docs/reference/mf7.html @@ -1,76 +1,13 @@ - - - - - - - -The full Fisher Information Matrix (FIM) for one individual Calculating one model switch at a time, good for large matrices. — mf7 • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -The full Fisher Information Matrix (FIM) for one individual Calculating one model switch at a time, good for large matrices. — mf7 • PopED + + - - - - -
    -
    - -
    - -
    +
    @@ -152,94 +80,96 @@

    The full Fisher Information Matrix (FIM) for one individual Calculating one 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)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    model_switch

    A vector that is the same size as xt, specifying which model each sample belongs to.

    x

    A vector for the discrete design variables.

    a

    A vector of covariates.

    bpop

    The fixed effects parameter values. Supplied as a vector.

    d

    A between subject variability matrix (OMEGA in NONMEM).

    sigma

    A residual unexplained variability matrix (SIGMA in NONMEM).

    docc

    A between occasion variability matrix.

    poped.db

    A PopED database.

    - -

    Value

    - -

    As a list:

    -
    ret

    The FIM for one individual

    -
    poped.db

    A PopED database

    - -

    See also

    - - +
    +
    mf7(model_switch, xt_ind, x, a, bpop, d, sigma, docc, poped.db)
    +
    + +
    +

    Arguments

    +
    model_switch
    +

    A vector that is the same size as xt, specifying which model each sample belongs to.

    + + +
    x
    +

    A vector for the discrete design variables.

    + + +
    a
    +

    A vector of covariates.

    + + +
    bpop
    +

    The fixed effects parameter values. Supplied as a vector.

    + + +
    d
    +

    A between subject variability matrix (OMEGA in NONMEM).

    + + +
    sigma
    +

    A residual unexplained variability matrix (SIGMA in NONMEM).

    + + +
    docc
    +

    A between occasion variability matrix.

    + + +
    poped.db
    +

    A PopED database.

    + +
    +
    +

    Value

    + + +

    As a list:

    +
    ret
    +

    The FIM for one individual

    + +
    poped.db
    +

    A PopED database

    + +
    +
    +
    - - - + + diff --git a/docs/reference/mfea.html b/docs/reference/mfea.html index 9ddbe85..92ea7f9 100644 --- a/docs/reference/mfea.html +++ b/docs/reference/mfea.html @@ -1,80 +1,17 @@ - - - - - - - -Modified Fedorov Exchange Algorithm — mfea • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Modified Fedorov Exchange Algorithm — mfea • PopED - - - - - - - - - - - - - - + + -
    -
    - -
    - -
    +
    @@ -160,350 +88,347 @@

    Modified Fedorov Exchange Algorithm

    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,
    -  ...
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    poped.db

    A PopED database.

    model_switch

    A matrix that is the same size as xt, specifying which model each sample belongs to.

    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.

    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:

      -
    • column 1 the type of the +

      +
      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,
      +  ...
      +)
      +
      + +
      +

      Arguments

      +
      poped.db
      +

      A PopED database.

      + + +
      model_switch
      +

      A matrix that is the same size as xt, specifying which model each sample belongs to.

      + + +
      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.

      + + +
      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:

      • 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).

      • -
    ddescr

    Matrix defining the diagonals of the IIV (same logic as for -the bpopdescr).

    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 initial OFV. If set to zero then it is computed.

    EAStepSize

    Exchange Algorithm StepSize

    ourzero

    Value to interpret as zero in design

    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?

    trflag

    Should the optimization be output to the screen and to a file?

    ...

    arguments passed to evaluate.fim and ofv_fim.

    - -

    References

    + + +
    ddescr
    +

    Matrix defining the diagonals of the IIV (same logic as for +the bpopdescr).

    + + +
    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 initial OFV. If set to zero then it is computed.

    + + +
    EAStepSize
    +

    Exchange Algorithm StepSize

    + + +
    ourzero
    +

    Value to interpret as zero in design

    + + +
    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?

    + + +
    trflag
    +

    Should the optimization be output to the screen and to a file?

    + + +
    ...
    +

    arguments passed to evaluate.fim and ofv_fim.

    + +
    +
    +

    References

    -
      -
    1. J. Nyberg, S. Ueckert, E.A. Stroemberg, S. Hennig, M.O. Karlsson and A.C. Hooker, "PopED: An extended, +

      1. 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.

      2. -
      - -

      See also

      - - - -

      Examples

      -
      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: 0x7fe20a979808> -#> <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.046 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) - - -} - +
    + -
    +
    +

    Examples

    +
    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)
    +  
    +  
    +}
    +
    +
    +
    +
    + - - - + + diff --git a/docs/reference/mftot.html b/docs/reference/mftot.html index aa17844..b6aeaa8 100644 --- a/docs/reference/mftot.html +++ b/docs/reference/mftot.html @@ -1,75 +1,12 @@ - - - - - - - -Evaluate the Fisher Information Matrix (FIM) — mftot • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Evaluate the Fisher Information Matrix (FIM) — mftot • PopED - - - - + + -
    -
    - -
    - -
    +
    @@ -150,214 +78,220 @@

    Evaluate the Fisher Information Matrix (FIM)

    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,
    -  ...
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    model_switch

    A matrix that is the same size as xt, specifying which model each sample belongs to.

    groupsize

    A vector of the number of individuals in each group.

    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.

    x

    A matrix for the discrete design variables. Each row is a group.

    a

    A matrix of covariates. Each row is a group.

    bpop

    The fixed effects parameter values. Supplied as a vector.

    d

    A between subject variability matrix (OMEGA in NONMEM).

    sigma

    A residual unexplained variability matrix (SIGMA in NONMEM).

    docc

    A between occasion variability matrix.

    poped.db

    A PopED database.

    - -

    Value

    - -

    As a list:

    -
    ret

    The FIM

    -
    poped.db

    A PopED database

    - -

    See also

    - -

    For an easier function to use, please see evaluate.fim.

    +
    +
    mftot(
    +  model_switch,
    +  groupsize,
    +  ni,
    +  xt,
    +  x,
    +  a,
    +  bpop,
    +  d,
    +  sigma,
    +  docc,
    +  poped.db,
    +  ...
    +)
    +
    + +
    +

    Arguments

    +
    model_switch
    +

    A matrix that is the same size as xt, specifying which model each sample belongs to.

    + + +
    groupsize
    +

    A vector of the number of individuals in each group.

    + + +
    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.

    + + +
    x
    +

    A matrix for the discrete design variables. Each row is a group.

    + + +
    a
    +

    A matrix of covariates. Each row is a group.

    + + +
    bpop
    +

    The fixed effects parameter values. Supplied as a vector.

    + + +
    d
    +

    A between subject variability matrix (OMEGA in NONMEM).

    + + +
    sigma
    +

    A residual unexplained variability matrix (SIGMA in NONMEM).

    + + +
    docc
    +

    A between occasion variability matrix.

    + + +
    poped.db
    +

    A PopED database.

    + +
    +
    +

    Value

    + + +

    As a list:

    +
    ret
    +

    The FIM

    + +
    poped.db
    +

    A PopED database

    + +
    +
    +

    See also

    +

    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()

    - -

    Examples

    -
    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: 0x7fe20a979808> -#> <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 -#>
    -
    +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()

    +
    + +
    +

    Examples

    +
    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
    +#> 
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/model_prediction.html b/docs/reference/model_prediction.html index cc6a000..85e7c78 100644 --- a/docs/reference/model_prediction.html +++ b/docs/reference/model_prediction.html @@ -1,77 +1,14 @@ - - - - - - - -Model predictions — model_prediction • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Model predictions — model_prediction • PopED - - - - - - - - - - - - + + - - -
    -
    - -
    - -
    +
    @@ -154,1743 +82,1775 @@

    Model predictions

    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
    -)
    +
    +
    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
    +)
    +
    + +
    +

    Arguments

    +
    poped.db
    +

    A PopED database created by create.poped.database.

    + + +
    design
    +

    A list that is passed as arguments to the function create_design to create a design object.

    + + +
    model
    +

    A list containing the model elements to use for the predictions

    + + +
    parameters
    +

    A list of parameters to use in the model predictions.

    + -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    poped.db

    A PopED database created by create.poped.database.

    design

    A list that is passed as arguments to the function create_design to create a design object.

    model

    A list containing the model elements to use for the predictions

    parameters

    A list of parameters to use in the model predictions.

    IPRED

    Should we simulate individual predictions?

    DV

    should we simulate observations?

    dosing

    A list of lists that adds dosing records to the data frame (Each inner list corresponding to a group in the design).

    predictions

    Should the resulting data frame have predictions? Either TRUE or FALSE -or NULL in which case the function decides based on other arguments.

    filename

    A filename that the data frame should be written to in comma separate value (csv) format.

    models_to_use

    Which model numbers should we use? -Model numbers are defined in design below using model_switch. For an explanation see create_design.

    model_num_points

    How many extra observation rows should be created in the data frame for each group or individual +

    IPRED
    +

    Should we simulate individual predictions?

    + + +
    DV
    +

    should we simulate observations?

    + + +
    dosing
    +

    A list of lists that adds dosing records to the data frame (Each inner list corresponding to a group in the design).

    + + +
    predictions
    +

    Should the resulting data frame have predictions? Either TRUE or FALSE +or NULL in which case the function decides based on other arguments.

    + + +
    filename
    +

    A filename that the data frame should be written to in comma separate value (csv) format.

    + + +
    models_to_use
    +

    Which model numbers should we use? +Model numbers are defined in design below using model_switch. For an explanation see create_design.

    + + +
    model_num_points
    +

    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.

    model_minxt

    The minimum time value for extra observation rows indicated by model_num_points. -A vector the same length as the number of models

    model_maxxt

    The minimum time value for extra observation rows indicated by model_num_points. -A vector the same length as the number of models

    include_sample_times

    Should observations rows in the output data frame include the times indicated in the input design?

    groups_to_use

    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).

    include_a

    Should we include the continuous design variables in the output?

    include_x

    Should we include the discrete design variables in the output?

    manipulation

    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.

    PI

    Compute prediction intervals for the data given the model. Predictions are based on first-order approximations to -the model variance and a normality assumption of that variance.

    PI_conf_level

    The confidence level for the prediction interval computed.

    +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.

    -

    Value

    -

    A dataframe containing a design and (potentially) simulated data with some dense grid of samples and/or -based on the input design.

    -

    See also

    +
    model_minxt
    +

    The minimum time value for extra observation rows indicated by model_num_points. +A vector the same length as the number of models

    - -

    Examples

    -
    ## 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. +
    model_maxxt
    +

    The minimum time value for extra observation rows indicated by model_num_points. +A vector the same length as the number of models

    -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: 0x7fe25cadfcb0> -#> <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) -} +
    include_sample_times
    +

    Should observations rows in the output data frame include the times indicated in the input design?

    -## -- 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 2.3800236 2.352885 3.4254357 1 1 70 -#> 2 1 1.0 4.2029869 4.167358 5.4711041 1 1 70 -#> 3 1 2.0 6.0250484 6.628460 7.3821834 1 1 70 -#> 4 1 6.0 10.6003247 9.428073 7.9462805 1 1 70 -#> 5 1 24.0 7.3829039 7.111946 5.6858561 1 1 70 -#> 6 1 36.0 5.1180355 5.665993 4.5402483 1 1 70 -#> 7 1 72.0 2.6919875 2.865000 2.3116966 1 1 70 -#> 8 1 120.0 1.1947993 1.154134 0.9398657 1 1 70 -#> 9 2 0.5 2.5705709 2.416020 3.4254357 1 1 70 -#> 10 2 1.0 4.7509404 4.166896 5.4711041 1 1 70 -#> 11 2 2.0 5.7171194 6.334689 7.3821834 1 1 70 -#> 12 2 6.0 7.6625930 8.183819 7.9462805 1 1 70 -#> 13 2 24.0 6.5161958 6.013418 5.6858561 1 1 70 -#> 14 2 36.0 4.9060740 4.806975 4.5402483 1 1 70 -#> 15 2 72.0 2.4332146 2.455401 2.3116966 1 1 70 -#> 16 2 120.0 0.9933456 1.002590 0.9398657 1 1 70 -#> 17 3 0.5 5.4419156 5.831451 3.4254357 1 1 70 -#> 18 3 1.0 8.0770953 8.064518 5.4711041 1 1 70 -#> 19 3 2.0 10.1800510 9.125600 7.3821834 1 1 70 -#> 20 3 6.0 8.6966384 8.472325 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 1.331747 3.4254357 1 1 70 -#> 2 1 1.0 2.425106 5.4711041 1 1 70 -#> 3 1 2.0 4.053278 7.3821834 1 1 70 -#> 4 1 6.0 6.564106 7.9462805 1 1 70 -#> 5 1 24.0 5.606070 5.6858561 1 1 70 -#> 6 1 36.0 4.652204 4.5402483 1 1 70 -#> 7 1 72.0 2.657258 2.3116966 1 1 70 -#> 8 1 120.0 1.259309 0.9398657 1 1 70 -#> 9 2 0.5 5.041980 3.4254357 1 1 70 -#> 10 2 1.0 7.300742 5.4711041 1 1 70 -#> 11 2 2.0 8.723086 7.3821834 1 1 70 -#> 12 2 6.0 8.731333 7.9462805 1 1 70 -#> 13 2 24.0 7.192552 5.6858561 1 1 70 -#> 14 2 36.0 6.320159 4.5402483 1 1 70 -#> 15 2 72.0 4.288082 2.3116966 1 1 70 -#> 16 2 120.0 2.556484 0.9398657 1 1 70 -#> 17 3 0.5 1.373968 3.4254357 1 1 70 -#> 18 3 1.0 2.497014 5.4711041 1 1 70 -#> 19 3 2.0 4.156027 7.3821834 1 1 70 -#> 20 3 6.0 6.602481 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)) +
    groups_to_use
    +

    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).

    -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 1.8824573 2.6986425 3.4254357 1 1 70 -#> 2 1 1.0 4.4606407 4.5224462 5.4711041 1 1 70 -#> 3 1 2.0 6.1021726 6.5605583 7.3821834 1 1 70 -#> 4 1 6.0 8.0079320 7.7839864 7.9462805 1 1 70 -#> 5 1 24.0 5.9242971 5.5574735 5.6858561 1 1 70 -#> 6 1 36.0 4.1273096 4.4035807 4.5402483 1 1 70 -#> 7 1 72.0 2.2569618 2.1907440 2.3116966 1 1 70 -#> 8 1 120.0 0.7775830 0.8635865 0.9398657 1 1 70 -#> 9 2 0.5 1.3147314 1.2950745 3.4254357 1 1 70 -#> 10 2 1.0 2.3422395 2.3370827 5.4711041 1 1 70 -#> 11 2 2.0 3.9529858 3.8424651 7.3821834 1 1 70 -#> 12 2 6.0 6.6757835 5.9423279 7.9462805 1 1 70 -#> 13 2 24.0 6.2962206 4.7862925 5.6858561 1 1 70 -#> 14 2 36.0 3.9901656 3.8830024 4.5402483 1 1 70 -#> 15 2 72.0 1.9881554 2.0728924 2.3116966 1 1 70 -#> 16 2 120.0 0.8062582 0.8976806 0.9398657 1 1 70 -#> 17 3 0.5 2.6556066 2.6104406 3.4254357 1 1 70 -#> 18 3 1.0 4.9511436 4.5376033 5.4711041 1 1 70 -#> 19 3 2.0 5.9386580 6.9882512 7.3821834 1 1 70 -#> 20 3 6.0 9.0706361 9.2475260 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)) +
    include_a
    +

    Should we include the continuous design variables in the output?

    -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 69.30103 50 -#> 2 1 1.0 NA NA NA 1 1 69.30103 50 -#> 3 1 2.0 NA NA NA 1 1 69.30103 50 -#> 4 1 6.0 NA NA NA 1 1 69.30103 50 -#> 5 1 24.0 NA NA NA 1 1 69.30103 50 -#> 6 1 36.0 NA NA NA 1 1 69.30103 50 -#> 7 1 72.0 NA NA NA 1 1 69.30103 50 -#> 8 1 120.0 NA NA NA 1 1 69.30103 50 -#> 9 2 0.5 NA NA NA 1 1 70.32465 50 -#> 10 2 1.0 NA NA NA 1 1 70.32465 50 -#> 11 2 2.0 NA NA NA 1 1 70.32465 50 -#> 12 2 6.0 NA NA NA 1 1 70.32465 50 -#> 13 2 24.0 NA NA NA 1 1 70.32465 50 -#> 14 2 36.0 NA NA NA 1 1 70.32465 50 -#> 15 2 72.0 NA NA NA 1 1 70.32465 50 -#> 16 2 120.0 NA NA NA 1 1 70.32465 50 -#> 17 3 0.5 NA NA NA 1 1 77.19992 50 -#> 18 3 1.0 NA NA NA 1 1 77.19992 50 -#> 19 3 2.0 NA NA NA 1 1 77.19992 50 -#> 20 3 6.0 NA NA NA 1 1 77.19992 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 69.30103 50 -#> 2 1 1.0 NA NA NA 1 1 69.30103 50 -#> 3 1 2.0 NA NA NA 1 1 69.30103 50 -#> 4 1 6.0 NA NA NA 1 1 69.30103 50 -#> 5 1 24.0 NA NA NA 1 1 69.30103 50 -#> 6 1 36.0 NA NA NA 1 1 69.30103 50 -#> 7 1 72.0 NA NA NA 1 1 69.30103 50 -#> 8 1 120.0 NA NA NA 1 1 69.30103 50 -#> 9 2 0.5 NA NA NA 1 1 70.32465 50 -#> 10 2 1.0 NA NA NA 1 1 70.32465 50 -#> 11 2 2.0 NA NA NA 1 1 70.32465 50 -#> 12 2 6.0 NA NA NA 1 1 70.32465 50 -#> 13 2 24.0 NA NA NA 1 1 70.32465 50 -#> 14 2 36.0 NA NA NA 1 1 70.32465 50 -#> 15 2 72.0 NA NA NA 1 1 70.32465 50 -#> 16 2 120.0 NA NA NA 1 1 70.32465 50 -#> 17 3 0.5 NA NA NA 1 1 77.19992 50 -#> 18 3 1.0 NA NA NA 1 1 77.19992 50 -#> 19 3 2.0 NA NA NA 1 1 77.19992 50 -#> 20 3 6.0 NA NA NA 1 1 77.19992 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 +
    include_x
    +

    Should we include the discrete design variables in the output?

    -(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
    +
    manipulation
    +

    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.

    + + +
    PI
    +

    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.

    + + +
    PI_conf_level
    +

    The confidence level for the prediction interval computed.

    + + +
    PI_ln_dist
    +

    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.

    -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))) +
    +
    +

    Value

    + -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
    -
    +

    A dataframe containing a design and (potentially) simulated data with some dense grid of samples and/or +based on the input design.

    +
    +
    +

    See also

    + +
    + +
    +

    Examples

    +
    ## 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
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/ofv_criterion.html b/docs/reference/ofv_criterion.html index 698c312..d52f66c 100644 --- a/docs/reference/ofv_criterion.html +++ b/docs/reference/ofv_criterion.html @@ -1,76 +1,13 @@ - - - - - - - -Normalize an objective function by the size of the FIM matrix — ofv_criterion • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Normalize an objective function by the size of the FIM matrix — ofv_criterion • PopED - - + + - - -
    -
    - -
    - -
    +

    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.

    +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
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - -
    ofv_f

    An objective function

    num_parameters

    The number of parameters to use for normalization

    poped.db

    a poped database

    ofv_calc_type

    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))

    • -
    - -

    Value

    - -

    The specified criterion value.

    -

    See also

    +
    +
    ofv_criterion(
    +  ofv_f,
    +  num_parameters,
    +  poped.db,
    +  ofv_calc_type = poped.db$settings$ofv_calc_type
    +)
    +
    - +
    +

    Arguments

    +
    ofv_f
    +

    An objective function

    -

    Examples

    -
    library(PopED) -############# START ################# -## Create PopED database -## (warfarin model for optimization) -##################################### +
    num_parameters
    +

    The number of parameters to use for normalization

    -## 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). +
    poped.db
    +

    a poped database

    -## 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: 0x7fe20a979808> -#> <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)) +
    ofv_calc_type
    +

    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))

    • +
    -############# END ################### -## Create PopED database -## (warfarin model for optimization) -##################################### +
    +
    +

    Value

    + +

    The specified criterion value.

    +
    +
    +

    See also

    + +
    -## 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
    -
    +
    +

    Examples

    +
    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
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/ofv_fim.html b/docs/reference/ofv_fim.html index 82525c9..0c2e8c6 100644 --- a/docs/reference/ofv_fim.html +++ b/docs/reference/ofv_fim.html @@ -1,76 +1,13 @@ - - - - - - - -Evaluate a criterion of the Fisher Information Matrix (FIM) — ofv_fim • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Evaluate a criterion of the Fisher Information Matrix (FIM) — ofv_fim • PopED - - + + - - -
    -
    - -
    - -
    +
    @@ -152,200 +80,210 @@

    Evaluate a criterion of the Fisher Information Matrix (FIM)

    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,
    -  ...
    -)
    +
    +
    ofv_fim(
    +  fmf,
    +  poped.db,
    +  ofv_calc_type = poped.db$settings$ofv_calc_type,
    +  ds_index = poped.db$parameters$ds_index,
    +  use_log = TRUE,
    +  ...
    +)
    +
    + +
    +

    Arguments

    +
    fmf
    +

    The FIM

    + -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - -
    fmf

    The FIM

    poped.db

    A poped database

    ofv_calc_type

    OFV calculation type for FIM

      -
    • 1 = "D-optimality". Determinant of the FIM: det(FIM)

    • +
      poped.db
      +

      A poped database

      + + +
      ofv_calc_type
      +

      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

    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.

    use_log

    Should the criterion be in the log domain?

    ...

    arguments passed to evaluate.fim and ofv_fim.

    - -

    Value

    + -

    The specified criterion value.

    -

    See also

    - - -

    Examples

    -
    library(PopED) - -############# START ################# -## Create PopED database -## (warfarin model for optimization) -##################################### +
    ds_index
    +

    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.

    -## 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). +
    use_log
    +

    Should the criterion be in the log domain?

    -## 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: 0x7fe20a979808> -#> <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)) +
    ...
    +

    arguments passed to evaluate.fim and ofv_fim.

    -############# END ################### -## Create PopED database -## (warfarin model for optimization) -##################################### +
    +
    +

    Value

    + +

    The specified criterion value.

    +
    +
    +

    See also

    + +
    -## 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
    -
    +
    +

    Examples

    +
    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
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/ones.html b/docs/reference/ones.html index 05ad1c9..ddf4123 100644 --- a/docs/reference/ones.html +++ b/docs/reference/ones.html @@ -1,75 +1,12 @@ - - - - - - - -Create a matrix of ones — ones • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Create a matrix of ones — ones • PopED + + - - - - -
    -
    - -
    - -
    +
    @@ -150,76 +78,79 @@

    Create a matrix of ones

    Create a matrix of ones of size (dim1 x dim2).

    -
    ones(dim1, dim2 = NULL)
    - -

    Arguments

    - - - - - - - - - - -
    dim1

    The dimension of the matrix (if square) or the number of rows.

    dim2

    The number of columns

    - -

    Value

    - -

    A matrix of ones

    -

    See also

    - -

    Other MATLAB: -cell(), -diag_matlab(), -feval(), -fileparts(), -isempty(), -randn(), -rand(), -size(), -tic(), -toc(), -zeros()

    - -

    Examples

    -
    -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
    +
    +
    ones(dim1, dim2 = NULL)
    +
    + +
    +

    Arguments

    +
    dim1
    +

    The dimension of the matrix (if square) or the number of rows.

    + + +
    dim2
    +

    The number of columns

    + +
    +
    +

    Value

    + + +

    A matrix of ones

    +
    +
    +

    See also

    +

    Other MATLAB: +cell(), +diag_matlab(), +feval(), +fileparts(), +isempty(), +randn(), +rand(), +size(), +tic(), +toc(), +zeros()

    +
    + +
    +

    Examples

    +
    
    +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
    +
    +
    +
    - - - + + diff --git a/docs/reference/optim_ARS.html b/docs/reference/optim_ARS.html index 932c26a..bf817ca 100644 --- a/docs/reference/optim_ARS.html +++ b/docs/reference/optim_ARS.html @@ -1,77 +1,14 @@ - - - - - - - -Optimize a function using adaptive random search. — optim_ARS • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Optimize a function using adaptive random search. — optim_ARS • PopED - - - - - - - - - - - - - - + + -
    -
    - -
    - -
    +
    @@ -154,827 +82,797 @@

    Optimize a function using adaptive random search.

    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,
    -  ...
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    par

    A vector of initial values for the parameters to be optimized over.

    fn

    A function to be minimized (or maximized), +

    +
    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,
    +  ...
    +)
    +
    + +
    +

    Arguments

    +
    par
    +

    A vector of initial values for the parameters to be optimized over.

    + + +
    fn
    +

    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

    Lower bounds on the parameters. A vector.

    upper

    Upper bounds on the parameters. A vector.

    allowed_values

    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).

    loc_fac

    Locality factor for determining the standard deviation of the sampling distribution around the current +It should return a scalar result.

    + + +
    lower
    +

    Lower bounds on the parameters. A vector.

    + + +
    upper
    +

    Upper bounds on the parameters. A vector.

    + + +
    allowed_values
    +

    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).

    + + +
    loc_fac
    +

    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).

    no_bounds_sd

    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).

    iter

    The number of iterations for the algorithm to perform (this is a maximum number, it could be less).

    iter_adapt

    The number of iterations before adapting (shrinking) the parameter search space.

    adapt_scale

    The scale for adapting the size of the sampling distribution. The adaptation of the +except in cases when there are no upper or lower limits (e.g. when upper=Inf or lower=-Inf).

    + + +
    no_bounds_sd
    +

    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).

    + + +
    iter
    +

    The number of iterations for the algorithm to perform (this is a maximum number, it could be less).

    + + +
    iter_adapt
    +

    The number of iterations before adapting (shrinking) the parameter search space.

    + + +
    adapt_scale
    +

    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.

    max_run

    The maximum number of iterations to run without a change in the best parameter estimates.

    trace

    Should the algorithm output results intermittently.

    trace_iter

    How many iterations between each update to the screen about the result of the search.

    new_par_max_it

    The algorithm randomly chooses samples based on the current best set of parameters. If when drawing +(upper - lower)/(loc_fac*ff*adapt_scale) where ff starts at 1 and increases by 1 for each adaptation.

    + + +
    max_run
    +

    The maximum number of iterations to run without a change in the best parameter estimates.

    + + +
    trace
    +

    Should the algorithm output results intermittently.

    + + +
    trace_iter
    +

    How many iterations between each update to the screen about the result of the search.

    + + +
    new_par_max_it
    +

    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.

    maximize

    Should the function be maximized? Default is to minimize.

    parallel

    Should we use parallel computations?

    parallel_type

    Which type of parallelization should be used? +no new parameter sets, then the algorithm stops.

    + + +
    maximize
    +

    Should the function be maximized? Default is to minimize.

    + + +
    parallel
    +

    Should we use parallel computations?

    + + +
    parallel_type
    +

    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.

    num_cores

    The number of cores to use in the parallelization. By default is set to the number +See start_parallel.

    + + +
    num_cores
    +

    The number of cores to use in the parallelization. By default is set to the number output from -parallel::detectCores(). -See start_parallel.

    mrgsolve_model

    If the computations require a mrgsolve model and you +parallel::detectCores(). +See start_parallel.

    + + +
    mrgsolve_model
    +

    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.

    seed

    The random seed to use in the algorithm,

    allow_replicates

    Should the algorithm allow parameters to have the same value?

    replicates_index

    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.

    generator

    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.

    - -

    References

    +object created by mread or mcode.

    + + +
    seed
    +

    The random seed to use in the algorithm,

    + + +
    allow_replicates
    +

    Should the algorithm allow parameters to have the same value?

    + +
    replicates_index
    +

    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.

    + + +
    generator
    +

    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.

    + +
    +
    +

    References

    -
      -
    1. M. Foracchia, A.C. Hooker, P. Vicini and A. Ruggeri, "PopED, a software fir optimal +

      1. 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.

      2. 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.

      3. -
      - -

      See also

      - - - -

      Examples

      -
      -## "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 = 83.4526 -#> It. 10 | OFV = 76.4507 -#> It. 15 | OFV = 76.4507 -#> It. 20 | OFV = 76.4507 -#> It. 25 | OFV = 76.4507 -#> It. 30 | OFV = 70.9847 -#> It. 35 | OFV = 70.9847 -#> It. 40 | OFV = 70.9847 -#> It. 45 | OFV = 70.9847 -#> It. 50 | OFV = 70.9847 -#> It. 55 | OFV = 70.9847 -#> It. 60 | OFV = 70.9847 -#> It. 65 | OFV = 70.9847 -#> It. 70 | OFV = 70.9847 -#> It. 75 | OFV = 70.9847 -#> It. 80 | OFV = 70.9847 -#> It. 85 | OFV = 70.9847 -#> It. 90 | OFV = 70.9847 -#> It. 95 | OFV = 70.9847 -#> It. 100 | OFV = 70.9847 -#> It. 105 | OFV = 68.8229 -#> It. 110 | OFV = 68.8229 -#> It. 115 | OFV = 68.8229 -#> It. 120 | OFV = 68.8229 -#> It. 125 | OFV = 68.8229 -#> It. 130 | OFV = 68.8229 -#> It. 135 | OFV = 68.8229 -#> It. 140 | OFV = 68.8229 -#> It. 145 | OFV = 68.8229 -#> It. 150 | OFV = 68.5656 -#> It. 155 | OFV = 68.5656 -#> It. 160 | OFV = 68.5656 -#> It. 165 | OFV = 68.5656 -#> It. 170 | OFV = 68.5656 -#> It. 175 | OFV = 68.5656 -#> It. 180 | OFV = 68.5656 -#> It. 185 | OFV = 68.5656 -#> It. 190 | OFV = 68.5656 -#> It. 195 | OFV = 68.5656 -#> It. 200 | OFV = 68.5656 -#> It. 205 | OFV = 68.4446 -#> It. 210 | OFV = 68.4446 -#> It. 215 | OFV = 68.4446 -#> It. 220 | OFV = 68.4446 -#> It. 225 | OFV = 68.4446 -#> It. 230 | OFV = 68.4446 -#> It. 235 | OFV = 68.4446 -#> It. 240 | OFV = 68.4446 -#> It. 245 | OFV = 68.4446 -#> It. 250 | OFV = 68.4446 -#> It. 255 | OFV = 68.4446 -#> It. 260 | OFV = 68.4446 -#> It. 265 | OFV = 68.4446 -#> It. 270 | OFV = 68.4446 -#> It. 275 | OFV = 68.4446 -#> It. 280 | OFV = 68.4446 -#> It. 285 | OFV = 68.4446 -#> It. 290 | OFV = 68.4446 -#> It. 295 | OFV = 68.4446 -#> It. 300 | OFV = 68.4446 -#> It. 305 | OFV = 68.4446 -#> It. 310 | OFV = 68.4446 -#> It. 315 | OFV = 68.4446 -#> It. 320 | OFV = 68.4446 -#> It. 325 | OFV = 68.4446 -#> It. 330 | OFV = 68.4446 -#> It. 335 | OFV = 68.4446 -#> It. 340 | OFV = 68.4446 -#> It. 345 | OFV = 68.4446 -#> It. 350 | OFV = 68.4446 -#> It. 355 | OFV = 68.4446 -#> It. 360 | OFV = 68.4446 -#> It. 365 | OFV = 68.4446 -#> It. 370 | OFV = 68.4446 -#> It. 375 | OFV = 68.4446 -#> It. 380 | OFV = 68.4446 -#> It. 385 | OFV = 68.4446 -#> It. 390 | OFV = 68.4446 -#> It. 395 | OFV = 67.5762 -#> It. 400 | OFV = 67.5762 -#> -#> Total iterations: 400 -#> Elapsed time: 0.189 seconds. -#> -#> Final OFV = 67.57618 -#> Parameters: -15.35198 -#>
      -# 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 = 82.9206 -#> It. 10 | OFV = 81.2685 -#> It. 15 | OFV = 70.2732 -#> It. 20 | OFV = 70.2732 -#> It. 25 | OFV = 70.2732 -#> It. 30 | OFV = 70.2732 -#> It. 35 | OFV = 70.2732 -#> It. 40 | OFV = 70.2732 -#> It. 45 | OFV = 70.2732 -#> It. 50 | OFV = 70.2732 -#> It. 55 | OFV = 70.2732 -#> It. 60 | OFV = 70.2732 -#> It. 65 | OFV = 70.2641 -#> It. 70 | OFV = 70.2641 -#> It. 75 | OFV = 70.2641 -#> It. 80 | OFV = 70.2641 -#> It. 85 | OFV = 70.2641 -#> It. 90 | OFV = 70.2641 -#> It. 95 | OFV = 70.2641 -#> It. 100 | OFV = 70.2641 -#> It. 105 | OFV = 70.2641 -#> It. 110 | OFV = 70.2641 -#> It. 115 | OFV = 70.2641 -#> It. 120 | OFV = 70.2641 -#> It. 125 | OFV = 70.2641 -#> It. 130 | OFV = 70.2641 -#> It. 135 | OFV = 70.2641 -#> It. 140 | OFV = 68.4052 -#> It. 145 | OFV = 68.4052 -#> It. 150 | OFV = 68.4052 -#> It. 155 | OFV = 68.4052 -#> It. 160 | OFV = 68.4052 -#> It. 165 | OFV = 68.4052 -#> It. 170 | OFV = 68.4052 -#> It. 175 | OFV = 68.4052 -#> It. 180 | OFV = 68.4052 -#> It. 185 | OFV = 68.4052 -#> It. 190 | OFV = 68.4052 -#> It. 195 | OFV = 67.6696 -#> It. 200 | OFV = 67.6696 -#> It. 205 | OFV = 67.6696 -#> It. 210 | OFV = 67.6696 -#> It. 215 | OFV = 67.6696 -#> It. 220 | OFV = 67.6696 -#> It. 225 | OFV = 67.6696 -#> It. 230 | OFV = 67.6696 -#> It. 235 | OFV = 67.6696 -#> It. 240 | OFV = 67.6696 -#> It. 245 | OFV = 67.6696 -#> It. 250 | OFV = 67.6696 -#> It. 255 | OFV = 67.6696 -#> It. 260 | OFV = 67.6696 -#> It. 265 | OFV = 67.6696 -#> It. 270 | OFV = 67.6696 -#> It. 275 | OFV = 67.6696 -#> It. 280 | OFV = 67.6696 -#> It. 285 | OFV = 67.6696 -#> It. 290 | OFV = 67.6696 -#> It. 295 | OFV = 67.6696 -#> It. 300 | OFV = 67.6696 -#> It. 305 | OFV = 67.6696 -#> It. 310 | OFV = 67.6696 -#> It. 315 | OFV = 67.6696 -#> It. 320 | OFV = 67.6696 -#> It. 325 | OFV = 67.6696 -#> It. 330 | OFV = 67.6696 -#> It. 335 | OFV = 67.6696 -#> It. 340 | OFV = 67.6696 -#> It. 345 | OFV = 67.6696 -#> It. 350 | OFV = 67.6696 -#> It. 355 | OFV = 67.6696 -#> It. 360 | OFV = 67.6696 -#> It. 365 | OFV = 67.6696 -#> It. 370 | OFV = 67.6696 -#> It. 375 | OFV = 67.6696 -#> It. 380 | OFV = 67.6696 -#> It. 385 | OFV = 67.6696 -#> It. 390 | OFV = 67.6696 -#> Maximum number of identical optimal values reached (max_run=200), optimization stopped. -#> -#> Total iterations: 392 -#> Elapsed time: 0.174 seconds. -#> -#> Final OFV = 67.6696 -#> Parameters: -15.97183 -#>
      -# 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 = 3460 -#> It. 10 | OFV = 3460 -#> It. 15 | OFV = 3460 -#> It. 20 | OFV = 3110.35 -#> It. 25 | OFV = 3110.35 -#> It. 30 | OFV = 2769.9 -#> It. 35 | OFV = 2508.65 -#> It. 40 | OFV = 1914.21 -#> It. 45 | OFV = 1886.45 -#> It. 50 | OFV = 1886.45 -#> It. 55 | OFV = 1886.45 -#> It. 60 | OFV = 1886.45 -#> It. 65 | OFV = 1763.46 -#> It. 70 | OFV = 1763.46 -#> It. 75 | OFV = 1763.46 -#> It. 80 | OFV = 902.615 -#> It. 85 | OFV = 902.615 -#> It. 90 | OFV = 902.615 -#> It. 95 | OFV = 902.615 -#> It. 100 | OFV = 902.615 -#> It. 105 | OFV = 902.615 -#> It. 110 | OFV = 902.615 -#> It. 115 | OFV = 902.615 -#> It. 120 | OFV = 902.615 -#> It. 125 | OFV = 902.615 -#> It. 130 | OFV = 902.615 -#> It. 135 | OFV = 902.615 -#> It. 140 | OFV = 865.598 -#> It. 145 | OFV = 865.598 -#> It. 150 | OFV = 772.584 -#> It. 155 | OFV = 772.584 -#> It. 160 | OFV = 772.584 -#> It. 165 | OFV = 772.584 -#> It. 170 | OFV = 772.584 -#> It. 175 | OFV = 715.613 -#> It. 180 | OFV = 699.241 -#> It. 185 | OFV = 699.241 -#> It. 190 | OFV = 699.241 -#> It. 195 | OFV = 699.241 -#> It. 200 | OFV = 699.241 -#> It. 205 | OFV = 621.414 -#> It. 210 | OFV = 621.414 -#> It. 215 | OFV = 621.414 -#> It. 220 | OFV = 621.414 -#> It. 225 | OFV = 621.414 -#> It. 230 | OFV = 621.414 -#> It. 235 | OFV = 621.414 -#> It. 240 | OFV = 606.201 -#> It. 245 | OFV = 606.201 -#> It. 250 | OFV = 606.201 -#> It. 255 | OFV = 606.201 -#> It. 260 | OFV = 606.201 -#> It. 265 | OFV = 606.201 -#> It. 270 | OFV = 606.201 -#> It. 275 | OFV = 606.201 -#> It. 280 | OFV = 606.201 -#> It. 285 | OFV = 606.201 -#> It. 290 | OFV = 536.585 -#> It. 295 | OFV = 536.585 -#> It. 300 | OFV = 536.585 -#> It. 305 | OFV = 536.585 -#> It. 310 | OFV = 536.585 -#> It. 315 | OFV = 536.585 -#> It. 320 | OFV = 536.585 -#> It. 325 | OFV = 536.585 -#> It. 330 | OFV = 536.585 -#> It. 335 | OFV = 536.585 -#> It. 340 | OFV = 536.585 -#> It. 345 | OFV = 536.585 -#> It. 350 | OFV = 536.585 -#> It. 355 | OFV = 536.585 -#> It. 360 | OFV = 536.585 -#> It. 365 | OFV = 512.881 -#> It. 370 | OFV = 512.881 -#> It. 375 | OFV = 506.252 -#> It. 380 | OFV = 506.252 -#> It. 385 | OFV = 506.252 -#> It. 390 | OFV = 506.252 -#> It. 395 | OFV = 506.252 -#> It. 400 | OFV = 503.399 -#> -#> Total iterations: 400 -#> Elapsed time: 0.271 seconds. -#> -#> Final OFV = 503.399 -#> Parameters: 2.130566 2 2 2.059427 2 2 2.167358 2 2 2.142739 2 2 2.030765 2.254329 2 2 2.56842 2.045564 2.276299 2 2 2 2 2 3.690364 -#>
      - -## 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 = 28885 -#> It. 10 | OFV = 28498 -#> It. 15 | OFV = 27136 -#> It. 20 | OFV = 26242 -#> It. 25 | OFV = 25509 -#> It. 30 | OFV = 25509 -#> It. 35 | OFV = 25509 -#> It. 40 | OFV = 25089 -#> It. 45 | OFV = 23414 -#> It. 50 | OFV = 23414 -#> It. 55 | OFV = 23414 -#> It. 60 | OFV = 20070 -#> It. 65 | OFV = 19725 -#> It. 70 | OFV = 19102 -#> It. 75 | OFV = 18976 -#> It. 80 | OFV = 18976 -#> It. 85 | OFV = 18976 -#> It. 90 | OFV = 18976 -#> It. 95 | OFV = 18410 -#> It. 100 | OFV = 18410 -#> It. 105 | OFV = 18410 -#> It. 110 | OFV = 18410 -#> It. 115 | OFV = 18410 -#> It. 120 | OFV = 17812 -#> It. 125 | OFV = 16702 -#> It. 130 | OFV = 16702 -#> It. 135 | OFV = 16702 -#> It. 140 | OFV = 16665 -#> It. 145 | OFV = 16665 -#> It. 150 | OFV = 16665 -#> It. 155 | OFV = 16665 -#> It. 160 | OFV = 16665 -#> It. 165 | OFV = 16665 -#> It. 170 | OFV = 16665 -#> It. 175 | OFV = 16665 -#> It. 180 | OFV = 16665 -#> It. 185 | OFV = 16665 -#> It. 190 | OFV = 16665 -#> It. 195 | OFV = 16665 -#> It. 200 | OFV = 16665 -#> It. 205 | OFV = 16665 -#> It. 210 | OFV = 16665 -#> It. 215 | OFV = 16665 -#> It. 220 | OFV = 16665 -#> It. 225 | OFV = 16665 -#> It. 230 | OFV = 16665 -#> It. 235 | OFV = 16665 -#> It. 240 | OFV = 16665 -#> It. 245 | OFV = 16665 -#> It. 250 | OFV = 16665 -#> It. 255 | OFV = 16665 -#> It. 260 | OFV = 16665 -#> It. 265 | OFV = 16665 -#> It. 270 | OFV = 16665 -#> It. 275 | OFV = 16665 -#> It. 280 | OFV = 16665 -#> It. 285 | OFV = 16665 -#> It. 290 | OFV = 16665 -#> It. 295 | OFV = 16665 -#> It. 300 | OFV = 16665 -#> It. 305 | OFV = 16665 -#> It. 310 | OFV = 16063 -#> It. 315 | OFV = 16063 -#> It. 320 | OFV = 16063 -#> It. 325 | OFV = 16063 -#> It. 330 | OFV = 16063 -#> It. 335 | OFV = 15999 -#> It. 340 | OFV = 15999 -#> It. 345 | OFV = 15999 -#> It. 350 | OFV = 15999 -#> It. 355 | OFV = 15999 -#> It. 360 | OFV = 15999 -#> It. 365 | OFV = 15999 -#> It. 370 | OFV = 15999 -#> It. 375 | OFV = 15999 -#> It. 380 | OFV = 15999 -#> It. 385 | OFV = 15264 -#> It. 390 | OFV = 15264 -#> It. 395 | OFV = 15264 -#> It. 400 | OFV = 15264 -#> -#> Total iterations: 400 -#> Elapsed time: 0.278 seconds. -#> -#> Final OFV = 15264 -#> Parameters: 1 19 8 5 4 3 18 2 14 9 12 15 13 16 17 6 11 7 20 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 = 23.0891 -#> It. 10 | OFV = 23.0891 -#> It. 15 | OFV = 34.1068 -#> It. 20 | OFV = 34.1068 -#> It. 25 | OFV = 34.6902 -#> It. 30 | OFV = 34.6902 -#> It. 35 | OFV = 34.6902 -#> It. 40 | OFV = 34.6902 -#> It. 45 | OFV = 34.6902 -#> It. 50 | OFV = 34.6902 -#> It. 55 | OFV = 34.6902 -#> It. 60 | OFV = 34.6902 -#> It. 65 | OFV = 34.6902 -#> It. 70 | OFV = 34.6902 -#> It. 75 | OFV = 35.4986 -#> It. 80 | OFV = 46.4501 -#> It. 85 | OFV = 46.4501 -#> It. 90 | OFV = 46.4501 -#> It. 95 | OFV = 46.4501 -#> It. 100 | OFV = 46.6179 -#> It. 105 | OFV = 46.6179 -#> It. 110 | OFV = 47.6976 -#> It. 115 | OFV = 47.6976 -#> It. 120 | OFV = 47.6976 -#> It. 125 | OFV = 47.6976 -#> It. 130 | OFV = 47.6976 -#> It. 135 | OFV = 47.6976 -#> It. 140 | OFV = 47.6976 -#> It. 145 | OFV = 47.6976 -#> It. 150 | OFV = 47.6976 -#> It. 155 | OFV = 47.6976 -#> It. 160 | OFV = 47.6976 -#> It. 165 | OFV = 47.6976 -#> It. 170 | OFV = 47.6976 -#> It. 175 | OFV = 47.6976 -#> It. 180 | OFV = 47.6976 -#> It. 185 | OFV = 47.6976 -#> It. 190 | OFV = 47.6976 -#> It. 195 | OFV = 47.6976 -#> It. 200 | OFV = 47.6976 -#> It. 205 | OFV = 47.7032 -#> 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 -#> It. 385 | OFV = 47.7055 -#> It. 390 | OFV = 47.7055 -#> It. 395 | OFV = 47.7055 -#> It. 400 | OFV = 47.7055 -#> -#> Total iterations: 400 -#> Elapsed time: 0.191 seconds. -#> -#> Final OFV = 47.7055 -#> Parameters: 6.562641 -#>
      -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") -} -
      +
    +
    +

    See also

    + +
    + +
    +

    Examples

    +
    
    +## "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")
    +}
    +
    +
    +
    - - - + + diff --git a/docs/reference/optim_LS.html b/docs/reference/optim_LS.html index d255468..e829519 100644 --- a/docs/reference/optim_LS.html +++ b/docs/reference/optim_LS.html @@ -1,79 +1,16 @@ - - - - - - - -Optimize a function using a line search algorithm. — optim_LS • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Optimize a function using a line search algorithm. — optim_LS • PopED - - - - - - - - - - - - - - + + -
    -
    - -
    - -
    +
    @@ -158,419 +86,421 @@

    Optimize a function using a line search algorithm.

    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,
    -  ...
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    par

    A vector of initial values for the parameters to be optimized over.

    fn

    A function to be minimized (or maximized), +

    +
    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,
    +  ...
    +)
    +
    + +
    +

    Arguments

    +
    par
    +

    A vector of initial values for the parameters to be optimized over.

    + + +
    fn
    +

    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

    Lower bounds on the parameters. A vector.

    upper

    Upper bounds on the parameters. A vector.

    allowed_values

    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).

    line_length

    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.

    trace

    Should the algorithm output results intermittently.

    maximize

    Should the function be maximized? Default is to minimize.

    parallel

    Should we use parallel computations?

    parallel_type

    Which type of parallelization should be used? +It should return a scalar result.

    + + +
    lower
    +

    Lower bounds on the parameters. A vector.

    + + +
    upper
    +

    Upper bounds on the parameters. A vector.

    + + +
    allowed_values
    +

    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).

    + + +
    line_length
    +

    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.

    + + +
    trace
    +

    Should the algorithm output results intermittently.

    + + +
    maximize
    +

    Should the function be maximized? Default is to minimize.

    + + +
    parallel
    +

    Should we use parallel computations?

    + + +
    parallel_type
    +

    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.

    num_cores

    The number of cores to use in the parallelization. By default is set to the number +See start_parallel.

    + + +
    num_cores
    +

    The number of cores to use in the parallelization. By default is set to the number output from -parallel::detectCores(). -See start_parallel.

    mrgsolve_model

    If the computations require a mrgsolve model and you +parallel::detectCores(). +See start_parallel.

    + + +
    mrgsolve_model
    +

    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.

    seed

    The random seed to use in the algorithm,

    allow_replicates

    Should the algorithm allow parameters to have the same value?

    replicates_index

    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.

    ofv_initial

    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.

    closed_bounds

    Are the upper and lower limits open (boundaries not allowed) or closed (boundaries allowed) bounds?

    ...

    Additional arguments passed to fn and start_parallel.

    - -

    References

    +object created by mread or mcode.

    + + +
    seed
    +

    The random seed to use in the algorithm,

    + + +
    allow_replicates
    +

    Should the algorithm allow parameters to have the same value?

    + + +
    replicates_index
    +

    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.

    + + +
    ofv_initial
    +

    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.

    + +
    closed_bounds
    +

    Are the upper and lower limits open (boundaries not allowed) or closed (boundaries allowed) bounds?

    + + +
    ...
    +

    Additional arguments passed to fn and start_parallel.

    + +
    +
    +

    References

    -
      -
    1. M. Foracchia, A.C. Hooker, P. Vicini and A. Ruggeri, "PopED, a software fir optimal +

      1. 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.

      2. 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.

      3. -
      - -

      See also

      - - - -

      Examples

      -
      # "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.045 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.048 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 7 -#> Changed from 3 to 2.14414 ; OFV = 3370.22 -#> Searching parameter 16 -#> Changed from 3 to 2.14414 ; OFV = 3280.43 -#> Searching parameter 2 -#> Changed from 3 to 2.14414 ; OFV = 3190.65 -#> Searching parameter 25 -#> Changed from 3 to 4 ; OFV = 3146.65 -#> Searching parameter 20 -#> Changed from 3 to 2.14414 ; OFV = 3056.87 -#> Searching parameter 11 -#> Changed from 3 to 2.14414 ; OFV = 2967.09 -#> Searching parameter 1 -#> Changed from 3 to 2 ; OFV = 2789.85 -#> Searching parameter 13 -#> Changed from 3 to 2.14414 ; OFV = 2700.07 -#> Searching parameter 18 -#> Changed from 3 to 2.14414 ; OFV = 2610.29 -#> Searching parameter 9 -#> Changed from 3 to 2.14414 ; OFV = 2520.5 -#> Searching parameter 21 -#> Changed from 3 to 2 ; OFV = 2397.28 -#> Searching parameter 4 -#> Changed from 3 to 2.14414 ; OFV = 2307.5 -#> Searching parameter 5 -#> Changed from 3 to 2 ; OFV = 2184.28 -#> Searching parameter 8 -#> Changed from 3 to 2 ; OFV = 2026.82 -#> Searching parameter 12 -#> Changed from 3 to 2 ; OFV = 1869.37 -#> Searching parameter 19 -#> Changed from 3 to 2 ; OFV = 1711.91 -#> Searching parameter 15 -#> Changed from 3 to 2 ; OFV = 1589.68 -#> Searching parameter 10 -#> Changed from 3 to 2 ; OFV = 1432.22 -#> Searching parameter 22 -#> Changed from 3 to 2 ; OFV = 1304.22 -#> Searching parameter 3 -#> Changed from 3 to 2 ; OFV = 1146.77 -#> Searching parameter 6 -#> Changed from 3 to 2 ; OFV = 984.533 -#> Searching parameter 17 -#> Changed from 3 to 2 ; OFV = 827.077 -#> Searching parameter 23 -#> Changed from 3 to 2 ; OFV = 699.077 -#> Searching parameter 24 -#> Changed from 3 to 2.10811 ; OFV = 610.183 -#> Searching parameter 14 -#> Changed from 3 to 2 ; OFV = 446.962 -#> -#> Elapsed time: 0.191 seconds. -#> -#> Final OFV = 446.9622 -#> Parameters: 2 2.144144 2 2.144144 2 2 2.144144 2 2.144144 2 2.144144 2 2.144144 2 2 2.144144 2 2.144144 2 2.144144 2 2 2 2.108108 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.002 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") -} -
      +
    +
    +

    See also

    + +
    + +
    +

    Examples

    +
    # "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")
    +}
    +
    +
    +
    - - - + + diff --git a/docs/reference/optimize_groupsize-1.png b/docs/reference/optimize_groupsize-1.png index 6a56281..e99551d 100644 Binary files a/docs/reference/optimize_groupsize-1.png and b/docs/reference/optimize_groupsize-1.png differ diff --git a/docs/reference/optimize_groupsize.html b/docs/reference/optimize_groupsize.html index dd8153f..21acfa6 100644 --- a/docs/reference/optimize_groupsize.html +++ b/docs/reference/optimize_groupsize.html @@ -1,75 +1,12 @@ - - - - - - - -Title Optimize the proportion of individuals in the design groups — optimize_groupsize • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Title Optimize the proportion of individuals in the design groups — optimize_groupsize • PopED - + + - - - -
    -
    - -
    - -
    +
    @@ -150,169 +78,174 @@

    Title Optimize the proportion of individuals in the design groups

    Title Optimize the proportion of individuals in the design groups

    -
    optimize_groupsize(
    -  poped.db,
    -  props = c(poped.db$design$groupsize/sum(poped.db$design$groupsize)),
    -  trace = 1,
    -  ...
    -)
    +
    +
    optimize_groupsize(
    +  poped.db,
    +  props = c(poped.db$design$groupsize/sum(poped.db$design$groupsize)),
    +  trace = 1,
    +  ...
    +)
    +
    -

    Arguments

    - - - - - - - - - - - - - - - - - - -
    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.

    trace

    Should there be tracing of the optimization? Value can be integer values. -Larger numbers give more information.

    ...

    Arguments passed to ofv_fim and optim

    +
    +

    Arguments

    +
    poped.db
    +

    A PopED database.

    -

    Value

    -

    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.

    +
    props
    +

    The proportions of individuals in each group +(relative to the total number of individuals) +to start the optimization from.

    + -

    Examples

    -
    # 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) +
    trace
    +

    Should there be tracing of the optimization? Value can be integer values. +Larger numbers give more information.

    -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.2176534 -#> 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.9515724 -#> 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 -#>
    +
    ...
    +

    Arguments passed to ofv_fim and optim

    -# 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
    +
    +
    +

    Value

    + +

    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.

    +
    -
    +
    +

    Examples

    +
    # 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
    +
    +
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/optimize_n_eff-1.png b/docs/reference/optimize_n_eff-1.png index 6a56281..e99551d 100644 Binary files a/docs/reference/optimize_n_eff-1.png and b/docs/reference/optimize_n_eff-1.png differ diff --git a/docs/reference/optimize_n_eff.html b/docs/reference/optimize_n_eff.html index 52e7ea6..bb8e8a5 100644 --- a/docs/reference/optimize_n_eff.html +++ b/docs/reference/optimize_n_eff.html @@ -1,75 +1,12 @@ - - - - - - - -Translate efficiency to number of subjects — optimize_n_eff • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Translate efficiency to number of subjects — optimize_n_eff • PopED - + + - - - -
    -
    - -
    - -
    +
    @@ -150,159 +78,164 @@

    Translate efficiency to number of subjects

    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, ...)
    +
    +
    optimize_n_eff(poped.db, ofv_ref, norm_group_fim = NULL, ...)
    +
    + +
    +

    Arguments

    +
    poped.db
    +

    A PopED database.

    -

    Arguments

    - - - - - - - - - - - - - - - - - - -
    poped.db

    A PopED database.

    ofv_ref

    A reference OFV value to compare to.

    norm_group_fim

    The FIM per individual in each design group. If NULL, then -these are computed.

    ...

    Arguments passed to evaluate.fim and efficiency.

    -

    Value

    +
    ofv_ref
    +

    A reference OFV value to compare to.

    -

    The number of individuals needed.

    -

    Examples

    -
    # 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) +
    norm_group_fim
    +

    The FIM per individual in each design group. If NULL, then +these are computed.

    -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.2176534 -#> 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.9515724 -#> 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 -#>
    +
    ...
    +

    Arguments passed to evaluate.fim and efficiency.

    -# 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
    +
    +
    +

    Value

    + +

    The number of individuals needed.

    +
    -
    +
    +

    Examples

    +
    # 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
    +
    +
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/optimize_n_rse-1.png b/docs/reference/optimize_n_rse-1.png index 6a56281..e99551d 100644 Binary files a/docs/reference/optimize_n_rse-1.png and b/docs/reference/optimize_n_rse-1.png differ diff --git a/docs/reference/optimize_n_rse.html b/docs/reference/optimize_n_rse.html index 17736af..e724362 100644 --- a/docs/reference/optimize_n_rse.html +++ b/docs/reference/optimize_n_rse.html @@ -1,76 +1,13 @@ - - - - - - - -Optimize the number of subjects based on desired uncertainty of a parameter. — optimize_n_rse • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Optimize the number of subjects based on desired uncertainty of a parameter. — optimize_n_rse • PopED + + - - - - -
    -
    - -
    - -
    +
    @@ -152,115 +80,118 @@

    Optimize the number of subjects based on desired uncertainty of a parameter. based on the current design and the desired uncertainty of a single parameter

    -
    optimize_n_rse(
    -  poped.db,
    -  bpop_idx,
    -  need_rse,
    -  use_percent = TRUE,
    -  allowed_values = seq(poped.db$design$m, sum(poped.db$design$groupsize) * 5, by =
    -    poped.db$design$m)
    -)
    +
    +
    optimize_n_rse(
    +  poped.db,
    +  bpop_idx,
    +  need_rse,
    +  use_percent = TRUE,
    +  allowed_values = seq(poped.db$design$m, sum(poped.db$design$groupsize) * 5, by =
    +    poped.db$design$m)
    +)
    +
    + +
    +

    Arguments

    +
    poped.db
    +

    A PopED database.

    -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - -
    poped.db

    A PopED database.

    bpop_idx

    The index number of the parameter, currently only bpop parameters are allowed.

    need_rse

    The relative standard error (RSE) one would like to achieve (in percent, by default).

    use_percent

    Should the RSE be represented as a percentage (T/F)?

    allowed_values

    A vector of the allowed total number of subjects in the study.

    -

    Value

    +
    bpop_idx
    +

    The index number of the parameter, currently only bpop parameters are allowed.

    -

    The total number of subjects needed and the RSE of the parameter.

    -

    Examples

    -
    # 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) +
    need_rse
    +

    The relative standard error (RSE) one would like to achieve (in percent, by default).

    -# 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 -#>
    -
    +
    use_percent
    +

    Should the RSE be represented as a percentage (T/F)?

    + + +
    allowed_values
    +

    A vector of the allowed total number of subjects in the study.

    + +
    +
    +

    Value

    + + +

    The total number of subjects needed and the RSE of the parameter.

    +
    + +
    +

    Examples

    +
    # 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 
    +#> 
    +
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/pargen.html b/docs/reference/pargen.html index 6948fc7..ad7cff0 100644 --- a/docs/reference/pargen.html +++ b/docs/reference/pargen.html @@ -1,75 +1,12 @@ - - - - - - - -Parameter simulation — pargen • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Parameter simulation — pargen • PopED - - - - + + -
    -
    - -
    - -
    +
    @@ -150,194 +78,194 @@

    Parameter simulation

    Function generates random samples for a list of parameters

    -
    pargen(par, user_dist_pointer, sample_size, bLHS, sample_number, poped.db)
    +
    +
    pargen(par, user_dist_pointer, sample_size, bLHS, sample_number, poped.db)
    +
    -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - -
    par

    A matrix describing the parameters. Each row is a parameter and -the matrix has three columns:

      -
    1. First column - Type of +

      +

      Arguments

      +
      par
      +

      A matrix describing the parameters. Each row is a parameter and +the matrix has three columns:

      1. First column - Type of distribution (0-fixed, 1-normal, 2-uniform, 3-user specified, 4-lognormal, 5-Truncated normal).

      2. Second column - Mean of distribution.

      3. Third column - Variance or range of distribution.

      4. -
    user_dist_pointer

    A text string of the name of a function that -generates random samples from a user defined distribution.

    sample_size

    The number of random samples per parameter to generate

    bLHS

    Logical, indicating if Latin Hypercube Sampling should be used.

    sample_number

    The sample number to extract from a user distribution.

    poped.db

    A PopED database.

    - -

    Value

    - -

    A matrix of random samples of size (sample_size x - number_of_parameters)

    - -

    Examples

    -
    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: 0x7fe20a979808> -#> <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)) +
    user_dist_pointer
    +

    A text string of the name of a function that +generates random samples from a user defined distribution.

    -############# END ################### -## Create PopED database -## (warfarin example) -##################################### +
    sample_size
    +

    The number of random samples per parameter to generate

    -# 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) +
    bLHS
    +

    Logical, indicating if Latin Hypercube Sampling should be used.

    -# 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) +
    sample_number
    +

    The sample number to extract from a user distribution.

    -pars.n <- pargen(par=bpop_vals_ed_n, - user_dist_pointer=NULL, - sample_size=1000, - bLHS=1, - sample_number=NULL, - poped.db) +
    poped.db
    +

    A PopED database.

    -# 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) +
    +
    +

    Value

    + +

    A matrix of random samples of size (sample_size x + number_of_parameters)

    +
    -
    +
    +

    Examples

    +
    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)
    +
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/plot_efficiency_of_windows-1.png b/docs/reference/plot_efficiency_of_windows-1.png index 28e802a..244757a 100644 Binary files a/docs/reference/plot_efficiency_of_windows-1.png and b/docs/reference/plot_efficiency_of_windows-1.png differ diff --git a/docs/reference/plot_efficiency_of_windows.html b/docs/reference/plot_efficiency_of_windows.html index 36a2675..8ed195b 100644 --- a/docs/reference/plot_efficiency_of_windows.html +++ b/docs/reference/plot_efficiency_of_windows.html @@ -1,81 +1,18 @@ - - - - - - - -Plot the efficiency of windows — plot_efficiency_of_windows • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Plot the efficiency of windows — plot_efficiency_of_windows • PopED - - - - - - - - - - - - + + - - -
    -
    - -
    - -
    +
    @@ -162,239 +90,241 @@

    Plot the efficiency of windows

    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)),
    -  ...
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    poped.db

    A poped database

    xt_windows

    The distance on one direction from the optimal sample +

    +
    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)),
    +  ...
    +)
    +
    + +
    +

    Arguments

    +
    poped.db
    +

    A poped database

    + + +
    xt_windows
    +

    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.

    xt_plus

    The upper distance from the optimal sample times (xt + +in poped.db$design$xt.

    + + +
    xt_plus
    +

    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.

    xt_minus

    The lower distance from the optimal sample times (xt - +found in poped.db$design$xt.

    + + +
    xt_minus
    +

    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.

    iNumSimulations

    The number of design simulations to make within the -specified windows.

    y_eff

    Should one of the plots created have efficiency on the y-axis?

    y_rse

    Should created plots include the relative standard error of each -parameter as a value on the y-axis?

    ofv_calc_type

    OFV calculation type for FIM

      -
    • 1 = "D-optimality". Determinant of the FIM: det(FIM)

    • +found in poped.db$design$xt.

      + + +
      iNumSimulations
      +

      The number of design simulations to make within the +specified windows.

      + + +
      y_eff
      +

      Should one of the plots created have efficiency on the y-axis?

      + + +
      y_rse
      +

      Should created plots include the relative standard error of each +parameter as a value on the y-axis?

      + + +
      ofv_calc_type
      +

      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))

      • -
    mean_line

    Should a mean value line be created?

    mean_color

    The color of the mean value line.

    deviate_by_id

    Should the computations look at deviations per -individual instead of per group?

    parallel

    Should we use parallel computations (T/F)? + + + +

    mean_line
    +

    Should a mean value line be created?

    + + +
    mean_color
    +

    The color of the mean value line.

    + + +
    deviate_by_id
    +

    Should the computations look at deviations per +individual instead of per group?

    + + +
    parallel
    +

    Should we use parallel computations (T/F)? Other options can be defined in this function and passed -to start_parallel. See especially +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.

    seed

    The random seed to use.

    ...

    Extra arguments passed to evaluate.fim

    - -

    Value

    - -

    A ggplot object.

    -

    See also

    - -

    Other evaluate_design: -evaluate.fim(), -evaluate_design(), -evaluate_power(), -get_rse(), -model_prediction(), -plot_model_prediction()

    +compiled code or are using mrgsolve.

    + + +
    seed
    +

    The random seed to use.

    + + +
    ...
    +

    Extra arguments passed to evaluate.fim

    + +
    +
    +

    Value

    + + +

    A ggplot object.

    +
    +
    +

    See also

    + - -

    Examples

    -
    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: 0x7fe20a979808> -#> <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) -} +plot_model_prediction()

    +
    -
    +
    +

    Examples

    +
    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)
    +}
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/plot_model_prediction.html b/docs/reference/plot_model_prediction.html index 3729069..b44ad47 100644 --- a/docs/reference/plot_model_prediction.html +++ b/docs/reference/plot_model_prediction.html @@ -1,76 +1,13 @@ - - - - - - - -Plot model predictions — plot_model_prediction • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Plot model predictions — plot_model_prediction • PopED - - - - + + -
    -
    - -
    - -
    +
    @@ -152,388 +80,398 @@

    Plot model predictions

    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,
    -  ...
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    poped.db

    A PopED database.

    model_num_points

    How many extra observation rows should be created in the data frame for each group or individual +

    +
    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,
    +  ...
    +)
    +
    + +
    +

    Arguments

    +
    poped.db
    +

    A PopED database.

    + + +
    model_num_points
    +

    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.

    groupsize_sim

    How many individuals per group should be -simulated when DV=TRUE or IPRED=TRUE to create prediction intervals?

    separate.groups

    Should there be separate plots for each group.

    sample.times

    Should sample times be shown on the plots.

    sample.times.IPRED

    Should sample times be shown based on the IPRED y-values.

    sample.times.DV

    Should sample times be shown based on the DV y-values.

    PRED

    Should a PRED line be drawn.

    IPRED

    Should we simulate individual predictions?

    IPRED.lines

    Should IPRED lines be drawn?

    IPRED.lines.pctls

    Should lines be drawn at the chosen percentiles of the IPRED values?

    alpha.IPRED.lines

    What should the transparency for the IPRED.lines be?

    alpha.IPRED

    What should the transparency of the IPRED CI?

    sample.times.size

    What should the size of the sample.times be?

    DV

    should we simulate observations?

    alpha.DV

    What should the transparency of the DV CI?

    DV.lines

    Should DV lines be drawn?

    DV.points

    Should DV points be drawn?

    alpha.DV.lines

    What should the transparency for the DV.lines be?

    alpha.DV.points

    What should the transparency for the DV.points be?

    sample.times.DV.points

    TRUE or FALSE.

    sample.times.DV.lines

    TRUE or FALSE.

    alpha.sample.times.DV.points

    What should the transparency for the sample.times.DV.points be?

    alpha.sample.times.DV.lines

    What should the transparency for the sample.times.DV.lines be?

    y_lab

    The label of the y-axis.

    facet_scales

    Can be "free", "fixed", "free_x" or "free_y"

    facet_label_names

    TRUE or FALSE

    model.names

    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.

    DV.mean.sd

    Plot the mean and standard deviation of simulated observations.

    PI

    Plot prediction intervals for the expected data given the model. +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.

    + + +
    groupsize_sim
    +

    How many individuals per group should be +simulated when DV=TRUE or IPRED=TRUE to create prediction intervals?

    + + +
    separate.groups
    +

    Should there be separate plots for each group.

    + + +
    sample.times
    +

    Should sample times be shown on the plots.

    + + +
    sample.times.IPRED
    +

    Should sample times be shown based on the IPRED y-values.

    + + +
    sample.times.DV
    +

    Should sample times be shown based on the DV y-values.

    + + +
    PRED
    +

    Should a PRED line be drawn.

    + + +
    IPRED
    +

    Should we simulate individual predictions?

    + + +
    IPRED.lines
    +

    Should IPRED lines be drawn?

    + + +
    IPRED.lines.pctls
    +

    Should lines be drawn at the chosen percentiles of the IPRED values?

    + + +
    alpha.IPRED.lines
    +

    What should the transparency for the IPRED.lines be?

    + + +
    alpha.IPRED
    +

    What should the transparency of the IPRED CI?

    + + +
    sample.times.size
    +

    What should the size of the sample.times be?

    + + +
    DV
    +

    should we simulate observations?

    + + +
    alpha.DV
    +

    What should the transparency of the DV CI?

    + + +
    DV.lines
    +

    Should DV lines be drawn?

    + + +
    DV.points
    +

    Should DV points be drawn?

    + + +
    alpha.DV.lines
    +

    What should the transparency for the DV.lines be?

    + + +
    alpha.DV.points
    +

    What should the transparency for the DV.points be?

    + + +
    sample.times.DV.points
    +

    TRUE or FALSE.

    + + +
    sample.times.DV.lines
    +

    TRUE or FALSE.

    + + +
    alpha.sample.times.DV.points
    +

    What should the transparency for the sample.times.DV.points be?

    + + +
    alpha.sample.times.DV.lines
    +

    What should the transparency for the sample.times.DV.lines be?

    + + +
    y_lab
    +

    The label of the y-axis.

    + + +
    facet_scales
    +

    Can be "free", "fixed", "free_x" or "free_y"

    + + +
    facet_label_names
    +

    TRUE or FALSE

    + + +
    model.names
    +

    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.

    + + +
    DV.mean.sd
    +

    Plot the mean and standard deviation of simulated observations.

    + + +
    PI
    +

    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.

    PI_alpha

    The transparency of the PI.

    ...

    Additional arguments passed to the model_prediction function.

    - -

    Value

    - -

    A ggplot object. If you would like to further edit this plot don't -forget to load the ggplot2 library using library(ggplot2).

    -

    See also

    - -

    model_prediction

    +more approximate than using DV=T and groupsize_sim = some large number.

    + + +
    PI_alpha
    +

    The transparency of the PI.

    + + +
    ...
    +

    Additional arguments passed to the model_prediction function.

    + +
    +
    +

    Value

    + + +

    A ggplot object. If you would like to further edit this plot don't +forget to load the ggplot2 library using library(ggplot2).

    +
    +
    +

    See also

    + - -

    Examples

    -
    ## 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: 0x7fe25cadfcb0> -#> <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 model_prediction(poped.db, model_num_points = model_num_points, PI = PI, ...): 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 model_prediction(poped.db, model_num_points = model_num_points, PI = PI, ...): 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 model_prediction(poped.db, model_num_points = model_num_points, PI = PI, ...): 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 model_prediction(poped.db, model_num_points = model_num_points, PI = PI, ...): 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 model_prediction(poped.db, model_num_points = model_num_points, PI = PI, ...): object 'poped.db' not found
    - -
    +plot_efficiency_of_windows()

    +
    + +
    +

    Examples

    +
    ## 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
    +
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/poped.choose.html b/docs/reference/poped.choose.html index d047dd5..932ecba 100644 --- a/docs/reference/poped.choose.html +++ b/docs/reference/poped.choose.html @@ -1,75 +1,12 @@ - - - - - - - -Choose between arg1 and arg2 — poped.choose • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Choose between arg1 and arg2 — poped.choose • PopED - - + + - - -
    -
    - -
    - -
    +
    @@ -150,63 +78,64 @@

    Choose between arg1 and arg2

    Function chooses arg1 unless it is NULL in which case arg2 is chosen.

    -
    poped.choose(arg1, arg2)
    - -

    Arguments

    - - - - - - - - - - -
    arg1

    The first argument

    arg2

    The second argument

    - -

    See also

    - - - -

    Examples

    -
    -poped.choose(2,5) -
    #> [1] 2
    -poped.choose("foo",66) -
    #> [1] "foo"
    -poped.choose(NULL,"hello") -
    #> [1] "hello"
    +
    +
    poped.choose(arg1, arg2)
    +
    + +
    +

    Arguments

    +
    arg1
    +

    The first argument

    + + +
    arg2
    +

    The second argument

    + +
    + + +
    +

    Examples

    +
    
    +poped.choose(2,5)
    +#> [1] 2
    +
    +poped.choose("foo",66)
    +#> [1] "foo"
    +
    +poped.choose(NULL,"hello")
    +#> [1] "hello"
    +
    +
    +
    - - - + + diff --git a/docs/reference/poped_gui.html b/docs/reference/poped_gui.html index cf1b171..250242a 100644 --- a/docs/reference/poped_gui.html +++ b/docs/reference/poped_gui.html @@ -1,75 +1,12 @@ - - - - - - - -Run the graphical interface for PopED — poped_gui • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Run the graphical interface for PopED — poped_gui • PopED + + - - - - -
    -
    - -
    - -
    +
    @@ -150,35 +78,32 @@

    Run the graphical interface for PopED

    Run the graphical interface for PopED

    -
    poped_gui()
    - +
    +
    poped_gui()
    +
    +
    - - - + + diff --git a/docs/reference/poped_optim.html b/docs/reference/poped_optim.html index 4da4569..6ea1aea 100644 --- a/docs/reference/poped_optim.html +++ b/docs/reference/poped_optim.html @@ -1,78 +1,15 @@ - - - - - - - -Optimize a design defined in a PopED database — poped_optim • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Optimize a design defined in a PopED database — poped_optim • PopED - - - - - - - - - - - - - - + + -
    -
    - -
    - -
    +
    @@ -156,89 +84,89 @@

    Optimize a design defined in a PopED database

    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,
    -  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,
    -  ...
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    poped.db

    A PopED database.

    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?

    opt_samps

    Are the number of sample times per group being optimized?

    opt_inds

    Are the number of individuals per group being optimized?

    method

    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.

    control

    Contains control arguments for each method specified.

    trace

    Should the algorithm output results intermittently.

    fim.calc.type

    The method used for calculating the FIM. Potential values:

      -
    • 0 = Full FIM. No assumption that fixed and random effects are uncorrelated.

    • +
      +
      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,
      +  ...
      +)
      +
      + +
      +

      Arguments

      +
      poped.db
      +

      A PopED database.

      + + +
      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?

      + + +
      opt_samps
      +

      Are the number of sample times per group being optimized?

      + + +
      opt_inds
      +

      Are the number of individuals per group being optimized?

      + + +
      method
      +

      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.

      + + +
      control
      +

      Contains control arguments for each method specified.

      + + +
      trace
      +

      Should the algorithm output results intermittently.

      + + +
      fim.calc.type
      +

      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).

      • @@ -249,139 +177,143 @@

        Arg
      • 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_calc_type

    OFV calculation type for FIM

      -
    • 1 = "D-optimality". Determinant of the FIM: det(FIM)

    • +
    + + +
    ofv_calc_type
    +

    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))

    • -
    approx_type

    Approximation method for model, 0=FO, 1=FOCE, 2=FOCEI, 3=FOI.

    d_switch
      -
    • ******START OF CRITERION SPECIFICATION OPTIONS**********

    • -

    D-family design (1) or ED-family design (0) (with or without parameter uncertainty)

    ED_samp_size

    Sample size for E-family sampling

    bLHS

    How to sample from distributions in E-family calculations. 0=Random Sampling, 1=LatinHyperCube --

    use_laplace

    Should the Laplace method be used in calculating the expectation of the OFV?

    out_file

    Save output from the optimization to a file.

    parallel

    Should we use parallel computations?

    parallel_type

    Which type of parallelization should be used? + + + +

    ds_index
    +

    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.

    + + +
    approx_type
    +

    Approximation method for model, 0=FO, 1=FOCE, 2=FOCEI, 3=FOI.

    + + +
    d_switch
    +
    • ******START OF CRITERION SPECIFICATION OPTIONS**********

    • +

    D-family design (1) or ED-family design (0) (with or without parameter uncertainty)

    + + +
    ED_samp_size
    +

    Sample size for E-family sampling

    + + +
    bLHS
    +

    How to sample from distributions in E-family calculations. 0=Random Sampling, 1=LatinHyperCube --

    + + +
    use_laplace
    +

    Should the Laplace method be used in calculating the expectation of the OFV?

    + + +
    out_file
    +

    Save output from the optimization to a file.

    + + +
    parallel
    +

    Should we use parallel computations?

    + + +
    parallel_type
    +

    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.

    num_cores

    The number of cores to use in the parallelization. By default is set to the number +See start_parallel.

    + + +
    num_cores
    +

    The number of cores to use in the parallelization. By default is set to the number output from -parallel::detectCores(). -See start_parallel.

    mrgsolve_model

    If the computations require a mrgsolve model and you +parallel::detectCores(). +See start_parallel.

    + + +
    mrgsolve_model
    +

    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.

    loop_methods

    Should the optimization methods be looped for +object created by mread or mcode.

    + + +
    loop_methods
    +

    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?

    iter_max

    If line search is used then the algorithm tests if line +stop_crit_eff?

    + + +
    iter_max
    +

    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.

    stop_crit_eff

    If loop_methods==TRUE, the looping will stop if the +iteration is run unless iter_max iterations have already been run.

    + + +
    stop_crit_eff
    +

    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).

    stop_crit_diff

    If loop_methods==TRUE, the looping will stop if the +off and the efficiency must be greater than or equal to this value to stop the looping).

    + + +
    stop_crit_diff
    +

    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).

    stop_crit_rel

    If loop_methods==TRUE, the looping will stop if the +off and the difference in criterion value must be greater than or equal to this value to stop the looping).

    + + +
    stop_crit_rel
    +

    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).

    ofv_fun

    User defined function used to compute the objective function. The function must have a poped database object as its first +off and the relative difference in criterion value must be greater than or equal to this value to stop the looping).

    + + +
    ofv_fun
    +

    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.

    maximize

    Should the objective function be maximized or minimized?

    allow_replicates

    Should the algorithm allow optimized design components to have the same value? If FALSE then +e.g. "cost.txt" has a function named "cost" in it.

    + + +
    maximize
    +

    Should the objective function be maximized or minimized?

    + + +
    allow_replicates
    +

    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).

    allow_replicates_xt

    Should the algorithm allow optimized xt design components to have the same value? If FALSE then -all discrete optimizations will not allow replicates.

    allow_replicates_a

    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.

    - -

    Details

    +(equivalent to allow_replicates_xt=FALSE and allow_replicates_a=FALSE).

    + + +
    allow_replicates_xt
    +

    Should the algorithm allow optimized xt design components to have the same value? If FALSE then +all discrete optimizations will not allow replicates.

    + + +
    allow_replicates_a
    +

    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.

    +
    +
    +

    Details

    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 @@ -392,11 +324,11 @@

    Details 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.

    -

    References

    - +
    +
    +

    References

    -
      -
    1. M. Foracchia, A.C. Hooker, P. Vicini and A. +

      1. 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.

      2. J. @@ -404,655 +336,657 @@

        R Hooker, "PopED: An extended, parallelized, nonlinear mixed effects models optimal design tool", Computer Methods and Programs in Biomedicine, 108, 2012.

      3. -
      - -

      See also

      - - - -

      Examples

      -
      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: 0x7fe20a979808> -#> <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.03 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.024 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.524 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.012 seconds. -#> -#> Final OFV = 1.244413 -#> Parameters: 92.68227 -#> -#> ******************************************* -#> Running BFGS Optimization -#> ******************************************* -#> initial value -1.244413 -#> final value -1.252389 -#> stopped after 2 iterations -#> -#> ******************************************* -#> Running Line Search Optimization -#> ******************************************* -#> -#> Initial parameters: 93.27637 -#> Initial OFV: 1.252389 -#> -#> Searching parameter 1 -#> Changed from 93.2764 to 100 ; OFV = 1.34267 -#> -#> Elapsed time: 0.017 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.008 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.018 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.582 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.007 seconds. -#> -#> Final OFV = 0.833124 -#> Parameters: 62.05002 -#> -#> ******************************************* -#> Running BFGS Optimization -#> ******************************************* -#> initial value 0.833124 -#> final value 0.730106 -#> stopped after 2 iterations -#> -#> ******************************************* -#> Running Line Search Optimization -#> ******************************************* -#> -#> Initial parameters: 54.37735 -#> Initial OFV: 0.7301058 -#> -#> Searching parameter 1 -#> Changed from 54.3773 to 0.01 ; OFV = 0.000134267 -#> -#> Elapsed time: 0.023 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.009 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.014 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.669 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) +
    +
    +

    See also

    + +
    - 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))) - -} -
    +
    +

    Examples

    +
    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)))
    +  
    +}
    +
    +
    + - - - + + diff --git a/docs/reference/poped_optim_1.html b/docs/reference/poped_optim_1.html index 67b4799..8423024 100644 --- a/docs/reference/poped_optim_1.html +++ b/docs/reference/poped_optim_1.html @@ -1,93 +1,30 @@ - - - - - - - -Optimization main module for PopED +<!-- Generated by pkgdown: do not edit by hand --><html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Optimization main module for PopED 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_1 • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + -
    -
    - -
    - -
    +
    @@ -179,85 +107,84 @@

    Optimization main module for PopED 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,
    -  ...
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    poped.db

    A PopED database.

    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?

    opt_samps

    Are the number of sample times per group being optimized?

    opt_inds

    Are the number of individuals per group being optimized?

    method

    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.

    control

    Contains control arguments for each method specified.

    trace

    Should the algorithm output results intermittently.

    fim.calc.type

    The method used for calculating the FIM. Potential values:

      -
    • 0 = Full FIM. No assumption that fixed and random effects are uncorrelated.

    • +
      +
      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,
      +  ...
      +)
      +
      + +
      +

      Arguments

      +
      poped.db
      +

      A PopED database.

      + + +
      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?

      + + +
      opt_samps
      +

      Are the number of sample times per group being optimized?

      + + +
      opt_inds
      +

      Are the number of individuals per group being optimized?

      + + +
      method
      +

      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.

      + + +
      control
      +

      Contains control arguments for each method specified.

      + + +
      trace
      +

      Should the algorithm output results intermittently.

      + + +
      fim.calc.type
      +

      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).

      • @@ -268,120 +195,116 @@

        Arg
      • 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_calc_type

    OFV calculation type for FIM

      -
    • 1 = "D-optimality". Determinant of the FIM: det(FIM)

    • +
    + + +
    ofv_calc_type
    +

    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))

    • -
    approx_type

    Approximation method for model, 0=FO, 1=FOCE, 2=FOCEI, 3=FOI.

    d_switch
      -
    • ******START OF CRITERION SPECIFICATION OPTIONS**********

    • -

    D-family design (1) or ED-family design (0) (with or without parameter uncertainty)

    ED_samp_size

    Sample size for E-family sampling

    bLHS

    How to sample from distributions in E-family calculations. 0=Random Sampling, 1=LatinHyperCube --

    use_laplace

    Should the Laplace method be used in calculating the expectation of the OFV?

    out_file

    Save output from the optimization to a file.

    parallel

    Should we use parallel computations?

    parallel_type

    Which type of parallelization should be used? + + + +

    approx_type
    +

    Approximation method for model, 0=FO, 1=FOCE, 2=FOCEI, 3=FOI.

    + + +
    d_switch
    +
    • ******START OF CRITERION SPECIFICATION OPTIONS**********

    • +

    D-family design (1) or ED-family design (0) (with or without parameter uncertainty)

    + + +
    ED_samp_size
    +

    Sample size for E-family sampling

    + + +
    bLHS
    +

    How to sample from distributions in E-family calculations. 0=Random Sampling, 1=LatinHyperCube --

    + + +
    use_laplace
    +

    Should the Laplace method be used in calculating the expectation of the OFV?

    + + +
    out_file
    +

    Save output from the optimization to a file.

    + + +
    parallel
    +

    Should we use parallel computations?

    + + +
    parallel_type
    +

    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.

    num_cores

    The number of cores to use in the parallelization. By default is set to the number +See start_parallel.

    + + +
    num_cores
    +

    The number of cores to use in the parallelization. By default is set to the number output from -parallel::detectCores(). -See start_parallel.

    loop_methods

    Should the optimization methods be looped for +parallel::detectCores(). +See start_parallel.

    + + +
    loop_methods
    +

    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?

    iter_max

    If line search is used then the algorithm tests if line +stop_crit_eff?

    + + +
    iter_max
    +

    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.

    stop_crit_eff

    If loop_methods==TRUE, the looping will stop if the +iteration is run unless iter_max iterations have already been run.

    + + +
    stop_crit_eff
    +

    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).

    stop_crit_diff

    If loop_methods==TRUE, the looping will stop if the +off and the efficiency must be greater than or equal to this value to stop the looping).

    + + +
    stop_crit_diff
    +

    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).

    stop_crit_rel

    If loop_methods==TRUE, the looping will stop if the +off and the difference in criterion value must be greater than or equal to this value to stop the looping).

    + + +
    stop_crit_rel
    +

    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).

    ofv_fun

    User defined function used to compute the objective function. The function must have a poped database object as its first +off and the relative difference in criterion value must be greater than or equal to this value to stop the looping).

    + + +
    ofv_fun
    +

    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.

    maximize

    Should the objective function be maximized or minimized?

    ...

    arguments passed to other functions.

    - -

    References

    +e.g. "cost.txt" has a function named "cost" in it.

    + + +
    maximize
    +

    Should the objective function be maximized or minimized?

    + +
    ...
    +

    arguments passed to other functions.

    + +
    +
    +

    References

    -
      -
    1. M. Foracchia, A.C. Hooker, P. Vicini and A. +

      1. 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.

      2. J. @@ -389,51 +312,47 @@

        R Hooker, "PopED: An extended, parallelized, nonlinear mixed effects models optimal design tool", Computer Methods and Programs in Biomedicine, 108, 2012.

      3. -
      - -

      See also

      - - +
    +
    +

    See also

    + +
    +
    - - - + + diff --git a/docs/reference/poped_optim_2.html b/docs/reference/poped_optim_2.html index 2f821d8..1d33fac 100644 --- a/docs/reference/poped_optim_2.html +++ b/docs/reference/poped_optim_2.html @@ -1,80 +1,17 @@ - - - - - - - -Optimization main module for PopED — poped_optim_2 • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Optimization main module for PopED — poped_optim_2 • PopED - - - - - - - - - - - - - - + + -
    -
    - -
    - -
    +
    @@ -160,86 +88,85 @@

    Optimization main module for PopED

    (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,
    -  ...
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    poped.db

    A PopED database.

    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?

    opt_samps

    Are the number of sample times per group being optimized?

    opt_inds

    Are the number of individuals per group being optimized?

    method

    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.

    control

    Contains control arguments for each method specified.

    trace

    Should the algorithm output results intermittently.

    fim.calc.type

    The method used for calculating the FIM. Potential values:

      -
    • 0 = Full FIM. No assumption that fixed and random effects are uncorrelated.

    • +
      +
      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,
      +  ...
      +)
      +
      + +
      +

      Arguments

      +
      poped.db
      +

      A PopED database.

      + + +
      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?

      + + +
      opt_samps
      +

      Are the number of sample times per group being optimized?

      + + +
      opt_inds
      +

      Are the number of individuals per group being optimized?

      + + +
      method
      +

      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.

      + + +
      control
      +

      Contains control arguments for each method specified.

      + + +
      trace
      +

      Should the algorithm output results intermittently.

      + + +
      fim.calc.type
      +

      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).

      • @@ -250,131 +177,128 @@

        Arg
      • 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_calc_type

    OFV calculation type for FIM

      -
    • 1 = "D-optimality". Determinant of the FIM: det(FIM)

    • +
    + + +
    ofv_calc_type
    +

    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))

    • -
    approx_type

    Approximation method for model, 0=FO, 1=FOCE, 2=FOCEI, 3=FOI.

    d_switch
      -
    • ******START OF CRITERION SPECIFICATION OPTIONS**********

    • -

    D-family design (1) or ED-family design (0) (with or without parameter uncertainty)

    ED_samp_size

    Sample size for E-family sampling

    bLHS

    How to sample from distributions in E-family calculations. 0=Random Sampling, 1=LatinHyperCube --

    use_laplace

    Should the Laplace method be used in calculating the expectation of the OFV?

    out_file

    Save output from the optimization to a file.

    parallel

    Should we use parallel computations?

    parallel_type

    Which type of parallelization should be used? + + + +

    approx_type
    +

    Approximation method for model, 0=FO, 1=FOCE, 2=FOCEI, 3=FOI.

    + + +
    d_switch
    +
    • ******START OF CRITERION SPECIFICATION OPTIONS**********

    • +

    D-family design (1) or ED-family design (0) (with or without parameter uncertainty)

    + + +
    ED_samp_size
    +

    Sample size for E-family sampling

    + + +
    bLHS
    +

    How to sample from distributions in E-family calculations. 0=Random Sampling, 1=LatinHyperCube --

    + + +
    use_laplace
    +

    Should the Laplace method be used in calculating the expectation of the OFV?

    + + +
    out_file
    +

    Save output from the optimization to a file.

    + + +
    parallel
    +

    Should we use parallel computations?

    + + +
    parallel_type
    +

    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.

    num_cores

    The number of cores to use in the parallelization. By default is set to the number +See start_parallel.

    + + +
    num_cores
    +

    The number of cores to use in the parallelization. By default is set to the number output from -parallel::detectCores(). -See start_parallel.

    loop_methods

    Should the optimization methods be looped for +parallel::detectCores(). +See start_parallel.

    + + +
    loop_methods
    +

    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?

    iter_max

    If line search is used then the algorithm tests if line +stop_crit_eff?

    + + +
    iter_max
    +

    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.

    stop_crit_eff

    If loop_methods==TRUE, the looping will stop if the +iteration is run unless iter_max iterations have already been run.

    + + +
    stop_crit_eff
    +

    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).

    stop_crit_diff

    If loop_methods==TRUE, the looping will stop if the +off and the efficiency must be greater than or equal to this value to stop the looping).

    + + +
    stop_crit_diff
    +

    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).

    stop_crit_rel

    If loop_methods==TRUE, the looping will stop if the +off and the difference in criterion value must be greater than or equal to this value to stop the looping).

    + + +
    stop_crit_rel
    +

    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).

    ofv_fun

    User defined function used to compute the objective function. The function must have a poped database object as its first +off and the relative difference in criterion value must be greater than or equal to this value to stop the looping).

    + + +
    ofv_fun
    +

    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.

    maximize

    Should the objective function be maximized or minimized?

    transform_parameters

    Should we transform the parameters before optimization?

    ...

    arguments passed to other functions.

    - -

    Details

    +e.g. "cost.txt" has a function named "cost" in it.

    + +
    maximize
    +

    Should the objective function be maximized or minimized?

    + + +
    transform_parameters
    +

    Should we transform the parameters before optimization?

    + + +
    ...
    +

    arguments passed to other functions.

    + +
    +
    +

    Details

    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.

    -

    References

    - +
    +
    +

    References

    -
      -
    1. M. Foracchia, A.C. Hooker, P. Vicini and A. +

      1. 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.

      2. J. @@ -382,51 +306,47 @@

        R Hooker, "PopED: An extended, parallelized, nonlinear mixed effects models optimal design tool", Computer Methods and Programs in Biomedicine, 108, 2012.

      3. -
      - -

      See also

      - - +
    +
    +

    See also

    + +
    +
    - - - + + diff --git a/docs/reference/poped_optim_3.html b/docs/reference/poped_optim_3.html index e42697d..b08cad3 100644 --- a/docs/reference/poped_optim_3.html +++ b/docs/reference/poped_optim_3.html @@ -1,80 +1,17 @@ - - - - - - - -Optimization main module for PopED — poped_optim_3 • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Optimization main module for PopED — poped_optim_3 • PopED - - - - - - - - - - - - - - + + -
    -
    - -
    - -
    +
    @@ -160,89 +88,89 @@

    Optimization main module for PopED

    (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,
    -  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,
    -  ...
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    poped.db

    A PopED database.

    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?

    opt_samps

    Are the number of sample times per group being optimized?

    opt_inds

    Are the number of individuals per group being optimized?

    method

    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.

    control

    Contains control arguments specified for each method separately.

    trace

    Should the algorithm output results intermittently.

    fim.calc.type

    The method used for calculating the FIM. Potential values:

      -
    • 0 = Full FIM. No assumption that fixed and random effects are uncorrelated.

    • +
      +
      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,
      +  ...
      +)
      +
      + +
      +

      Arguments

      +
      poped.db
      +

      A PopED database.

      + + +
      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?

      + + +
      opt_samps
      +

      Are the number of sample times per group being optimized?

      + + +
      opt_inds
      +

      Are the number of individuals per group being optimized?

      + + +
      method
      +

      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.

      + + +
      control
      +

      Contains control arguments specified for each method separately.

      + + +
      trace
      +

      Should the algorithm output results intermittently.

      + + +
      fim.calc.type
      +

      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).

      • @@ -253,131 +181,135 @@

        Arg
      • 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_calc_type

    OFV calculation type for FIM

      -
    • 1 = "D-optimality". Determinant of the FIM: det(FIM)

    • +
    + + +
    ofv_calc_type
    +

    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))

    • -
    approx_type

    Approximation method for model, 0=FO, 1=FOCE, 2=FOCEI, 3=FOI.

    d_switch
      -
    • ******START OF CRITERION SPECIFICATION OPTIONS**********

    • -

    D-family design (1) or ED-family design (0) (with or without parameter uncertainty)

    ED_samp_size

    Sample size for E-family sampling

    bLHS

    How to sample from distributions in E-family calculations. 0=Random Sampling, 1=LatinHyperCube --

    use_laplace

    Should the Laplace method be used in calculating the expectation of the OFV?

    out_file

    Save output from the optimization to a file.

    parallel

    Should we use parallel computations?

    parallel_type

    Which type of parallelization should be used? + + + +

    ds_index
    +

    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.

    + + +
    approx_type
    +

    Approximation method for model, 0=FO, 1=FOCE, 2=FOCEI, 3=FOI.

    + + +
    d_switch
    +
    • ******START OF CRITERION SPECIFICATION OPTIONS**********

    • +

    D-family design (1) or ED-family design (0) (with or without parameter uncertainty)

    + + +
    ED_samp_size
    +

    Sample size for E-family sampling

    + + +
    bLHS
    +

    How to sample from distributions in E-family calculations. 0=Random Sampling, 1=LatinHyperCube --

    + + +
    use_laplace
    +

    Should the Laplace method be used in calculating the expectation of the OFV?

    + + +
    out_file
    +

    Save output from the optimization to a file.

    + + +
    parallel
    +

    Should we use parallel computations?

    + + +
    parallel_type
    +

    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.

    num_cores

    The number of cores to use in the parallelization. By default is set to the number +See start_parallel.

    + + +
    num_cores
    +

    The number of cores to use in the parallelization. By default is set to the number output from -parallel::detectCores(). -See start_parallel.

    loop_methods

    Should the optimization methods be looped for +parallel::detectCores(). +See start_parallel.

    + + +
    loop_methods
    +

    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?

    iter_max

    If line search is used then the algorithm tests if line +stop_crit_eff?

    + + +
    iter_max
    +

    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.

    stop_crit_eff

    If loop_methods==TRUE, the looping will stop if the +iteration is run unless iter_max iterations have already been run.

    + + +
    stop_crit_eff
    +

    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).

    stop_crit_diff

    If loop_methods==TRUE, the looping will stop if the +off and the efficiency must be greater than or equal to this value to stop the looping).

    + + +
    stop_crit_diff
    +

    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).

    stop_crit_rel

    If loop_methods==TRUE, the looping will stop if the +off and the difference in criterion value must be greater than or equal to this value to stop the looping).

    + + +
    stop_crit_rel
    +

    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).

    ofv_fun

    User defined function used to compute the objective function. The function must have a poped database object as its first +off and the relative difference in criterion value must be greater than or equal to this value to stop the looping).

    + + +
    ofv_fun
    +

    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.

    maximize

    Should the objective function be maximized or minimized?

    allow_replicates

    Should the algorithm allow parameters to have the same value?

    ...

    arguments passed to other functions.

    - -

    Details

    +e.g. "cost.txt" has a function named "cost" in it.

    + +
    maximize
    +

    Should the objective function be maximized or minimized?

    + + +
    allow_replicates
    +

    Should the algorithm allow parameters to have the same value?

    + + +
    ...
    +

    arguments passed to other functions.

    + +
    +
    +

    Details

    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.

    -

    References

    - +
    +
    +

    References

    -
      -
    1. M. Foracchia, A.C. Hooker, P. Vicini and A. +

      1. 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.

      2. J. @@ -385,51 +317,47 @@

        R Hooker, "PopED: An extended, parallelized, nonlinear mixed effects models optimal design tool", Computer Methods and Programs in Biomedicine, 108, 2012.

      3. -
      - -

      See also

      - - +
    +
    +

    See also

    + +
    +
    - - - + + diff --git a/docs/reference/poped_optimize.html b/docs/reference/poped_optimize.html index 1da3f72..d10c780 100644 --- a/docs/reference/poped_optimize.html +++ b/docs/reference/poped_optimize.html @@ -1,76 +1,13 @@ - - - - - - - -Retired optimization module for PopED — poped_optimize • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Retired optimization module for PopED — poped_optimize • PopED - - - - + + -
    -
    - -
    - -
    +
    -

    This function is an older version of poped_optim. Please use 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,
    -  ...
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    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.

    bpop

    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, +

      +
      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,
      +  ...
      +)
      +
      + +
      +

      Arguments

      +
      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.

      + + +
      bpop
      +

      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 +

    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.

    d

    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(). +arguments in 'bpop' then the order will be worked out automatically.

    + + +
    d
    +

    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.

    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 initial 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?

    opt_samps

    Are the number of sample times per group being optimized?

    opt_inds

    Are the number of individuals per group being 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:

      -
    • 0 = Full FIM. No assumption that fixed and random effects are uncorrelated.

    • +arguments in 'd' then the order will be worked out automatically.

      + + +
      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 initial 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?

      + + +
      opt_samps
      +

      Are the number of sample times per group being optimized?

      + + +
      opt_inds
      +

      Are the number of individuals per group being 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:

      • 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).

      • @@ -316,426 +242,423 @@

        Arg
      • 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_calc_type

    OFV calculation type for FIM

      -
    • 1 = "D-optimality". Determinant of the FIM: det(FIM)

    • +
    + + +
    ofv_calc_type
    +

    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))

    • -
    approx_type

    Approximation method for model, 0=FO, 1=FOCE, 2=FOCEI, 3=FOI.

    bUseExchangeAlgorithm

    Use Exchange algorithm (1=TRUE, 0=FALSE)

    iter

    The number of iterations entered into the blockheader_2 function.

    d_switch
      -
    • ******START OF CRITERION SPECIFICATION OPTIONS**********

    • -

    D-family design (1) or ED-family design (0) (with or without parameter uncertainty)

    ED_samp_size

    Sample size for E-family sampling

    bLHS

    How to sample from distributions in E-family calculations. 0=Random Sampling, 1=LatinHyperCube --

    use_laplace

    Should the Laplace method be used in calculating the expectation of the OFV?

    ...

    arguments passed to other functions. See Doptim.

    - -

    Details

    + + + +
    approx_type
    +

    Approximation method for model, 0=FO, 1=FOCE, 2=FOCEI, 3=FOI.

    + + +
    bUseExchangeAlgorithm
    +

    Use Exchange algorithm (1=TRUE, 0=FALSE)

    + + +
    iter
    +

    The number of iterations entered into the blockheader_2 function.

    + + +
    d_switch
    +
    • ******START OF CRITERION SPECIFICATION OPTIONS**********

    • +

    D-family design (1) or ED-family design (0) (with or without parameter uncertainty)

    + +
    ED_samp_size
    +

    Sample size for E-family sampling

    + + +
    bLHS
    +

    How to sample from distributions in E-family calculations. 0=Random Sampling, 1=LatinHyperCube --

    + + +
    use_laplace
    +

    Should the Laplace method be used in calculating the expectation of the OFV?

    + + +
    ...
    +

    arguments passed to other functions. See Doptim.

    + +
    +
    +

    Details

    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.

    -

    References

    - +
    +
    +

    References

    -
      -
    1. M. Foracchia, A.C. Hooker, P. Vicini and A. Ruggeri, "PopED, a software fir optimal +

      1. 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.

      2. 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.

      3. -
      - -

      See also

      - - - -

      Examples

      -
      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: 0x7fe20a979808> -#> <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.02 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.00262406222188805 -#> -0.000132029318557143 -#> 0.00495629130901136 -#> -0.000109895323235429 -#> -0.000341253277398965 -#> 2.72641241963075e-05 -#> 0.000160460619480128 -#> 3.06136916146239e-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.312884e-04 -#> aopt: -#> 7.024140e+01 -#> OFV(mf) : 55.6095 -#> diff : 0.00279928 -#> ************************************************************* -#> Stochastic gradient run time: 0.463 seconds -#> -#> ***************************** -#> Line Search -#> -#> Searching xt5 on group 1 -#> group 1 -- xt[5] changed from 23.7103 to 120 -#> OFV(MF) changed from 55.6095 to 55.6533 -#> Searching xt2 on group 1 -#> Searching xt7 on group 1 -#> group 1 -- xt[7] changed from 72.2897 to 120 -#> OFV(MF) changed from 55.6533 to 55.7007 -#> Searching xt4 on group 1 -#> Searching xt8 on group 1 -#> Searching xt3 on group 1 -#> Searching xt6 on group 1 -#> Searching xt1 on group 1 -#> group 1 -- xt[1] changed from 0.210319 to 0.01 -#> OFV(MF) changed from 55.7007 to 55.7289 -#> group 1 -- xt[1] changed from 0.01 to 60.005 -#> OFV(MF) changed from 55.7289 to 55.742 -#> group 1 -- xt[1] changed from 60.005 to 120 -#> OFV(MF) changed from 55.742 to 55.8146 -#> OFV(MF): 55.8146 -#> -#> Best value for OFV(MF) = 55.8146 -#> -#> Best value for xt: -#> Group 1: 0.9503 2.29 5.71 36.29 120 120 120 120 -#> -#> Searching a1 on individual/group 1 -#> group 1 -- a[1] changed from 70.2414 to 100 -#> OFV(MF) changed from 55.8146 to 56.5866 -#> OFV(MF): 56.5866 -#> Best value for OFV(MF) = 56.5866 -#> -#> Best value for a: -#> Group 1: 100 [0.01,100] -#> -#> -#> Line search run time: 0.367 seconds -#> *************************** -#> -#> =============================================================================== -#> FINAL RESULTS -#> Optimized Sampling Schedule -#> Group 1: 0.9503 2.29 5.71 36.29 120 120 120 120 -#> -#> Optimized Covariates: -#> Group 1: 100 -#> -#> OFV = 56.5866 -#> -#> Efficiency: -#> ((exp(ofv_final) / exp(ofv_init))^(1/n_parameters)) = 1.1604 -#> -#> 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 35 -#> d_KA 0.6 0 0 -#> sig_prop 0.01 32 25 -#> sig_add 0.25 26 16 -#> -#> Total running time: 0.853 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) - - -} -
      +
    +
    +

    See also

    + +
    + +
    +

    Examples

    +
    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)
    +  
    +  
    +}
    +
    +
    +
    - - - + + diff --git a/docs/reference/rand.html b/docs/reference/rand.html index a132b7a..18b2ae5 100644 --- a/docs/reference/rand.html +++ b/docs/reference/rand.html @@ -1,75 +1,12 @@ - - - - - - - -Function written to match MATLAB's rand function — rand • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Function written to match MATLAB's rand function — rand • PopED + + - - - - -
    -
    - -
    - -
    +
    @@ -150,77 +78,80 @@

    Function written to match MATLAB's rand function

    Generate random samples from a uniform distribution [0,1] and return in matrix form

    -
    rand(dim1, dim2 = NULL)
    - -

    Arguments

    - - - - - - - - - - -
    dim1

    The dimension of the matrix (if square), otherwise the number of rows.

    dim2

    The number of columns, if different from the number of rows.

    - -

    Value

    - -

    Matrix of random generated samples.

    -

    See also

    - -

    Other MATLAB: -cell(), -diag_matlab(), -feval(), -fileparts(), -isempty(), -ones(), -randn(), -size(), -tic(), -toc(), -zeros()

    - -

    Examples

    -
    -rand(2,3) -
    #> [,1] [,2] [,3] -#> [1,] 0.4439026 0.2914748 0.2586957 -#> [2,] 0.4247310 0.3254103 0.5499438
    -rand(5) -
    #> [,1] [,2] [,3] [,4] [,5] -#> [1,] 0.9469163 0.2400191 0.7638355 0.20230708 0.69384319 -#> [2,] 0.1673143 0.7310202 0.3757153 0.57494827 0.66557678 -#> [3,] 0.4020192 0.5915827 0.3663031 0.03598259 0.06027171 -#> [4,] 0.2654931 0.7119258 0.8858246 0.45258304 0.41472746 -#> [5,] 0.9242550 0.3142227 0.9434154 0.28693224 0.53305555
    +
    +
    rand(dim1, dim2 = NULL)
    +
    + +
    +

    Arguments

    +
    dim1
    +

    The dimension of the matrix (if square), otherwise the number of rows.

    + + +
    dim2
    +

    The number of columns, if different from the number of rows.

    + +
    +
    +

    Value

    + + +

    Matrix of random generated samples.

    +
    +
    +

    See also

    +

    Other MATLAB: +cell(), +diag_matlab(), +feval(), +fileparts(), +isempty(), +ones(), +randn(), +size(), +tic(), +toc(), +zeros()

    +
    + +
    +

    Examples

    +
    
    +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
    +
    +
    +
    - - - + + diff --git a/docs/reference/randn.html b/docs/reference/randn.html index 58e253e..8b738e9 100644 --- a/docs/reference/randn.html +++ b/docs/reference/randn.html @@ -1,75 +1,12 @@ - - - - - - - -Function written to match MATLAB's randn function — randn • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Function written to match MATLAB's randn function — randn • PopED + + - - - - -
    -
    - -
    - -
    +
    @@ -150,77 +78,80 @@

    Function written to match MATLAB's randn function

    Generate random samples from a standardized normal distribution and return in matrix form.

    -
    randn(dim1, dim2 = NULL)
    - -

    Arguments

    - - - - - - - - - - -
    dim1

    The dimension of the matrix (if square), otherwise the number of rows.

    dim2

    The number of columns, if different from the number of rows.

    - -

    Value

    - -

    Matrix of random generated samples.

    -

    See also

    - -

    Other MATLAB: -cell(), -diag_matlab(), -feval(), -fileparts(), -isempty(), -ones(), -rand(), -size(), -tic(), -toc(), -zeros()

    - -

    Examples

    -
    -randn(2,3) -
    #> [,1] [,2] [,3] -#> [1,] 0.9712144 1.0130774 0.1491799 -#> [2,] 0.4875448 0.1479461 -1.3667303
    -randn(5) -
    #> [,1] [,2] [,3] [,4] [,5] -#> [1,] -0.333643126 -1.28105576 -0.08062677 -2.3971761 -1.6036518 -#> [2,] -1.014570302 -0.06340291 1.04803150 0.8896998 2.0915851 -#> [3,] 0.072088985 -1.01810795 -0.78249267 -0.2160804 -0.4684677 -#> [4,] -0.005091017 0.20862835 0.58510806 -1.2907941 0.8625832 -#> [5,] -0.359382124 -0.19491085 -1.89262569 -0.5540628 -0.7404393
    +
    +
    randn(dim1, dim2 = NULL)
    +
    + +
    +

    Arguments

    +
    dim1
    +

    The dimension of the matrix (if square), otherwise the number of rows.

    + + +
    dim2
    +

    The number of columns, if different from the number of rows.

    + +
    +
    +

    Value

    + + +

    Matrix of random generated samples.

    +
    +
    +

    See also

    +

    Other MATLAB: +cell(), +diag_matlab(), +feval(), +fileparts(), +isempty(), +ones(), +rand(), +size(), +tic(), +toc(), +zeros()

    +
    + +
    +

    Examples

    +
    
    +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
    +
    +
    +
    - - - + + diff --git a/docs/reference/shrinkage.html b/docs/reference/shrinkage.html index 4c6f34d..0363feb 100644 --- a/docs/reference/shrinkage.html +++ b/docs/reference/shrinkage.html @@ -1,75 +1,12 @@ - - - - - - - -Predict shrinkage of empirical Bayes estimates (EBEs) in a population model — shrinkage • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Predict shrinkage of empirical Bayes estimates (EBEs) in a population model — shrinkage • PopED - - - - + + -
    -
    - -
    - -
    +
    @@ -150,143 +78,143 @@

    Predict shrinkage of empirical Bayes estimates (EBEs) in a population model<

    Predict shrinkage of empirical Bayes estimates (EBEs) in a population model

    -
    shrinkage(poped.db, use_mc = FALSE, num_sim_ids = 1000, use_purrr = FALSE)
    +
    +
    shrinkage(poped.db, use_mc = FALSE, num_sim_ids = 1000, use_purrr = FALSE)
    +
    + +
    +

    Arguments

    +
    poped.db
    +

    A PopED database

    -

    Arguments

    - - - - - - - - - - - - - - - - - - -
    poped.db

    A PopED database

    use_mc

    Should the calculation be based on monte-carlo simulations. If -not then then a first order approximation is used

    num_sim_ids

    If use_mc=TRUE, how many individuals should be -simulated to make the computations.

    use_purrr

    If use_mc=TRUE then should the method use the package -purrr in calculations? This may speed up computations (potentially).

    -

    Value

    +
    use_mc
    +

    Should the calculation be based on monte-carlo simulations. If +not then then a first order approximation is used

    -

    The shrinkage computed in variance units, standard deviation units - and the relative standard errors of the EBEs.

    -

    References

    +
    num_sim_ids
    +

    If use_mc=TRUE, how many individuals should be +simulated to make the computations.

    + + +
    use_purrr
    +

    If use_mc=TRUE then should the method use the package +purrr in calculations? This may speed up computations (potentially).

    + +
    +
    +

    Value

    + + +

    The shrinkage computed in variance units, standard deviation units + and the relative standard errors of the EBEs.

    +
    +
    +

    References

    -
      -
    1. Combes, F. P., Retout, S., +

      1. 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 + 2355-67. doi:10.1007/s11095-013-1079-3 .

      2. 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 + doi:10.1177/0091270010397731 .

      3. -
      - - -

      Examples

      -
      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: 0x7fe20a979808> -#> <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 x 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
      - -
      +
    + +
    +

    Examples

    +
    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
    +
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/size.html b/docs/reference/size.html index 2feb39d..a9b3e09 100644 --- a/docs/reference/size.html +++ b/docs/reference/size.html @@ -1,75 +1,12 @@ - - - - - - - -Function written to match MATLAB's size function — size • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Function written to match MATLAB's size function — size • PopED + + - - - - -
    -
    - -
    - -
    +
    @@ -150,73 +78,77 @@

    Function written to match MATLAB's size function

    Function written to match MATLAB's size function

    -
    size(obj, dimension.index = NULL)
    - -

    Arguments

    - - - - - - - - - - -
    obj

    An object you want to know the various dimensions of. Typically a matrix.

    dimension.index

    Which dimension you are interested in.

    - -

    Value

    - -

    The dimensions of the object or specific dimension you are interested in.

    -

    See also

    - -

    Other MATLAB: -cell(), -diag_matlab(), -feval(), -fileparts(), -isempty(), -ones(), -randn(), -rand(), -tic(), -toc(), -zeros()

    - -

    Examples

    -
    -size(c(2,3,4,5,6)) -
    #> [1] 1 5
    -size(10) -
    #> [1] 1 1
    -size(zeros(4,7)) -
    #> [1] 4 7
    -
    +
    +
    size(obj, dimension.index = NULL)
    +
    + +
    +

    Arguments

    +
    obj
    +

    An object you want to know the various dimensions of. Typically a matrix.

    + + +
    dimension.index
    +

    Which dimension you are interested in.

    + +
    +
    +

    Value

    + + +

    The dimensions of the object or specific dimension you are interested in.

    +
    +
    +

    See also

    +

    Other MATLAB: +cell(), +diag_matlab(), +feval(), +fileparts(), +isempty(), +ones(), +randn(), +rand(), +tic(), +toc(), +zeros()

    +
    + +
    +

    Examples

    +
    
    +size(c(2,3,4,5,6))
    +#> [1] 1 5
    +
    +size(10)
    +#> [1] 1 1
    +
    +size(zeros(4,7))
    +#> [1] 4 7
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/start_parallel.html b/docs/reference/start_parallel.html index bfe5917..cd4fb74 100644 --- a/docs/reference/start_parallel.html +++ b/docs/reference/start_parallel.html @@ -1,77 +1,14 @@ - - - - - - - -Start parallel computational processes — start_parallel • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Start parallel computational processes — start_parallel • PopED - - + + - - -
    -
    - -
    - -
    +
    @@ -154,86 +82,84 @@

    Start parallel computational processes

    systems the default is "multicore"

    -
    start_parallel(
    -  parallel = TRUE,
    -  num_cores = NULL,
    -  parallel_type = NULL,
    -  seed = NULL,
    -  dlls = NULL,
    -  mrgsolve_model = NULL,
    -  ...
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    parallel

    Should the parallel functionality start up?

    num_cores

    How many cores to use. Default is -parallel::detectCores(). See detectCores for more information.

    parallel_type

    Which type of parallelization should be used? Can be +

    +
    start_parallel(
    +  parallel = TRUE,
    +  num_cores = NULL,
    +  parallel_type = NULL,
    +  seed = NULL,
    +  dlls = NULL,
    +  mrgsolve_model = NULL,
    +  ...
    +)
    +
    + +
    +

    Arguments

    +
    parallel
    +

    Should the parallel functionality start up?

    + + +
    num_cores
    +

    How many cores to use. Default is +parallel::detectCores(). See detectCores for more information.

    + + +
    parallel_type
    +

    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.

    seed

    The random seed to use.

    dlls

    If the computations require compiled code (DLL's) and you are +for you depending on your operating system.

    + + +
    seed
    +

    The random seed to use.

    + + +
    dlls
    +

    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").

    mrgsolve_model

    If the computations require a mrgsolve model and you +the extension as a text vector c("this_file","that_file").

    + + +
    mrgsolve_model
    +

    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

    +object created by mread or mcode

    -

    Value

    -

    An atomic vector (TRUE or FALSE) with two attributes: "type" and "cores".

    +
    ...
    +

    Arguments passed to makeCluster

    + +
    +
    +

    Value

    + + +

    An atomic vector (TRUE or FALSE) with two attributes: "type" and "cores".

    +
    +
    - - - + + diff --git a/docs/reference/summary.poped_optim.html b/docs/reference/summary.poped_optim.html index 0d77e84..0edc839 100644 --- a/docs/reference/summary.poped_optim.html +++ b/docs/reference/summary.poped_optim.html @@ -1,75 +1,12 @@ - - - - - - - -Display a summary of output from poped_optim — summary.poped_optim • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Display a summary of output from poped_optim — summary.poped_optim • PopED - - + + - - -
    -
    - -
    - -
    +
    @@ -150,245 +78,245 @@

    Display a summary of output from poped_optim

    Display a summary of output from poped_optim

    -
    # S3 method for poped_optim
    -summary(object, ...)
    - -

    Arguments

    - - - - - - - - - - -
    object

    An object returned from poped_optim to summarize.

    ...

    Additional arguments. Passed to blockfinal.

    - - -

    Examples

    -
    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: 0x7fe20a979808> -#> <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.018 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.031 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.399 seconds
    +
    +
    # S3 method for poped_optim
    +summary(object, ...)
    +
    -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.399 seconds
    +
    +

    Arguments

    +
    object
    +

    An object returned from poped_optim to summarize.

    + + +
    ...
    +

    Additional arguments. Passed to blockfinal.

    + +
    + +
    +

    Examples

    +
    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
    +
    +
    +
    - - - + + diff --git a/docs/reference/test_mat_size.html b/docs/reference/test_mat_size.html index b17acb2..67944ef 100644 --- a/docs/reference/test_mat_size.html +++ b/docs/reference/test_mat_size.html @@ -1,75 +1,12 @@ - - - - - - - -Test to make sure that matricies are the right size — test_mat_size • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Test to make sure that matricies are the right size — test_mat_size • PopED - + + - - - -
    -
    - -
    - -
    +
    @@ -150,64 +78,63 @@

    Test to make sure that matricies are the right size

    Test to make sure that matricies are the right size

    -
    test_mat_size(correct_size, mat, name)
    - -

    Arguments

    - - - - - - - - - - - - - - -
    correct_size

    the correct size of a matrix

    mat

    The matrix to test.

    name

    The name of the matrix as a string.

    - - -

    Examples

    -
    -test_mat_size(c(2,3),zeros(2,3),"foo") -
    #> [1] 1
    -if (FALSE) { - test_mat_size(c(2,3),zeros(2,6),"foo") -} - -test_mat_size(c(1,3),c(2,6,7),"foo") -
    #> [1] 1
    - - -
    +
    +
    test_mat_size(correct_size, mat, name)
    +
    + +
    +

    Arguments

    +
    correct_size
    +

    the correct size of a matrix

    + + +
    mat
    +

    The matrix to test.

    + + +
    name
    +

    The name of the matrix as a string.

    + +
    + +
    +

    Examples

    +
    
    +test_mat_size(c(2,3),zeros(2,3),"foo")
    +#> [1] 1
    +
    +if (FALSE) {
    +  test_mat_size(c(2,3),zeros(2,6),"foo")
    +}
    +
    +test_mat_size(c(1,3),c(2,6,7),"foo")
    +#> [1] 1
    +
    +
    +
    +
    +
    +
    - - - + + diff --git a/docs/reference/tic.html b/docs/reference/tic.html index c240025..03cac89 100644 --- a/docs/reference/tic.html +++ b/docs/reference/tic.html @@ -1,75 +1,12 @@ - - - - - - - -Timer function (as in MATLAB) — tic • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Timer function (as in MATLAB) — tic • PopED - - - - + + -
    -
    - -
    - -
    +
    @@ -150,77 +78,81 @@

    Timer function (as in MATLAB)

    Function to start a timer. Stop with toc().

    -
    tic(gcFirst = FALSE, name = ".poped_savedTime")
    +
    +
    tic(gcFirst = FALSE, name = ".poped_savedTime")
    +
    + +
    +

    Arguments

    +
    gcFirst
    +

    Perform garbage collection?

    -

    Arguments

    - - - - - - - - - - -
    gcFirst

    Perform garbage collection?

    name

    The saved name of the time object.

    -

    Note

    +
    name
    +

    The saved name of the time object.

    +
    +
    +

    Note

    This is a modified version of the same function in the matlab R-package.

    -

    See also

    - -

    Other MATLAB: -cell(), -diag_matlab(), -feval(), -fileparts(), -isempty(), -ones(), -randn(), -rand(), -size(), -toc(), -zeros()

    - -

    Examples

    -
    -tic() -toc() -
    #> Elapsed time: 0 seconds.
    -tic(name="foo") -toc() -
    #> Elapsed time: 0.002 seconds.
    tic() -toc() -
    #> Elapsed time: 0.001 seconds.
    toc() -
    #> Elapsed time: 0.001 seconds.
    tic() -toc(name="foo") -
    #> Elapsed time: 0.003 seconds.
    +
    +
    +

    See also

    +

    Other MATLAB: +cell(), +diag_matlab(), +feval(), +fileparts(), +isempty(), +ones(), +randn(), +rand(), +size(), +toc(), +zeros()

    +
    + +
    +

    Examples

    +
    
    +tic()
    +toc()
    +#> Elapsed time: 0 seconds.
    +
    +tic(name="foo")
    +toc()
    +#> Elapsed time: 0.001 seconds.
    +tic()
    +toc()
    +#> Elapsed time: 0 seconds.
    +toc()
    +#> Elapsed time: 0.001 seconds.
    +tic()
    +toc(name="foo")
    +#> Elapsed time: 0.003 seconds.
    +
    +
    +
    - - - + + diff --git a/docs/reference/toc.html b/docs/reference/toc.html index 8ffa6f1..505677b 100644 --- a/docs/reference/toc.html +++ b/docs/reference/toc.html @@ -1,75 +1,12 @@ - - - - - - - -Timer function (as in MATLAB) — toc • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Timer function (as in MATLAB) — toc • PopED - - - - + + -
    -
    - -
    - -
    +
    @@ -150,77 +78,81 @@

    Timer function (as in MATLAB)

    Function to stop a timer. Start with tic().

    -
    toc(echo = TRUE, name = ".poped_savedTime")
    +
    +
    toc(echo = TRUE, name = ".poped_savedTime")
    +
    + +
    +

    Arguments

    +
    echo
    +

    Print time to screen?

    -

    Arguments

    - - - - - - - - - - -
    echo

    Print time to screen?

    name

    The saved name of the time object.

    -

    Note

    +
    name
    +

    The saved name of the time object.

    +
    +
    +

    Note

    This is a modified version of the same function in the matlab R-package.

    -

    See also

    - -

    Other MATLAB: -cell(), -diag_matlab(), -feval(), -fileparts(), -isempty(), -ones(), -randn(), -rand(), -size(), -tic(), -zeros()

    - -

    Examples

    -
    -tic() -toc() -
    #> Elapsed time: 0.001 seconds.
    -tic(name="foo") -toc() -
    #> Elapsed time: 0.003 seconds.
    tic() -toc() -
    #> Elapsed time: 0.001 seconds.
    toc() -
    #> Elapsed time: 0.002 seconds.
    tic() -toc(name="foo") -
    #> Elapsed time: 0.006 seconds.
    +
    +
    +

    See also

    +

    Other MATLAB: +cell(), +diag_matlab(), +feval(), +fileparts(), +isempty(), +ones(), +randn(), +rand(), +size(), +tic(), +zeros()

    +
    + +
    +

    Examples

    +
    
    +tic()
    +toc()
    +#> Elapsed time: 0 seconds.
    +
    +tic(name="foo")
    +toc()
    +#> Elapsed time: 0.001 seconds.
    +tic()
    +toc()
    +#> Elapsed time: 0 seconds.
    +toc()
    +#> Elapsed time: 0 seconds.
    +tic()
    +toc(name="foo")
    +#> Elapsed time: 0.002 seconds.
    +
    +
    +
    - - - + + diff --git a/docs/reference/tryCatch.W.E.html b/docs/reference/tryCatch.W.E.html index 80759b6..aa416c6 100644 --- a/docs/reference/tryCatch.W.E.html +++ b/docs/reference/tryCatch.W.E.html @@ -1,76 +1,13 @@ - - - - - - - -tryCatch both warnings (with value) and errors — tryCatch.W.E • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -tryCatch both warnings (with value) and errors — tryCatch.W.E • PopED - + + - - - -
    -
    - -
    - -
    +
    @@ -152,50 +80,49 @@

    tryCatch both warnings (with value) and errors

    a warning, also keep the computed result.

    -
    tryCatch.W.E(expr)
    +
    +
    tryCatch.W.E(expr)
    +
    -

    Arguments

    - - - - - - -
    expr

    an R expression to evaluate

    +
    +

    Arguments

    +
    expr
    +

    an R expression to evaluate

    -

    Value

    +
    +
    +

    Value

    + -

    a list with 'value' and 'warning', where +

    a list with 'value' and 'warning', where 'value' may be an error caught.

    -

    Author

    - +
    +
    +

    Author

    Martin Maechler, The R Core Team

    +
    +
    - - - + + diff --git a/docs/reference/zeros.html b/docs/reference/zeros.html index 6f846ed..b7ae253 100644 --- a/docs/reference/zeros.html +++ b/docs/reference/zeros.html @@ -1,75 +1,12 @@ - - - - - - - -Create a matrix of zeros. — zeros • PopED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Create a matrix of zeros. — zeros • PopED + + - - - - -
    -
    - -
    - -
    +
    @@ -150,79 +78,84 @@

    Create a matrix of zeros.

    Create a matrix of zeros of size (dim1 x dim2).

    -
    zeros(dim1, dim2 = NULL)
    - -

    Arguments

    - - - - - - - - - - -
    dim1

    The dimension of the matrix (if square) or the number of rows.

    dim2

    The number of columns

    - -

    Value

    - -

    A matrix of zeros.

    -

    See also

    - -

    Other MATLAB: -cell(), -diag_matlab(), -feval(), -fileparts(), -isempty(), -ones(), -randn(), -rand(), -size(), -tic(), -toc()

    - -

    Examples

    -
    -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
    +
    +
    zeros(dim1, dim2 = NULL)
    +
    + +
    +

    Arguments

    +
    dim1
    +

    The dimension of the matrix (if square) or the number of rows.

    + + +
    dim2
    +

    The number of columns

    + +
    +
    +

    Value

    + + +

    A matrix of zeros.

    +
    +
    +

    See also

    +

    Other MATLAB: +cell(), +diag_matlab(), +feval(), +fileparts(), +isempty(), +ones(), +randn(), +rand(), +size(), +tic(), +toc()

    +
    + +
    +

    Examples

    +
    
    +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
    +
    +
    +
    - - - + + diff --git a/vignettes/articles/model_def_other_pkgs.Rmd b/vignettes/articles/model_def_other_pkgs.Rmd index e945c19..27b382a 100644 --- a/vignettes/articles/model_def_other_pkgs.Rmd +++ b/vignettes/articles/model_def_other_pkgs.Rmd @@ -15,10 +15,6 @@ output: #fig_height: 5 #bibliography: ["blq.bib"] #biblio-style: "apalike" -vignette: > - %\VignetteIndexEntry{Defining models for PopED using R based PKPD simulators} - %\VignetteEngine{knitr::rmarkdown} - %\VignetteEncoding{UTF-8} link-citations: true editor_options: chunk_output_type: console