Learn R Programming

MixFrac (version 1.0)

generate_ff: Generate Mixed-Level or Regular Fractional Factorial Designs

Description

generate_ff() constructs mixed-level fractional factorial designs or, when all factors share the same number of levels \(s\), automatically searches for a regular \(s^{k-p}\) fractional factorial using generator relations.

#' The function performs:

  • Part 1: Design construction (regular or mixed-level)

  • Part 2: Design diagnostics: balance (Hhat), J2, GBM, alias chains, and strong confounding summary

  • Part 3 (optional): Deterministic trend-free run order based on Coster (1993)

Output printing can be controlled via the parts argument.

Usage

generate_ff(
  levels_spec,
  n_runs,
  max_iter = 100,
  a = 1,
  b = 1,
  max_int_order = 3,
  alias_min_abs_corr = 0.9,
  tf = FALSE,
  parts = c(1, 2, 3),
  verbose = TRUE
)

Value

A list containing:

  • design_int -> integer-coded design

  • design_labels -> decoded factor levels

  • level_maps -> internal mapping of coded levels

  • Hhat -> balance measure

  • J2hat -> near-orthogonality measure

  • GBM -> general balance metric

  • gbm_resolution -> smallest order with imbalance

  • model_matrix -> model matrix with interactions

  • corr_matrix -> correlation matrix

  • alias_chains -> alias chain structure

  • alias_summary -> strong confounding pairs

  • trend_free_result -> (if tf = TRUE) run order, reordered design, and final trend objective

Returned invisibly unless assigned.

Arguments

levels_spec

A numeric vector such as c(2,3,4) (levels per factor), or a named list of level labels (e.g. list(A = 1:2, B = 1:3, C = 1:4)).

n_runs

Number of experimental runs required.

max_iter

Maximum number of iterations for coordinate exchange or unique-subset improvement (default: 100).

a

Weight for the J2 near-orthogonality criterion.

b

Weight for the Hhat balance criterion.

max_int_order

Highest-order interaction used when building model matrices for alias calculations. Default is 3.

alias_min_abs_corr

Minimum absolute correlation required for a pair of model terms to appear in the strong confounding summary table.

tf

Logical. When TRUE, computes a trend-free run order (Part 3) based on deterministic pairwise swapping.

parts

Integer vector selecting which sections to print:

  • 1 -> Part 1: Design

  • 2 -> Part 2: Properties & alias

  • 3 -> Part 3: Trend-free order

To print all: parts = c(1,2,3) (default).

verbose

Logical. When TRUE, prints results. When FALSE, performs all computations silently.

Details

Automatic Regular Fractional Factorial Detection

When all factors have the same number of levels \(s\), and when \(n\_runs = s^{k-p}\), the function attempts to find a regular \(s^{k-p}\) fraction via a heuristic generator search inspired by Guo et al. (2007). The objective minimized is:

The objective function minimized is Z = a * J2 + b * Hhat.

If no acceptable generator set is found, the algorithm reverts to a mixed-level design strategy.

Mixed-Level Fractional Factorials

Mixed-level designs are constructed using the Pantoja-Pacheco et al. (2021) NONBPA skeleton for nonmultiple levels, followed by a Guo-style coordinate exchange improvement on the \(Z\)-criterion.

Alias Structure (Rios-Lira et al., 2021)

Alias relationships are computed from the correlation matrix of the model matrix (main effects + interactions). Chains are built by selecting the pair of terms with the highest absolute correlation, choosing the lower-order term as the chain leader.

Trend-Free Run Order (Coster, 1993)

When tf = TRUE, a deterministic pairwise-swap algorithm produces a run order orthogonal to polynomial time trends (linear by default).

References

Guo, Y., Simpson, J. R., & Pignatiello, J. J. (2007). Construction of Efficient Mixed-Level Fractional Factorial Designs. Journal of Quality Technology, 39(3), 241-257. tools:::Rd_expr_doi("10.1080/00224065.2007.11917691")

Pantoja-Pacheco, Y. V. et al. (2021). One Note for Fractionation and Increase for Mixed-Level Designs When the Levels Are Not Multiple. Mathematics, 9(13), 1455. tools:::Rd_expr_doi("10.3390/math9131455")

Rios-Lira, A. J. et al. (2021). Alias Structures and Sequential Experimentation for Mixed-Level Designs. Mathematics, 9(23), 3053. tools:::Rd_expr_doi("10.3390/math9233053")

Coster, D. C. (1993). Trend-Free Run Orders of Mixed-Level Fractional Factorial Designs. Annals of Statistics, 21(4), 2072-2086. tools:::Rd_expr_doi("10.1214/aos/1176349410")

Examples

Run this code
# \donttest{

# Mixed-level design (2 x 3 x 4), 12 runs, all parts printed
generate_ff(c(2,3,4), 12, tf = TRUE)

# Only Part 1 (design)
generate_ff(c(2,3,4), 12, parts = 1, tf = FALSE)

# Parts 1 and 2 only
generate_ff(c(2,3,4), 12, parts = c(1,2), tf = FALSE)

# Only Part 3 (trend-free run order)
generate_ff(c(2,3,4), 12, parts = 3, tf = TRUE)

# }

Run the code above in your browser using DataLab