| coverage | R Documentation |
functions for calculating covering proportions for a given strength, and for visualizing those
coverage(D, t, isInteger=TRUE, verbose=0, start0=TRUE, parallel=1)
coverage_iter(D, t, isInteger=TRUE, start0=TRUE,
progress=FALSE, abortnot1=FALSE, start.proj=1)
coverplot(coverageD, D=NULL, t=NULL, isInteger=TRUE, start0=TRUE,
type="projections",
main=NULL, xlab=NULL, ylab=NULL,
col=rgb(0,0,1,0.5), las=1, plot=TRUE, ...)
D |
array |
t |
small positive integer, interaction strength to be considered |
isInteger |
logical (default |
verbose |
0 (default) returns only four percentages, 1 and 2 return more detail. Anything apart from 1 and 2 behaves like 0. |
start0 |
logical (default |
parallel |
number of threads to be used (default: 1); if increased, package parallel must be available |
progress |
logical (default |
abortnot1 |
logical (default |
start.proj |
integer, the number of the projection to start with in lexicographical
order; ignored for |
coverageD |
a class |
type |
|
main |
title of plot |
xlab, ylab |
axis titles |
las |
orientation of tickmark labels |
col |
color |
plot |
logical (default |
... |
further arguments to polygon |
Functions coverage and coverage_iter return an object of S3 class CAcoverage, which is a
list with elements
total |
total proportion of covered |
ave |
average of |
min |
the minimum proportion of |
simple |
proportion of projections which are fully covered |
tots |
|
ncovered |
|
proportions |
|
projections |
|
tabs |
|
notcovereds |
|
message |
|
The coverplot functions return a list of coordinates x and y, strength t
and proportions (from call with verbose=1).
If one only needs a TRUE/FALSE check of whether or not perfect coverage is reached,
accompanied by the number of uncovered t-tuples and some examples, function
ca_verify of package caverify is much faster than function
coverage.
Function coverage_iter calculates the same quantities as function coverage;
instead of creating all projections at once, it creates them iteratively, which is slower
but doable for large cases for which function coverage fails for memory reasons.
This iterative version is, at least at present, not parallelized. It allows a progress bar
(which slightly deteriorates run time, e.g., on my Windows 10 machine, about 7 milliseconds
per 1000 projections). It also allows to request abortion on encountering the first violation
of strength t coverage.
In case of aborting, the function returns NA values for
all four metrics, and as a fifth list element, the message at which projection the violation
occurred; coverage_iter does not have a verbose argument, but using the
verbose argument on printing an object that resulted from an aborted run prints
that message.
For abortnot1=TRUE, function runs that did not abort up to a particular
iteration can be restarted at the subsequent iteration. The actual restart point will be
the first projection starting with the same first element as the requested start.proj
e.g., for t=3 and a matrix D with 6 columns, the first ten 3-factor projections
start with 1, followed by six projections that start with 2, three projections that start with 3
and a single projection that starts with 4 (10 + 6 + 3 + 1 = 20). start.proj=12 will start
with the projection 2:3:4, i.e., the 11th projection,
which is the first that starts with 2. For projections that start with 1, the second factor is
also relevant for the start position: the first four projections have 2 in the second position,
then there are three with 3 in the second position, then two with 4, and finally one with 5.
Thus, for start.proj=7, start.proj will be reduced to 5, and the projection
is 1:3:4 (the first that starts with 1:3).
Per default, the print method for class CAcoverage prints the first four
elements only.
Function coverplot, with type=projections, plots the
percentage of projections on the horizontal axis and
the coverage on the vertical axis (visualizing the average taken over projections);
with type=tuples, the percentage of tuples (i.e., projections as weighted by tuples)
is shown on the horizontal axis, visualizing the total percentage covered.
Sorting of the combinations on the horizontal axis is from best to worst coverage.
For function coverage_iter, in case of starting at projection start.now,
the user is responsible to ensure that all prior runs have also been checked; the calculated
values assume that the prior runs showed perfect coverage.
caverify::ca_verify()
## fixed levels
D <- KSK(k=10)
coverage(D, 2)
coverage(D, 3)
## mixed levels, total and ave are different
plan <- cbind(rep(0:2, each=3), c(rep(0:1, 4), 1), c(rep(0:1, each=4),0))
coverage(plan, 2)
## verbose content not printed per default
coverage(plan, 2, verbose=1)
print(coverage(plan, 2, verbose=1), digits=4, verbose=TRUE)
print(coverage(plan, 2, verbose=2), digits=4, verbose=TRUE)
## two of three projections fully covered,
## one covered 5/6 only
cD2 <- coverage(plan, 2, verbose=2)
coverplot(cD2, type="projections") ## 2/3 at 1, 1/3 at 5/6=0.833333
## the not fully covered projection involves the 3-level
## column and thus has 6/(6+6+4)=37.5 pct of the tuples instead of 1/3
coverplot(cD2, type="tuples")
## it is also possible to call coverplot on the design itself
## however, repeated calls will then require recalculation
## of coverage, which can be demanding.
## Where storage space is problematic for verbose=2,
## working directly with the design may be doable
## (but time is likely also an issue).
##
coverplot(D=plan, t=2, type="projections")
coverplot(D=plan, t=2, type="tuples")
## the Hadamard based 16 run design for 14 columns
## that is available from FrF2::pb;
## the design has levels -1 and 1 and columns are factors
## therefore, isInteger=FALSE has to be used
if (require(FrF2)){
CA3.2tothe14 <- FrF2::pb(16, 14)
print(coverage(CA3.2tothe14, 3, isInteger=FALSE))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.