| Type: | Package |
| Title: | Optimal Row-Column Designs for Asymmetrical Factorial Experiments |
| Version: | 0.1.0 |
| Maintainer: | Sukanta Dash <sukanta.iasri@gmail.com> |
| Description: | Constructs and analyzes optimal row-column designs for mixed-level factorial experiments under two field situations like square field layouts, where the number of rows and columns are equal, and rectangular field layouts, where one blocking direction is determined by a selected block size. For square field layouts, the package implements direct common-factor constructions by first forming two component treatment arrays, one for each factor or super-factor, and then combining them through a symbolic cell-wise product following Gopinath, Parsad and Mandal (2018) <doi:10.1080/03610926.2017.1376091>. For rectangular field layouts, the package constructs designs by extracting a balanced principal block from a mixed-level block design derived from r package mixedfact, treating it as the principal column, taking the complete treatment set as the principal row, and generating the full row-column design by cyclic modular development. The package also provides diagnostic tools for connectedness, orthogonal factorial structure, balance, estimability, A-, D-, and E-efficiency, E-optimality, and MV-optimality criterion values. These designs are practically useful in agricultural, industrial, and biological experiments where treatments have factorial structure and heterogeneity must be controlled simultaneously in two directions. |
| License: | GPL-3 |
| Encoding: | UTF-8 |
| Depends: | R (≥ 4.0.0) |
| Imports: | stats |
| Suggests: | mixedfact, roxygen2, testthat (≥ 3.0.0) |
| RoxygenNote: | 7.3.3 |
| Config/testthat/edition: | 3 |
| NeedsCompilation: | no |
| Packaged: | 2026-05-04 03:54:39 UTC; Sukanta |
| Author: | Archana A [aut], Sukanta Dash [aut, cre] |
| Repository: | CRAN |
| Date/Publication: | 2026-05-06 19:50:16 UTC |
Generation and Analysis of Row-Column Designs for Asymmetrical Factorial Experiments
Description
Generate RCD for both rectangular and Square Field using Euclid's algorithm.
Author(s)
Maintainer: Sukanta Dash sukanta.iasri@gmail.com
Authors:
Archana A archanamscagri19@gmail.com
Generate all treatment combinations
Description
Creates the complete treatment set for a mixed-level factorial experiment in lexicographic order consistent with the MFRCD code.
Usage
all_treatment_combinations(levels)
Arguments
levels |
Integer vector giving the number of levels of the factors. |
Value
Integer matrix whose rows are all treatment combinations and whose columns are factors.
Compute a principal-block balance score
Description
Computes the sum of squared deviations of factor-level counts in a block from their ideal equal counts.
Usage
block_balance_score(block, levels)
Arguments
block |
Integer matrix representing a candidate block. |
levels |
Integer vector of factor levels. |
Value
Numeric balance score; smaller values indicate better balance.
Check a multi-factor row-column design generated by rc_factorial_n
Description
Checks treatment coverage, frequencies, dimensions, and replications for a design generated by rc_factorial_n() with attributes available.
Usage
check_rc_factorial_n(D)
Arguments
D |
Design matrix generated by |
Value
A list of basic design diagnostics.
Check row and column level balance
Description
Computes factor-level counts in each row and column and reports exact row balance and as-balanced-as-possible column balance.
Usage
check_row_column_balance(arr, levels)
Arguments
arr |
Three-dimensional numeric design array with dimensions rows, columns, and factors. |
levels |
Integer vector of factor levels. |
Value
A list containing row and column count tables and balance indicators.
Examples
obj <- rc_method2(2, 4)
check_row_column_balance(obj$numeric_design, c(2, 4))$row_balanced_exact
Create compact public property-check output
Description
Reduces the full verification output to the tables displayed by mfrcd(..., check_properties = TRUE, details = FALSE).
Usage
compact_property_checks(property_checks)
Arguments
property_checks |
Output from |
Value
A compact list of design checks, connectedness, efficiencies, optimality criteria, effect diagnostics, and OFS cross-information.
Compute A-, D-, and E-efficiencies from eigenvalues
Description
Computes canonical A-, D-, and E-efficiency values from eigenvalues of an adjusted information matrix relative to the treatment replication number.
Usage
compute_ade_efficiency(eig, replications, df, tol = 1e-07)
Arguments
eig |
Numeric vector of eigenvalues. |
replications |
Treatment replication number. |
df |
Degrees of freedom of the effect or contrast space. |
tol |
Numerical tolerance. |
Value
Named numeric vector with A_efficiency, D_efficiency, and E_efficiency.
Compute E- and MV-optimality criterion values
Description
Calculates the E criterion value as the smallest positive eigenvalue of the adjusted treatment information matrix, and the MV criterion value as the maximum variance over elementary treatment contrasts.
Usage
compute_emv_optimality(C, tol = 1e-07)
Arguments
C |
Treatment information matrix adjusted for rows and columns. |
tol |
Numerical tolerance. |
Value
A list containing a summary table, eigenvalues, positive eigenvalues, and the pairwise elementary-contrast variance matrix.
References
Morgan, J. P. and Jermjitpornchai, S. (2021). Optimal row-column designs with three rows. Statistics and Applications, 19, 257-275.
Row, column, and row-column connectedness diagnostics
Description
Computes connectedness of the row component design, column component design, and full row-column design.
Usage
connectedness_diagnostics(info, tol = 1e-07)
Arguments
info |
Output from |
tol |
Numerical tolerance. |
Value
A list containing a summary table and the corresponding component information matrices.
Connectedness diagnostics from an information matrix
Description
Computes numerical rank, required rank, connectedness, and number of components for a treatment information matrix.
Usage
connectedness_from_information(C, tol = 1e-07)
Arguments
C |
Treatment information matrix. |
tol |
Numerical tolerance. |
Value
A one-row data frame with connectedness diagnostics.
Count treatment graph components from an information matrix
Description
Builds an adjacency graph from non-zero off-diagonal entries of an information matrix and counts connected components.
Usage
count_connected_components_from_C(C, tol = 1e-07)
Arguments
C |
Treatment information matrix. |
tol |
Numerical tolerance for deciding non-zero entries. |
Value
Integer number of connected components.
Extract numeric design data from supported inputs
Description
Extracts a numeric design array and factor levels from an MFRCD object, numeric array, or printed design matrix.
Usage
extract_numeric_design(x, levels = NULL, sep = "")
Arguments
x |
MFRCD details list, three-dimensional numeric array, or printed design matrix. |
levels |
Optional integer vector of factor levels. |
sep |
Character separator used in printed treatment labels. |
Value
A list with elements arr and levels.
Extract a principal block from mixedfact
Description
Calls mixedfact::mixedfact() to generate candidate blocks and selects a principal block either as the first block or as the block with the smallest balance score.
Usage
extract_principal_block_mixedfact(
levels,
block_size,
mixedfact_method = "auto",
choose_block = "best"
)
Arguments
levels |
Integer vector of factor levels. |
block_size |
Required block size. |
mixedfact_method |
Method argument passed to |
choose_block |
Selection rule, either |
Value
A list containing the selected principal block, the full mixedfact output, and all candidate blocks.
Construct mean and contrast bases for one factor
Description
Builds an orthonormal mean column and Helmert contrast basis for a factor with s levels.
Usage
factor_contrast_basis(s)
Arguments
s |
Number of levels of the factor. |
Value
A list with elements mean and contrast.
Construct factorial-effect contrast bases
Description
Constructs orthonormal contrast bases for all factorial effects up to a specified order using Kronecker products of factor mean and contrast bases.
Usage
factorial_effect_bases(levels, max_order = NULL)
Arguments
levels |
Integer vector of factor levels. |
max_order |
Maximum interaction order to include. If |
Value
A named list of effect bases and metadata.
Format two component arrays as treatment labels
Description
Combines two numeric component matrices into a character row-column design by concatenating entries cell by cell.
Usage
format_design(D1, D2, sep = "")
Arguments
D1 |
Numeric matrix for the first factor or super-factor. |
D2 |
Numeric matrix for the second factor or super-factor. Must have the same dimensions as |
sep |
Character separator inserted between component labels. Defaults to |
Value
A character matrix with row names R1, R2, ... and column names C1, C2, ....
Kronecker product of a list of matrices
Description
Computes a left-associative Kronecker product over a list of matrices.
Usage
kronecker_reduce(mats)
Arguments
mats |
List of matrices. |
Value
Numeric matrix equal to the Kronecker product of all matrices in mats.
Convert a printed design matrix to a numeric array
Description
Parses a character row-column design into a three-dimensional numeric array.
Usage
labels_to_numeric_array(D, levels, sep = "")
Arguments
D |
Character matrix of treatment labels. |
levels |
Integer vector of factor levels. |
sep |
Character separator used in treatment labels. |
Value
Three-dimensional integer array with dimensions rows, columns, and factors.
Detailed factor-level balance diagnostics
Description
Computes exact and as-balanced-as-possible row and column balance diagnostics for each factor.
Usage
level_balance_diagnostics(arr, levels)
Arguments
arr |
Three-dimensional numeric design array. |
levels |
Integer vector of factor levels. |
Value
A list containing per-factor row and column counts and aggregate balance indicators.
Examples
obj <- rc_method2(2, 4)
level_balance_diagnostics(obj$numeric_design, c(2, 4))$row_exact_all
Create a two-factor numeric design array
Description
Stores two component design matrices as a three-dimensional numeric array with dimensions rows, columns, and factors.
Usage
make_numeric_array(D1, D2)
Arguments
D1 |
Numeric matrix for the first factor or super-factor. |
D2 |
Numeric matrix for the second factor or super-factor. |
Value
A three-dimensional integer array with third dimension named F1 and F2.
Assemble public MFRCD output
Description
Combines a printed design matrix with compact property checks for console display.
Usage
make_public_output(design, property_checks)
Arguments
design |
Character row-column design matrix. |
property_checks |
Output from |
Value
A list containing the design and compact verification tables.
Build row-column treatment information matrices
Description
Constructs model matrices and the treatment information matrix adjusted for row and column effects for a row-column design.
Usage
make_row_column_information(arr, levels, tol = 1e-08)
Arguments
arr |
Three-dimensional numeric design array with dimensions rows, columns, and factors. |
levels |
Integer vector of factor levels. |
tol |
Numerical tolerance used in generalized inverses. |
Value
A list containing the adjusted treatment information matrix, incidence matrices, treatment IDs, frequencies, dimensions, and replication information.
Numerical matrix rank
Description
Computes the rank of a matrix using singular values and a relative tolerance.
Usage
matrix_rank_tol(A, tol = 1e-08)
Arguments
A |
Numeric matrix. |
tol |
Numerical tolerance. |
Value
Integer matrix rank.
Generate a mixed-factor row-column design
Description
Main user-facing function for generating mixed-factor row-column designs. Without block_size, the function first attempts the direct Method 1/2 construction through super-factor grouping. When block_size is supplied, or when no direct construction is available, it uses a mixedfact principal-block construction.
Usage
mfrcd(
levels,
block_size = NULL,
sep = "",
details = FALSE,
check_properties = FALSE,
use_mixedfact = TRUE,
mixedfact_method = "auto",
choose_block = "best",
group1 = NULL,
group2 = NULL,
prefer = c("auto", "direct", "mixedfact"),
tol = 1e-07
)
Arguments
levels |
Integer vector giving the number of levels of the factors. |
block_size |
Optional block size. If supplied, the mixedfact principal-block route is used and the block size becomes the number of rows. |
sep |
Character separator for printed treatment labels. |
details |
Logical. If |
check_properties |
Logical. If |
use_mixedfact |
Logical. If |
mixedfact_method |
Method argument passed to |
choose_block |
Principal-block selection rule, either |
group1 |
Optional integer vector of factor indices for the first super-factor in direct construction. |
group2 |
Optional integer vector of factor indices for the second super-factor in direct construction. |
prefer |
Construction route preference, one of |
tol |
Numerical tolerance for verification checks. |
Value
If check_properties = FALSE and details = FALSE, a character matrix containing the row-column design. If check_properties = TRUE, a compact list containing the design and verification tables. If details = TRUE, a full construction object is returned.
Examples
mfrcd(c(2, 4))
out <- mfrcd(c(2, 4), check_properties = TRUE)
out$design_checks
if (requireNamespace("mixedfact", quietly = TRUE)) {
mfrcd(c(3, 5), block_size = 5)
}
Convert an integer to mixed-radix digits
Description
Represents a non-negative integer using a vector of mixed radix bases. This is used to expand a super-factor level into the levels of its component factors.
Usage
mixed_radix_digits(x, bases)
Arguments
x |
Non-negative integer to expand. |
bases |
Integer vector of radices, usually the levels of component factors. |
Value
Integer vector of length length(bases) containing the mixed-radix digits.
Component-wise modular addition of treatments
Description
Adds two treatment combinations component-wise modulo the corresponding factor levels.
Usage
mod_add_treatment(x, y, levels)
Arguments
x |
Numeric vector giving the first treatment combination. |
y |
Numeric vector giving the second treatment combination. |
levels |
Integer vector of factor levels. |
Value
Integer vector representing (x + y) mod levels.
Parse a treatment label
Description
Parses a treatment label into integer factor levels. Labels may be concatenated digits or separated by punctuation/space.
Usage
parse_treatment_label(label, n_factors)
Arguments
label |
Character treatment label. |
n_factors |
Number of factors expected in the label. |
Value
Integer vector of factor levels.
Convert a principal block to a numeric matrix
Description
Converts a principal block supplied as labels, matrix, or data frame into an integer matrix with one column per factor.
Usage
principal_block_to_matrix(principal_block, levels)
Arguments
principal_block |
Principal block as a character vector, matrix, or data frame. |
levels |
Integer vector of factor levels. |
Value
Integer matrix representing the principal block.
Pseudo-inverse of a symmetric matrix
Description
Computes a numerical pseudo-inverse of a symmetric matrix using its eigen-decomposition.
Usage
pseudo_inverse_symmetric(A, tol = 1e-07)
Arguments
A |
Symmetric numeric matrix. |
tol |
Numerical tolerance for positive eigenvalues. |
Value
Symmetric pseudo-inverse matrix.
Move the zero treatment to the first row of a block
Description
Reorders a principal block so that the all-zero treatment, if present, appears first.
Usage
put_zero_treatment_first(pb)
Arguments
pb |
Integer matrix representing a principal block. |
Value
Integer matrix with the all-zero row first when available.
Construct a row-column design for multiple factors by super-factor grouping
Description
Groups an n-factor mixed-level factorial experiment into two super-factors, applies Method 1 or Method 2 when possible, and expands the super-factor levels back to the original factor levels by mixed-radix representation.
Usage
rc_factorial_n(levels, sep = "", details = FALSE, group1 = NULL, group2 = NULL)
Arguments
levels |
Integer vector giving the number of levels of the factors. |
sep |
Character separator for printed treatment labels. |
details |
Logical. If |
group1 |
Optional integer vector giving factor indices to place in the first super-factor. |
group2 |
Optional integer vector giving factor indices to place in the second super-factor. If omitted and |
Value
If details = FALSE, a character matrix giving the row-column design. If details = TRUE, a list with design, numeric design, selected grouping, method, and parameters.
Examples
rc_factorial_n(c(2, 4))
rc_factorial_n(c(2, 3, 2))
Construct a row-column design from a principal block
Description
Constructs a row-column design by taking a principal block as the principal column, taking the complete treatment set as the principal row, and developing the design by component-wise modular addition. If principal_block is not supplied, it is obtained from mixedfact.
Usage
rc_from_principal_block(
levels,
block_size,
principal_block = NULL,
use_mixedfact = TRUE,
mixedfact_method = "auto",
choose_block = "best",
sep = "",
details = FALSE
)
Arguments
levels |
Integer vector giving factor levels. |
block_size |
Required number of rows, equal to the size of the principal block. |
principal_block |
Optional principal block as labels, matrix, or data frame. If |
use_mixedfact |
Logical. If |
mixedfact_method |
Method argument passed to |
choose_block |
Selection rule for candidate blocks, either |
sep |
Character separator for printed treatment labels. |
details |
Logical. If |
Value
A character design matrix if details = FALSE; otherwise a list containing the design, numeric design, principal column, principal row, diagnostics, and mixedfact output.
Examples
rc_from_principal_block(
levels = c(2, 3),
block_size = 3,
principal_block = c("00", "12", "11")
)
Construct a two-factor row-column design by Method 1
Description
Generates a row-column design for a two-factor factorial experiment s1 x s2 when the two numbers of levels have a common factor. The construction follows Method 1 of Gopinath, Parsad and Mandal for incomplete row-column designs with factorial treatment structure.
Usage
rc_method1(s1, s2, f = NULL, sep = "")
Arguments
s1 |
Number of levels of the first factor. |
s2 |
Number of levels of the second factor. |
f |
Optional common factor of |
sep |
Character separator for printed treatment labels. |
Value
A list containing the construction method, parameters, component matrices D1 and D2, the printed design, and a numeric design array.
References
Gopinath, P. P., Parsad, R. and Mandal, B. N. (2018). Incomplete row-column designs with factorial treatment structure for estimating main effects with full efficiency. Communications in Statistics - Theory and Methods, 47, 4493-4502.
Examples
rc_method1(3, 6)$design
Construct a two-factor row-column design by Method 2
Description
Generates a row-column design for a two-factor factorial experiment s1 x s2 when s2 is a multiple of s1. The construction follows Method 2 of Gopinath, Parsad and Mandal.
Usage
rc_method2(s1, s2, sep = "")
Arguments
s1 |
Number of levels of the first factor. |
s2 |
Number of levels of the second factor. Must be a multiple of |
sep |
Character separator for printed treatment labels. |
Value
A list containing the construction method, parameters, component matrices D1 and D2, the printed design, and a numeric design array.
References
Gopinath, P. P., Parsad, R. and Mandal, B. N. (2018). Incomplete row-column designs with factorial treatment structure for estimating main effects with full efficiency. Communications in Statistics - Theory and Methods, 47, 4493-4502.
Examples
rc_method2(2, 4)$design
Cyclically right-shift a vector
Description
Performs a cyclic right shift of a vector by k positions.
Usage
right_shift(x, k = 1)
Arguments
x |
Vector to shift. |
k |
Number of positions for the cyclic shift. |
Value
A vector with the same entries as x, cyclically shifted to the right.
Generalized inverse by singular value decomposition
Description
Computes a Moore-Penrose-style generalized inverse using singular value decomposition and a numerical tolerance.
Usage
svd_ginv(A, tol = sqrt(.Machine$double.eps))
Arguments
A |
Numeric matrix. |
tol |
Numerical tolerance for deciding positive singular values. |
Value
Numeric matrix giving a generalized inverse of A.
Symmetrize a matrix
Description
Replaces a square matrix by (A + t(A)) / 2.
Usage
symmetrize_matrix(A)
Arguments
A |
Numeric square matrix. |
Value
Symmetric numeric matrix.
Map treatment combinations to treatment indices
Description
Converts rows of a treatment matrix into one-based treatment indices under mixed-radix ordering.
Usage
treatment_index_from_matrix(trt_mat, levels)
Arguments
trt_mat |
Integer matrix of treatment combinations. |
levels |
Integer vector of factor levels. |
Value
Integer vector of one-based treatment indices.
Create a treatment label
Description
Converts a numeric treatment vector to a character label.
Usage
treatment_label(x, sep = "")
Arguments
x |
Numeric vector giving a treatment combination. |
sep |
Character separator inserted between factor levels. |
Value
A single character label.
Verify row-column design properties
Description
Computes OFS diagnostics, main-effect and two-factor-interaction estimability, connectedness, balance, A/D/E efficiencies, E-optimality value, and MV-optimality value for a generated MFRCD design.
Usage
verify_mfrcd(
x,
levels = NULL,
sep = "",
tol = 1e-07,
max_order = NULL,
verbose = FALSE
)
Arguments
x |
MFRCD details list, numeric design array, or printed design matrix. |
levels |
Optional integer vector of factor levels, required when |
sep |
Character separator used in treatment labels. |
tol |
Numerical tolerance for rank, eigenvalue, and orthogonality checks. |
max_order |
Maximum factorial-effect order to include. If |
verbose |
Logical. If |
Value
A list containing summary checks, effect-level diagnostics, connectedness, efficiencies, optimality criteria, information matrices, and treatment frequencies.
Examples
obj <- mfrcd(c(2, 4), details = TRUE)
chk <- verify_mfrcd(obj)
chk$summary$ofs
chk$main_effects_and_2fi