backup_options <- options() options(width = 3000) knitr::opts_chunk$set(collapse = TRUE, comment = "#>",echo = FALSE, warning = FALSE, message = FALSE, cache = FALSE, tidy = FALSE, size = "small") devtools::load_all()

In this example, we simulate an 1-compartment model with linear elimination for IV infusion over 1 hour (inspired by [@Sukeishi2021]). One hundred and fifty (150) subjects receive a 400mg loading dose on the first day, followed by 4 daily doses of 200mg. Blood samples are taken at the end of the $1^{st}$ infusion (H1), H20, H44, H66 and H120. By evaluating this design, we will then select 4 sampling times on intervals (0,48) and (72,120) for an optimal design using PSO (Particle Swarm Optimization) algorithm.

Reports of the design evaluation and optimization are available at https://github.com/iame-researchCenter/PFIM

`MyProject_evaluation`

: project for the design evaluation named `eval_PK_Sukeishi-2021-GS441524`

`MyProject_optimization`

: project for the design optimization named `opti_PK_Sukeishi-2021-GS441524`

MyProject_evaluation = PFIMProject( name = "eval_PK_Sukeishi-2021-GS441524" ) MyProject_optimization = PFIMProject( name = "opti_PK_Sukeishi-2021-GS441524" )

MyStatisticalModel = StatisticalModel()

`Linear1InfusionSingleDose_ClV`

from the library of modelsMyPKModel = getModel( PFIMLibraryOfModels, "Linear1InfusionSingleDose_ClV" )

MyStatisticalModel = defineModelEquations( MyStatisticalModel, MyPKModel )

pV = ModelParameter( "V", mu = 50, omega = sqrt( .26 ), distribution = LogNormalDistribution() ) pCl = ModelParameter( "Cl", mu = 5, omega = sqrt( .34 ), distribution = LogNormalDistribution() )

MyStatisticalModel = defineParameter( MyStatisticalModel, pV ) MyStatisticalModel = defineParameter( MyStatisticalModel, pCl )

`RespPK`

and create and add the response PK to the statistical modelerrorModelresponsePK = Combined1( sigma_inter = 0.5, sigma_slope = sqrt( 0.15 ) ) responsePK = Response( "RespPK", errorModelresponsePK ) MyStatisticalModel = addResponse( MyStatisticalModel, responsePK )

MyProject_evaluation = defineStatisticalModel( MyProject_evaluation, MyStatisticalModel ) MyProject_optimization = defineStatisticalModel( MyProject_optimization, MyStatisticalModel )

`Design`

MyDesign = Design( "Design" )

`Bras test`

of size 150brasTest = Arm( name = "Bras test", arm_size = 150 )

`RespPK`

brasTest = addSampling( brasTest, SamplingTimes( outcome = "RespPK", sample_time = c( 1,12,24,44,72,120 ) ) )

`brasTest`

create and add the administration parameters of the response PKadministration_brasTest = Administration( outcome = "RespPK", Tinf = rep( 1, 5 ), time_dose = seq( 0, 96, 24 ) , amount_dose = c( 400, rep( 200, 4 ) ) ) brasTest = addAdministration( brasTest, administration_brasTest )

`brasTest`

to the design `MyDesign`

MyDesign = addArm( MyDesign, brasTest )

`MyDesign`

to the PFIM project `MyProject`

MyProject_evaluation = addDesign( MyProject_evaluation, MyDesign )

evaluationPop = EvaluatePopulationFIM( MyProject_evaluation ) evaluationInd = EvaluateIndividualFIM( MyProject_evaluation ) evaluationBay = EvaluateBayesianFIM( MyProject_evaluation )

show( evaluationPop ) show( evaluationInd ) show( evaluationBay )

# set the path and name of the report to save the report outputPath = "....." plotOptions = list( unitTime=c("hour"), unitResponses= c("mcg/mL","DI%") ) reportPFIMProject( evaluationPop, outputPath = outputPath, plotOptions = plotOptions ) reportPFIMProject( evaluationInd, outputPath = outputPath, plotOptions = plotOptions ) reportPFIMProject( evaluationBay, outputPath = outputPath, plotOptions = plotOptions )

`MyDesign2`

to the project `MyProject_optimization`

MyDesign2 = Design( name = "MyDesign2") MyProject_optimization = addDesign( MyProject_optimization, MyDesign2 )

samplingBoundsConstraintRespPK = SamplingConstraint( response = "RespPK", continuousSamplingTimes = list( c( 1,48 ), c( 72,120 ) ) ) samplingMinimalDelayConstraintRespPK = SamplingConstraint( response = "RespPK", min_delay = 5 ) Constr1 = DesignConstraint() Constr1 = addSamplingConstraint( Constr1, samplingBoundsConstraintRespPK ) Constr1 = addSamplingConstraint( Constr1, samplingMinimalDelayConstraintRespPK ) brasTest2 = addSamplingConstraints( brasTest2, Constr1 )

MyDesign2 = addArm( MyDesign2, brasTest2 )

MyProject_optimization = addDesign( MyProject_optimization, MyDesign2 )

psoOptimizer = PSOAlgorithm( maxIteration = 100, populationSize = 10, personalLearningCoefficient = 2.05, globalLearningCoefficient = 2.05, showProcess = TRUE )

optimization_populationFIM = OptimizeDesign( MyProject_optimization, psoOptimizer, PopulationFim() )

```
show( optimization_populationFIM )
```

# set the path to save the report outputPath = "....." plotOptions = list( unitTime=c("hour"), unitResponses= c("mcg/mL","DI%") ) reportPFIMProject( optimization_populationFIM, outputPath = outputPath, plotOptions = plotOptions )

```
options(backup_options)
```

**Any scripts or data that you put into this service are public.**

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.