optimal.bcra4f3
finds constrained optimal sample allocation (COSA) solutions for designs with 4-levels
where level 3 units are randomly assigned to treatment and control groups within level 4 units (fixed blocks).
COSA can be found in the following forms,
(i) under budgetary constraints given marginal costs per unit,
(ii) under power contraints given marginal costs per unit,
(iii) under MDES contraints given marginal costs per unit, and
(iv) under sample size contraints for one or more levels along with any of the i,ii, or iii options.optimal.bcra4f3(cn, cJ, cK, cL, cost=NULL, n=NULL, J=NULL, K=NULL, L=NULL,
power=.80, mdes=.25, alpha=.05, two.tail=TRUE,
nJKL0=c(10,10,10,10), ncase=10, gm=2,
constrain="cost", optimizer="auglag_cobyla",
rho3, rho2,
P=.50, g3=0, R32=0, R22=0, R12=0)
TRUE
for two-tailed hypothesis testing, FALSE
for one-tailed hypothesis testing."cost"
, "power"
, or "mdes"
."auglag_cobyla"
, "auglag_lbfgs"
, "auglag_mma"
, or "auglag_slsqp"
.nloptr
log and output.round.optim
solution. MDES is calculated at the specified power (default .80), and power is calculated at the specified MDES (default .25).nloptr
(Ypma, 2014) package, an implementation of NLopt (Johnson, n.d.) in R (R Core Team, 2016).
More specifically, Augmented Lagrangian method is used for global optimization (AUGLAG, Birgin & Martines, 2008; Conn, Gould, & Toint, 1991)
in conjuction with one of the following local optimization algorithms:
Constrained Optimization by Linear Approximations (COBYLA, Powell, 1994),
Low Storage BFGS (LBFGS, Liu & Nocedal, 1989),
Method of Moving Asymptotes (MMA, Svanberg, 2002),
or Sequental Least-Squares Quadratic Programming (SLSQP, Kraft, 1988).
See http://ab-initio.mit.edu/wiki/index.php/NLopt_Algorithms for a brief summary. nloptr
returns values that are not integer. Rounding may produce cost, power or MDES values different from what was specified.
A better solution is approximated using brute force. If the constrained value (cost, power or MDES)
in the output deviates from what was specified, increasing grid multiplier (gm
) often solves the problem.
More cases can be printed by increasing ncase
. Further definition of design parameters can be found in Dong & Maynard (2013).nloptr
: R interface to NLopt. R package version 1.0.4. Package available at https://cran.r-project.org/package=nloptrmdes.bcra4f3, power.bcra4f3, mrss.bcra4f3
## Not run: ------------------------------------
#
# optimal.bcra4f3(cn=1, cJ=10, cK=100, cL=1000, cost=75600,
# constrain="cost",
# rho3=.15, rho2=.20)
#
#
## ---------------------------------------------
Run the code above in your browser using DataLab