| MCAt | R Documentation |
either from a given CA D, by makes unused levels of some columns flexible ( arbitrary strength), or for strength 2 only, from required numbers of levels, by a construction generalized from Sherwood (2008). In either case, the result is treated by function postopNCK for reducing its run size.
MCA2(nlevels, D=NULL, outerRetry=NULL, innerRetry=NULL, seed=NULL,
verbose=0, nocafast=FALSE, ...)
MCAt(nlevels, t, outerRetry=NULL, innerRetry=NULL, seed=NULL,
verbose=0, nocafast=FALSE, ...)
CA_to_MCA(D, cs, tolevs, t=attr(D, "t"), outerRetry=NULL,
innerRetry=NULL, seed=NULL, verbose=0, nocafast=FALSE, ...)
N_upper_MCA(nlevels, t=2, internet = TRUE, ...)
N_upper_MCA2(nlevels, internet = TRUE, returnMore=FALSE, ...)
projBoseMCA(nlevels, t=2, ...)
nlevels |
a vector of numbers of levels, or a data.frame that is the table
of that vector, with levels in decreasing order and column names |
t |
integer, the strength of |
outerRetry |
|
innerRetry |
|
seed |
the seed for making |
verbose |
integer number, handed to |
nocafast |
logical; if |
... |
currently used by |
D |
for |
cs |
integer vector of column numbers |
tolevs |
integer vector of target numbers of levels for the columns indicated
by |
internet |
logical: is an internet connection available (for DWYER or NIST download) |
returnMore |
logical: should |
Functions MCA2, MCAt and CA_to_MCA return a matrix of
class ca with attributes of the ingoing matrix (dimensions modified),
and attributes Call and seed modified,
and often with flexible values in most columns. For function MCA2,
the number of levels is in decreasing order
(regardless of the order specified in nlevels).
Function N_upper_MCA returns an upper bound for the run size of an MCA
obtainable via the constructions (named integer, obtained by bestN,
where the size can be obtained by using the CA of the construction indicated
by the name as the D in function CA_to_MCA).
Function projBoseMCA returns a matrix of class ca with attributes;
for numeric nlevels, the columns are in the order of nlevels, otherwise
the columns with more levels come before the columns with fewer levels.
Function MCA2 implements Groemping's (2025) generalization of the first
construction of Sherwood (2008) for creating mixed covering arrays (MCAs).
The algorithm is described in Groemping (2025). Its key idea is to
start from a uniform CA, make superfluous levels flexible, and expand
columns with enough flexible entries into more columns of the same number of levels,
using a recursive substitution of flexible values with ordered designs.
The result is then post-processed by function postopNCK,
unless this is suppressed by the argument outerRetry=0. Post-processing
can also be done separately by directly using function postopNCK
on the result of function MCA2, regardless whether it was created with
or without post-processing.
Function MCAt implements an automated version of function CA_to_MCA,
in which the start array D for that function is automatically determined, so
that the user can simply specify the required numbers of levels with the required strength.
Function CA_to_MCA sets unused levels of the columns in cs to NA, i.e.,
makes them flexible, as, e.g., described in Moura et al. (2003). Subsequently, the function
postopNCK applies the method of Nayery et al. (2013) for
making entire rows flexible and removing them. Repeated runs can remove more rows.
The outerRetry argument gives the number of calls to postopNCK.
if the bottom rows of the outcome still look promising, the function can be called
again for removing even more rows.
Without specifying a seed, the results will differ from call to call. If you want it reproducible, make sure to set an integer seed. Run sizes and run times can be very seed-dependent in some situations, and it can happen that encountering a small design is a rare lucky case. Therefore, one may sometimes want to walk over a vector of random seeds and pick the best resulting design (reproducible by keeping track of the seeds).
The run size optimization can take a long time. It can be suppressed by setting
outerRetry to zero, and this should be done for large settings.
Per default, the optimization is switched on. Its progress is reported
by interim messages. The functions (try to) react beneficial to user interrupts:
They return the result from the previous successful outer retry
(make sure the outer retry has finished before escaping calculations!).
Function N_upper_MCA reports an upper bound on the run number for an MCA
of the setting. That bound is obtained by using function bestN for
the maximum number of levels with the total number of columns. Depending on the situation,
the bound may be sharp (e.g., for eight five-level columns with two 3-level columns)
or dramatically too large (e.g., for one eight-level column with ten 2-level columns).
Function projBoseMCA implements Theorem 2.3 of Colbourn (2008) as well as
Corollary 2.2 of the same paper, which also references Stevens, Ling and Mendelsohn
(2002, their Theorem 2.6). It works for two different numbers of levels only.
It is most powerful for q+1 columns at q-1 levels with a single column at q+1 levels,
where q is a prime power (the Corollary 2.2 situation);
in these cases the run size is optimal ((q-1)*(q+1)=q^2-1).
There is not much experience yet with the post-optimization performance. The defaults for the related parameters may change in the future.
Ulrike Groemping
Colbourn (2008), Groemping (2025), Moura et al. (2003), Nayeri et al. (2013), Sherwood (2008), Stevens, Ling and Mendelsohn (2002)
##################################################
### MCA2
##################################################
## small example with fast optimization to global optimum
## which is 2*8
## 16 runs
D <- MCA2(c(rep(2,10), 8))
dim(D)
coverage(D, 2)
## N_upper_MCA is very pessimistic
N_upper_MCA(c(rep(2,10), 8), t=2)
## N_upper_MCA2 is better but still very pessimistic
## for this tiny example
N_upper_MCA2(c(rep(2,10), 8))
## a more dramatic difference
N_upper_MCA(c(4,4,4,3,3,rep(2,60)), 2) ## much too large
N_upper_MCA2(c(4,4,4,3,3,rep(2,60)), 2) ## exact size before postprocessing
## a lesser difference
N_upper_MCA(c(rep(5,8), 3,3))
N_upper_MCA2(c(rep(5,8), 3,3), returnMore=TRUE)
D <- MCA2(c(rep(5,8), 3,3), D=miscCA(2,9,5), outerRetry=0)
dim(D)
head(D); tail(D)
## create a large design without trying a run size optimization
D <- MCA2(c(rep(2,70), rep(3,80), rep(4,8), rep(6,2)),
outerRetry=0)
dim(D)
coverage(D, 2)
## alternative call for the same setting
D <- MCA2(data.frame(levels=c(6,4,3,2), frequency=c(2,8,80,70)),
outerRetry=0)
## make a lucky run reproducible by using a random seed
myseed <- sample(32000, 1)
print(myseed)
Doptimized <- postopNCK(D, 2, seed=myseed, verbose=1, restarts=1)
## This runs for a while.
## Lower bound 36 runs is likely not achievable.
## 42 or 41 rows were repeatedly achieved.
## use the argument D for starting with a naive
## CA of 45 runs for 30 5-level columns
## (default would start with CA(29, 2, 7, 5), which is the best for
## seven 5-level columns and permits expansion as required);
D <- MCA2(c(5, rep(4,2), rep(3,7), rep(2,20)), D=bestCA(2,30,5),
outerRetry=0)
## make a lucky run reproducible by using a random seed
myseed <- sample(32000, 1)
## with cafast::postopNCK_c, with increased outerMaxnochange,
## the optimum size 20 can be reached (was e.g. the case for
## seeds 1188 or 25063 on Windows).
## Without package cafast, run time would be excessive;
## can be interrupted with <ESC> if run size improvement
## has been sufficient or seems to stall
## (make sure to wait until the outer retry has safely finished);
Doptimized <- postopNCK(D, 2, seed=myseed, verbose=1,
outerMaxnochange=30)
dim(Doptimized)
## optimization stopped, because the global optimum was reached
########################################################
### MCAt
########################################################
## create a strength 4 CA, initially unoptimized
D <- MCAt(c(4,4,3,2,2,2), 4, outerRetry=0)
dim(D) ## much larger than the optimum run size
########################################################
### CA_to_MCA
########################################################
# a small example
## six 3-level columns in 33 runs
D <- bestCA(3,6,3)
## to three 3-level and three 2-level columns in 27 runs
Dmixed <- CA_to_MCA(D, cs=4:6, tolev=rep(2, 3), t=3, outerRetry=0)
dim(Dmixed)
## (optimal)
coverage(Dmixed, 3)
## works
## five 3-level columns in 33 runs
D <- bestCA(3,5,3) ## CA(33,3,5,3)
## to four 3-level columns and one 2-level column in 33 runs,
Dmixed <- CA_to_MCA(D, cs=5, tolev=2, t=3) ## last column reduced to 2 levels
## the search cannot reduce the number of runs
## D can be easily reduced to the optimal 27 runs,
## if two columns are reduced to 2 levels each:
Dmixed <- CA_to_MCA(D, cs=4:5, tolev=c(2,2), t=3)
######################################################
#### projBoseMCA #############
######################################################
## corollary 2.2 cases (a single number of levels is different,
## and two larger than the others)
D <- projBoseMCA(c(rep(4,6),6))
head(D)
dim(D)
D <- projBoseMCA(c(rep(6,8),8))
head(D)
dim(D)
## NOTE: example() skips the examples below (for MCA2 and MCAt),
## unless the user specifies
## options(run_heavy_examples = TRUE)
## This is because they could be very slow depending on sample.kind.
## different setting,
## optimize run size within the call (using a good seed)
D <- MCA2(c(rep(2,30), rep(3,2)), seed=333, outerRetry=3)
coverage(D, 2)
attributes(D)
## reasonably quickly reduces to 11 runs on my Windows machine
## lower bound is 9 runs (3*3)
## CAgen yields 14 runs with IPOG-F
D <- MCAt(c(4,4,3,2,2,2), 4, outerRetry=0)
## with seed 888, the optimum is quickly reached on Windows
Doptimized <- postopNCK(D, 4, innerRetry = 3, seed=888)
dim(Doptimized)
## optimum 4*4*3*2=96
## many other seeds stop at 97 or 98 runs after longer iteration
## could also use
D <- MCAt(c(4,4,3,2,2,2), 4, innerRetry=3, seed=888)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.