tic()
toc()
-#> Elapsed time: 0.001 seconds.
+#> Elapsed time: 0 seconds.
tic(name="foo")
toc()
#> Elapsed time: 0.002 seconds.
tic()
toc()
-#> Elapsed time: 0.001 seconds.
+#> Elapsed time: 0 seconds.
toc()
#> Elapsed time: 0.001 seconds.
tic()
diff --git a/search.json b/search.json
index f97c9e4..967d818 100644
--- a/search.json
+++ b/search.json
@@ -1 +1 @@
-[{"path":"https://andrewhooker.github.io/PopED/articles/examples.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Examples","text":"vignette, try highlight PopED features may useful. code related specific features like highlight described vignette. features () presented r-scripts “examples” folder PopED installation directory. can view list example files using commands: can open one examples (example, ex.1..PK.1.comp.oral.md.intro.R) using following code table provides check list features 15 available examples. Note: features available PopED demonstrated supplied examples.","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] \"one_comp_oral_CL.c\" #> [25] \"tmdd_qss_one_target.c\" #> [26] \"two_comp_oral_CL.c\" 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))"},{"path":"https://andrewhooker.github.io/PopED/articles/examples.html","id":"analytic-solution-of-pkpd-model-multiple-study-arms","dir":"Articles","previous_headings":"","what":"Analytic solution of PKPD model, multiple study arms","title":"Examples","text":"full code example available ex.4.PKPD.1.comp.emax.R. define PKPD mode using analytical equations. PK one compartment model intravenous bolus administration linear elimination. PD ordinary Emax model driven PK concentrations. expected output measurement (PK PD) given vector model_switch (see details). error model also accommodate response models. poped.db object vector specify model_switch order assign sampling times defined vector xt PK (=1) PD (=2) model. model predictions show typical PK PD profiles three dose groups expected 95% prediction interval data. initial design, shown poped.db object, consists 3 arms doses 0, 1, 2 mg; PK sampling times 0.33, 0.66, 0.9, 5 hours/days; PD sampling times 0.1, 1, 2, 5 hours/days. model.names=c(\"PK\",\"PD\") one can name outputs graph.","code":"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)) }) } ## -- 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 )) } 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)) plot_model_prediction( poped.db,PI=TRUE, facet_scales=\"free\", separate.groups=TRUE, model.names=c(\"PK\",\"PD\"))"},{"path":"https://andrewhooker.github.io/PopED/articles/examples.html","id":"ode-solution-of-pk-model-multiple-dosing","dir":"Articles","previous_headings":"","what":"ODE solution of PK model, multiple dosing","title":"Examples","text":"full code example available ex.9.PK.2.comp.oral.md.ode.compiled.R. example, deSolve library needs installed computing solutions system differential equations. faster solutions one can use pre-compiled code using Rcpp library (see ). define two compartment model R using deSolve notation Now define initial conditions ODE system A_ini named vector, case compartments initialized zero c(A1=0,A2=0,A3=0). dosing input defined data.frame dose_dat referring named compartment var = c(\"A1\"), specified dose_times value=c(DOSE*Favail) dose amounts. Note covariates DOSE regimen TAU can differ arm optimized (shown ex.1..PK.1.comp.oral.md.intro.R). information see help pages ?deSolve::ode ?deSolve::events. creating PopED database. ff_fun point function providing solution ODE. , names parameter definition (fg) function match parameters used two functions. plot population prediction model initial design Faster computations Rcpp: also define system using Rcpp, produce compiled code run faster (examples ex.2.c.warfarin.ODE.compiled.R). First redefine ODE system using Rcpp. Next add compiled function (two_comp_oral_ode_Rcpp) ODE solver. Finally create poped database use functions updating previously created database. can compare time design evaluation two methods describing model. difference noticeable gets larger complex ODE models.","code":"library(deSolve) 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))) }) } 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)) }) } 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)) plot_model_prediction(poped.db,model_num_points = 500) 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); }') 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)) }) } poped.db.Rcpp <- create.poped.database( poped.db, ff_fun=\"ff.PK.2.comp.oral.md.ode.Rcpp\") tic(); eval <- evaluate_design(poped.db); toc() #> Elapsed time: 2.759 seconds. tic(); eval <- evaluate_design(poped.db.Rcpp); toc() #> Elapsed time: 1.318 seconds."},{"path":"https://andrewhooker.github.io/PopED/articles/examples.html","id":"ode-solution-of-tmdd-model-with-2-outputs-multiple-arms-different-dose-routes-different-number-of-sample-times-per-arm","dir":"Articles","previous_headings":"","what":"ODE solution of TMDD model with 2 outputs, Multiple arms, different dose routes, different number of sample times per arm","title":"Examples","text":"full code example available ex.8.tmdd_qss_one_target_compiled.R. function defines dosing derives ODE solution, discrete covariate SC_FLAG used give dose either A1 A2, sub-cutaneous IV compartment. Two different sub-studies defined, different sampling times per arm - terms total number samples actual times1. Due difference numbers relatively complicated study design define sample times (xt), sample time measure (model_switch) samples taken study time (G_xt) matrices. three variables xt, model_switch, G_xt matrices row representing one arm, number columns maximum number samples (endpoints) arms (.e., max(ni)). clear elements matrices considered specify number samples per arm defining vector ni create.poped.database function. can plugged normal poped.db setup. Now can plot population predictions group evaluate design.","code":"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)) }) } 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 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))) plot_model_prediction(poped.db.2,facet_scales=\"free\") eval_2 <- evaluate_design(poped.db.2) round(eval_2$rse) # in percent"},{"path":"https://andrewhooker.github.io/PopED/articles/examples.html","id":"model-with-continuous-covariates","dir":"Articles","previous_headings":"","what":"Model with continuous covariates","title":"Examples","text":"R code example available ex.12.covariate_distributions.R. Let’s assume model covariate included model description. define one-compartment PK model uses allometric scaling weight effect clearance volume distribution. Now define design. case one group individuals, define individuals’ typical weight 70 kg (=c(WT=70)). can create plot model prediction typical individual evaluate initial design output produced see covariate parameters can estimated according design calculation (RSE WT_CL WT_V NA). ? Well, calculation done assuming every individual group covariate (speed calculation). clearly poor assumption case! Distribution covariates: can improve computation assuming distribution covariate (WT) individuals study. set groupsize=1, number groups 50 (m=50) assume WT sampled normal distribution mean=70 sd=10 (=.list(rnorm(50, mean = 70, sd = 10)). see , given distribution weights, covariate effect parameters (WT_CL WT_V) well estimated. However, looking one sample 50 individuals. Maybe better approach look distribution RSEs number experiments given expected weight distribution. Note, variance RSE covariate effect case strongly correlated variance weight distribution (shown).","code":"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 ) } 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) ) plot_model_prediction(poped_db) 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 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.3 round(ev$rse) 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))"},{"path":"https://andrewhooker.github.io/PopED/articles/examples.html","id":"model-with-discrete-covariates","dir":"Articles","previous_headings":"","what":"Model with discrete covariates","title":"Examples","text":"See ex.11.PK.prior.R. covariate isPediatric distinguish adults pediatrics. Alternatively, DOSE TAU first example can considered discrete covariates.","code":""},{"path":"https://andrewhooker.github.io/PopED/articles/examples.html","id":"model-with-inter-occasion-variability-iov","dir":"Articles","previous_headings":"","what":"Model with Inter-Occasion Variability (IOV)","title":"Examples","text":"full code example available ex.14.PK.IOV.R. IOV introduced bocc[x,y] parameter definition function matrix first argument x indicating index IOV variances, second argument y denoting occasion. used example derive different clearance values, .e., CL_OCC_1 CL_OCC_2. parameters can now used model function define change parameters occasions (change occurs 7th dose one-compartment model first order absorption). within-subject variability variances (docc) defined poped database 3-column matrix one row per IOV-parameter, middle column giving variance values. can visualize IOV looking example individual. see PK profile changes 7th dose (red line) due change clearance. can also see design relatively poor estimating IOV parameter:","code":"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 ) } 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)) }) } 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) ) 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\") ev <- evaluate_design(poped.db) round(ev$rse)"},{"path":"https://andrewhooker.github.io/PopED/articles/examples.html","id":"full-omega-matrix","dir":"Articles","previous_headings":"","what":"Full omega matrix","title":"Examples","text":"full code example available ex.15.full.covariance.matrix.R. covd object used defining covariances subject variances (-diagonal elements full variance-covariance matrix subject variability). covariances mean? indicate correlation inter-individual variabilities, ca. 0.8 clearance volume, well volume absorption rate. can clearly see difference variance model predictions. Evaluating designs without covariances: Note, precision parameters barely affected including full covariance matrix. likely different practice ill-conditioned numerical problems. Evaluate designs full FIM (instead reduced)","code":"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 ) (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 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) ev1 <- evaluate_design(poped.db) ev2 <- evaluate_design(poped.db_with) round(ev1$rse) round(ev2$rse) 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)"},{"path":"https://andrewhooker.github.io/PopED/articles/examples.html","id":"include-a-prior-fim-compute-power-to-identify-a-parameter","dir":"Articles","previous_headings":"","what":"Include a prior FIM, compute power to identify a parameter","title":"Examples","text":"example incorporate prior knowledge current study design calculation. First expected FIM obtained experiment adults computed. FIM added current experiment children. One also use observed FIM using estimation software fit one realization design ($COVARIANCE step NONMEM example). full code example available ex.11.PK.prior.R. Note define parameters one-compartment first-order absorption model using covariate called isPediatric switch adult pediatric models, bpop[5]=pedCL factor multiply adult clearance bpop[3] obtain pediatric one. design design space adults defined (Two arms, 5 sample time points per arm, doses 20 40 mg, isPediatric = 0). want pool results (.e. add FIMs together), also provide pedCL parameter adult children FIMs dimensions. Create plot model without variability store FIM adult design evaluate design obvious estimate pediatric covariate adult data ; hence warning message. can also note zeros 4th column 4th row FIM indicating pedCL estimated adult data. can evaluate adult design without warning, setting pedCL parameter fixed (.e., estimated): One obtains good estimates parameters adults (<60% RSE ). pediatrics covariate isPediatric = 1. define one arm, 4 sample-time points. can create plot pediatric model without variability Evaluate design pediatrics study alone. Clearly design problems . can add prior information adult study evaluate design (.e., pooling adult pediatric data). pooled data leads much higher precision parameter estimates compared either study separately. One can also obtain power estimating pediatric difference clearance (power estimating bpop[5] different 1). see clearly distinguish parameter one need 14 children pediatric study (80% power \\(\\alpha=0.05\\)).","code":"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 ) } 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)) ) plot_model_prediction(poped.db, model_num_points = 300) (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 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 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)) ) plot_model_prediction(poped.db.ped, model_num_points = 300) evaluate_design(poped.db.ped) #> $ofv #> [1] -15.2274 #> #> $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 #> 2.472122e+01 3.084970e+01 7.414552e+08 7.414552e+08 1.162309e+02 1.811978e+02 #> d_CL #> 7.729188e+01 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 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"},{"path":"https://andrewhooker.github.io/PopED/articles/examples.html","id":"design-evaluation-including-uncertainty-in-the-model-parameters-robust-design","dir":"Articles","previous_headings":"","what":"Design evaluation including uncertainty in the model parameters (robust design)","title":"Examples","text":"example aim evaluate design incorporating uncertainty around parameter values model. full code example available ex.2.d.warfarin.ED.R. illustration one Warfarin examples software comparison : Nyberg et al.2. define fixed effects model add 10% uncertainty Favail. use Matrix defining fixed effects, per row (row number = parameter_number) : column 1 type distribution E-family designs (0 = Fixed, 1 = Normal, 2 = Uniform, 3 = User Defined Distribution, 4 = lognormal 5 = truncated normal) column 2 defines mean. column 3 defines variance distribution (length uniform distribution). define log-normal distribution model parameter set define initial design design space. Specifically note bpop=bpop_vals_ed ED_samp_size=20 arguments. ED_samp_size=20 indicates number samples used evaluating E-family objective functions. can also provide ED_samp_size argument design evaluation optimization arguments: can see result, based MC sampling, somewhat variable samples.","code":"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 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) 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.142 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.135 seconds."},{"path":"https://andrewhooker.github.io/PopED/articles/examples.html","id":"design-evaluation-for-a-subset-of-model-parameters-of-interest-ds-optimality","dir":"Articles","previous_headings":"","what":"Design evaluation for a subset of model parameters of interest (Ds optimality)","title":"Examples","text":"Ds-optimality criterion can used one interested estimating subset “s” model parameters precisely possible. full code example available ex.2.e.warfarin.Ds.R. First define initial design design space: Ds optimality add ds_index option create.poped.database function indicate whether parameter interesting (=0) (=1). Moreover, set ofv_calc_type=6 computing Ds optimality criterion (set 4 default, computing log determinant FIM). details available running command ?create.poped.database. Design evaluation:","code":"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 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"},{"path":"https://andrewhooker.github.io/PopED/articles/examples.html","id":"shrinkage","dir":"Articles","previous_headings":"","what":"Shrinkage","title":"Examples","text":"full code example available “ex.13.shrinkage.R”. evaluate estimation quality individual random effects model (b’s) use function shrinkage(). output shows us expected shrinkage variance scale (\\(shrink_{var}=1-var(b_j)/D(j,j)\\)) standard deviation scale (\\(shrink_{sd}=1-sd(b_j)/sqrt(D(j,j))\\)), well standard errors \\(b_j\\) estimates.","code":"shrinkage(poped.db) #> # A tibble: 3 × 5 #> d_KA d_V `D[3,3]` type group #> #> 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"},{"path":"https://andrewhooker.github.io/PopED/articles/examples.html","id":"further-examples","dir":"Articles","previous_headings":"","what":"Further examples","title":"Examples","text":"Available PopED, shown examples: Espresso design Handling BLQ data Irregular dosing complex: e.g. switching s.c. .v. within one arm. Constraining optimization different allowed sampling times group Constraining optimization different allowed sampling times response Keep sampling time fixed (automatically part optimal design protocol) Handling derived outputs implemented: Symbolic differentiation","code":""},{"path":"https://andrewhooker.github.io/PopED/articles/handling_LOQ.html","id":"define-a-model","dir":"Articles","previous_headings":"","what":"Define a model","title":"Optimal design with LOQ data in PopED","text":"define, example, one-compartment pharmacokinetic model linear absorption (analytic solution) PopED (Nyberg et al. 2012). Next define parameters function. DOSEis defined covariate (vector ) can optimize value later. use additive proportional residual unexplained variability (RUV) model, predefined PopED function feps.add.prop.","code":"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)) })} 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]) }"},{"path":"https://andrewhooker.github.io/PopED/articles/handling_LOQ.html","id":"define-an-initial-design-and-design-space","dir":"Articles","previous_headings":"","what":"Define an initial design and design space","title":"Optimal design with LOQ data in PopED","text":"Now define model parameter values, initial design design space optimization. define model parameters similar Warfarin example software comparison Nyberg et al. (2015) arbitrary design two groups 20 individuals.","code":"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)"},{"path":"https://andrewhooker.github.io/PopED/articles/handling_LOQ.html","id":"simulation","dir":"Articles","previous_headings":"","what":"Simulation","title":"Optimal design with LOQ data in PopED","text":"First may make sense check model design make sure get expect simulating data. plot model typical values two groups:","code":"plot_model_prediction(poped_db, model_num_points = 500,facet_scales = \"free\",PI=T)"},{"path":"https://andrewhooker.github.io/PopED/articles/handling_LOQ.html","id":"design-evaluation","dir":"Articles","previous_headings":"","what":"Design evaluation","title":"Optimal design with LOQ data in PopED","text":"Next, evaluate initial design. see relative standard error parameters (percent) relatively well estimated initial design except proportional RUV parameter (sig_prop).","code":"eval_full <- evaluate_design(poped_db) round(eval_full$rse) #> CL V KA d_CL d_V d_KA sig_prop sig_add #> 5 4 15 34 70 28 89 36"},{"path":"https://andrewhooker.github.io/PopED/articles/handling_LOQ.html","id":"loq-handling","dir":"Articles","previous_headings":"","what":"LOQ handling","title":"Optimal design with LOQ data in PopED","text":"assume LOQ level 2 concentration units. shown red dotted line. use optimization criteria based D6 (loq_method=1 default) D2 (loq_method=2) methods Vong et al. (2012). D6 method, shown better method comparison SSE studies, updated method investigate points 95% PI overlaps LOQ, otherwise set design point either information full information. filter situations low probabilities (loq_prob_limit = 0.001). CI% low probability limit can specified calculation (default values loq_PI_conf_level = 0.95 loq_prob_limit = 0.001). way can get D6 method compute reasonable time-frames even larger number design samples. can evaluate design methods test speed computation. see D6 significantly slower D2 (D6 accurate representation RSE expected using M3 estimation methods). D2 nmethod removing last data point Predicted parameter uncertainty three methods shown table (relative standard error, RSE, percent). see uncertainty generally higher LOQ evaluations (expected). also see D2 method ignores data LOQ (last observation design), predictions uncertainty significantly larger.","code":"library(ggplot2) plot_model_prediction(poped_db, model_num_points = 500,facet_scales = \"free\",PI=T) + geom_hline(yintercept = 2,color=\"red\",linetype=\"dotted\",linewidth=1) 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.047 #> D2 evaluation time: 0.007 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)"},{"path":"https://andrewhooker.github.io/PopED/articles/handling_LOQ.html","id":"uloq-handling","dir":"Articles","previous_headings":"LOQ handling","what":"ULOQ handling","title":"Optimal design with LOQ data in PopED","text":"needed can also handle upper limits quantification. Lets assume ULOQ 7 units addition LLOQ 2 units: RSE (%) initial design using different methods handling LOQ ULOQ.","code":"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\",linewidth=1) + geom_hline(yintercept = 7,color=\"blue\",linetype=\"dotted\",linewidth=1) 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."},{"path":"https://andrewhooker.github.io/PopED/articles/handling_LOQ.html","id":"design-optimization","dir":"Articles","previous_headings":"","what":"Design optimization","title":"Optimal design with LOQ data in PopED","text":"can optimize design using different methods computing FIM. optimize using lower LOQ. Design points apraoch ignoring LOQ, using D2 method, using D6 method Predictions using D6 method optimizations shows expected %RSE parameters design used LOQ 2 concentration units. see D2 may reasonable strategy optimize designs “good enough” D6 method slow optimization. RSE (%) optimized designs evaluated using D6 method.","code":"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) 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))"},{"path":[]},{"path":"https://andrewhooker.github.io/PopED/articles/handling_LOQ.html","id":"version-information","dir":"Articles","previous_headings":"","what":"Version information","title":"Optimal design with LOQ data in PopED","text":"","code":"sessionInfo() #> R version 4.3.2 (2023-10-31) #> Platform: x86_64-pc-linux-gnu (64-bit) #> Running under: Ubuntu 22.04.3 LTS #> #> Matrix products: default #> BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 #> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0 #> #> locale: #> [1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8 #> [4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8 #> [7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C #> [10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C #> #> time zone: UTC #> tzcode source: system (glibc) #> #> attached base packages: #> [1] stats graphics grDevices utils datasets methods base #> #> other attached packages: #> [1] PopED_0.6.0.9002 kableExtra_1.3.4 knitr_1.45 ggplot2_3.4.4 #> #> loaded via a namespace (and not attached): #> [1] sass_0.4.7 utf8_1.2.4 generics_0.1.3 xml2_1.3.5 #> [5] gtools_3.9.4 stringi_1.8.1 digest_0.6.33 magrittr_2.0.3 #> [9] evaluate_0.23 grid_4.3.2 pkgload_1.3.3 mvtnorm_1.2-3 #> [13] fastmap_1.1.1 rprojroot_2.0.4 jsonlite_1.8.7 brio_1.1.3 #> [17] httr_1.4.7 rvest_1.0.3 purrr_1.0.2 fansi_1.0.5 #> [21] viridisLite_0.4.2 scales_1.2.1 codetools_0.2-19 textshaping_0.3.7 #> [25] jquerylib_0.1.4 cli_3.6.1 rlang_1.1.2 munsell_0.5.0 #> [29] withr_2.5.2 cachem_1.0.8 yaml_2.3.7 tools_4.3.2 #> [33] memoise_2.0.1 dplyr_1.1.3 colorspace_2.1-0 webshot_0.5.5 #> [37] vctrs_0.6.4 R6_2.5.1 lifecycle_1.0.4 stringr_1.5.1 #> [41] fs_1.6.3 ragg_1.2.6 pkgconfig_2.0.3 desc_1.4.2 #> [45] pkgdown_2.0.7 pillar_1.9.0 bslib_0.5.1 gtable_0.3.4 #> [49] glue_1.6.2 systemfonts_1.0.5 highr_0.10 xfun_0.41 #> [53] tibble_3.2.1 tidyselect_1.2.0 rstudioapi_0.15.0 farver_2.1.1 #> [57] htmltools_0.5.7 labeling_0.4.3 rmarkdown_2.25 svglite_2.1.2 #> [61] testthat_3.2.0 compiler_4.3.2"},{"path":"https://andrewhooker.github.io/PopED/articles/intro-poped.html","id":"define-a-model","dir":"Articles","previous_headings":"","what":"Define a model","title":"Introduction to PopED","text":"define one-compartment pharmacokinetic model linear absorption using analytical solution. case solution applicable multiple single dosing. Note function also predefined PopED ff.PK.1.comp.oral.md.CL (see ?ff.PK.1.comp.oral.md.CL information). Next define parameters function, case -subject variability (BSV) parameter log-normally distributed (parameter Favail assumed BSV). DOSE TAU defined covariates (vector ) can optimize values later. Now define residual unexplained variability (RUV) function, case RUV additive proportional component.","code":"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 f=(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( f=f,poped.db=poped.db)) }) } 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]) } feps <- function(model_switch,xt,parameters,epsi,poped.db){ returnArgs <- ff(model_switch,xt,parameters,poped.db) f <- returnArgs[[1]] poped.db <- returnArgs[[2]] y = f*(1+epsi[,1])+epsi[,2] return(list(y=y,poped.db=poped.db)) }"},{"path":"https://andrewhooker.github.io/PopED/articles/intro-poped.html","id":"create-a-poped-database","dir":"Articles","previous_headings":"","what":"Create a PopED database","title":"Introduction to PopED","text":"create poped database link model defined set model parameters, initial design design space optimization. example, parameter values defined fixed effects (bpop), -subject variability variances (d) residual variability variances (sigma). also fix parameter Favail using notfixed_bpop, since oral dosing parameter identifiable. Fixing parameter means assume parameter estimated (know without uncertainty). addition, fix small additive RUV term, term reflecting higher error expected low concentration measurements (limit quantification measurements) typically calculated analytical assay methods (example, standard deviation parameter might 20% limit quantification). initial design, define two groups (m=2) 20 individuals (groupsize=20), doses 20 mg 40 mg every 24 hours (). initial design 5 sample times per individual (xt). design space, can searched optimization, define potential dose range 0 200 mg (mina maxa), range potential sample times 0 10 hours first three samples 240 248 hours last two samples (minxt maxxt). Finally, fix two groups subjects sample times (bUseGrouped_xt=TRUE).","code":"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)"},{"path":"https://andrewhooker.github.io/PopED/articles/intro-poped.html","id":"design-simulation","dir":"Articles","previous_headings":"","what":"Design simulation","title":"Introduction to PopED","text":"First may make sense check model design make sure get expect simulating data. plot model typical values: Next, plot expected prediction interval (default 95% PI) data taking account BSV RUV using option PI=TRUE. option makes predictions based first-order approximations model variance normality assumption variance. Better (slower) computations possible DV=T, IPRED=T groupsize_sim = large number options. can get predictions numerically well:","code":"plot_model_prediction(poped.db, model_num_points = 300) plot_model_prediction(poped.db, PI=TRUE, separate.groups=T, model_num_points = 300, sample.times = FALSE) 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"},{"path":"https://andrewhooker.github.io/PopED/articles/intro-poped.html","id":"design-evaluation","dir":"Articles","previous_headings":"","what":"Design evaluation","title":"Introduction to PopED","text":"Next, evaluate initial design see fixed-effect residual variability parameters relatively well estimated design, -subject variability parameters less well estimated.","code":"(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"},{"path":"https://andrewhooker.github.io/PopED/articles/intro-poped.html","id":"evaluate-alternative-design","dir":"Articles","previous_headings":"Design evaluation","what":"Evaluate alternative design","title":"Introduction to PopED","text":"alternative design sparse sampling? example, individual 3 time points 1, 2 245 hours:","code":"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"},{"path":"https://andrewhooker.github.io/PopED/articles/intro-poped.html","id":"comparison-of-designs","dir":"Articles","previous_headings":"Design evaluation","what":"Comparison of designs","title":"Introduction to PopED","text":"precision CL similar alternative design parameters less well estimated. Comparing objective function value (OFV), see alternative design (less samples per subject) smaller OFV (=worse). can compare two OFVs using efficiency, tells us proportion extra individuals needed alternative design information content original design (around 4 times individuals currently design).","code":"(design_eval <- round(data.frame(\"Design 1\"=ds1$rse,\"Design 2\"=ds2$rse))) efficiency(ds2$ofv,ds1$ofv,poped.db) #> [1] 3.965919 #> attr(,\"description\") #> [1] \"(exp(ofv_final) / exp(ofv_init))^(1/n_parameters)\""},{"path":"https://andrewhooker.github.io/PopED/articles/intro-poped.html","id":"design-optimization","dir":"Articles","previous_headings":"","what":"Design optimization","title":"Introduction to PopED","text":"Now can optimize sample times original design maximizing OFV1. see four distinct sample times design. means model, exact parameter values, information study inform parameter estimation sample times.","code":"output <- poped_optim(poped.db, opt_xt=TRUE) summary(output) #> =============================================================================== #> FINAL RESULTS #> Optimized Sampling Schedule #> Group 1: 0.4573 10 10 240 240.9 #> Group 2: 0.4573 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: 17.17 seconds plot_model_prediction(output$poped.db)"},{"path":"https://andrewhooker.github.io/PopED/articles/intro-poped.html","id":"examine-efficiency-of-sampling-windows","dir":"Articles","previous_headings":"Design optimization","what":"Examine efficiency of sampling windows","title":"Introduction to PopED","text":"course, means multiple samples time points. can explore practical design looking loss efficiency spread sample times uniform distribution around optimal points (\\(\\pm 30\\) minutes). see efficiency (\\((|FIM_{optimized}|/|FIM_{initial}|)^{1/npar}\\)) drops 80% cases, mostly caused increase parameter uncertainty BSV parameter absorption (om_KA). Smaller windows different windowing different samples might needed. investigate see ?plot_efficiency_of_windows.","code":"plot_efficiency_of_windows(output$poped.db,xt_windows=0.5)"},{"path":"https://andrewhooker.github.io/PopED/articles/intro-poped.html","id":"optimize-over-a-discrete-design-space","dir":"Articles","previous_headings":"Design optimization","what":"Optimize over a discrete design space","title":"Introduction to PopED","text":"previous example optimized continuous design space (sample times optimized value lower upper limit). also limit search “allowed” values, example, samples taken hour allowed. see optimization ran somewhat quicker, gave less efficient design.","code":"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: 10.479 seconds plot_model_prediction(output_discrete$poped.db, model_num_points = 300)"},{"path":"https://andrewhooker.github.io/PopED/articles/intro-poped.html","id":"optimize-other-design-variables","dir":"Articles","previous_headings":"Design optimization","what":"Optimize ‘Other’ design variables","title":"Introduction to PopED","text":"One also optimize dose, see different dose help parameter estimation . case results predictable … higher doses give observations somewhat lower absolute residual variability leading groups highest allowed dose levels (200 mg case).","code":"output_dose_opt <- poped_optim(output$poped.db, opt_xt=TRUE, opt_a=TRUE)"},{"path":"https://andrewhooker.github.io/PopED/articles/intro-poped.html","id":"cost-function-to-optimize-dose","dir":"Articles","previous_headings":"Design optimization","what":"Cost function to optimize dose","title":"Introduction to PopED","text":"Optimizing dose study just better model parameter estimates may somewhat implausible. Instead, let’s use cost function optimize dose based sort target concentration … perhaps typical population trough concentrations 0.2 0.35 two groups patients 240 hours. First define criteria use optimize doses, least squares minimization. Now minimize cost function see optimal doses 31.6 55.2 two groups. leads population trough concentrations 0.2 0.35 two groups patients 240 hours:","code":"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 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: 3.866 seconds library(ggplot2) plot_model_prediction(output_cost$poped.db, model_num_points = 300)+ coord_cartesian(xlim=c(230,250))"},{"path":"https://andrewhooker.github.io/PopED/articles/model_def_other_pkgs.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Defining models for PopED using R based PKPD simulators","text":"simple example couple PopED external R based PKPD simulation tools. Typically, tools might R packages can simulate ordinary differential equation (ODE) based models. document see couple PopED models, defined ODEs, implemented using: deSolve (native R ODE models) deSolve (compiled C ODE models) deSolve (compiled C++ ODE models using Rcpp) PKPDsim mrgsolve rxode2","code":"library(PopED) library(PKPDsim) library(mrgsolve) #> #> Attaching package: 'mrgsolve' #> The following object is masked from 'package:stats': #> #> filter library(deSolve) library(Rcpp) library(rxode2) #> rxode2 2.0.14 using 2 threads (see ?getRxThreads) #> no cache: create with `rxCreateCache()`"},{"path":"https://andrewhooker.github.io/PopED/articles/model_def_other_pkgs.html","id":"the-model","dir":"Articles","previous_headings":"","what":"The model","title":"Defining models for PopED using R based PKPD simulators","text":"use one-compartment linear absorption population pharmacokinetic (PK) model example (see ). model can described following set ODEs: \\[ \\begin{split} \\frac{dA_{0}}{dt} &= - k_{} \\cdot A_{0}\\\\ \\frac{dA_{1}}{dt} &=-(CL/V_1)\\cdot A_1 + k_{} \\cdot A_{0} \\\\ f(t) &= A_1/V_1 \\end{split} \\] compartment amounts assumed zero time zero (\\(\\boldsymbol{}[t=0]=0\\)). Inputs system come tablet form added amount \\(A_{0}\\) according \\[ \\text{Input}(t,D,t_D) = \\begin{cases} D, &\\text{} \\quad t = t_D \\\\ 0, &\\text{otherwise} \\end{cases} \\] Parameter values defined : \\[ \\begin{split} k_a &= \\theta_{k_a} \\cdot e^{\\eta_{k_a}} \\\\ CL &= \\theta_{CL} \\cdot e^{\\eta_{CL}} \\\\ V_1 &= \\theta_{V_1} \\cdot e^{\\eta_{V_1}} \\\\ \\end{split} \\] elements subject variability (BSV), \\(\\eta_{j}\\), vary across individuals come normal distributions means zero variances \\(\\omega^2_{j}\\). residual unexplained variability (RUV) model proportional additive component \\[ y = f(t) \\cdot (1+\\varepsilon_{prop}) + \\varepsilon_{add} \\] elements \\(\\boldsymbol{\\varepsilon}_{j}\\) vary accross observations come normal distributions means zero variances \\(\\sigma^2_{j}\\).","code":""},{"path":"https://andrewhooker.github.io/PopED/articles/model_def_other_pkgs.html","id":"model-implementation","dir":"Articles","previous_headings":"","what":"Model implementation","title":"Defining models for PopED using R based PKPD simulators","text":"implement model using number different methods. ODE solvers, possible, set tuning parameters values (atol, rtol, etc.).","code":""},{"path":"https://andrewhooker.github.io/PopED/articles/model_def_other_pkgs.html","id":"analytic-solution","dir":"Articles","previous_headings":"Model implementation","what":"Analytic solution","title":"Defining models for PopED using R based PKPD simulators","text":"First implement analytic solution model function used PopED. assume single dose multiple dosing dose interval TAU time units. named vector parameters defines values KA, CL, V, DOSE TAU used compute value f time point vector xt.","code":"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)) }) }"},{"path":"https://andrewhooker.github.io/PopED/articles/model_def_other_pkgs.html","id":"ode-solution-using-desolve","dir":"Articles","previous_headings":"Model implementation","what":"ODE solution using deSolve","title":"Defining models for PopED using R based PKPD simulators","text":"model can implemented using ODEs. ODEs defined deSolve: , just analytic solution, named vector parameters defines values KA, CL, V, DOSE TAU used compute value f time point vector xt. inputs system (dosing amounts times) need added events deSolve ODE solver called deSolve::ode().","code":"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))) }) } 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 <- deSolve::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)) }) }"},{"path":"https://andrewhooker.github.io/PopED/articles/model_def_other_pkgs.html","id":"ode-solution-using-desolve-and-compiled-c-code","dir":"Articles","previous_headings":"Model implementation","what":"ODE solution using deSolve and compiled C code","title":"Defining models for PopED using R based PKPD simulators","text":"can use compiled C code deSolve speed computing solutions ODEs. C code written separate file needs compiled looks like : code available file PopED distribution, compiled following commands: function used compute value f time point vector xt, given inputs system (dosing amounts times), needs changed slightly, updating arguments deSolve::ode().","code":"/* file one_comp_oral_CL.c */ #include static double parms[3]; #define CL parms[0] #define V parms[1] #define KA parms[2] /* initializer */ void initmod(void (* odeparms)(int *, double *)) { int N=3; odeparms(&N, parms); } /* Derivatives and 1 output variable */ void derivs (int *neq, double *t, double *y, double *ydot, double *yout, int *ip) { if (ip[0] <1) error(\"nout should be at least 1\"); ydot[0] = -KA*y[0]; ydot[1] = KA*y[0] - CL/V*y[1]; yout[0] = y[0]+y[1]; } /* END file one_comp_oral_CL.c */ file.copy(system.file(\"examples/one_comp_oral_CL.c\", package=\"PopED\"),\"./one_comp_oral_CL.c\") #> [1] TRUE system('R CMD SHLIB one_comp_oral_CL.c') dyn.load(paste(\"one_comp_oral_CL\", .Platform$dynlib.ext, sep = \"\")) 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 <- deSolve::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\"]),] f = out[, \"A2\"]/V f=cbind(f) # must be a column matrix return(list(f=f,poped.db=poped.db)) }) }"},{"path":"https://andrewhooker.github.io/PopED/articles/model_def_other_pkgs.html","id":"ode-solution-using-desolve-and-compiled-c-code-via-rcpp","dir":"Articles","previous_headings":"Model implementation","what":"ODE solution using deSolve and compiled C++ code (via Rcpp)","title":"Defining models for PopED using R based PKPD simulators","text":"define ODE system using inline C++ code compiled via Rcpp , arguments deSolve::ode() need updated:","code":"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 <- deSolve::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 f = out[match(times_xt,out[,\"time\"]),\"A2\",drop=F]/p[[\"V\"]] return(list(f=f,poped.db=poped.db)) }"},{"path":"https://andrewhooker.github.io/PopED/articles/model_def_other_pkgs.html","id":"ode-solution-using-pkpdsim","dir":"Articles","previous_headings":"Model implementation","what":"ODE solution using PKPDsim","title":"Defining models for PopED using R based PKPD simulators","text":"can use PKPDsim describe set ODEs. adjust function used compute value f time point vector xt, given inputs system (dosing amounts times), using ODE solver PKPDsim::sim_core().","code":"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) f <- 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\") } f <- f[m_tmp] return(list(f = f, poped.db = poped.db)) }"},{"path":"https://andrewhooker.github.io/PopED/articles/model_def_other_pkgs.html","id":"ode-solution-using-mrgsolve","dir":"Articles","previous_headings":"Model implementation","what":"ODE solution using mrgsolve","title":"Defining models for PopED using R based PKPD simulators","text":"can also use mrgsolve describe set ODEs. compile load model mcode Finally, adjust function used compute value f time point vector xt, given inputs system (dosing amounts times), using ODE solver mrgsolve::mrgsim_q().","code":"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 ' moda <- mrgsolve::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 <- mrgsolve::mrgsim_q(moda, data=data) f <- out$CP f <- f[match(times_xt,out$time)] return(list(f=matrix(f,ncol=1),poped.db=poped.db)) }"},{"path":"https://andrewhooker.github.io/PopED/articles/model_def_other_pkgs.html","id":"ode-solution-using-rxode2","dir":"Articles","previous_headings":"Model implementation","what":"ODE solution using rxode2","title":"Defining models for PopED using R based PKPD simulators","text":"can use rxode2 describe set ODEs. adjust function used compute value f time point vector xt, given inputs system (dosing amounts times), using ODE solver rxode2::rxSolve().","code":"modrx <- rxode2::rxode2({ d/dt(DEPOT) = -KA*DEPOT; d/dt(CENT) = KA*DEPOT - (CL/V)*CENT; CP=CENT/V; }) #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ 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 <- rxode2::rxSolve(modrx, p, data, atol=1e-8, rtol=1e-8,maxsteps=5000, returnType=\"data.frame\") f <- out$CP[match(times_xt,out$time)] return(list(f=matrix(f,ncol=1),poped.db=poped.db)) }"},{"path":"https://andrewhooker.github.io/PopED/articles/model_def_other_pkgs.html","id":"common-model-elements","dir":"Articles","previous_headings":"Model implementation","what":"Common model elements","title":"Defining models for PopED using R based PKPD simulators","text":"functions used define BSV RUV.","code":"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)) }"},{"path":"https://andrewhooker.github.io/PopED/articles/model_def_other_pkgs.html","id":"create-poped-databases","dir":"Articles","previous_headings":"","what":"Create PopED databases","title":"Defining models for PopED using R based PKPD simulators","text":"Next define model use, parameters models, intial design design design space design calculation. create number databases correspond different model implementations. initial design 2 group design, doses 20 mg 40 mg every 24 hours. group sampling schedule, 3 samples first day study 2 10th day study.","code":"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)"},{"path":"https://andrewhooker.github.io/PopED/articles/model_def_other_pkgs.html","id":"model-predictions","dir":"Articles","previous_headings":"","what":"Model predictions","title":"Defining models for PopED using R based PKPD simulators","text":"difference model predictions different implementations? visual representation model predictions study design, based analytic solution: can compare different predictions plot accross model implementations. see accuracy different methods within machine precision (small).","code":"plot_model_prediction(poped_db_analytic,model_num_points = 500,PI=T,separate.groups = T) 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.998734e-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"},{"path":"https://andrewhooker.github.io/PopED/articles/model_def_other_pkgs.html","id":"evaluate-the-design","dir":"Articles","previous_headings":"","what":"Evaluate the design","title":"Defining models for PopED using R based PKPD simulators","text":"compare computation Fisher Information Matrix (FIM). comparing \\(ln(det(FIM))\\) (lnD-objective function value, ofv). computations give similar results:","code":"(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_ode_desolve <- evaluate_design(poped_db_ode_desolve) all.equal(eval_std$ofv,eval_ode_desolve$ofv) #> [1] \"Mean relative difference: 2.493043e-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.493043e-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.493043e-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.361612e-08\""},{"path":"https://andrewhooker.github.io/PopED/articles/model_def_other_pkgs.html","id":"speed-of-fim-computation","dir":"Articles","previous_headings":"","what":"Speed of FIM computation","title":"Defining models for PopED using R based PKPD simulators","text":"can compare speed computations. Analytic solutions fast, expected, case 20 times faster ODE methods. mrgsolve fastest ODE solvers example. Note much speed difference mrgsolve, RxODE PKPDsim found due overhead pre- post-processing simulation ODE systems. ways handling pre- post-processing may speed computations.","code":"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)"},{"path":"https://andrewhooker.github.io/PopED/articles/model_def_other_pkgs.html","id":"version-information","dir":"Articles","previous_headings":"","what":"Version information","title":"Defining models for PopED using R based PKPD simulators","text":"","code":"devtools::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.3.2 (2023-10-31) #> os Ubuntu 22.04.3 LTS #> system x86_64, linux-gnu #> ui X11 #> language en #> collate C.UTF-8 #> ctype C.UTF-8 #> tz UTC #> date 2023-11-16 #> pandoc 2.19.2 @ /usr/bin/ (via rmarkdown) #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date (UTC) lib source #> backports 1.4.1 2021-12-13 [1] RSPM #> BH 1.81.0-1 2023-01-22 [1] RSPM #> bslib 0.5.1 2023-08-11 [1] RSPM #> cachem 1.0.8 2023-05-01 [1] RSPM #> callr 3.7.3 2022-11-02 [1] RSPM #> checkmate 2.3.0 2023-10-25 [1] RSPM #> cli 3.6.1 2023-03-23 [1] RSPM #> codetools 0.2-19 2023-02-01 [3] CRAN (R 4.3.2) #> colorspace 2.1-0 2023-01-23 [1] RSPM #> crayon 1.5.2 2022-09-29 [1] RSPM #> data.table 1.14.8 2023-02-17 [1] RSPM #> desc 1.4.2 2022-09-08 [1] RSPM #> deSolve * 1.38 2023-09-05 [1] RSPM #> devtools 2.4.5 2022-10-11 [1] RSPM #> digest 0.6.33 2023-07-07 [1] RSPM #> dparser 1.3.1-10 2023-03-16 [1] RSPM #> dplyr 1.1.3 2023-09-03 [1] RSPM #> ellipsis 0.3.2 2021-04-29 [1] RSPM #> evaluate 0.23 2023-11-01 [1] RSPM #> fansi 1.0.5 2023-10-08 [1] RSPM #> farver 2.1.1 2022-07-06 [1] RSPM #> fastmap 1.1.1 2023-02-24 [1] RSPM #> fs 1.6.3 2023-07-20 [1] RSPM #> generics 0.1.3 2022-07-05 [1] RSPM #> ggplot2 3.4.4 2023-10-12 [1] RSPM #> glue 1.6.2 2022-02-24 [1] RSPM #> gtable 0.3.4 2023-08-21 [1] RSPM #> highr 0.10 2022-12-22 [1] RSPM #> htmltools 0.5.7 2023-11-03 [1] RSPM #> htmlwidgets 1.6.2 2023-03-17 [1] RSPM #> httpuv 1.6.12 2023-10-23 [1] RSPM #> httr 1.4.7 2023-08-15 [1] RSPM #> jquerylib 0.1.4 2021-04-26 [1] RSPM #> jsonlite 1.8.7 2023-06-29 [1] RSPM #> kableExtra * 1.3.4 2021-02-20 [1] RSPM #> knitr * 1.45 2023-10-30 [1] RSPM #> labeling 0.4.3 2023-08-29 [1] RSPM #> later 1.3.1 2023-05-02 [1] RSPM #> lattice 0.21-9 2023-10-01 [3] CRAN (R 4.3.2) #> lifecycle 1.0.4 2023-11-07 [1] RSPM #> lotri 0.4.3 2023-03-20 [1] RSPM #> magrittr 2.0.3 2022-03-30 [1] RSPM #> memoise 2.0.1 2021-11-26 [1] RSPM #> mime 0.12 2021-09-28 [1] RSPM #> miniUI 0.1.1.1 2018-05-18 [1] RSPM #> mrgsolve * 1.1.1 2023-08-16 [1] RSPM #> munsell 0.5.0 2018-06-12 [1] RSPM #> nlme 3.1-163 2023-08-09 [3] CRAN (R 4.3.2) #> pillar 1.9.0 2023-03-22 [1] RSPM #> pkgbuild 1.4.2 2023-06-26 [1] RSPM #> pkgconfig 2.0.3 2019-09-22 [1] RSPM #> pkgdown 2.0.7 2022-12-14 [1] RSPM #> pkgload 1.3.3 2023-09-22 [1] RSPM #> PKPDsim * 1.3.0 2023-03-02 [1] RSPM #> PopED * 0.6.0.9002 2023-11-16 [1] local #> PreciseSums 0.6 2023-04-22 [1] RSPM #> prettyunits 1.2.0 2023-09-24 [1] RSPM #> processx 3.8.2 2023-06-30 [1] RSPM #> profvis 0.3.8 2023-05-02 [1] RSPM #> promises 1.2.1 2023-08-10 [1] RSPM #> ps 1.7.5 2023-04-18 [1] RSPM #> purrr 1.0.2 2023-08-10 [1] RSPM #> qs 0.25.5 2023-02-22 [1] RSPM #> R6 2.5.1 2021-08-19 [1] RSPM #> ragg 1.2.6 2023-10-10 [1] RSPM #> RApiSerialize 0.1.2 2022-08-25 [1] RSPM #> Rcpp * 1.0.11 2023-07-06 [1] RSPM #> RcppParallel 5.1.7 2023-02-27 [1] RSPM #> remotes 2.4.2.1 2023-07-18 [1] RSPM #> rlang 1.1.2 2023-11-04 [1] RSPM #> rmarkdown 2.25 2023-09-18 [1] RSPM #> rprojroot 2.0.4 2023-11-05 [1] RSPM #> rstudioapi 0.15.0 2023-07-07 [1] RSPM #> rvest 1.0.3 2022-08-19 [1] RSPM #> rxode2 * 2.0.14 2023-10-07 [1] RSPM #> rxode2et 2.0.10 2023-03-17 [1] RSPM #> rxode2ll 2.0.11 2023-03-17 [1] RSPM #> rxode2parse 2.0.16 2023-03-28 [1] RSPM #> rxode2random 2.0.11 2023-03-28 [1] RSPM #> sass 0.4.7 2023-07-15 [1] RSPM #> scales 1.2.1 2022-08-20 [1] RSPM #> sessioninfo 1.2.2 2021-12-06 [1] RSPM #> shiny 1.7.5.1 2023-10-14 [1] RSPM #> stringfish 0.15.8 2023-05-30 [1] RSPM #> stringi 1.8.1 2023-11-13 [1] RSPM #> stringr 1.5.1 2023-11-14 [1] RSPM #> svglite 2.1.2 2023-10-11 [1] RSPM #> sys 3.4.2 2023-05-23 [1] RSPM #> systemfonts 1.0.5 2023-10-09 [1] RSPM #> textshaping 0.3.7 2023-10-09 [1] RSPM #> tibble 3.2.1 2023-03-20 [1] RSPM #> tidyselect 1.2.0 2022-10-10 [1] RSPM #> urlchecker 1.0.1 2021-11-30 [1] RSPM #> usethis 2.2.2 2023-07-06 [1] RSPM #> utf8 1.2.4 2023-10-22 [1] RSPM #> vctrs 0.6.4 2023-10-12 [1] RSPM #> viridisLite 0.4.2 2023-05-02 [1] RSPM #> webshot 0.5.5 2023-06-26 [1] RSPM #> withr 2.5.2 2023-10-30 [1] RSPM #> xfun 0.41 2023-11-01 [1] RSPM #> xml2 1.3.5 2023-07-06 [1] RSPM #> xtable 1.8-4 2019-04-21 [1] RSPM #> yaml 2.3.7 2023-01-23 [1] RSPM #> #> [1] /home/runner/work/_temp/Library #> [2] /opt/R/4.3.2/lib/R/site-library #> [3] /opt/R/4.3.2/lib/R/library #> #> ────────────────────────────────────────────────────────────────────────────── #sessionInfo()"},{"path":"https://andrewhooker.github.io/PopED/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Andrew C. Hooker. Author, maintainer, translator, copyright holder. Marco Foracchia. Author. O-Matrix version Eric Stroemberg. Contributor. MATLAB version Martin Fink. Contributor. Streamlining code, added functionality, vignettes Giulia Lestini. Contributor. Streamlining code, added functionality, vignettes Sebastian Ueckert. Author. MATLAB version Joakim Nyberg. Author. MATLAB version","code":""},{"path":"https://andrewhooker.github.io/PopED/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Nyberg J, Ueckert S, Stroemberg EA, Hennig S, Karlsson MO, Hooker AC (2012). “PopED: extended, parallelized, nonlinear mixed effects models optimal design tool.” Computer Methods Programs Biomedicine, 108. Foracchia M, Hooker AC, Vicini P, Ruggeri (2004). “POPED, software optimal experiment design population kinetics.” Computer Methods Programs Biomedicine, 74.","code":"@Article{, title = {PopED: An extended, parallelized, nonlinear mixed effects models optimal design tool}, author = {Joakim Nyberg and Sebastian Ueckert and Eric A Stroemberg and Stefanie Hennig and Mats O Karlsson and Andrew C Hooker}, journal = {Computer Methods and Programs in Biomedicine}, year = {2012}, volume = {108}, } @Article{, title = {POPED, a software for optimal experiment design in population kinetics}, author = {Marco Foracchia and Andrew C Hooker and Paolo Vicini and A Ruggeri}, journal = {Computer Methods and Programs in Biomedicine}, year = {2004}, volume = {74}, }"},{"path":"https://andrewhooker.github.io/PopED/index.html","id":"poped-","dir":"","previous_headings":"","what":"Population (and Individual) Optimal Experimental Design","title":"Population (and Individual) Optimal Experimental Design","text":"PopED computes optimal experimental designs population individual studies based nonlinear mixed-effect models. Often based computation Fisher Information Matrix (FIM).","code":""},{"path":"https://andrewhooker.github.io/PopED/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Population (and Individual) Optimal Experimental Design","text":"need R installed. Download latest version R www.r-project.org. can install released version PopED CRAN : development version GitHub :","code":"install.packages(\"PopED\") # install.packages(\"devtools\") devtools::install_github(\"andrewhooker/PopED\")"},{"path":"https://andrewhooker.github.io/PopED/index.html","id":"getting-started","dir":"","previous_headings":"","what":"Getting started","title":"Population (and Individual) Optimal Experimental Design","text":"get started need define model. initial design (design space want optimize). tasks perform. Learn introduction PopED","code":""},{"path":"https://andrewhooker.github.io/PopED/index.html","id":"contact","dir":"","previous_headings":"","what":"Contact","title":"Population (and Individual) Optimal Experimental Design","text":"welcome : submit suggestions bug-reports : https://github.com/andrewhooker/PopED/issues send pull request : https://github.com/andrewhooker/PopED compose friendly e-mail : andrew.hooker@farmaci.uu.se","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/Doptim.html","id":null,"dir":"Reference","previous_headings":"","what":"D-family optimization function — Doptim","title":"D-family optimization function — Doptim","text":"Optimize objective function. 4 different optimization algorithms used function Adaptive random search. See RS_opt. Stochastic gradient. Broyden Fletcher Goldfarb Shanno (BFGS) method nonlinear minimization box constraints. line search. See a_line_search. optimization algorithms run series, taking input output previous method. stopping rule used test line search algorithm fids better optimum initial value. , chain algorithms run . line search used argument iter_tot defines number times chain algorithms run. function takes information PopED database supplied argument. PopED database supplies information model, parameters, design methods use. arguments coming PopED database can overwritten; supplied used instead arguments PopED database.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/Doptim.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"D-family optimization function — Doptim","text":"","code":"Doptim( poped.db, ni, xt, model_switch, x, a, bpopdescr, ddescr, maxxt, minxt, maxa, mina, fmf = 0, dmf = 0, trflag = TRUE, bUseRandomSearch = poped.db$settings$bUseRandomSearch, bUseStochasticGradient = poped.db$settings$bUseStochasticGradient, bUseBFGSMinimizer = poped.db$settings$bUseBFGSMinimizer, bUseLineSearch = poped.db$settings$bUseLineSearch, sgit = poped.db$settings$sgit, ls_step_size = poped.db$settings$ls_step_size, BFGSConvergenceCriteriaMinStep = poped.db$settings$BFGSConvergenceCriteriaMinStep, BFGSProjectedGradientTol = poped.db$settings$BFGSProjectedGradientTol, BFGSTolerancef = poped.db$settings$BFGSTolerancef, BFGSToleranceg = poped.db$settings$BFGSToleranceg, BFGSTolerancex = poped.db$settings$BFGSTolerancex, iter_tot = poped.db$settings$iNumSearchIterationsIfNotLineSearch, iter_max = 10, ... )"},{"path":"https://andrewhooker.github.io/PopED/reference/Doptim.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"D-family optimization function — Doptim","text":"poped.db PopED database. ni vector number samples group. xt matrix sample times. row vector sample times group. model_switch matrix size xt, specifying model sample belongs . x matrix discrete design variables. row group. matrix covariates. row group. bpopdescr Matrix defining fixed effects, per row (row number = parameter_number) : column 1 type distribution E-family designs (0 = Fixed, 1 = Normal, 2 = Uniform, 3 = User Defined Distribution, 4 = lognormal 5 = truncated normal) column 2 defines mean. column 3 defines variance distribution (length uniform distribution). ddescr Matrix defining diagonals IIV (logic bpopdescr). maxxt Matrix single value defining maximum value xt sample. single value supplied xt values given maximum value. minxt Matrix single value defining minimum value xt sample. single value supplied xt values given minimum value maxa Vector defining max value covariate. single value supplied values given max value mina Vector defining min value covariate. single value supplied values given max value fmf initial value FIM. set zero computed. dmf initial OFV. set zero computed. trflag optimization output screen file? bUseRandomSearch ******START Optimization algorithm SPECIFICATION OPTIONS********** Use random search (1=TRUE, 0=FALSE) bUseStochasticGradient Use Stochastic Gradient search (1=TRUE, 0=FALSE) bUseBFGSMinimizer Use BFGS Minimizer (1=TRUE, 0=FALSE) bUseLineSearch Use Line search (1=TRUE, 0=FALSE) sgit Number stochastic gradient iterations ls_step_size Number grid points line search. 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 iter_tot Number iterations use line search used. Must less iter_max used. iter_max line search used algorithm tests line search (always run end optimization iteration) changes design way. , algorithm stops. yes, new iteration run unless iter_max iterations already run. ... arguments passed evaluate.fim ofv_fim.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/Doptim.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"D-family optimization function — Doptim","text":"M. Foracchia, .C. Hooker, P. Vicini . Ruggeri, \"PopED, software optimal experimental design population kinetics\", Computer Methods Programs Biomedicine, 74, 2004. J. Nyberg, S. Ueckert, E.. Stroemberg, S. Hennig, M.O. Karlsson .C. Hooker, \"PopED: extended, parallelized, nonlinear mixed effects models optimal design tool\", Computer Methods Programs Biomedicine, 108, 2012.","code":""},{"path":[]},{"path":"https://andrewhooker.github.io/PopED/reference/Doptim.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"D-family optimization function — Doptim","text":"","code":"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)) #> }) #> } #> #> ## -- parameter definition function ## -- names match parameters in function ff sfg <- function(x,a,bpop,b,bocc){ parameters=c(CL=bpop[1]*exp(b[1]), V=bpop[2]*exp(b[2]), KA=bpop[3]*exp(b[3]), Favail=bpop[4], DOSE=a[1]) return(parameters) } ## -- Define initial design and design space poped.db <- create.poped.database(ff_fun=ff.PK.1.comp.oral.sd.CL, fg_fun=sfg, fError_fun=feps.add.prop, bpop=c(CL=0.15, V=8, KA=1.0, Favail=1), notfixed_bpop=c(1,1,1,0), d=c(CL=0.07, V=0.02, KA=0.6), sigma=c(prop=0.01,add=0.25), groupsize=32, xt=c( 0.5,1,2,6,24,36,72,120), minxt=0.01, maxxt=120, a=c(DOSE=70), mina=c(DOSE=0.01), maxa=c(DOSE=100)) ############# END ################### ## Create PopED database ## (warfarin model for optimization) ##################################### if (FALSE) { ############## # typically one will use poped_optimize # This then calls Doptim for continuous optimization problems ############## # RS+SG+LS optimization of sample times # optimization with just a few iterations # only to check that things are working output <- poped_optimize(poped.db,opt_xt=T, rsit=5,sgit=5,ls_step_size=5) # RS+SG+LS optimization of sample times # (longer run time than above but more likely to reach a maximum) output <- poped_optimize(poped.db,opt_xt=T) get_rse(output$fmf,output$poped.db) plot_model_prediction(output$poped.db) # Random search (just a few samples here) rs.output <- poped_optimize(poped.db,opt_xt=1,opt_a=1,rsit=20, bUseRandomSearch= 1, bUseStochasticGradient = 0, bUseBFGSMinimizer = 0, bUseLineSearch = 0) # line search, DOSE and sample time optimization ls.output <- poped_optimize(poped.db,opt_xt=1,opt_a=1, bUseRandomSearch= 0, bUseStochasticGradient = 0, bUseBFGSMinimizer = 0, bUseLineSearch = 1, ls_step_size=10) # Stochastic gradient search, DOSE and sample time optimization sg.output <- poped_optimize(poped.db,opt_xt=1,opt_a=1, bUseRandomSearch= 0, bUseStochasticGradient = 1, bUseBFGSMinimizer = 0, bUseLineSearch = 0, sgit=20) # BFGS search, DOSE and sample time optimization bfgs.output <- poped_optimize(poped.db,opt_xt=1,opt_a=1, bUseRandomSearch= 0, bUseStochasticGradient = 0, bUseBFGSMinimizer = 1, bUseLineSearch = 0) ############## # If you really want to you can use Doptim dirtectly ############## dsl <- downsizing_general_design(poped.db) poped.db$settings$optsw[2] <- 1 # sample time optimization output <- Doptim(poped.db,dsl$ni, dsl$xt, dsl$model_switch, dsl$x, dsl$a, dsl$bpop, dsl$d, dsl$maxxt, dsl$minxt,dsl$maxa,dsl$mina) }"},{"path":"https://andrewhooker.github.io/PopED/reference/Dtrace.html","id":null,"dir":"Reference","previous_headings":"","what":"Trace optimization routines — Dtrace","title":"Trace optimization routines — Dtrace","text":"helper function writing output screen files optimizing.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/Dtrace.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Trace optimization routines — Dtrace","text":"","code":"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 )"},{"path":"https://andrewhooker.github.io/PopED/reference/Dtrace.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Trace optimization routines — Dtrace","text":"fn file output information . Can also screen ''. iteration number. ni vector number samples group. xtopt matrix defining current best sampling schedule. xopt cell structure defining current best discrete design variables. aopt matrix defining current best continuous design variables. gxt matrix defining current gradient xt vector. ga matrix defining current gradient continuous design variables. dmf current OFV. diff difference previous iteration. ixt xt Gradient Inversion occurred . ia Gradient Inversion occurred . itvector iteration vector. currently used. dmfvector dmf vector. currently used. poped.db PopED database. opt_xt sample times optimized? opt_a continuous design variables optimized? opt_x discrete design variables optimized? opt_samps number sample times per group optimized? opt_inds number individuals per group optimized? rsit Number Random search iterations convergence_eps Stochastic Gradient convergence value, (difference OFV D-optimal, difference gradient ED-optimal)","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/Dtrace.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Trace optimization routines — Dtrace","text":"","code":"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)) #> }) #> } #> #> ## -- 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 #> *************************************************************"},{"path":"https://andrewhooker.github.io/PopED/reference/LEDoptim.html","id":null,"dir":"Reference","previous_headings":"","what":"Optimization function for D-family, E-family and Laplace approximated ED designs — LEDoptim","title":"Optimization function for D-family, E-family and Laplace approximated ED designs — LEDoptim","text":"Optimize objective function D-family, E-family Laplace approximated ED designs. Right now one optimization algorithm used function Adaptive random search. See RS_opt. function takes information PopED database supplied argument. PopED database supplies information model, parameters, design methods use. arguments coming PopED database can overwritten; supplied used instead arguments PopED database.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/LEDoptim.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Optimization function for D-family, E-family and Laplace approximated ED designs — LEDoptim","text":"","code":"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, ... )"},{"path":"https://andrewhooker.github.io/PopED/reference/LEDoptim.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Optimization function for D-family, E-family and Laplace approximated ED designs — LEDoptim","text":"poped.db PopED database. model_switch matrix size xt, specifying model sample belongs . ni vector number samples group. xt matrix sample times. row vector sample times group. x matrix discrete design variables. row group. matrix covariates. row group. bpopdescr Matrix defining fixed effects, per row (row number = parameter_number) : column 1 type distribution E-family designs (0 = Fixed, 1 = Normal, 2 = Uniform, 3 = User Defined Distribution, 4 = lognormal 5 = truncated normal) column 2 defines mean. column 3 defines variance distribution (length uniform distribution). ddescr Matrix defining diagonals IIV (logic bpopdescr). maxxt Matrix single value defining maximum value xt sample. single value supplied xt values given maximum value. minxt Matrix single value defining minimum value xt sample. single value supplied xt values given minimum value maxa Vector defining max value covariate. single value supplied values given max value mina Vector defining min value covariate. single value supplied values given max value ofv_init initial OFV. set zero computed. fim_init initial value FIM. set zero computed. trflag optimization output screen file? header_flag header text printed ? footer_flag footer text printed ? opt_xt sample times optimized? opt_a continuous design variables optimized? opt_x discrete design variables optimized? out_file file output directed ? string, file handle using file \"\" output screen. d_switch ******START CRITERION SPECIFICATION OPTIONS********** D-family design (1) ED-family design (0) (without parameter uncertainty) use_laplace Laplace method used calculating expectation OFV? laplace.fim E(FIM) calculated computing Laplace approximated E(OFV). Typically FIM need computed , desired, calculation done using standard MC integration technique, can slow. use_RS function use random search algorithm? ... arguments passed evaluate.fim ofv_fim.","code":""},{"path":[]},{"path":"https://andrewhooker.github.io/PopED/reference/LEDoptim.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Optimization function for D-family, E-family and Laplace approximated ED designs — LEDoptim","text":"","code":"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)) #> }) #> } #> #> ## -- 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=\"\") }"},{"path":"https://andrewhooker.github.io/PopED/reference/LinMatrixH.html","id":null,"dir":"Reference","previous_headings":"","what":"Model linearization with respect to epsilon. — LinMatrixH","title":"Model linearization with respect to epsilon. — LinMatrixH","text":"function performs linearization model respect residual variability. Derivative model w.r.t. eps evaluated eps=0","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/LinMatrixH.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Model linearization with respect to epsilon. — LinMatrixH","text":"","code":"LinMatrixH(model_switch, xt_ind, x, a, bpop, b_ind, bocc_ind, poped.db)"},{"path":"https://andrewhooker.github.io/PopED/reference/LinMatrixH.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Model linearization with respect to epsilon. — LinMatrixH","text":"model_switch matrix size xt, specifying model sample belongs . xt_ind vector individual/group sample times x matrix discrete design variables. row group. matrix covariates. row group. bpop fixed effects parameter values. Supplied vector. b_ind vector individual realization BSV terms b bocc_ind Vector individual realizations BOV terms bocc poped.db PopED database.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/LinMatrixH.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Model linearization with respect to epsilon. — LinMatrixH","text":"matrix size (samples per individual x number epsilons)","code":""},{"path":[]},{"path":"https://andrewhooker.github.io/PopED/reference/LinMatrixL.html","id":null,"dir":"Reference","previous_headings":"","what":"The linearized matrix L — LinMatrixL","title":"The linearized matrix L — LinMatrixL","text":"Function computes derivative model respect subject variability terms model (b's bocc's) evaluated defined point (b_ind bocc_ind).","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/LinMatrixL.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"The linearized matrix L — LinMatrixL","text":"","code":"LinMatrixL(model_switch, xt_ind, x, a, bpop, b_ind, bocc_ind, poped.db)"},{"path":"https://andrewhooker.github.io/PopED/reference/LinMatrixL.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"The linearized matrix L — LinMatrixL","text":"model_switch vector size xt, specifying model sample belongs . x vector discrete design variables. vector covariates. bpop fixed effects parameter values. Supplied vector. b_ind point evaluate derivative bocc_ind point evaluate derivative poped.db PopED database.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/LinMatrixL.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"The linearized matrix L — LinMatrixL","text":"list: y matrix size (samples per individual x number random effects) poped.db PopED database","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/LinMatrixL.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"The linearized matrix L — LinMatrixL","text":"","code":"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)) #> }) #> } #> #> ## -- 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 #>"},{"path":"https://andrewhooker.github.io/PopED/reference/LinMatrixLH.html","id":null,"dir":"Reference","previous_headings":"","what":"Model linearization with respect to epsilon and eta. — LinMatrixLH","title":"Model linearization with respect to epsilon and eta. — LinMatrixLH","text":"function performs linearization model respect residual variability subject variability. Derivative model w.r.t. eps eta, evaluated eps=0 b=b_ind.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/LinMatrixLH.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Model linearization with respect to epsilon and eta. — LinMatrixLH","text":"","code":"LinMatrixLH( model_switch, xt_ind, x, a, bpop, b_ind, bocc_ind, NumEPS, poped.db )"},{"path":"https://andrewhooker.github.io/PopED/reference/LinMatrixLH.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Model linearization with respect to epsilon and eta. — LinMatrixLH","text":"model_switch matrix size xt, specifying model sample belongs . xt_ind vector individual/group sample times x matrix discrete design variables. row group. matrix covariates. row group. bpop fixed effects parameter values. Supplied vector. b_ind vector individual realization BSV terms b bocc_ind Vector individual realizations BOV terms bocc NumEPS number eps() terms model. poped.db PopED database.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/LinMatrixLH.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Model linearization with respect to epsilon and eta. — LinMatrixLH","text":"matrix size (samples per individual x (number sigma x number omega))","code":""},{"path":[]},{"path":"https://andrewhooker.github.io/PopED/reference/LinMatrixLH.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Model linearization with respect to epsilon and eta. — LinMatrixLH","text":"","code":"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)) #> }) #> } #> #> ## -- 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 #>"},{"path":"https://andrewhooker.github.io/PopED/reference/LinMatrixL_occ.html","id":null,"dir":"Reference","previous_headings":"","what":"Model linearization with respect to occasion variability parameters. — LinMatrixL_occ","title":"Model linearization with respect to occasion variability parameters. — LinMatrixL_occ","text":"function performs linearization model respect occasion variability parameter.. Derivative model w.r.t. eta_occ, evaluated bocc_ind.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/LinMatrixL_occ.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Model linearization with respect to occasion variability parameters. — LinMatrixL_occ","text":"","code":"LinMatrixL_occ( model_switch, xt_ind, x, a, bpop, b_ind, bocc_ind, iCurrentOcc, poped.db )"},{"path":"https://andrewhooker.github.io/PopED/reference/LinMatrixL_occ.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Model linearization with respect to occasion variability parameters. — LinMatrixL_occ","text":"model_switch matrix size xt, specifying model sample belongs . xt_ind vector individual/group sample times x matrix discrete design variables. row group. matrix covariates. row group. bpop fixed effects parameter values. Supplied vector. b_ind vector individual realization BSV terms b bocc_ind Vector individual realizations BOV terms bocc iCurrentOcc current occasion. poped.db PopED database.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/LinMatrixL_occ.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Model linearization with respect to occasion variability parameters. — LinMatrixL_occ","text":"matrix size (samples per individual x number iovs)","code":""},{"path":[]},{"path":"https://andrewhooker.github.io/PopED/reference/LinMatrixL_occ.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Model linearization with respect to occasion variability parameters. — LinMatrixL_occ","text":"","code":"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)) #> }) #> } #> #> ## -- 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 #>"},{"path":"https://andrewhooker.github.io/PopED/reference/PopED.html","id":null,"dir":"Reference","previous_headings":"","what":"PopED - Population (and individual) optimal Experimental Design. — PopED","title":"PopED - Population (and individual) optimal Experimental Design. — PopED","text":"PopED computes optimal experimental designs population individual studies based nonlinear mixed-effect models. Often based computation Fisher Information Matrix (FIM).","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/PopED.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"PopED - Population (and individual) optimal Experimental Design. — PopED","text":"get started need define model. initial design (design space want optimize). tasks perform. number functions help tasks. user-level functions defined meant run minimum arguments (beginners advanced users). Many functions package (listed ) called user-level functions often user friendly (developer level advanced user functions). Define structural model: ff.PK.1.comp.oral.md.CL, ff.PK.1.comp.oral.md.KE, ff.PK.1.comp.oral.sd.CL, ff.PK.1.comp.oral.sd.KE, ff.PKPD.1.comp.oral.md.CL.imax, ff.PKPD.1.comp.sd.CL.emax. Define residual unexplained variability model (residual error model): feps.add.prop, feps.add, feps.prop. Create initial study design (design space): create.poped.database. Evaluate model /design simulation graphics: plot_model_prediction, model_prediction, plot_efficiency_of_windows. Evaluate design using FIM: evaluate_design, evaluate.fim, evaluate.e.ofv.fim, ofv_fim, get_rse. Optimize design (evaluate afterwards using functions): poped_optim, See \"Examples\" section short introduction using functions. several examples, r-scripts, \"examples\" folder PopED installation directory located (run R command line): system.file(\"examples\", package=\"PopED\").","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/PopED.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"PopED - Population (and individual) optimal Experimental Design. — PopED","text":"J. Nyberg, S. Ueckert, E.. Stroemberg, S. Hennig, M.O. Karlsson .C. Hooker, \"PopED: extended, parallelized, nonlinear mixed effects models optimal design tool\", Computer Methods Programs Biomedicine, 108, 2012. M. Foracchia, .C. Hooker, P. Vicini . Ruggeri, \"PopED, software optimal experimental design population kinetics\", Computer Methods Programs Biomedicine, 74, 2004. https://andrewhooker.github.io/PopED/","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/PopED.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"PopED - Population (and individual) optimal Experimental Design. — PopED","text":"","code":"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) }"},{"path":"https://andrewhooker.github.io/PopED/reference/RS_opt.html","id":null,"dir":"Reference","previous_headings":"","what":"Optimize the objective function using an adaptive random search algorithm for D-family and E-family designs. — RS_opt","title":"Optimize the objective function using an adaptive random search algorithm for D-family and E-family designs. — RS_opt","text":"Optimize objective function using adaptive random search algorithm. Optimization can performed D-family E-family designs. function works discrete continuous optimization variables. function takes information PopED database supplied argument. PopED database supplies information model, parameters, design methods use. arguments coming PopED database can overwritten; default arguments NULL function, supplied used instead arguments PopED database.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/RS_opt.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Optimize the objective function using an adaptive random search algorithm for D-family and E-family designs. — RS_opt","text":"","code":"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, ... )"},{"path":"https://andrewhooker.github.io/PopED/reference/RS_opt.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Optimize the objective function using an adaptive random search algorithm for D-family and E-family designs. — RS_opt","text":"poped.db PopED database. ni vector number samples group. xt matrix sample times. row vector sample times group. model_switch matrix size xt, specifying model sample belongs . x matrix discrete design variables. row group. matrix covariates. row group. bpopdescr Matrix defining fixed effects, per row (row number = parameter_number) : column 1 type distribution E-family designs (0 = Fixed, 1 = Normal, 2 = Uniform, 3 = User Defined Distribution, 4 = lognormal 5 = truncated normal) column 2 defines mean. column 3 defines variance distribution (length uniform distribution). ddescr Matrix defining diagonals IIV (logic bpopdescr). maxxt Matrix single value defining maximum value xt sample. single value supplied xt values given maximum value. minxt Matrix single value defining minimum value xt sample. single value supplied xt values given minimum value maxa Vector defining max value covariate. single value supplied values given max value mina Vector defining min value covariate. single value supplied values given max value fmf initial value FIM. set zero computed. dmf initial OFV. set zero computed. trflag optimization output screen file? opt_xt sample times optimized? opt_a continuous design variables optimized? opt_x discrete design variables optimized? cfaxt First step factor sample times cfaa Stochastic Gradient search first step factor covariates rsit Number Random search iterations rsit_output Number iterations random search screen output fim.calc.type method used calculating FIM. Potential values: 0 = Full FIM. assumption fixed random effects uncorrelated. 1 = Reduced FIM. Assume correlation FIM fixed random effects, set elements FIM zero. 2 = weighted models (placeholder). 3 = currently used. 4 = Reduced FIM computing derivatives respect standard deviation residual unexplained variation (sqrt(SIGMA) NONMEM). matches done PFIM, assumes standard deviation residual unexplained variation estimated parameter (NOTE: NONMEM estimates variance residual unexplained variation default). 5 = Full FIM parameterized ,B,C matrices & derivative variance. 6 = Calculate one model switch time, good large matrices. 7 = Reduced FIM parameterized ,B,C matrices & derivative variance. approx_type Approximation method model, 0=FO, 1=FOCE, 2=FOCEI, 3=FOI. iter number iterations entered blockheader_2 function. d_switch ******START CRITERION SPECIFICATION OPTIONS********** D-family design (1) ED-family design (0) (without parameter uncertainty) use_laplace Laplace method used calculating expectation OFV? laplace.fim E(FIM) calculated computing Laplace approximated E(OFV). Typically FIM need computed , desired, calculation done using standard MC integration technique, can slow. header_flag header text printed ? footer_flag footer text printed ? out_file file output directed ? string, file handle using file \"\" output screen. compute_inv inverse FIM used compute expected RSE values? Often needed except diagnostic purposes. ... arguments passed evaluate.fim ofv_fim.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/RS_opt.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Optimize the objective function using an adaptive random search algorithm for D-family and E-family designs. — RS_opt","text":"M. Foracchia, .C. Hooker, P. Vicini . Ruggeri, \"PopED, software fir optimal experimental design population kinetics\", Computer Methods Programs Biomedicine, 74, 2004. J. Nyberg, S. Ueckert, E.. Stroemberg, S. Hennig, M.O. Karlsson .C. Hooker, \"PopED: extended, parallelized, nonlinear mixed effects models optimal design tool\", Computer Methods Programs Biomedicine, 108, 2012.","code":""},{"path":[]},{"path":"https://andrewhooker.github.io/PopED/reference/RS_opt.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Optimize the objective function using an adaptive random search algorithm for D-family and E-family designs. — RS_opt","text":"","code":"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)) #> }) #> } #> #> ## -- 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.036 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=\"\") }"},{"path":"https://andrewhooker.github.io/PopED/reference/a_line_search.html","id":null,"dir":"Reference","previous_headings":"","what":"Optimize using line search — a_line_search","title":"Optimize using line search — a_line_search","text":"function performs grid search sequentially along design variables. grid defined ls_step_size.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/a_line_search.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Optimize using line search — a_line_search","text":"","code":"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 )"},{"path":"https://andrewhooker.github.io/PopED/reference/a_line_search.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Optimize using line search — a_line_search","text":"poped.db PopED database. out_file output file write . bED algorithm use E-family methods. Logical. diff OFV difference deemed significant changing design. , changing design variable difference new old OFV less diff change made. fmf_initial initial value FIM. 0 FIM calculated poped.db. dmf_initial initial value objective function value (OFV). 0 OFV calculated poped.db. opt_xt sample times optimized? opt_a continuous design variables optimized? opt_x discrete design variables optimized? opt_samps number sample times per group optimized? opt_inds number individuals per group optimized? ls_step_size Number grid points line search.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/a_line_search.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Optimize using line search — a_line_search","text":"list containing: fmf FIM. dmf final value objective function value. best_changed algorithm found better design starting design. xt matrix sample times. row vector sample times group. x matrix discrete design variables. row group. matrix covariates. row group. poped.db PopED database.","code":""},{"path":[]},{"path":"https://andrewhooker.github.io/PopED/reference/a_line_search.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Optimize using line search — a_line_search","text":"","code":"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)) #> }) #> } #> #> ## -- 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 xt8 on group 1 #> Searching xt6 on group 1 #> group 1 -- xt[6] changed from 36 to 0.01 #> OFV(MF) changed from 55.3964 to 55.7162 #> group 1 -- xt[6] changed from 0.01 to 90.0025 #> OFV(MF) changed from 55.7162 to 55.7556 #> group 1 -- xt[6] changed from 90.0025 to 120 #> OFV(MF) changed from 55.7556 to 55.7972 #> Searching xt5 on group 1 #> Searching xt3 on group 1 #> Searching xt4 on group 1 #> Searching xt7 on group 1 #> group 1 -- xt[7] changed from 72 to 90.0025 #> OFV(MF) changed from 55.7972 to 55.8529 #> Searching xt2 on group 1 #> group 1 -- xt[2] changed from 1 to 0.01 #> OFV(MF) changed from 55.8529 to 55.89 #> group 1 -- xt[2] changed from 0.01 to 30.0075 #> OFV(MF) changed from 55.89 to 55.9369 #> group 1 -- xt[2] changed from 30.0075 to 90.0025 #> OFV(MF) changed from 55.9369 to 55.9441 #> group 1 -- xt[2] changed from 90.0025 to 120 #> OFV(MF) changed from 55.9441 to 55.9617 #> Searching xt1 on group 1 #> OFV(MF): 55.9617 #> #> Best value for OFV(MF) = 55.9617 #> #> Best value for xt: #> Group 1: 0.5 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.9617 to 56.1549 #> group 1 -- a[1] changed from 75.0025 to 100 #> OFV(MF) changed from 56.1549 to 56.7447 #> OFV(MF): 56.7447 #> Best value for OFV(MF) = 56.7447 #> #> Best value for a: #> Group 1: 100 [0.01,100] #> #> #> Line search run time: 0.314 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\") }"},{"path":"https://andrewhooker.github.io/PopED/reference/bfgsb_min.html","id":null,"dir":"Reference","previous_headings":"","what":"Nonlinear minimization using BFGS with box constraints — bfgsb_min","title":"Nonlinear minimization using BFGS with box constraints — bfgsb_min","text":"implementation Broyden Fletcher Goldfarb Shanno (BFGS) method nonlinear minimization box constraints.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/bfgsb_min.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Nonlinear minimization using BFGS with box constraints — bfgsb_min","text":"","code":"bfgsb_min(f_name, f_options, x0, l, u, options = list())"},{"path":"https://andrewhooker.github.io/PopED/reference/bfgsb_min.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Nonlinear minimization using BFGS with box constraints — bfgsb_min","text":"f_name function name (text string) returns objective function gradient objective function, order. See calc_ofv_and_grad used Doptim. f_options Options f_name argument. x0 initial values optimize l lower bounds u upper bounds options list additional settings arguments","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/bfgsb_min.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Nonlinear minimization using BFGS with box constraints — bfgsb_min","text":"list containing: x_k objective function. f_k gradient. B_k hessian.","code":""},{"path":[]},{"path":"https://andrewhooker.github.io/PopED/reference/bfgsb_min.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Nonlinear minimization using BFGS with box constraints — bfgsb_min","text":"","code":"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)) #> }) #> } #> #> ## -- 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) }"},{"path":"https://andrewhooker.github.io/PopED/reference/blockexp.html","id":null,"dir":"Reference","previous_headings":"","what":"Summarize your experiment for optimization routines — blockexp","title":"Summarize your experiment for optimization routines — blockexp","text":"Create output screen text file summarizes initial design design space use optimize.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/blockexp.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Summarize your experiment for optimization routines — blockexp","text":"","code":"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] )"},{"path":"https://andrewhooker.github.io/PopED/reference/blockexp.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Summarize your experiment for optimization routines — blockexp","text":"fn file handle write . poped.db PopED database. e_flag output uncertainty around parameters? opt_xt sample times optimized? opt_a continuous design variables optimized? opt_x discrete design variables optimized? opt_samps number sample times per group optimized? opt_inds number individuals per group optimized?","code":""},{"path":[]},{"path":"https://andrewhooker.github.io/PopED/reference/blockexp.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Summarize your experiment for optimization routines — blockexp","text":"","code":"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)) #> }) #> } #> #> ## -- 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"},{"path":"https://andrewhooker.github.io/PopED/reference/blockfinal.html","id":null,"dir":"Reference","previous_headings":"","what":"Result function for optimization routines — blockfinal","title":"Result function for optimization routines — blockfinal","text":"Create output screen text file summarizes problem solved.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/blockfinal.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Result function for optimization routines — blockfinal","text":"","code":"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, ... )"},{"path":"https://andrewhooker.github.io/PopED/reference/blockfinal.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Result function for optimization routines — blockfinal","text":"fn file handle write . fmf initial value FIM. set zero computed. dmf initial OFV. set zero computed. groupsize vector number individuals group. ni vector number samples group. xt matrix sample times. row vector sample times group. x matrix discrete design variables. row group. matrix covariates. row group. model_switch matrix size xt, specifying model sample belongs . bpop Matrix defining fixed effects, per row (row number = parameter_number) : column 1 type distribution E-family designs (0 = Fixed, 1 = Normal, 2 = Uniform, 3 = User Defined Distribution, 4 = lognormal 5 = truncated normal) column 2 defines mean. column 3 defines variance distribution (length uniform distribution). Can also just supply parameter values vector c() uncertainty around parameter value used. parameter order 'bpop' defined 'fg_fun' 'fg_file'. use named arguments 'bpop' order worked automatically. d Matrix defining diagonals IIV (logic fixed effects matrix bpop define uncertainty). One can also just supply parameter values c(). parameter order 'd' defined 'fg_fun' 'fg_file'. use named arguments 'd' order worked automatically. docc Matrix defining IOV, IOV variances IOV distribution d bpop. sigma Matrix defining variances can covariances residual variability terms model. can also just supply diagonal parameter values (variances) c(). poped.db PopED database. opt_xt sample times optimized? opt_a continuous design variables optimized? opt_x discrete design variables optimized? opt_inds number individuals per group optimized? fmf_init Initial FIM. dmf_init Initial OFV. param_cvs_init initial design parameter RSE values percent. compute_inv inverse FIM used compute expected RSE values? Often needed except diagnostic purposes. out_file file output directed ? string, file handle using file \"\" output screen. trflag optimization output screen file? footer_flag footer text printed ? ... arguments passed evaluate.fim ofv_fim.","code":""},{"path":[]},{"path":"https://andrewhooker.github.io/PopED/reference/blockfinal.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Result function for optimization routines — blockfinal","text":"","code":"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)) #> }) #> } #> #> ## -- 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.531 seconds"},{"path":"https://andrewhooker.github.io/PopED/reference/blockheader.html","id":null,"dir":"Reference","previous_headings":"","what":"Header function for optimization routines — blockheader","title":"Header function for optimization routines — blockheader","text":"Create output screen text file summarizes problem tying solve.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/blockheader.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Header function for optimization routines — blockheader","text":"","code":"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, ... )"},{"path":"https://andrewhooker.github.io/PopED/reference/blockheader.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Header function for optimization routines — blockheader","text":"poped.db PopED database. name name used output file. Combined name_header iter. \"\" output screen. iter last number name printed output file, combined name. e_flag output uncertainty around parameters? opt_xt sample times optimized? opt_a continuous design variables optimized? opt_x discrete design variables optimized? opt_samps number sample times per group optimized? opt_inds number individuals per group optimized? fmf initial value FIM. set zero computed. dmf initial OFV. set zero computed. bpop Matrix defining fixed effects, per row (row number = parameter_number) : column 1 type distribution E-family designs (0 = Fixed, 1 = Normal, 2 = Uniform, 3 = User Defined Distribution, 4 = lognormal 5 = truncated normal) column 2 defines mean. column 3 defines variance distribution (length uniform distribution). Can also just supply parameter values vector c() uncertainty around parameter value used. parameter order 'bpop' defined 'fg_fun' 'fg_file'. use named arguments 'bpop' order worked automatically. d Matrix defining diagonals IIV (logic fixed effects matrix bpop define uncertainty). One can also just supply parameter values c(). parameter order 'd' defined 'fg_fun' 'fg_file'. use named arguments 'd' order worked automatically. docc Matrix defining IOV, IOV variances IOV distribution d bpop. sigma Matrix defining variances can covariances residual variability terms model. can also just supply diagonal parameter values (variances) c(). name_header initial portion file name. file_path path file created. out_file file output directed ? string, file handle using file \"\" output screen. compute_inv inverse FIM used compute expected RSE values? Often needed except diagnostic purposes. trflag optimization output screen file? header_flag header text printed ? ... Additional arguments passed functions.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/blockheader.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Header function for optimization routines — blockheader","text":"fn file handle ('' name='')","code":""},{"path":[]},{"path":"https://andrewhooker.github.io/PopED/reference/blockheader.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Header function for optimization routines — blockheader","text":"","code":"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)) #> }) #> } #> #> ## -- 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"},{"path":"https://andrewhooker.github.io/PopED/reference/blockopt.html","id":null,"dir":"Reference","previous_headings":"","what":"Summarize your optimization settings for optimization routines — blockopt","title":"Summarize your optimization settings for optimization routines — blockopt","text":"Create output screen text file summarizes optimization settings use optimize.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/blockopt.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Summarize your optimization settings for optimization routines — blockopt","text":"","code":"blockopt(fn, poped.db, opt_method = \"\")"},{"path":"https://andrewhooker.github.io/PopED/reference/blockopt.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Summarize your optimization settings for optimization routines — blockopt","text":"fn file handle write . poped.db PopED database. opt_method \"RS\" (random search), \"SG\" (stochastic gradient) \"\" (discrete optimization) specific output produced.","code":""},{"path":[]},{"path":"https://andrewhooker.github.io/PopED/reference/blockopt.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Summarize your optimization settings for optimization routines — blockopt","text":"","code":"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)) #> }) #> } #> #> ## -- 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"},{"path":"https://andrewhooker.github.io/PopED/reference/build_sfg.html","id":null,"dir":"Reference","previous_headings":"","what":"Build PopED parameter function from a model function — build_sfg","title":"Build PopED parameter function from a model function — build_sfg","text":"Build PopED parameter function model function","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/build_sfg.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Build PopED parameter function from a model function — build_sfg","text":"","code":"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() )"},{"path":"https://andrewhooker.github.io/PopED/reference/build_sfg.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Build PopED parameter function from a model function — build_sfg","text":"model string text describing model function name covariates list covariate names filtered model par_names list parameter names model file. supplied undefined variables model file extracted covariate names filtered list. etas Can \"exp\", \"prop\", \"add\" \"none\". Either one value parameters list defining model per parameter. no_etas Parameters etas associated . env environment create function .","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/build_sfg.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Build PopED parameter function from a model function — build_sfg","text":"parameter model function used input PopED calculations.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/build_sfg.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Build PopED parameter function from a model function — build_sfg","text":"","code":"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]) #> 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]) #> "},{"path":"https://andrewhooker.github.io/PopED/reference/calc_autofocus.html","id":null,"dir":"Reference","previous_headings":"","what":"Compute the autofocus portion of the stochastic gradient routine — calc_autofocus","title":"Compute the autofocus portion of the stochastic gradient routine — calc_autofocus","text":"Compute autofocus portion stochastic gradient routine","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/calc_autofocus.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Compute the autofocus portion of the stochastic gradient routine — calc_autofocus","text":"","code":"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 )"},{"path":"https://andrewhooker.github.io/PopED/reference/calc_autofocus.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Compute the autofocus portion of the stochastic gradient routine — calc_autofocus","text":"m Number groups study. individual group design. ni_var ni_var. dmf initial OFV. set zero computed. varopt varopt. varopto varopto. maxvar maxvar. minvar minvar. gradvar gradvar. normgvar normgvar. avar avar. model_switch matrix size xt, specifying model sample belongs . groupsize vector number individuals group. xtopt optimal sampling times matrix. xopt optimal discrete design variables matrix. aopt optimal continuous design variables matrix. ni vector number samples group. bpop Matrix defining fixed effects, per row (row number = parameter_number) : column 1 type distribution E-family designs (0 = Fixed, 1 = Normal, 2 = Uniform, 3 = User Defined Distribution, 4 = lognormal 5 = truncated normal) column 2 defines mean. column 3 defines variance distribution (length uniform distribution). Can also just supply parameter values vector c() uncertainty around parameter value used. parameter order 'bpop' defined 'fg_fun' 'fg_file'. use named arguments 'bpop' order worked automatically. d Matrix defining diagonals IIV (logic fixed effects matrix bpop define uncertainty). One can also just supply parameter values c(). parameter order 'd' defined 'fg_fun' 'fg_file'. use named arguments 'd' order worked automatically. sigma Matrix defining variances can covariances residual variability terms model. can also just supply diagonal parameter values (variances) c(). docc Matrix defining IOV, IOV variances IOV distribution d bpop. poped.db PopED database.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/calc_autofocus.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Compute the autofocus portion of the stochastic gradient routine — calc_autofocus","text":"list containing: navar autofocus parameter. poped.db PopED database.","code":""},{"path":[]},{"path":"https://andrewhooker.github.io/PopED/reference/calc_autofocus.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Compute the autofocus portion of the stochastic gradient routine — calc_autofocus","text":"","code":"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)) #> }) #> } #> #> ## -- 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) }"},{"path":"https://andrewhooker.github.io/PopED/reference/calc_ofv_and_fim.html","id":null,"dir":"Reference","previous_headings":"","what":"Calculate the Fisher Information Matrix (FIM) and the OFV(FIM) for either point values or parameters or distributions. — calc_ofv_and_fim","title":"Calculate the Fisher Information Matrix (FIM) and the OFV(FIM) for either point values or parameters or distributions. — calc_ofv_and_fim","text":"function computes expectation FIM OFV(FIM) either point values parameter estimates parameter distributions given model, parameters, distributions parameter uncertainty, design methods defined PopED database.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/calc_ofv_and_fim.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Calculate the Fisher Information Matrix (FIM) and the OFV(FIM) for either point values or parameters or distributions. — calc_ofv_and_fim","text":"","code":"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, ... )"},{"path":"https://andrewhooker.github.io/PopED/reference/calc_ofv_and_fim.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Calculate the Fisher Information Matrix (FIM) and the OFV(FIM) for either point values or parameters or distributions. — calc_ofv_and_fim","text":"poped.db PopED database. ofv current ofv. zero value simply returned unchanged. fim current FIM. zero value simply returned unchanged. d_switch ******START CRITERION SPECIFICATION OPTIONS********** D-family design (1) ED-family design (0) (without parameter uncertainty) bpopdescr Matrix defining fixed effects, per row (row number = parameter_number) : column 1 type distribution E-family designs (0 = Fixed, 1 = Normal, 2 = Uniform, 3 = User Defined Distribution, 4 = lognormal 5 = truncated normal) column 2 defines mean. column 3 defines variance distribution (length uniform distribution). ddescr Matrix defining diagonals IIV (logic bpopdescr). bpop Matrix defining fixed effects, per row (row number = parameter_number) : column 1 type distribution E-family designs (0 = Fixed, 1 = Normal, 2 = Uniform, 3 = User Defined Distribution, 4 = lognormal 5 = truncated normal) column 2 defines mean. column 3 defines variance distribution (length uniform distribution). Can also just supply parameter values vector c() uncertainty around parameter value used. parameter order 'bpop' defined 'fg_fun' 'fg_file'. use named arguments 'bpop' order worked automatically. d Matrix defining diagonals IIV (logic fixed effects matrix bpop define uncertainty). One can also just supply parameter values c(). parameter order 'd' defined 'fg_fun' 'fg_file'. use named arguments 'd' order worked automatically. docc_full occasion variability matrix. model_switch matrix size xt, specifying model sample belongs . ni vector number samples group. xt matrix sample times. row vector sample times group. x matrix discrete design variables. row group. matrix covariates. row group. fim.calc.type method used calculating FIM. Potential values: 0 = Full FIM. assumption fixed random effects uncorrelated. 1 = Reduced FIM. Assume correlation FIM fixed random effects, set elements FIM zero. 2 = weighted models (placeholder). 3 = currently used. 4 = Reduced FIM computing derivatives respect standard deviation residual unexplained variation (sqrt(SIGMA) NONMEM). matches done PFIM, assumes standard deviation residual unexplained variation estimated parameter (NOTE: NONMEM estimates variance residual unexplained variation default). 5 = Full FIM parameterized ,B,C matrices & derivative variance. 6 = Calculate one model switch time, good large matrices. 7 = Reduced FIM parameterized ,B,C matrices & derivative variance. use_laplace Laplace method used calculating expectation OFV? laplace.fim E(FIM) calculated computing Laplace approximated E(OFV). Typically FIM need computed , desired, calculation done using standard MC integration technique, can slow. ofv_fun User defined function used compute objective function. function must poped database object first argument \"...\" argument list. Can referenced function file name function defined file name file. e.g. \"cost.txt\" function named \"cost\" . evaluate_fim FIM calculated? ... arguments passed function.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/calc_ofv_and_fim.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Calculate the Fisher Information Matrix (FIM) and the OFV(FIM) for either point values or parameters or distributions. — calc_ofv_and_fim","text":"list containing FIM OFV(FIM) E(FIM) E(OFV(FIM)) according function arguments.","code":""},{"path":[]},{"path":"https://andrewhooker.github.io/PopED/reference/calc_ofv_and_fim.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Calculate the Fisher Information Matrix (FIM) and the OFV(FIM) for either point values or parameters or distributions. — calc_ofv_and_fim","text":"","code":"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)) #> }) #> } #> #> ## -- 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) }"},{"path":"https://andrewhooker.github.io/PopED/reference/calc_ofv_and_grad.html","id":null,"dir":"Reference","previous_headings":"","what":"Compute an objective function and gradient — calc_ofv_and_grad","title":"Compute an objective function and gradient — calc_ofv_and_grad","text":"Compute objective function gradient respect optimization parameters. function can passed Broyden Fletcher Goldfarb Shanno (BFGS) method nonlinear minimization box constraints implemented bfgsb_min.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/calc_ofv_and_grad.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Compute an objective function and gradient — calc_ofv_and_grad","text":"","code":"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 )"},{"path":"https://andrewhooker.github.io/PopED/reference/calc_ofv_and_grad.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Compute an objective function and gradient — calc_ofv_and_grad","text":"x matrix discrete design variables. row group. optxt sampling times optimized opta continuous design variables optimized model_switch matrix size xt, specifying model sample belongs . aa aa value axt axt value groupsize vector number individuals group. ni vector number samples group. xtopto xtopto value xopto xopto value aopto aopto value bpop Matrix defining fixed effects, per row (row number = parameter_number) : column 1 type distribution E-family designs (0 = Fixed, 1 = Normal, 2 = Uniform, 3 = User Defined Distribution, 4 = lognormal 5 = truncated normal) column 2 defines mean. column 3 defines variance distribution (length uniform distribution). Can also just supply parameter values vector c() uncertainty around parameter value used. parameter order 'bpop' defined 'fg_fun' 'fg_file'. use named arguments 'bpop' order worked automatically. d Matrix defining diagonals IIV (logic fixed effects matrix bpop define uncertainty). One can also just supply parameter values c(). parameter order 'd' defined 'fg_fun' 'fg_file'. use named arguments 'd' order worked automatically. sigma Matrix defining variances can covariances residual variability terms model. can also just supply diagonal parameter values (variances) c(). docc_full occasion variability matrix. poped.db PopED database. only_fim gradient calculated?","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/calc_ofv_and_grad.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Compute an objective function and gradient — calc_ofv_and_grad","text":"list containing: f objective function. g gradient.","code":""},{"path":[]},{"path":"https://andrewhooker.github.io/PopED/reference/calc_ofv_and_grad.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Compute an objective function and gradient — calc_ofv_and_grad","text":"","code":"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)) #> }) #> } #> #> ## -- 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.079631185 #> [2,] -0.025697327 #> [3,] -0.312973785 #> [4,] 0.009484133 #> [5,] 0.019485307 #> [6,] -0.001675713 #> [7,] -0.009544061 #> [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) }"},{"path":"https://andrewhooker.github.io/PopED/reference/cell.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a cell array (a matrix of lists) — cell","title":"Create a cell array (a matrix of lists) — cell","text":"Create cell array MATLAB.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/cell.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a cell array (a matrix of lists) — cell","text":"","code":"cell(...)"},{"path":"https://andrewhooker.github.io/PopED/reference/cell.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a cell array (a matrix of lists) — cell","text":"... Dimensions cell array.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/cell.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a cell array (a matrix of lists) — cell","text":"list empty lists.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/cell.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Create a cell array (a matrix of lists) — cell","text":"modified version function matlab R-package.","code":""},{"path":[]},{"path":"https://andrewhooker.github.io/PopED/reference/cell.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a cell array (a matrix of lists) — cell","text":"","code":"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 #>"},{"path":"https://andrewhooker.github.io/PopED/reference/convert_variables.html","id":null,"dir":"Reference","previous_headings":"","what":"Create global variables in the PopED database — convert_variables","title":"Create global variables in the PopED database — convert_variables","text":"Function takes design variables input files converts global variables needed PopED. Typically used user. Instead use function create.poped.database.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/convert_variables.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create global variables in the PopED database — convert_variables","text":"","code":"convert_variables(poped.db)"},{"path":"https://andrewhooker.github.io/PopED/reference/convert_variables.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create global variables in the PopED database — convert_variables","text":"poped.db PopED database","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/convert_variables.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create global variables in the PopED database — convert_variables","text":"PopED database","code":""},{"path":[]},{"path":"https://andrewhooker.github.io/PopED/reference/create.poped.database.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a PopED database — create.poped.database","title":"Create a PopED database — create.poped.database","text":"function takes input file (previously created poped database) supplied user, function arguments, creates database can used run PopED functions. function supplies default values elements database specified input file function arguments. Default arguments supplied Usage section (easiest use text search find values interested ).","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/create.poped.database.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a PopED database — create.poped.database","text":"","code":"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) )"},{"path":"https://andrewhooker.github.io/PopED/reference/create.poped.database.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a PopED database — create.poped.database","text":"popedInput PopED database file empty list list(). List elements match values seen Usage section (defaults function arguments). ff_file ******START MODEL DEFINITION OPTIONS********** string giving function name filename path structural model. filename function name must giving filename. e.g. \"ff.PK.1.comp.oral.md.KE\" ff_fun Function describing structural model. e.g. ff.PK.1.comp.oral.md.KE. fg_file string giving function name filename path parameter model. filename function name must giving filename. e.g. \"parameter.model\" fg_fun Function describing parameter model. e.g. parameter.model. fError_file string giving function name filename path residual error model. filename function name must giving filename. e.g. \"feps.prop\". fError_fun Function describing residual error model. e.g. feps.prop. optsw ******OPTIMIZE********** Row vector optimization tasks (1=TRUE,0=FALSE) following order: (Samples per subject, Sampling schedule, Discrete design variable, Continuous design variable, Number id per group). elements set zero => calculate FIM current design xt ******START INITIAL DESIGN OPTIONS********** Matrix defining initial sampling schedule. row group/individual. one vector supplied, e.g. c(1,2,3,4), groups initial design. m Number groups study. individual group design. x matrix defining initial discrete values model row group/individual. nx Number discrete design variables. Matrix defining initial continuous covariate values. n_rows=number groups, n_cols=number covariates. number rows one number groups > 1 groups assigned values. groupsize Vector defining size different groups (num individuals group). one number number every group. ni Vector defining number samples group. model_switch Matrix defining response certain sampling time belongs . maxni ******START DESIGN SPACE OPTIONS********** Max number samples per group/individual minni Min number samples per group/individual maxtotni Number defining maximum number samples allowed experiment. mintotni Number defining minimum number samples allowed experiment. maxgroupsize Vector defining max size different groups (max number individuals group) mingroupsize Vector defining min size different groups (min num individuals group) -- maxtotgroupsize total maximal groupsize groups mintotgroupsize total minimal groupsize groups maxxt Matrix single value defining maximum value xt sample. single value supplied xt values given maximum value. minxt Matrix single value defining minimum value xt sample. single value supplied xt values given minimum value discrete_xt Cell array cell defining discrete variables allowed xt value. Can also list values list(1:10) (values allowed xt), list lists list(1:10, 2:23, 4:6) (one value xt). See examples create_design_space. discrete_x Cell array defining discrete variables x value. See examples create_design_space. maxa Vector defining max value covariate. single value supplied values given max value mina Vector defining min value covariate. single value supplied values given max value discrete_a Cell array cell defining discrete variables allowed value. Can also list values list(1:10) (values allowed ), list lists list(1:10, 2:23, 4:6) (one value ). See examples create_design_space. bUseGrouped_xt Use grouped time points (1=TRUE, 0=FALSE). G_xt Matrix defining grouping sample points. Matching integers mean points matched. bUseGrouped_a Use grouped covariates (1=TRUE, 0=FALSE) G_a Matrix defining grouping covariates. Matching integers mean points matched. bUseGrouped_x Use grouped discrete design variables (1=TRUE, 0=FALSE). G_x Matrix defining grouping discrete design variables. Matching integers mean points matched. iFIMCalculationType ******START FIM CALCULATION OPTIONS********** Fisher Information Matrix type 0=Full FIM 1=Reduced FIM 2=weighted models 3=Loc models 4=reduced FIM derivative SD sigma PFIM 5=FULL FIM parameterized ,B,C matrices & derivative variance 6=Calculate one model switch time, good large matrices 7=Reduced FIM parameterized ,B,C matrices & derivative variance iApproximationMethod Approximation method model, 0=FO, 1=FOCE, 2=FOCEI, 3=FOI iFOCENumInd Num individuals step FOCE prior_fim prior FIM (added calculated FIM) strAutoCorrelationFile Filename path, function name, Autocorrelation function, empty string means autocorrelation. d_switch ******START CRITERION SPECIFICATION OPTIONS********** D-family design (1) ED-family design (0) (without parameter uncertainty) ofv_calc_type OFV calculation type FIM 1 = \"D-optimality\". Determinant FIM: det(FIM) 2 = \"-optimality\". Inverse sum expected parameter variances: 1/trace_matrix(inv(FIM)) 4 = \"lnD-optimality\". Natural logarithm determinant FIM: log(det(FIM)) 6 = \"Ds-optimality\". Ratio Determinant FIM Determinant uninteresting rows columns FIM: det(FIM)/det(FIM_u) 7 = Inverse sum expected parameter RSE: 1/sum(get_rse(FIM,poped.db,use_percent=FALSE)) ds_index Ds_index vector set 1 parameter uninteresting, otherwise 0. size=(1,num unfixed parameters). First unfixed bpop, unfixed d, unfixed docc last unfixed sigma. Default fixed effects important, everything else important. Used conjunction ofv_calc_type=6. strEDPenaltyFile Penalty function name path filename, empty string means penalty. User defined criterion can defined way. ofv_fun User defined function used compute objective function. function must poped database object first argument \"...\" argument list. Can referenced function file name function defined file name file. e.g. \"cost.txt\" function named \"cost\" . iEDCalculationType ******START E-FAMILY CRITERION SPECIFICATION OPTIONS********** ED Integral Calculation, 0=Monte-Carlo-Integration, 1=Laplace Approximation, 2=BFGS Laplace Approximation -- -- ED_samp_size Sample size E-family sampling bLHS sample distributions E-family calculations. 0=Random Sampling, 1=LatinHyperCube -- strUserDistributionFile Filename path, function name, user defined distributions E-family designs nbpop ******START Model parameters SPECIFICATION OPTIONS********** Number typical values NumRanEff Number IIV parameters. Typically can computed values supplied. NumDocc Number IOV variance parameters. Typically can computed values supplied. NumOcc Number occasions. Typically can computed values supplied. bpop Matrix defining fixed effects, per row (row number = parameter_number) : column 1 type distribution E-family designs (0 = Fixed, 1 = Normal, 2 = Uniform, 3 = User Defined Distribution, 4 = lognormal 5 = truncated normal) column 2 defines mean. column 3 defines variance distribution (length uniform distribution). Can also just supply parameter values vector c() uncertainty around parameter value used. parameter order 'bpop' defined 'fg_fun' 'fg_file'. use named arguments 'bpop' order worked automatically. d Matrix defining diagonals IIV (logic fixed effects matrix bpop define uncertainty). One can also just supply parameter values c(). parameter order 'd' defined 'fg_fun' 'fg_file'. use named arguments 'd' order worked automatically. covd Column major vector defining covariances IIV variances. , full IIV matrix covd <- IIV[lower.tri(IIV)]. sigma Matrix defining variances can covariances residual variability terms model. can also just supply diagonal parameter values (variances) c(). docc Matrix defining IOV, IOV variances IOV distribution d bpop. covdocc Column major vector defining covariance IOV, covd. notfixed_bpop ******START Model parameters fixed SPECIFICATION OPTIONS********** Vector defining typical value fixed (1=fixed, 0=fixed). parameter order 'notfixed_bpop' defined 'fg_fun' 'fg_file'. use named arguments 'notfixed_bpop' order worked automatically. notfixed_d Vector defining IIV fixed (1=fixed, 0=fixed). parameter order 'notfixed_d' defined 'fg_fun' 'fg_file'. use named arguments 'notfixed_d' order worked automatically. notfixed_covd Vector defining covariance IIV fixed (1=fixed, 0=fixed) notfixed_docc Vector defining IOV variance fixed (1=fixed, 0=fixed) notfixed_covdocc Vector row major order lower triangular matrix defining covariance IOV fixed (1=fixed, 0=fixed) notfixed_sigma Vector defining residual error parameter fixed (1=fixed, 0=fixed) notfixed_covsigma Vector defining covariance residual error parameter fixed (1=fixed, 0=fixed). Default fixed. bUseRandomSearch ******START 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 path, function name, run file used instead regular PopED call. poped_version ******START Labeling file names SPECIFICATION OPTIONS********** current PopED version modtit model title output_file Filename path output file search output_function_file Filename suffix result function file strIterationFileName Filename path storage current optimal design user_data ******START Miscellaneous SPECIFICATION OPTIONS********** User defined data structure , example used send data model ourzero Value interpret zero design dSeed seed number used optimization sampling -- integer -1 creates random seed .integer(Sys.time()) NULL. line_opta Vector line search continuous design variables (1=TRUE,0=FALSE) line_optx Vector line search discrete design variables (1=TRUE,0=FALSE) bShowGraphs Use graph output search use_logfile log file used (0=FALSE, 1=TRUE) m1_switch Method used calculate M1 (0=Complex difference, 1=Central difference, 20=Analytic derivative, 30=Automatic differentiation) m2_switch Method used calculate M2 (0=Central difference, 1=Central difference, 20=Analytic derivative, 30=Automatic differentiation) hle_switch Method used calculate linearization residual error (0=Complex difference, 1=Central difference, 30=Automatic differentiation) gradff_switch Method used calculate gradient model (0=Complex difference, 1=Central difference, 20=Analytic derivative, 30=Automatic differentiation) gradfg_switch Method used calculate gradient parameter vector g (0=Complex difference, 1=Central difference, 20=Analytic derivative, 30=Automatic differentiation) grad_all_switch Method used calculate gradients (0=Complex difference, 1=Central difference) rsit_output Number iterations random search screen output sgit_output Number iterations stochastic gradient search screen output hm1 Step length derivative linearized model w.r.t. typical values hlf Step length derivative model w.r.t. g hlg Step length derivative g w.r.t. b hm2 Step length derivative variance w.r.t. typical values hgd Step length derivative OFV w.r.t. time hle Step length derivative model w.r.t. sigma AbsTol absolute tolerance diff equation solver RelTol relative tolerance diff equation solver iDiffSolverMethod diff equation solver method, NULL default. bUseMemorySolver differential equation results stored memory (1) (0) rsit Number Random search iterations sgit Number stochastic gradient iterations intrsit Number Random search iterations discrete optimization. intsgit Number Stochastic Gradient search iterations discrete optimization maxrsnullit Iterations adaptive narrowing random search convergence_eps Stochastic Gradient convergence value, (difference OFV D-optimal, difference gradient ED-optimal) rslxt Random search locality factor sample times rsla Random search locality factor covariates cfaxt Stochastic Gradient search first step factor sample times cfaa Stochastic Gradient search first step factor covariates bGreedyGroupOpt Use greedy algorithm group assignment optimization EAStepSize Exchange Algorithm StepSize EANumPoints Exchange Algorithm NumPoints EAConvergenceCriteria Exchange Algorithm Convergence Limit/Criteria bEANoReplicates Avoid replicate samples 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 iterations ED-optimal design calculate convergence criteria ED_diff_percent ED-optimal design convergence criteria percent line_search_it Number grid points line search Doptim_iter Number iterations full Random search full Stochastic Gradient line search used iCompileOption ******START PARALLEL OPTIONS********** Compile options PopED -1 = compilation, 0 3 = Full compilation, 1 4 = using MCC (shared lib), 2 5 = MPI, Option 0,1,2 runs PopED option 3,4,5 stops compilation iUseParallelMethod Parallel method use (0 = Matlab PCT, 1 = MPI) MCC_Dep Additional dependencies used MCC compilation (mat-files), several space separated strExecuteName Compilation output executable name iNumProcesses Number processes use running parallel (e.g. 3 = 2 workers, 1 job manager) iNumChunkDesignEvals Number design evaluations evaluated process getting new work job manager Mat_Out_Pre prefix output mat file communicate executable strExtraRunOptions Extra options send e$g. MPI executable batch script, see execute_parallel$m information options dPollResultTime Polling time check parallel execution finished strFunctionInputName file containing popedInput structure used evaluate designs bParallelRS random search going executed parallel bParallelSG stochastic gradient search going executed parallel bParallelMFEA modified exchange algorithm going executed parallel bParallelLS line search going executed parallel","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/create.poped.database.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a PopED database — create.poped.database","text":"PopED database","code":""},{"path":[]},{"path":"https://andrewhooker.github.io/PopED/reference/create.poped.database.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a PopED database — create.poped.database","text":"","code":"## 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)) #> }) #> } #> #> ## -- 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"},{"path":"https://andrewhooker.github.io/PopED/reference/create_design.html","id":null,"dir":"Reference","previous_headings":"","what":"Create design variables for a full description of a design. — create_design","title":"Create design variables for a full description of a design. — create_design","text":"Create design variables fully describe design. variables supplied variables checked consistency , possible, changed sizes make sense inconsistencies. Returns list matricies compatible PopED.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/create_design.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create design variables for a full description of a design. — create_design","text":"","code":"create_design( xt, groupsize, m = NULL, x = NULL, a = NULL, ni = NULL, model_switch = NULL )"},{"path":"https://andrewhooker.github.io/PopED/reference/create_design.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create design variables for a full description of a design. — create_design","text":"xt Matrix defining sampling schedule. row group. groupsize Vector defining size different groups (number individuals group). m number defining number groups. Computed xt defined. x matrix defining discrete design variables model row group. Matrix defining continuous design variables. row group. ni Vector defining number samples group, computed elements xt group default. model_switch Matrix defining response certain sampling time belongs . Defaults one elements xt.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/create_design.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Create design variables for a full description of a design. — create_design","text":"value (vector/list values) supplied corresponds one group design multiple groups groups value(s). matrix expected list lists can supplied instead, list corresponding group.","code":""},{"path":[]},{"path":"https://andrewhooker.github.io/PopED/reference/create_design.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create design variables for a full description of a design. — create_design","text":"","code":"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)))"},{"path":"https://andrewhooker.github.io/PopED/reference/create_design_space.html","id":null,"dir":"Reference","previous_headings":"","what":"Create design variables and a design space for a full description of an optimization problem. — create_design_space","title":"Create design variables and a design space for a full description of an optimization problem. — create_design_space","text":"create_design_space takes initial design arguments design space creates design design space design optimization. Checks sizes supplied design space variables changes sizes make sense inconsistencies. Function arguments can use shorthand notation (single values, vectors, lists vectors list list) matricies. Returns list matricies compatible PopED.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/create_design_space.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create design variables and a design space for a full description of an optimization problem. — create_design_space","text":"","code":"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 )"},{"path":"https://andrewhooker.github.io/PopED/reference/create_design_space.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create design variables and a design space for a full description of an optimization problem. — create_design_space","text":"design output call create_design. maxni Vector defining maximum number samples per group. minni Vector defining minimum number samples per group. maxtotni Number defining maximum number samples allowed experiment. mintotni Number defining minimum number samples allowed experiment. maxgroupsize Vector defining maximum size different groups (maximum number individuals group) mingroupsize Vector defining minimum size different groups (minimum num individuals group) maxtotgroupsize total maximal groupsize groups mintotgroupsize total minimal groupsize groups maxxt Matrix single value defining maximum value xt sample. single value supplied xt values given maximum value. minxt Matrix single value defining minimum value xt sample. single value supplied xt values given minimum value xt_space Cell array cell defining discrete variables allowed xt value. Can also vector values c(1:10) (values allowed xt), list lists list(1:10, 2:23, 4:6) (one value xt row major order just one row xt, rows duplicated). maxa Vector defining maximum value covariate. single value supplied values given maximum value mina Vector defining minimum value covariate. single value supplied values given minimum value a_space Cell array cell defining discrete variables allowed value. Can also list values list(1:10) (values allowed ), list lists list(1:10, 2:23, 4:6) (one value ). x_space Cell array cell defining discrete variables x value. use_grouped_xt Group sampling times groups group values (TRUE FALSE). grouped_xt Matrix defining grouping sample points. Matching integers mean points matched. Allows finer control use_grouped_xt use_grouped_a Group continuous design variables groups group values (TRUE FALSE). grouped_a Matrix defining grouping continuous design variables. Matching integers mean values matched. Allows finer control use_grouped_a. use_grouped_x Group discrete design variables groups group values (TRUE FALSE). grouped_x Matrix defining grouping discrete design variables. Matching integers mean values matched. Allows finer control use_grouped_x. our_zero Value interpret zero design.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/create_design_space.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Create design variables and a design space for a full description of an optimization problem. — create_design_space","text":"value (vector list values) supplied corresponds one group design multiple groups groups value(s). matrix expected list lists can supplied instead, list corresponding group.","code":""},{"path":[]},{"path":"https://andrewhooker.github.io/PopED/reference/create_design_space.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create design variables and a design space for a full description of an optimization problem. — create_design_space","text":"","code":"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)))"},{"path":"https://andrewhooker.github.io/PopED/reference/design_summary.html","id":null,"dir":"Reference","previous_headings":"","what":"Display a summary of output from poped_db — design_summary","title":"Display a summary of output from poped_db — design_summary","text":"Display summary output poped_db","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/design_summary.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Display a summary of output from poped_db — design_summary","text":"","code":"design_summary(poped_db, file = \"\", ...)"},{"path":"https://andrewhooker.github.io/PopED/reference/design_summary.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Display a summary of output from poped_db — design_summary","text":"poped_db object returned create.poped.database summarize. file file handle write . Default R console. ... Additional arguments. Passed blockfinal.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/diag_matlab.html","id":null,"dir":"Reference","previous_headings":"","what":"Function written to match MATLAB's diag function — diag_matlab","title":"Function written to match MATLAB's diag function — diag_matlab","text":"differences tha MATLAB R version diag. Specifically, 1xN Nx1 matrix supplied R diag function just first element vector returned. function tries match MATLAB version handling vectors (matricies one dimension equal one), return diagonal matrix situations.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/diag_matlab.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Function written to match MATLAB's diag function — diag_matlab","text":"","code":"diag_matlab(mat)"},{"path":"https://andrewhooker.github.io/PopED/reference/diag_matlab.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Function written to match MATLAB's diag function — diag_matlab","text":"mat Either vector make diagonal matrix matrix want extract diagonal ","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/diag_matlab.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Function written to match MATLAB's diag function — diag_matlab","text":"Either diagonal matrix diagonal matrix.","code":""},{"path":[]},{"path":"https://andrewhooker.github.io/PopED/reference/diag_matlab.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Function written to match MATLAB's diag function — diag_matlab","text":"","code":"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"},{"path":"https://andrewhooker.github.io/PopED/reference/downsizing_general_design.html","id":null,"dir":"Reference","previous_headings":"","what":"Downsize a general design to a specific design — downsizing_general_design","title":"Downsize a general design to a specific design — downsizing_general_design","text":"Function takes design potentially empty design variables rescues design FIM can calculated using mftot.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/downsizing_general_design.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Downsize a general design to a specific design — downsizing_general_design","text":"","code":"downsizing_general_design(poped.db)"},{"path":"https://andrewhooker.github.io/PopED/reference/downsizing_general_design.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Downsize a general design to a specific design — downsizing_general_design","text":"poped.db PopED database","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/downsizing_general_design.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Downsize a general design to a specific design — downsizing_general_design","text":"list containing: ni vector number samples group. xt matrix sample times. row vector sample times group. model_switch matrix size xt, specifying model sample belongs . x matrix discrete design variables. row group. matrix covariates. row group. bpop matrix fixed effect parameter values.","code":""},{"path":[]},{"path":"https://andrewhooker.github.io/PopED/reference/ed_laplace_ofv.html","id":null,"dir":"Reference","previous_headings":"","what":"Evaluate the expectation of determinant the Fisher Information Matrix (FIM)\nusing the Laplace approximation. — ed_laplace_ofv","title":"Evaluate the expectation of determinant the Fisher Information Matrix (FIM)\nusing the Laplace approximation. — ed_laplace_ofv","text":"Compute expectation det(FIM) using Laplace approximation expectation. Computations made based model, parameters, distributions parameter uncertainty, design methods defined PopED database arguments function.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/ed_laplace_ofv.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Evaluate the expectation of determinant the Fisher Information Matrix (FIM)\nusing the Laplace approximation. — ed_laplace_ofv","text":"","code":"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(), ... )"},{"path":"https://andrewhooker.github.io/PopED/reference/ed_laplace_ofv.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Evaluate the expectation of determinant the Fisher Information Matrix (FIM)\nusing the Laplace approximation. — ed_laplace_ofv","text":"model_switch matrix size xt, specifying model sample belongs . groupsize vector number individuals group. ni vector number samples group. xtopto sampling times xopto discrete design variables aopto continuous design variables bpopdescr Matrix defining fixed effects, per row (row number = parameter_number) : column 1 type distribution E-family designs (0 = Fixed, 1 = Normal, 2 = Uniform, 3 = User Defined Distribution, 4 = lognormal 5 = truncated normal) column 2 defines mean. column 3 defines variance distribution (length uniform distribution). ddescr Matrix defining diagonals IIV (logic bpopdescr). covd Column major vector defining covariances IIV variances. , full IIV matrix covd <- IIV[lower.tri(IIV)]. sigma Matrix defining variances can covariances residual variability terms model. can also just supply diagonal parameter values (variances) c(). docc Matrix defining IOV, IOV variances IOV distribution d bpop. poped.db PopED database. method 0 use optimization routine translated PopED code written MATLAB optimize parameters Laplace approximation. 1 use optim compute k hessian k (see Dodds et al, JPP, 2005 information). 2 use fdHess compute hessian. return_gradient gradient returned. optxt sampling times optimized opta continuous design variables optimized x design parameters compute gradient . ... Arguments passed functions, pass anything another function.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/ed_laplace_ofv.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Evaluate the expectation of determinant the Fisher Information Matrix (FIM)\nusing the Laplace approximation. — ed_laplace_ofv","text":"FIM hessian FIM.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/ed_laplace_ofv.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Evaluate the expectation of determinant the Fisher Information Matrix (FIM)\nusing the Laplace approximation. — ed_laplace_ofv","text":"computation follows method outlined Dodds et al, \"Robust Population Pharmacokinetic Experiment Design\" JPP, 2005, equation 16. Typically function run user. Instead use evaluate.e.ofv.fim.","code":""},{"path":[]},{"path":"https://andrewhooker.github.io/PopED/reference/ed_laplace_ofv.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Evaluate the expectation of determinant the Fisher Information Matrix (FIM)\nusing the Laplace approximation. — ed_laplace_ofv","text":"","code":"## 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)) #> }) #> } #> #> ## -- 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.001 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) }"},{"path":"https://andrewhooker.github.io/PopED/reference/ed_mftot.html","id":null,"dir":"Reference","previous_headings":"","what":"Evaluate the expectation of the Fisher Information Matrix (FIM) and the expectation of the OFV(FIM). — ed_mftot","title":"Evaluate the expectation of the Fisher Information Matrix (FIM) and the expectation of the OFV(FIM). — ed_mftot","text":"Compute expectation FIM given model, parameters, distributions parameter uncertainty, design methods defined PopED database.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/ed_mftot.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Evaluate the expectation of the Fisher Information Matrix (FIM) and the expectation of the OFV(FIM). — ed_mftot","text":"","code":"ed_mftot( model_switch, groupsize, ni, xtoptn, xoptn, aoptn, bpopdescr, ddescr, covd, sigma, docc, poped.db, calc_fim = TRUE, ... )"},{"path":"https://andrewhooker.github.io/PopED/reference/ed_mftot.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Evaluate the expectation of the Fisher Information Matrix (FIM) and the expectation of the OFV(FIM). — ed_mftot","text":"model_switch matrix size xt, specifying model sample belongs . groupsize vector number individuals group. ni vector number samples group. xtoptn xtoptn value xoptn xoptn aoptn aoptn value bpopdescr Matrix defining fixed effects, per row (row number = parameter_number) : column 1 type distribution E-family designs (0 = Fixed, 1 = Normal, 2 = Uniform, 3 = User Defined Distribution, 4 = lognormal 5 = truncated normal) column 2 defines mean. column 3 defines variance distribution (length uniform distribution). ddescr Matrix defining diagonals IIV (logic bpopdescr). covd Column major vector defining covariances IIV variances. , full IIV matrix covd <- IIV[lower.tri(IIV)]. sigma Matrix defining variances can covariances residual variability terms model. can also just supply diagonal parameter values (variances) c(). docc Matrix defining IOV, IOV variances IOV distribution d bpop. poped.db PopED database. calc_fim FIM calculated just use user defined ed_penalty_pointer. ... arguments passed function.","code":""},{"path":"https://andrewhooker.github.io/PopED/reference/ed_mftot.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Evaluate the expectation of the Fisher Information Matrix (FIM) and the expectation of the OFV(FIM). — ed_mftot","text":"list containing E(FIM) E(OFV(FIM)) poped.db.","code":""},{"path":[]},{"path":"https://andrewhooker.github.io/PopED/reference/ed_mftot.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Evaluate the expectation of the Fisher Information Matrix (FIM) and the expectation of the OFV(FIM). — ed_mftot","text":"","code":"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)) #> }) #> } #> #>