| Type: | Package |
| Title: | Generation and Analysis of 3-Level and 5-Level Factorial Block Designs |
| Version: | 0.2.0 |
| Maintainer: | Sukanta Dash <sukanta.iasri@gmail.com> |
| Description: | Provides tools to generate and analyze 3-level and 5-level linear factorial block designs, including complete factorial layouts, fractional factorial layouts, confounded factorial layouts, and design-characteristic summaries. The package includes utilities for recursive construction, defining-contrast identification, alias and confounding summaries, incidence matrix construction, and selected design-characteristic diagnostics. The methodological framework follows foundational work on factorial block designs, including Gupta (1983) <doi:10.1111/j.2517-6161.1983.tb01253.x>. |
| License: | GPL-3 |
| Encoding: | UTF-8 |
| Imports: | MASS, Matrix, stats, utils |
| Suggests: | testthat (≥ 3.0.0) |
| Config/testthat/edition: | 3 |
| RoxygenNote: | 7.3.3 |
| NeedsCompilation: | no |
| Packaged: | 2026-05-07 12:15:32 UTC; Sukanta |
| Author: | Vankudoth Kumar [aut], Sukanta Dash [aut, cre], Med Ram Verma [aut] |
| Repository: | CRAN |
| Date/Publication: | 2026-05-07 13:40:02 UTC |
Generation and Analysis of Confounded and Fractional Factorial Block Designs
Description
Internal package-level roxygen directives used to generate the
package NAMESPACE automatically with roxygen2.
Author(s)
Maintainer: Sukanta Dash sukanta.iasri@gmail.com
Authors:
Vankudoth Kumar
Med Ram Verma
Analyze factorial block-design characteristics
Description
Computes incidence-based, estimability, balance, confounding, discrepancy, and optimality summaries for a factorial block design.
Usage
FactChar(factor_levels, blocks)
Arguments
factor_levels |
Integer vector giving the number of levels for each factor. |
blocks |
List of blocks, where each block is a character vector of treatment labels. |
Details
This function contains several local helper functions for pseudo-inverse calculation, contrast construction, Das-style diagnostics, discrepancy measures, and confounding checks. Those helper functions are scoped locally and are not intended to be documented as separate package-level functions.
Value
An object of class "lfebd3_analysis" containing the incidence
matrix, C-matrix, design-property flags, confounding summary, discrepancy
criteria, optimality diagnostics, and Das-style summaries. Use
print() to display the formatted report.
See Also
build_block_matrix(), lfebd3_analyze(), lfebd3.cf.full()
Examples
d <- lfebd3.cf.full(2, 1)
res <- FactChar(c(3, 3), convert_to_blocks(d))
stopifnot(inherits(res, "lfebd3_analysis"))
Fast factorial block-design screening diagnostics
Description
Computes a lightweight subset of the diagnostics returned by FactChar().
This function is intended for large designs, especially 5-level designs with
n > 3, where the exact all-effects diagnostics require large generalized
inverses and pairwise distance matrices. It preserves the same printed-object
class as FactChar() so the result can still be displayed with
print.lfebd3_analysis().
Usage
FactChar_fast(factor_levels, blocks)
Arguments
factor_levels |
Integer vector giving the number of levels for each factor. |
blocks |
List of blocks, where each block is a character vector of treatment labels. |
Value
An object of class "lfebd3_analysis" containing fast design
properties and block-confounding summaries. Expensive exact diagnostics are
set to NA or skipped and reported as such by print().
Examples
d <- as.data.frame(lfebd5.fr(3, c = 1))
blk <- list(B1 = apply(d, 1, paste0, collapse = ""))
res <- FactChar_fast(rep(5, 3), blk)
stopifnot(inherits(res, "lfebd3_analysis"))
Convert a full confounded LFBD data frame into blocks
Description
Extracts block columns from a data frame returned by lfebd3.cf.full().
Usage
as_blocks_from_cf_full(design_df)
Arguments
design_df |
Data frame containing a |
Value
A named list of character vectors, one vector per block.
Convert a run-ordered design into equal-sized blocks
Description
Splits the Treatment column of a run-ordered design data frame into
consecutive blocks of a specified size.
Usage
as_blocks_from_runs(design_df, block_size)
Arguments
design_df |
Data frame containing a |
block_size |
Positive integer giving the number of treatments per block. |
Value
A named list of character vectors, one vector per block.
Build a treatment-by-block incidence matrix
Description
Creates the incidence matrix for a block design from a list of treatment labels grouped by block.
Usage
build_block_matrix(blocks)
Arguments
blocks |
Named or unnamed list of blocks, where each block is a vector of treatment labels. |
Value
A binary matrix with treatments in rows and blocks in columns.
See Also
convert_to_blocks(), FactChar()
Examples
N <- build_block_matrix(list(B1 = c("00", "11"), B2 = c("01", "10")))
stopifnot(ncol(N) == 2)
Build a model matrix for factorial effects
Description
Generates the treatment-effect model matrix for a factorial design using sum-to-zero contrasts.
Usage
build_effect_matrix(trts, factor_levels)
Arguments
trts |
Character vector of treatment labels. Included for interface compatibility with the original script. |
factor_levels |
Integer vector giving the number of levels for each factor. |
Value
A model matrix with one row per treatment combination.
See Also
Examples
X <- build_effect_matrix(NULL, c(3, 3))
stopifnot(nrow(X) == 9)
Build recursive triplets for fractional or confounded reduction
Description
Recursively partitions a design matrix into three components and returns three reduced patterns used in the fractional and confounded selection rules.
Usage
build_triplet(mat, type = c("fractional", "confounded"))
Arguments
mat |
Matrix to be partitioned and reduced. |
type |
Character string specifying the reduction rule. Must be one of
|
Details
For 9-row base cases, the selection rule differs by type.
Fractional reduction uses consecutive row groups, whereas confounded
reduction uses interleaved row groups. Larger matrices are handled
recursively.
Value
A list of three matrices, conventionally interpreted as P1, P2,
and P3.
See Also
reduce_once(), reduce_repeated()
Canonicalize a mod-3 effect vector
Description
Standardizes a nonzero effect vector so that its first nonzero coefficient
is equal to 1 in mod-3 arithmetic.
Usage
canonical_effect(v)
Arguments
v |
Numeric vector encoding an effect in mod 3 arithmetic. |
Value
A canonicalized numeric vector in mod 3.
See Also
effect_label(), find_defining_contrasts()
Convert a generated design object to a block list
Description
Converts either a treatment-run data frame or a block-wise design data frame into a named list of blocks.
Usage
convert_to_blocks(design_df)
Arguments
design_df |
Data frame returned by a design-generation function. |
Value
A named list where each element is a character vector of treatment labels belonging to one block.
See Also
build_block_matrix(), FactChar()
Examples
blocks <- convert_to_blocks(lfebd3(2))
stopifnot(length(blocks) == 1)
Generate the defining subgroup from a defining-contrast basis
Description
Forms all mod-3 linear combinations of the supplied defining contrasts.
Usage
defining_subgroup(B)
Arguments
B |
Matrix whose columns are defining contrasts. |
Value
A matrix whose rows enumerate the defining subgroup.
See Also
find_defining_contrasts(), low_order_aliases_from_subgroup()
Compute direct aliases from defining contrasts
Description
Combines an effect with each defining contrast, and optionally with multiples of each contrast, to obtain direct aliases.
Usage
direct_aliases_from_dc(v, dc_basis, include_multiples = FALSE)
Arguments
v |
Target effect vector. |
dc_basis |
Matrix of defining contrasts. |
include_multiples |
Logical; if |
Value
A character vector of unique direct aliases.
See Also
find_defining_contrasts(), low_order_aliases_from_subgroup()
List low-order aliases for an effect
Description
Computes low-order aliases of a target effect using a supplied defining subgroup.
Usage
effect_aliases_low_order(v, subgroup, max_order = 2)
Arguments
v |
Target effect vector. |
subgroup |
Matrix whose rows represent subgroup elements. |
max_order |
Maximum order of aliases to retain. |
Value
A sorted character vector of aliased low-order effects.
See Also
low_order_aliases_from_subgroup()
Convert an effect vector to a compact label
Description
Converts a mod-3 effect vector to the string representation used throughout the aliasing and confounding summaries.
Usage
effect_label(v)
Arguments
v |
Numeric vector encoding an effect in mod 3 arithmetic. |
Value
A character string such as "I", "F11", or "F11F22".
See Also
effect_order(), canonical_effect()
Compute the order of an effect vector
Description
Counts the number of nonzero coefficients in a mod-3 effect vector.
Usage
effect_order(v)
Arguments
v |
Numeric vector encoding an effect in mod 3 arithmetic. |
Value
Integer giving the number of active factors in the effect.
See Also
effect_label(), canonical_effect()
Find defining contrasts for a fractional design
Description
Searches the effect space for mod-3 contrasts satisfied by a design matrix and extracts an independent basis of defining contrasts.
Usage
find_defining_contrasts(design_mat, expected_c = NULL)
Arguments
design_mat |
Design matrix whose rows correspond to treatment combinations and whose columns correspond to factors. |
expected_c |
Optional integer giving the expected number of defining contrasts to retain. |
Value
A list with components:
- basis
A matrix whose columns form an independent basis of defining contrasts.
- labels
Character vector of labels for the defining contrasts.
See Also
defining_subgroup(), fractional_confounding_summary(), lfebd3.fr()
Summarize aliasing and confounding in a fractional LFBD
Description
Produces a low-order summary for main effects and two-factor interactions under the defining subgroup of a fractional 3-level factorial design.
Usage
fractional_confounding_summary(n, dc_basis)
Arguments
n |
Integer. Number of factors. |
dc_basis |
Matrix whose columns form the basis of defining contrasts. |
Value
A data frame describing each listed effect, its order, low-order aliases, and simple estimability/confounding indicators.
See Also
find_defining_contrasts(), lfebd3.fr()
Backward-compatible one-stage 5-level fractional generator
Description
Generates the first-stage 5-level fractional factorial design. This function is retained for compatibility with earlier scripts.
Usage
fractional_factorial_5n(n)
Arguments
n |
Positive integer. Number of factors. |
Value
A data frame containing the selected fraction.
Backward-compatible complete 5-level factorial generator
Description
Calls lfebd5() and is kept for compatibility with earlier scripts.
Usage
full_factorial_5n(n)
Arguments
n |
Positive integer. Number of factors. |
Value
A data frame returned by lfebd5().
Generate the full ternary construction matrix
Description
Builds the full recursive ternary matrix used as the foundation for generating complete, fractional, and confounded 3-level factorial layouts in this script.
Usage
generate_Tn_full(n)
Arguments
n |
Integer. Number of recursion levels (or factors). |
Details
The construction starts from a single-column seed and applies the
3-by-3 recursive expansion rule n times. The returned matrix is
transposed so that downstream functions can extract the square design
submatrix directly.
Value
A matrix with entries in 0, 1, and 2
representing the full ternary construction after n
recursive expansions.
References
Elsawah, A.M. Multiple doubling: a simple effective construction technique for optimal two-level experimental designs. Statistical Papers 62, 2923–2967 (2021). DOI: 10.1007/s00362-020-01221-0
Gupta, S. C. (1983). Some new methods for constructing block designs having orthogonal factorial structure. Journal of the Royal Statistical Society, Series B (Methodological), 45, 297-307.
See Also
get_Tn_square(), lfebd3(), lfebd3.fr(), lfebd3.cf()
Examples
generate_Tn_full(1)
dim(generate_Tn_full(2))
get_Tn_square(1)
dim(get_Tn_square(2))
d <- lfebd3(2)
d
nrow(d)
d <- lfebd3.fr(2, 1)
d
attr(d, "defining_contrasts")
lfebd3.cf(2, 1)
dim(lfebd3.cf(3, 2))
d <- lfebd3.cf.full(2, 1)
d
colnames(d)
d <- lfebd3(2)
blk <- convert_to_blocks(d)
blk
d <- lfebd3.cf.full(2, 1)
convert_to_blocks(d)
d <- lfebd3.cf.full(2, 1)
blk <- convert_to_blocks(d)
build_block_matrix(blk)
X <- build_effect_matrix(NULL, c(3, 3))
dim(X)
head(X)
d <- lfebd3.cf.full(2, 1)
blk <- convert_to_blocks(d)
res <- FactChar(c(3, 3), blk)
print(res)
res <- lfebd3_analyze(
type = "lfebd3.cf.full",
n = 2,
r = 1,
show_design = FALSE,
run_analysis = FALSE
)
names(res)
Generate a catalog of effects up to a chosen order
Description
Enumerates main effects and, optionally, two-factor interactions for a symmetric factorial design coded in mod 3.
Usage
generate_effect_catalog(n, max_order = 2)
Arguments
n |
Integer. Number of factors. |
max_order |
Maximum interaction order to include. Currently used for main effects and two-factor interactions. |
Value
A list with components mat, labels, and orders.
See Also
fractional_confounding_summary()
Extract the square design matrix for a 3-level factorial construction
Description
Computes the square submatrix used as the base design matrix for the LFBD generators.
Usage
get_Tn_square(n)
Arguments
n |
Integer. Number of factors. |
Value
A 3^n x n? style square matrix derived from the full ternary
construction, with the first 3^n rows retained after transposition.
See Also
generate_Tn_full(), lfebd3(), lfebd3.fr(), lfebd3.cf()
Examples
T2 <- get_Tn_square(2)
stopifnot(nrow(T2) == 9)
Test linear independence modulo 3
Description
Checks whether adding a vector to an existing basis increases its mod-3 rank.
Usage
is_independent_mod3(B, v)
Arguments
B |
Matrix whose columns form the current basis. |
v |
Vector to test for independence. |
Value
Logical value; TRUE if v is independent of the columns of B
over mod 3, otherwise FALSE.
See Also
rank_mod3(), find_defining_contrasts()
Generate a complete factorial LFBD
Description
Creates the complete 3-level factorial layout from the ternary design construction and returns treatment labels in run order.
Usage
lfebd3(n)
Arguments
n |
Integer. Number of factors. |
Value
A data frame with columns:
- Run
Run labels such as
"run1","run2", ...- Treatment
Treatment combination labels formed by concatenating factor levels coded as
0,1, and2.
See Also
lfebd3.fr(), lfebd3.cf.full(), lfebd3_analyze()
Examples
d <- lfebd3(2)
stopifnot(nrow(d) == 9, all(c("Run", "Treatment") %in% names(d)))
Generate the principal block for a confounded LFBD
Description
Extracts the principal block of size 3^r from a complete 3-level
factorial design using the recursive confounded selection rule.
Usage
lfebd3.cf(n, r)
Arguments
n |
Integer. Number of factors. |
r |
Integer. Exponent determining the principal block size, so the
principal block contains |
Value
A matrix representing the principal block.
See Also
lfebd3.cf.full(), reduce_repeated()
Examples
B <- lfebd3.cf(3, r = 2)
stopifnot(nrow(B) == 9)
Generate the full confounded factorial design
Description
Builds the complete set of blocks induced by the principal block of a confounded 3-level factorial design.
Usage
lfebd3.cf.full(n, r, max_blocks_display = 12)
Arguments
n |
Integer. Number of factors. |
r |
Integer. Exponent determining the principal block size. |
max_blocks_display |
Integer. Reserved display helper parameter from the original script. |
Value
An invisible data frame whose first column identifies units and whose
remaining columns correspond to blocks (blk1, blk2, ...).
See Also
lfebd3.cf(), convert_to_blocks(), FactChar()
Examples
d <- lfebd3.cf.full(2, r = 1)
stopifnot("Unit" %in% names(d))
Generate a fractional 3-level LFBD
Description
Constructs a fractional layout from the complete ternary design by repeated fractional reduction and returns the design together with defining contrasts and a low-order confounding summary.
Usage
lfebd3.fr(n, c)
Arguments
n |
Integer. Number of factors. |
c |
Integer. Degree of fractionation, so the final number of runs is
|
Value
An object of class "lfebd3_fr" containing:
- design
A data frame with run labels and treatment labels.
- design_matrix
The reduced numeric design matrix.
- defining_contrasts
Character vector of defining contrast labels.
- confounding_summary
Data frame of main-effect and 2FI summaries.
See Also
lfebd3(), lfebd3.cf(), lfebd3_analyze()
Examples
d <- lfebd3.fr(2, 1)
d$design
d$defining_contrasts
Generate and analyze a 3-level LFBD in one call
Description
Generates a complete, fractional, or confounded 3-level factorial block
design and, optionally, computes design-characteristic diagnostics. The
factor-level vector is inferred automatically as rep(3, n).
Usage
lfebd3_analyze(
type = c("lfebd3", "lfebd3.fr", "lfebd3.cf", "lfebd3.cf.full"),
n,
c = NULL,
r = NULL,
block_size = NULL,
show_design = TRUE,
run_analysis = TRUE,
fast = NULL,
exact_limit = Inf,
print_limit = 50
)
Arguments
type |
Character string specifying the generator to use. Use
|
n |
Positive integer. Number of factors. |
c |
Optional non-negative integer. Degree of fractionation for
|
r |
Optional positive integer. Block-size exponent for
|
block_size |
Optional positive integer used to split run-ordered
complete or fractional designs into consecutive blocks. Required for
|
show_design |
Logical. Stored in the returned object and used by
|
run_analysis |
Logical. If |
fast |
Logical or |
exact_limit |
Positive integer. Maximum number of treatments for which
exact |
print_limit |
Positive integer. Maximum number of rows printed from
large generated designs and alias tables by |
Value
An object of class "lfebd3_analyze_result", a list with components
type, factor_levels, generated_design, blocks, analysis,
show_design, and show_confounding. Use print() to display a formatted
report.
See Also
lfebd3(), lfebd3.fr(), lfebd3.cf.full(), FactChar()
Examples
res <- lfebd3_analyze(
type = "lfebd3.fr",
n = 3,
c = 1,
block_size = 9,
show_design = FALSE,
run_analysis = FALSE
)
stopifnot(inherits(res, "lfebd3_analyze_result"))
Generate a complete 5-level factorial design
Description
Creates the complete 5-level factorial layout for n factors. Factor
columns are named F1, F2, and so on, and levels are coded as integers
0 through 4.
Usage
lfebd5(n)
Arguments
n |
Positive integer. Number of factors. |
Value
A data frame with 5^n rows and n factor columns.
Examples
d <- lfebd5(2)
stopifnot(nrow(d) == 25, ncol(d) == 2)
Generate a confounded 5-level factorial block design
Description
Generates a 5-level confounded factorial design with 5^n treatments
arranged in blocks of size 5^r. The result is returned in block-wise form.
Usage
lfebd5.cf(n, r = 1, return_info = FALSE)
Arguments
n |
Integer. Number of factors. Must be at least 3. |
r |
Positive integer. Block-size exponent; each block has |
return_info |
Logical. If |
Value
A data frame of class "lfebd5_cf_design" unless return_info = TRUE.
Examples
d <- lfebd5.cf(3, r = 1)
stopifnot(nrow(d) == 5, ncol(d) == 26)
Summarize independent confounding for a 5-level block design
Description
Returns independent confounded effects and related counts for a 5-level confounded design.
Usage
lfebd5.cf_independent_confounding(n, r, p = 5)
Arguments
n |
Integer. Number of factors. |
r |
Positive integer. Block-size exponent. |
p |
Integer modulus. Defaults to 5. |
Value
A list with confounding summaries and generator matrix.
Examples
info <- lfebd5.cf_independent_confounding(3, r = 1)
stopifnot(info$block_size == 5)
Generate a fractional 5-level factorial design
Description
Generates a 5-level fractional factorial design by repeated row selection and attaches defining-factor and aliasing summaries as attributes.
Usage
lfebd5.fr(n, c = 1, return_info = FALSE)
Arguments
n |
Integer. Number of factors. Must be at least 3. |
c |
Non-negative integer. Degree of fractionation; the design has
|
return_info |
Logical. If |
Value
A data frame of class "lfebd5_fr_design" unless return_info = TRUE.
Examples
d <- lfebd5.fr(3, c = 1)
stopifnot(nrow(d) == 25)
attr(d, "defining_factors")
Enumerate all confounded effects for a 5-level design
Description
Forms all nonzero confounded effects generated by an independent basis.
Usage
lfebd5_all_confounded_effects_from_design(D, p = 5)
Arguments
D |
Design data frame or matrix. |
p |
Integer modulus. Defaults to 5. |
Value
A data frame of all confounded effects.
Enumerate all defining factors for a 5-level design
Description
Forms all nonzero linear combinations of the independent defining factors.
Usage
lfebd5_all_defining_factors_from_design(D, p = 5)
Arguments
D |
Design data frame or matrix. |
p |
Integer modulus. Defaults to 5. |
Value
A data frame of defining factors, relations, and orders.
Generate and analyze a 5-level LFBD in one call
Description
Generates a complete, fractional, or confounded 5-level factorial block
design and, optionally, computes design-characteristic diagnostics. The
factor-level vector is inferred automatically as rep(5, n) unless supplied.
Usage
lfebd5_analyze(
type = base::c("lfebd5", "lfebd5.fr", "lfebd5.cf"),
factor_levels = NULL,
n,
c = NULL,
r = NULL,
block_size = NULL,
show_design = TRUE,
run_analysis = TRUE,
fast = NULL,
exact_limit = 125,
print_limit = 50
)
Arguments
type |
Character string specifying the generator to use. Use
|
factor_levels |
Optional integer vector. Must equal |
n |
Positive integer. Number of factors. |
c |
Optional non-negative integer. Degree of fractionation for
|
r |
Optional positive integer. Block-size exponent for
|
block_size |
Optional positive integer used to split run-ordered
complete or fractional designs into consecutive blocks. Required for
|
show_design |
Logical. Stored in the returned object and used by
|
run_analysis |
Logical. If |
fast |
Logical or |
exact_limit |
Positive integer. Maximum number of treatments for which
exact |
print_limit |
Positive integer. Maximum number of rows printed from
large generated designs and alias tables by |
Value
An object of class "lfebd5_analyze_result", a list with components
type, factor_levels, generated_design, design_table, blocks,
analysis, show_design, show_confounding, fast, and
print_limit. Use print() to display
a formatted report.
See Also
lfebd5(), lfebd5.fr(), lfebd5.cf(), FactChar()
Examples
res <- lfebd5_analyze(
type = "lfebd5.fr",
n = 3,
c = 1,
block_size = 25,
show_design = FALSE,
run_analysis = FALSE
)
stopifnot(inherits(res, "lfebd5_analyze_result"))
Find independent defining factors for a 5-level design
Description
Computes an independent defining-factor basis from a 5-level design matrix.
Usage
lfebd5_defining_factors_from_design(D, p = 5)
Arguments
D |
Design data frame or matrix. |
p |
Integer modulus. Defaults to 5. |
Value
A data frame of defining factors, relations, and orders.
Compute the order of a 5-level effect
Description
Counts the number of nonzero coefficients in an effect vector.
Usage
lfebd5_effect_order(coeffs)
Arguments
coeffs |
Integer vector of effect coefficients. |
Value
Integer effect order.
Convert a 5-level effect vector to a label
Description
Converts coefficients to labels such as F11, F12, or F11F24, matching
the 3-level notation convention.
Usage
lfebd5_effect_word(coeffs, factor_names = NULL)
Arguments
coeffs |
Integer vector of effect coefficients. |
factor_names |
Optional character vector of factor names. |
Value
A character effect label.
Generate the recursive 5-level construction matrix
Description
Builds the recursive construction matrix used by the 5-level factorial generators.
Usage
lfebd5_generate_Tn(n, p = 5)
Arguments
n |
Non-negative integer. Number of recursive expansions. |
p |
Integer modulus. Defaults to 5. |
Value
A data frame containing the generated construction matrix.
Find independent confounded effects for a 5-level design
Description
Computes independent confounded effects from the nullspace of the principal block or selected design.
Usage
lfebd5_independent_effects_from_design(D, p = 5)
Arguments
D |
Design data frame or matrix. |
p |
Integer modulus. Defaults to 5. |
Value
A data frame of independent confounded effects.
Compute main-effect aliases for a 5-level design
Description
Computes aliases of all main effects induced by the defining subgroup.
Usage
lfebd5_main_effect_aliases_from_design(D, p = 5)
Arguments
D |
Design data frame or matrix. |
p |
Integer modulus. Defaults to 5. |
Value
A data frame of main effects and their aliases.
Build the initial 5-level fractional selection matrix
Description
Constructs the first-stage row-selection matrix used by the 5-level fractional factorial generator.
Usage
lfebd5_make_selection_matrix(n)
Arguments
n |
Positive integer. Number of factors. |
Value
An integer matrix of selected row positions.
Build a 5-level confounded stage selection matrix
Description
Constructs the special first-stage confounded selection pattern and delegates later stages to the general fractional-stage pattern.
Usage
lfebd5_make_selection_matrix_cf_stage(n, stage)
Arguments
n |
Positive integer. Number of factors. |
stage |
Positive integer. Selection stage. |
Value
An integer matrix of selected row positions.
Build a general 5-level fractional stage selection matrix
Description
Constructs the repeated 5-row group pattern used in later 5-level fractional or confounded selection stages.
Usage
lfebd5_make_selection_matrix_fr_stage_general(n, stage)
Arguments
n |
Positive integer. Number of factors. |
stage |
Positive integer. Selection stage. |
Value
An integer matrix of selected row positions.
Build a 5-level fractional selection matrix for one stage
Description
Constructs the row-selection matrix used at one fractionation stage in the 5-level fractional generator.
Usage
lfebd5_make_selection_matrix_stage(n, stage)
Arguments
n |
Positive integer. Number of factors. |
stage |
Positive integer. Fractionation stage. |
Value
An integer matrix of selected row positions.
Compute a modular inverse
Description
Finds the multiplicative inverse of a nonzero element modulo p.
Usage
lfebd5_mod_inv(a, p = 5)
Arguments
a |
Integer value. |
p |
Integer modulus. Defaults to 5. |
Value
Integer inverse of a modulo p.
Reduce values modulo p
Description
Applies positive modular reduction.
Usage
lfebd5_modp(x, p = 5)
Arguments
x |
Numeric vector, matrix, or array. |
p |
Integer modulus. Defaults to 5. |
Value
x reduced modulo p.
Normalize a 5-level effect vector
Description
Scales an effect vector modulo p so that the first nonzero coefficient is
one.
Usage
lfebd5_normalize_effect(v, p = 5)
Arguments
v |
Integer vector of effect coefficients. |
p |
Integer modulus. Defaults to 5. |
Value
Normalized effect vector.
Compute a nullspace basis modulo p
Description
Computes a basis for the nullspace of a matrix over the field modulo p.
Usage
lfebd5_nullspace_modp(A, p = 5)
Arguments
A |
Matrix-like object. |
p |
Integer modulus. Defaults to 5. |
Value
A matrix whose rows form a nullspace basis.
Compute row-reduced echelon form modulo p
Description
Performs Gaussian elimination over the finite field modulo p.
Usage
lfebd5_rref_modp(A, p = 5)
Arguments
A |
Matrix-like object. |
p |
Integer modulus. Defaults to 5. |
Value
A list with components rref, pivots, and rank.
Convert a 5-level design to a run table
Description
Collapses factor columns into treatment labels used by the shared analysis functions.
Usage
lfebd5_to_run_table(D)
Arguments
D |
5-level design data frame or matrix. |
Value
A data frame with Run and Treatment columns.
Print a limited number of rows from a large object
Description
Internal helper used by print methods to avoid flooding the console with large generated designs or alias tables. It is not intended to be called directly by users.
Usage
lfebd_print_limited(x, print_limit = 50, row.names = FALSE)
Arguments
x |
Object to print. |
print_limit |
Maximum number of rows to print for matrices or data frames. |
row.names |
Logical; whether to print row names for tabular objects. |
Value
Invisibly returns x.
Compute low-order aliases from a defining subgroup
Description
Adds a target effect to each subgroup element and retains aliases whose
order does not exceed max_order.
Usage
low_order_aliases_from_subgroup(v, subgroup, max_order = 2)
Arguments
v |
Target effect vector. |
subgroup |
Matrix whose rows represent subgroup elements. |
max_order |
Maximum order of aliases to retain. |
Value
A sorted character vector of unique low-order aliases.
See Also
defining_subgroup(), fractional_confounding_summary()
Print an lfebd3 analysis object
Description
Displays the formatted report for an object returned by FactChar().
Usage
## S3 method for class 'lfebd3_analysis'
print(x, show_confounding = FALSE, ...)
Arguments
x |
An object of class |
show_confounding |
Logical. If |
... |
Further arguments passed to or from other methods. |
Value
Invisibly returns x.
Examples
d <- lfebd3.cf.full(2, 1)
res <- FactChar(c(3, 3), convert_to_blocks(d))
print(res)
Print a 3-level LFBD analysis result
Description
Displays the generated design and analysis diagnostics stored in an object
returned by lfebd3_analyze(). Printing is intentionally handled by this
S3 method so that the constructor itself can be used silently in scripts,
examples, and tests.
Usage
## S3 method for class 'lfebd3_analyze_result'
print(x, ...)
Arguments
x |
An object returned by |
... |
Further arguments passed to methods. |
Value
Invisibly returns x.
Examples
res <- lfebd3_analyze(
type = "lfebd3.fr",
n = 3,
c = 1,
block_size = 9,
show_design = FALSE,
run_analysis = FALSE
)
print(res)
Print a fractional 3-level LFBD object
Description
Displays the run table, defining contrasts, and low-order aliasing summary
stored in an object returned by lfebd3.fr(). Printing is handled by this
S3 method so that the object can also be inspected programmatically.
Usage
## S3 method for class 'lfebd3_fr'
print(x, ...)
Arguments
x |
Object of class |
... |
Further arguments passed to methods. |
Value
Invisibly returns x.
Examples
d <- lfebd3.fr(2, 1)
print(d)
Print a 5-level LFBD analysis result
Description
Displays the generated design and analysis diagnostics stored in an object
returned by lfebd5_analyze(). Printing is intentionally handled by this
S3 method so that the constructor itself can be used silently in scripts,
examples, and tests.
Usage
## S3 method for class 'lfebd5_analyze_result'
print(x, ...)
Arguments
x |
An object returned by |
... |
Further arguments passed to methods. |
Value
Invisibly returns x.
Examples
res <- lfebd5_analyze(
type = "lfebd5.fr",
n = 3,
c = 1,
block_size = 25,
show_design = FALSE,
run_analysis = FALSE
)
print(res)
Print a confounded 5-level design
Description
Displays a confounded 5-level block design and its confounded-effect summaries.
Usage
## S3 method for class 'lfebd5_cf_design'
print(x, ...)
Arguments
x |
Object of class |
... |
Further arguments passed to |
Value
Invisibly returns x.
Examples
d <- lfebd5.cf(3, r = 1)
print(d)
Print a fractional 5-level design
Description
Displays a fractional 5-level design with defining factors and main-effect aliases.
Usage
## S3 method for class 'lfebd5_fr_design'
print(x, ...)
Arguments
x |
Object of class |
... |
Further arguments passed to |
Value
Invisibly returns x.
Examples
d <- lfebd5.fr(3, c = 1)
print(d)
Print a generated design
Description
Convenience printer used by lfebd3_analyze() to display the generated
design object.
Usage
print_generated_design(design_df)
Arguments
design_df |
A generated design data frame. |
Value
Invisibly returns design_df.
Compute matrix rank over the field of integers mod 3
Description
Performs Gaussian elimination modulo 3 to determine the rank of a matrix.
Usage
rank_mod3(M)
Arguments
M |
Matrix-like object. |
Value
Integer rank of M computed under mod-3 arithmetic.
See Also
Reduce a design matrix by one factor of three
Description
Applies a single fractional or confounded reduction step to a design
matrix by selecting the first recursive pattern returned by
build_triplet().
Usage
reduce_once(mat, type = c("fractional", "confounded"))
Arguments
mat |
Matrix to reduce. |
type |
Character string specifying |
Value
A reduced matrix with one-third as many rows as mat when reduction
is possible.
See Also
build_triplet(), reduce_repeated()
Repeatedly reduce a design matrix
Description
Applies reduce_once() iteratively to obtain a smaller fractional or
confounded design.
Usage
reduce_repeated(mat, times, type = c("fractional", "confounded"))
Arguments
mat |
Matrix to reduce. |
times |
Non-negative integer giving the number of repeated reduction steps. |
type |
Character string specifying |
Value
A matrix obtained after times successive reductions.