---
title: "Introduction to MixFrac: Mixed-Level and Regular Fractional Factorial Designs"
author: "Sukanta Dash"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{MixFrac Introduction}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.width = 6,
  fig.height = 4
)
```
**Overview**

MixFrac provides tools for constructing mixed-level and regular
fractional factorial designs, computing alias structures, and generating
deterministic trend-free run orders.

The package is based on four key methodological sources:

Guo, Simpson & Pignatiello (2007) – mixed-level design efficiency (J2 + H^)

Pantoja-Pacheco et al. (2021) – NONBPA fractionation when levels differ

Ríos-Lira et al. (2021) – alias structures via model matrix correlations

Coster (1993) – trend-free run orders

This vignette demonstrates the main workflow.

Installation

To install the development version:

# install.packages("devtools")
# Install from local source (if you downloaded or created the package)
devtools::install("MixFrac")

**1. Mixed-Level Fractional Factorial Designs**

Consider a 2 × 3 × 4 design requiring 12 runs.

Writing

library(MixFrac)

res <- generate_ff(
c(2,3,4), # number of levels per factor
n_runs = 12, # required number of runs
tf = FALSE,
parts = c(1,2),
verbose = TRUE
)

The output provides:

The fractional design

Balance summary (per factor)

J2 and H^ metrics

GBM (general balance metrics)

Alias chains

Strong confounding summary

**2. Automatic Regular Fraction Detection (s^(k-p) Designs)**

When all factors have the same number of levels s, the package attempts
to find a regular fraction s^(k-p).

Example: three 2-level factors and 4 runs → candidate 2^(3-1):

Writing

res_reg <- generate_ff(
c(2,2,2),
n_runs = 4,
tf = FALSE,
parts = c(1,2),
verbose = TRUE
)

If a valid generator structure exists, MixFrac builds the canonical regular design.

**3. Alias Structures**

Alias structures are computed using correlation among model matrix columns
(main effects + interactions).

Writing
extract alias chains

res$alias_chains

Example of printed output:

[A] = A
[B] = B + 0.956 A:B
[C] = C + 0.984 A:C
[B:C] = B:C + 0.998 A:B:C


You may also extract the strong confounding pairs:

Writing

res$alias_summary

**4. Trend-Free Run Orders (Coster 1993)**

When tf = TRUE, the function computes a deterministic run order that is
orthogonal to polynomial time trends (degree 1 by default).

Writing

res_tf <- generate_ff(
c(2,3,4), 12,
tf = TRUE,
parts = 3,
verbose = TRUE
)

The result contains:

res_tf$trend_free_result$order
res_tf$trend_free_result$design_reordered
res_tf$trend_free_result$objective

**5. Silent Execution (Programmatic Use)**

To use MixFrac programmatically without printing:

Writing

silent <- generate_ff(
c(2,3,4), 12,
tf = TRUE,
parts = c(), # <- print nothing
verbose = FALSE # silent mode
)

The object silent contains all results:

Writing

names(silent)

**Conclusion**

MixFrac provides a unified workflow for:

Mixed-level fractional factorial construction

Automatic generation of regular designs when applicable

Confounding and alias analysis

Run orders that remove trend contamination

Its flexible interface allows both exploratory use and integration into
automated DoE pipelines.

**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.
https://doi.org/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.
https://doi.org/10.3390/math9131455

Ríos-Lira, A. J. et al. (2021).
Alias Structures and Sequential Experimentation for Mixed-Level Designs.
Mathematics, 9(23), 3053.
https://doi.org/10.3390/math9233053

Coster, D. C. (1993).
Trend-Free Run Orders of Mixed-Level Fractional Factorial Designs.
Annals of Statistics, 21(4), 2072–2086.
https://doi.org/10.1214/aos/1176349410
