Learn R Programming

⚠️There's a newer version (2.2.0) of this package.Take me there.

optedr

Overview

The package optedr is an optimal experimental design suite for calculating optimal designs, D-augmenting designs and efficiently rounding approximate design. Among its capabilities are:

  • Calculating D-, Ds-, A- and I-optimal designs for non-linear models.
  • D-augment designs controlling the loss of efficiency.
  • Evaluate the efficiency of a given design against the optimum.
  • Efficiently rounding approximate designs to exact designs.

Installation

You can install the released version of optedr from CRAN with:

install.packages("optedr")

You can install the latest version of the package from GitHub with:

devtools::install_github("kezrael/optedr")

Functions

The user available functions are:

  • opt_des() calculates optimal designs.
  • design_efficiency() evaluates the efficiency of a design against the optimum.
  • augment_design() augments designs, allowing the user to add points controlling the D-efficiency.
  • efficient_round() efficiently round approximate designs.
  • shiny_optimal() demo of optimal designs calculation with a graphical interface, applied to Antoine’s Equation.
  • shiny_augment() demo of augmenting design with a graphical interface, usable for a handful of models.

The optdes object generated by opt_des() has its own implementation of print(), summary() and plot().

Usage

library(optedr)

The calculation of an optimal design requires a to specify the Criterion, the model, the parameters and their initial values and the design_space.

resArr.D <- opt_des(Criterion = "D-Optimality",
                    model = y ~ a*exp(-b/x),
                    parameters = c("a", "b"),
                    par_values = c(1, 1500),
                    design_space = c(212, 422))
#> i Stop condition not reached, max iterations performed
#> i The lower bound for efficiency is 99.9986396401789%

resArr.D$optdes
#>      Point    Weight
#> 1 329.2966 0.5000068
#> 2 422.0000 0.4999932
resArr.D$sens
resArr.D$convergence

After calculating the D-optimal design, the user might want to add points to the design to fit their needs:

aug_arr <- augment_design(resArr.D$optdes, 0.3, y ~ a * exp(-b/x),
               parameters = c("a", "b"),
               par_values = c(1, 1500),
               design_space = c(212, 422),
               F)
#> The region(s) are  [250.98-422]The region(s) are  [250.98-422]The region(s) are  [250.98-422]
aug_arr
#>      Point    Weight
#> 1 329.2966 0.3500048
#> 2 422.0000 0.3499952
#> 3 260.0000 0.1500000
#> 4 380.0000 0.1500000

This new design can be rounded to the desired number of points:

(exact_design <- efficient_round(aug_arr, 20))
#>      Point Weight
#> 1 329.2966      7
#> 2 422.0000      7
#> 3 260.0000      3
#> 4 380.0000      3

And its efficiency compared against the optimum:

aprox_design <- exact_design
aprox_design$Weight <- aprox_design$Weight /sum(aprox_design$Weight)

design_efficiency(resArr.D, aprox_design)
#> i The efficiency of the design is 86.0744365761564%
#> [1] 0.8607444

Copy Link

Version

Install

install.packages('optedr')

Monthly Downloads

279

Version

2.0.0

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Carlos de la Calle-Arroyo

Last Published

November 18th, 2022

Functions in optedr (2.0.0)

IWFMult

Cocktail Algorithm implementation for I-Optimality and A-Optimality (with matB = diag(k))
crit

Master function for the criterion function
daugment_design

D-Augment Design
DWFMult

Cocktail Algorithm implementation for D-Optimality
dsens

Sensitivity function for D-Optimality
dcrit

Criterion function for D-Optimality
DsWFMult

Cocktail Algorithm implementation for Ds-Optimality
crosspoints

Calculate crosspoints
dssens

Sensitivity function for Ds-Optimality
dscrit

Criterion function for Ds-Optimality
dsaugment_design

Ds-Augment Design
design_efficiency

Efficiency between optimal design and a user given design
findminval

Find Minimum Value
delete_points

Remove low weight points
get_augment_region

Get Augment Regions
findmaxval

Find Maximum Value
eff

Efficiency between two Information Matrices
efficient_round

Efficient Round
getCross2

Give effective limits to candidate points region
get_daugment_region

Get D-augment region
findmax

Find Maximum
gradient

Gradient function
laugment_design

L-Augment Design
icrit

Criterion function for I-Optimality
opt_des

Calculates the optimal design for a specified Criterion
plot_convergence

Plot Convergence of the algorithm
inf_mat

Information Matrix
plot.optdes

Plot function for optdes
gradient22

Gradient function for a subset of variables
update_weights

Update weight D-Optimality
update_design_total

Merge close points of a design
update_sequence

Deletes duplicates points
tr

Trace
getStart

Find where the candidate points region starts
weight_function

Weight function per distribution
update_weightsI

Update weight I-Optimality
getPar

Parity of the crosspoints
update_design

Update Design with new point
summary.optdes

Summary function for optdes
shiny_optimal

Shiny Optimal
plot_sens

Plot sensitivity function
print.optdes

Print function for optdes
isens

Sensitivity function for I-Optimality
get_dsaugment_region

Get Ds-augment region
sens

Master function to calculate the sensitivity function
shiny_augment

Shiny D-augment
get_laugment_region

Get L-augment region
integrate_reg_int

Integrate IM
update_weightsDS

Update weight Ds-Optimality
add_design

Add two designs
add_points

Update design given crosspoints and alpha
augment_design

Augment Design
WFMult

Master function for the cocktail algorithm, that calls the appropriate one given the criterion.
check_inputs

Check Inputs