productPCA: Functions for partitioned CAs and their products

View source: R/productPCA.R

pcaCAR Documentation

Functions for partitioned CAs and their products

Description

Functions for partitioned CAs (PCAs) of coverage strength 2, and for a product of two PCAs. The number of rows of a product of a PCA(N, 2, k, v) and a PCA(M, 2, l, v) is N + M - v, the number of columns depends on the splits k = k1+k2 and l = l1+l2.

Usage

pcaCA(k, v, ...)

productPCA(D1, D2=NULL, k1=NULL, l1=NULL, ...)

CA_to_PCA(D, tryhard=FALSE, ignorePCAstatus=TRUE, nocafast=FALSE, ...)

is.PCA(D, start0=NULL, ...)

Arguments

k

integer: the number of requested columns

v

integer: the number of levels for each column

...

passed on to CA_to_PCA_c of package cafast (e.g., seconds) by CA_to_PCA; otherwise currently not used

D1

an N x k CA of strength 2 with v levels, split into k1 + k2 columns for productPCA

D2

an M x l CA of strength 2 with v levels, split into l1 + l2 columns for productPCA

D

an N x k CA of strength 2 with v levels

k1

width of P block in D1 (see Details section)

l1

width of P block in D2 (see Details section)

tryhard

logical: if nocafast=FALSE, tryhard=TRUE doubles the default search time allocated for cafast::CA_to_PCA_c; otherwise, if tryhard=TRUE, CA_to_PCA tries to achieve v constant rows for k-1 or k-2 columns; this may take a while in case of many columns.

ignorePCAstatus

logical: ignored if nocafast=FALSE; otherwise: should CA_to_PCA ignore the PCAstatus attribute of D (if any)?

nocafast

logical, should use of package cafast (function CA_to_PCA_c) be suppressed? Without suppression, tryhard=TRUE is translated to seconds=120 (unless seconds is given in ...), and ignorePCAstatus is ignored.

start0

NULL, or logical: do the values start with 0 (otherwise with 1)?

Value

Functions pcaCA and productPCA return a matrix of class ca that is a PCA with attribute PCAstatus.
For pcaCA, the number of columns is as requested, and the number of rows is the smallest possible according to the pre-calculated information data frame PCAcat; it can be explored using function N_pcaCA or function Ns (where the construction is applicable). The returned matrix has its levels coded from 0 to v-1.
For productPCA, the number of columns is k1*l1 + k1*l2 + k2*l1 (of which k1*l1 make up the left part), and the number of rows is N + M - v.
The returned matrix has its levels coded like the ingoing matrices, i.e., integers starting with 0 or 1.

Function CA_to_PCA returns an equivalent CA of S3 class ca that has PCA (or SCA) structure (see Section "Partitioned Covering Array (PCA)"), if possible. The resulting CA has an attribute PCAstatus, which is a list with elements type (PCA or SCA), k1 and k2. If package cafast was used, it also has an attribute PCAexact, which indicates whether an exhaustive search was completed.

Function is.PCA returns a logical with the analogous attribute; it can be (mis)used for checking consistency between the codings of designs by specifying start0.

Details

Function pcaCA returns a PCA from - possibly recursive - application to of function productPCA according to rules provided in the data frame PCAcat.

Function productPCA exploits a partitioned structure of the two CAs it combines (see Section "Partitioned Covering Array (PCA)"). The construction can be viewed as a kind of product, but is sometimes also called "cut-and-paste". It was proposed in Colbourn et al. (2006) and was slightly generalized later, see, e.g., in Colbourn and Torres-Jimenez (2013). Function productPCA also serves as work horse function for combining two CAs in many instances of the CAEX and recBoseCA constructions.

If two matrices D1 and D2 are specified, the function productPCA does a conventional PCAxPCA construction according to Theorem 3.2 of Colbourn et al. (2006).
If D2=NULL, the function uses the SCA constructed by function link{SCA_Bose} and exploits the fact that the sub matrix B1 of that SCA is itself a PCA (i.e., the SCA is a 2PCA in the notation of the Colbourn tables); for such cases, Theorem 3.3 of Colbourn et al. (2006) states that the number of columns of the first part in the result can be increased (which becomes relevant whenever using the result as the in-going matrix in another productPCA call). This is implemented by moving the bottom-most block of v rows from the resulting matrix to the top and applying function CA_to_PCA to the result; for avoiding this from happening, explicitly specify SCA_Bose(v) as the second matrix. Likewise, for any other 2PCA (i.e., PCA whose bottom left block is a PCA) in the role of D2, the user can postprocess the result of function productPCA in order to benefit from the properties of that matrix.

