Type: | Package |
Title: | Optimal Weight Exchange Algorithm for Optimal Designs for Three Models |
Version: | 0.1.2 |
Maintainer: | Shuai Hao <shuaih0303@gmail.com> |
Description: | An implementation of optimal weight exchange algorithm Yang(2013) <doi:10.1080/01621459.2013.806268> for three models. They are Crossover model with subject dropout, crossover model with proportional first order residual effects and interference model. You can use it to find either A-opt or D-opt approximate designs. Exact designs can be automatically rounded from approximate designs and relative efficiency is provided as well. |
License: | GPL-3 |
Encoding: | UTF-8 |
Suggests: | knitr, rmarkdown |
Imports: | gtools (≥ 3.9.3), MASS, methods, shiny (≥ 1.7.2) |
RoxygenNote: | 7.2.1 |
NeedsCompilation: | no |
Packaged: | 2022-09-15 05:11:11 UTC; Shuai |
Author: | Shuai Hao [aut, cre], Min Yang [aut], Wei Zheng [aut] |
Repository: | CRAN |
Date/Publication: | 2022-09-17 18:56:01 UTC |
OWEA: A package for optimal designs by implementing optimal weight exchange algorithm.
Description
The OWEA package provides relizations for three models: crossover with subject dropout, crossover with proportional first order residual, and interference model
Key functions
design
, design_app
, eff
, effLB
,
summary
Design Generator for Three Models
Description
Construct optimal approximate designs as well as efficient exact designs for crossover model with subject dropout, crossover model with proportional residual effect, and interference model.
Usage
design(
model = c("dropout", "proportional", "interference"),
n,
opt,
t,
p,
...,
max_iter = 40
)
Arguments
model |
an model indicator, must be one of 'dropout', 'proportional', or 'interference'. |
n |
Positive Integer, total number of observations needed. |
opt |
Integer. optimal criterion indicator, opt = 0 means D-opt, opt = 1 means A-opt |
t |
Positive interger,number or levels of treatment, the default coding is integer from 1 to t |
p |
Numeric, number of periods for crossover model or number of blocks for intereference model |
... |
other necessary control parameters required by specific model
For crossover with dropout, |
max_iter |
a positive integer. Controls maximum iteration time of exchange. Default is 40. |
Value
A S3 object of one of classes 'dropout', 'proportional' or 'interference'.
model |
the model name |
n |
total number of observations of exact design |
opt |
optimal criterion |
t |
number of levels of treaments |
p |
number of periods or plots in a block |
... |
other inputs |
initial_design |
a randomly chosen design as a starting point for newton's method |
exact_design |
an exact design rounded from approximate design |
approx_design |
optimal approximate design |
verify_equivalence |
result of general equivalence theorem, the last entry is the value of directional derivative |
time |
computing time for approximate design |
See Also
Examples
# NOTE: max_iter is usually set to 40.
# Here max_iter = 5 is for demenstration only.
# crossover dropout model
## D-optimal
example1 <- design('dropout',10,0,3,3,drop=c(0,0,0.5), max_iter = 5)
summary(example1)
eff(example1) # efficiency from rounding
effLB(example1) # obtain lower bound of efficiency
## A-optimal
design('dropout',10,1,3,3,drop=c(0,0,0.5), max_iter = 5)
# proportional model
## D-optimal
design('proportional',10,0,3,3, sigma = diag(1,3),tau = matrix(sqrt(1+3),
nrow=3, ncol=1),lambda = 0.2, max_iter = 5)
## A-optimal
design('proportional',10,1,3,3, sigma = diag(1,3), tau = matrix(sqrt(1+3),
nrow=3, ncol=1),lambda = 0.2, max_iter = 5)
# interference model
## D-optimal
design('interference',10,0,3,3, sigma = diag(1,3), max_iter = 5)
## A-optimal
design('interference',10,1,3,3, sigma = diag(1,3), max_iter = 5)
Shiny App for design
function
Description
A function to launch graphical interface to design
function.
Usage
design_app()
Examples
## Not run:
design_app() # lauching the app.
## End(Not run)
Efficiency generic function
Description
A generic function that returns the efficiency for either exact designs to approximate designs or exact design to a given design
Usage
eff(exact_design, ex = NULL)
## Default S3 method:
eff(exact_design, ex = NULL)
## S3 method for class 'dropout'
eff(exact_design, ex = NULL)
## S3 method for class 'proportional'
eff(exact_design, ex = NULL)
## S3 method for class 'interference'
eff(exact_design, ex = NULL)
Arguments
exact_design |
A S3 object returned by |
ex |
Matrix. Design to be compared to. Default is |
Value
Numeric. Relative Efficiency.
If ex
is given, return relative efficiency by \Phi_{example}/\Phi_{exact\_design}
;
If ex
is missing, return relative efficiency by \Phi_{approx\_design}/\Phi_{exact\_design}
.
See Also
see examples in design.
Lower Bound Efficiency for Crossover-Dropout Model
Description
The function take S3 object of class 'dropout' as input and return its lower bound of efficiency of exact design.
Usage
effLB(exact_design)
Arguments
exact_design |
A object of class returned by design function. |
Value
A list of relavent numerics.
optimal |
Optimal Criterion |
lower.bound |
Lower Bound of the exact design |
optimal.value |
The value of objective function at optimal approxiamte design |
See Also
see examples in design
.
Generate contrast matrix
Description
A function return a matrix of contrast for given values of configuration.
Usage
generate_contrast(opt, t, p)
## S3 method for class 'interference'
generate_contrast(opt, t, p)
## S3 method for class 'dropout'
generate_contrast(opt, t, p)
## S3 method for class 'proportional'
generate_contrast(opt, t, p)
Arguments
opt |
Numeric. |
t |
Positive Integer. The number of levels of treatments. of one of those classes 'dropout','proportional', or 'interference'. |
p |
Postitive Integer. The number of periods, or number of plots in a block. |
Generic function for information matrix.
Description
Returns a information matrix for a given design
Usage
infor_design(design, t, ...)
## Default S3 method:
infor_design(design, t)
## S3 method for class 'dropout'
infor_design(design, t, ...)
## S3 method for class 'interference'
infor_design(design, t, ...)
## S3 method for class 'proportional'
infor_design(design, t, ...)
Arguments
design |
Matrix. A design, each row is a design point with weight or repetition on the last entry. |
t |
Numeric. Number of levels of treatments. |
... |
Other control parameter to be passed to methods |
Value
An information matrix.
Function for objective function
Description
Function for objective function
Usage
phi(covar, opt)
Arguments
covar |
Matrix, a covariance matrix for parameters at certain design |
opt |
Integer. |
Summary method for S3 object
Description
Return summary info for S3 object return by design
function.
Usage
## S3 method for class 'dropout'
summary(object, ...)
## S3 method for class 'proportional'
summary(object, ...)
## S3 method for class 'interference'
summary(object, ...)
Arguments
object |
A S3 object of class 'dropout', 'proportional', or 'interference'. |
... |
other control parameters, but usually not necessary. |
Value
A list of key info.
exact_design |
exact design and its repetitions |
approximate_design |
approximate design and its weights |
computing_time |
computing time for approximate design |
See Also
see examples in design
.
Function for General Equivalence Theorem
Description
A function that examines general equivalence theorem and return the maximum of drectional derivative as long as its associated design point.
Usage
verify_equiv(opt, space, opt_infor, t, g_part, infor_design, ...)
Arguments
opt |
Integer. |
space |
Matrix. Design space, each row is a design point. |
opt_infor |
Matrix. Information matrix of current design. |
t |
Integer. Number of levels of treatment. |
g_part |
Matrix. Contrast matrix. Its column numbers must match the row number of information matrix. |
infor_design |
Function. A function for calculating information matrix. |
... |
other necessary control parameters. |
Value
A vector stands for a design point with its last entry being the maximum of directional derivative.
Implementation of Newton's method, Part 1.
Description
A function that optimizes weights for a given design using newton's method
Usage
weight1(opt, x, t, g_part, w0, infor_design, ...)
Arguments
opt |
Integer. |
x |
Matrix, the design at current stage. |
t |
Integer. Number of levels of treatment. |
g_part |
Matrix. Contrast matrix. Its column numbers must match the row number of information matrix. |
w0 |
Numeric Vector. Initial weights. |
infor_design |
Function. A function for calculating information matrix. |
... |
other necessary control parameters |
Value
A numeric vector of optimized weights.
Implementation of Newton's method, part 2.
Description
A function that removing boundary points after newton's method.
Usage
weight2(opt, x, t, g_part, w0, infor_design, ...)
Arguments
opt |
Integer. |
x |
Matrix, a design returned by |
t |
Integer. Number of levels of treatment. |
g_part |
Matrix. Contrast matrix. Its column numbers must match the row number of information matrix. |
w0 |
Numeric Vector. Initial weights. |
infor_design |
Function. A function for calculating information matrix. |
... |
other necessary control parameters |
Value
Matrix, an optimal design