CA_to_PCA rearranges D into a PCA structure (see Section "Partitioned Covering Array (PCA)") by rearranging columns, swapping symbols, and in case of tryhard=TRUE also rearranging rows.
Per default, the function calls function CA_to_PCA_c of package cafast, whenever that package is installed (version >= 0.1.1) and use of the package is not suppressed by the argument nocafast. There is no reason for the user to suppress use of package cafast, which speeds up the search enormously and increases the chance of finding a structure with a large number of columns in the left-hand side part. The function allows for 60 seconds run time per default. This run time is doubled by the argument tryhard=TRUE. Alternatively, the user can provide the seconds argument for function cafast::CA_to_PCA_c.
If package cafast is not available, tryhard=TRUE tries to achieve PCA status k2=1 or k2=2; in that case, if it is possible to achieve v constant rows (i.e., k2=0), the function finds these.
Without tryhard=TRUE, the resulting PCA will have k1 as the number of columns with v different levels in the first v rows.
tryhard=TRUE may be useful for small designs, but may substantially increase run times for D with many rows or many columns.

Function is.PCA checks the PCA status of its argument without modifying it in any way.

Partitioned Covering Array (PCA)

For an N x k CA(N, t, k, v) to be a PCA, the number of columns is split into k = k1 + k2, with k1>0 (otherwise no PCA), the number of rows is split into N = v + (N - v); such a PCA is denoted as PCA(N, t, (k1,k2), v).
The PCA structure, in this package, is arranged with top and bottom parts swapped versus partitioning of Colbourn et al. (2006). Parts are arranged here such that
the v x k1 matrix P (with each column consisting of the identity permutation of all levels) makes up the top left block,
the top right v x k2 block (which may be empty) is constant with all elements equal to the smallest level (for an SCA, which is a special case of a PCA) or has arbitrary levels (for a PCA), however, ensuring that the level in row i must not be larger than the ith level (important for the product to work on PCAs and not on SCAs only, and always possible to achieve by level permutation),
and the remaining two blocks (bottom left and bottom right) may contain arbitrary elements.
It is beneficial for the number of columns in a product, if the left-hand side block is as wide as possible.
It is beneficial for recursively taking products, if the bottom left block is itself a PCA, i.e., contains q rows for which a large number of columns consists of permutations of the values 0 to q-1 (also called a 2PCA).

References

Colbourn et al. (2006) and Torres-Jimenez et al. (2019) for the product with an SCA, Colbourn and Torres-Jimenez (2013) for the more general version with two PCAs

Examples

#################################################
### pcaCA
#################################################
## 44 6-level columns
dim(D <- pcaCA(44, 6))
coverage(D, 2)
## best implemented construction
Ns(2,44,6)
## as Torres-Jimenez does not share his arrays
eCAN(2, 44, 6)

### larger number of columns
N_pcaCA(2, 500, 8)
Ns(2, 500, 8) ## not best implemented (prime power v)
Ns(2, 500, 6) ## not eCAN, but best implemented (non-prime power v)


#################################################
### productPCA
#################################################
A <- SCA_Bose(4)  ## Bose array, arranged as SCA
EPCA <- productPCA(A, A)
coverage(EPCA, 2)
dim(EPCA)  ## 24 columns only, 28 runs only
eCAN(2, 24, 4) ## optimal, this construction!
eCAK(2, 28, 4) ## optimal, this construction
attr(EPCA, "PCAstatus")
## better, if D2 is left unspecified, because
## the structure of SCA_Bose(4) in the role of D2
## is exploited
EPCA2 <- productPCA(A)
attr(EPCA2, "PCAstatus")


########################################
## utilities CA_to_PCA and is.PCA
########################################
SCA61.2..9.1..7 <- CA_to_PCA(CS_MS(10, 7), tryhard=TRUE)
attributes(SCA61.2..9.1..7)

is.PCA(DoE.base::L36.2.8.6.3[,-(1:8)])
CA_to_PCA(DoE.base::L36.2.8.6.3[,-(1:8)])

## utility SCA_Bose
SCA_Bose(3)

## apply PCA construction
E <- productPCA(SCA_Bose(3))
dim(E)
coverage(E,2)
eCAN(2,15,3)  ## optimal for 15 columns
eCAK(2,15,3)  ## but does not cover 20 columns

## for non-prime power case
## use optimum CA(46,2,9,6)
MS6 <- CS_MS(k=9, v=6)
MS6 <- CA_to_PCA(MS6)
MS6 <- CA_to_PCA(MS6, tryhard=TRUE)
head(MS6)  ## it is an SCA with k1=8 and k2=9
dim(CA.86.6.80 <- productPCA(MS6, MS6))
## four too many runs
eCAN(2,80,6)

## another case
head(DoE.base::L36.2.8.6.3[,-(1:8)]) ## it is an SCA with k1=3 and k2=0,
                                     ## as all columns have six distinct
                                     ## values in first six rows
dim(productPCA(MS6, CA_to_PCA(DoE.base::L36.2.8.6.3[,-(1:8)] - 1)))
eCAN(2,27,6)  ## 8 too many runs

## the function also works for designs with flexible values (which are denoted by NA)
## productPCA
D <- productPCA(CAEX(N=16), CAEX(N=16))
dim(D)
eCAN(2,405,3) ## slightly worse than the best CA, which is obtained as CAEX(N=27)
is.PCA(D) ## is already good and cannot be further improved by the simple method used in CA_to_PCA
coverage(D, 2) ## slightly longer run time
## faster with ca_verify
caverify::ca_verify(D, 2)


CAs documentation built on Nov. 29, 2026, 1:06 a.m.