```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```

## The problem with Factorial Designs

Factorial designs are the most efficient designs for estimating effects.

\pause
Their efficiency \textbf{grows} as the number of factors increases.

\pause
Unfortunately, the number of runs also grows. Quickly.

Factors ($k$) | Runs ($2^k$)
--------------|--------------------
4 | 16
5 | 32
6 | 64
7 | 128
8 | 256
9 | 512

## How do we conduct experiments with lots of factors?

Most experimenters abandon factorial designs when the number of factors becomes large. Common strategies are to

 * Resort to one-at-a-time designs
 * Select only a subset of factors for a factorial design

\pause
In both cases we lose the efficiency and power of the factorial design.

A better method is to use a *fractional factorial design*.

## Fractional Factorial Designs

A (full) factorial design with $k$ factors, each with two levels, is called a $2^k$ design.

We can instead test $k$ factors using only half of the runs of a $2^k$ design. This is called a $2^{k-1}$ fractional design.

\pause
For example:

* A $2^4$ design tests 4 factors using 16 runs.
* A $2^{4-1}$ design tests 4 factors using 8 runs.
* A $2^3$ design tests 3 factors using 8 runs.

## Why do fractional factorial designs work?

Fractional designs are motivated by two guiding principles in statistical modeling:

1. *Effect sparsity* states that only a small proportion of the factors in an experiment will have significant effects.
2. *Effect hierarchy* states that lower-order interactions (including primary effects) are more important that higher-order interactions. (This is also called the *hierarchical ordering principle*.)

Both principles become ``more true'' as the number of factors increases.

\pause
Fractional designs rely on an assumption that 

\begin{center}
|low-order effects| $\gg$ |high-order effects|
\end{center}

## Example: the $2^{4-1}$ fractional design

We begin with a $2^3$ full factorial design (the *base design*).

I|A|B|C|AB|AC|BC|ABC
-|-|-|-|-|--|--|--|---
+ | $-$ | $-$ | $-$ | + | + | + | $-$
+ | + | $-$ | $-$ | $-$ | $-$ | + | +
+ | $-$ | + | $-$ | $-$ | + | $-$ | +
+ | + | + | $-$ | + | $-$ | $-$ | $-$
+ | $-$ | $-$ | + | + | $-$ | $-$ | +
+ | + | $-$ | + | $-$ | + | $-$ | $-$
+ | $-$ | + | + | $-$ | $-$ | + | $-$
+ | + | + | + | + | + | + | + 

\pause
This design is orthogonal and the design matrix is full rank. We can't add a column for D without messing up these properties.

## Confounding

If we choose to set D equal to an existing column in our design, we have *confounded* it. Since the factors vary together in our design we cannot estimate their effects separately. 

For example, let D=ABC. Then
\[ \beta_\mathrm{D|ABC} = \beta_\mathrm{D} + \beta_\mathrm{ABC} \]

\pause
However, by the hierarchical ordering principle we expect that $\beta_\mathrm{ABC} \approx 0 \ll \beta_\mathrm{D}$, so
\[ \beta_\mathrm{D|ABC} = \beta_\mathrm{D} \]

## The $2^{4-1}$ fractional design (with D=ABC)

We replace the highest interaction (ABC) with D and fill in the rest of the interactions.

\tiny
\setlength{\tabcolsep}{5pt}
\begin{tabular}{cccccccccccccccc}
\hline \\
 & & & & & & & D= & & & & & & & & \\
I & A & B & C & AB & AC & BC & ABC & AD & BD & CD & ABC & BCD & ABD & ACD & ABCD \\
\hline
     $+$ &    $-$ &    $-$ &    $-$ &     $+$ &     $+$ &     $+$ &    $-$ & $+$ &     $+$ &     $+$ &    $-$ &    $-$ &    $-$ &    $-$ &     $+$ \\
     $+$ &     $+$ &    $-$ &    $-$ &    $-$ &    $-$ &     $+$ &     $+$ & $+$ &    $-$ &    $-$ &     $+$ &     $+$ &    $-$ &    $-$ &     $+$ \\
     $+$ &    $-$ &     $+$ &    $-$ &    $-$ &     $+$ &    $-$ &     $+$ & $-$ &     $+$ &    $-$ &     $+$ &    $-$ &    $-$ &     $+$ &     $+$ \\
     $+$ &     $+$ &     $+$ &    $-$ &     $+$ &    $-$ &    $-$ &    $-$ & $-$ &    $-$ &     $+$ &    $-$ &     $+$ &    $-$ &     $+$ &     $+$ \\
     $+$ &    $-$ &    $-$ &     $+$ &     $+$ &    $-$ &    $-$ &     $+$ & $-$ &    $-$ &     $+$ &     $+$ &    $-$ &     $+$ &    $-$ &     $+$ \\
     $+$ &     $+$ &    $-$ &     $+$ &    $-$ &     $+$ &    $-$ &    $-$ & $-$ &     $+$ &    $-$ &    $-$ &     $+$ &     $+$ &    $-$ &     $+$ \\
     $+$ &    $-$ &     $+$ &     $+$ &    $-$ &    $-$ &     $+$ &    $-$ & $+$ &    $-$ &    $-$ &    $-$ &    $-$ &     $+$ &     $+$ &     $+$ \\
     $+$ &     $+$ &     $+$ &     $+$ &     $+$ &     $+$ &     $+$ &     $+$ & $+$ &     $+$ &     $+$ &     $+$ &     $+$ &     $+$ &     $+$ &     $+$ \\
\hline
\end{tabular}

\pause
\normalsize
All of the variables are now confounded:
\begin{center}
\begin{tabular}{ccc}
A + BCD && AB + CD \\
B + ACD && AC + BD \\
C + ABD && AD + BC \\
D + ABC && I + ABCD
\end{tabular}
\end{center}


## Generator Algebra

Filling in the entire design is impractical, especially for large designs. We can identify the *confounding pattern* (or *alias structure*) using a special type of algebra.

\pause
Generator Algebra Axioms

* XX = X$^2$ = I for any factor X.
* IX = X for any factor X.
* Multiplication commutes, associates, and distributes.

## Generating the $2^{4-1}$ design

\newcommand\vA{\mathrm{A}}
\newcommand\vB{\mathrm{B}}
\newcommand\vC{\mathrm{C}}
\newcommand\vD{\mathrm{D}}
\newcommand\vE{\mathrm{E}}
\newcommand\vI{\mathrm{I}}

We start with the *generator* of the design --- the replacement we made to the base design.

\begin{align*}
  \vD &= \vA\vB\vC \\
  (\vD)\vD &= (\vA\vB\vC)\vD \\
  \vD^2 &= \vA\vB\vC\vD \\
  \vI &= \vA\vB\vC\vD
\end{align*}

\pause
This last statement (I=ABCD) is called the *defining relation* for the design with generator D=ABC.

## Generating the $2^{4-1}$ design (continued)

With the defining relation (I=ABCD) we can compute the confounding for any variable.

\pause
For A:
\begin{align*}
  \vA(\vI) &= \vA(\vA\vB\vC\vD) \\
  \vA &= \vA^2\vB\vC\vD \\
   &= \vI\vB\vC\vD \\
    &= \vB\vC\vD
\end{align*}

\pause
For the interaction CD:
\pause
\begin{align*}
  \vC\vD(\vI) &= \vC\vD(\vA\vB\vC\vD) \\
  \vC\vD &= \vA\vB\vC^2\vD^2 \\
    &= \vA\vB
\end{align*}

## Practice: A $2^{5-1}$ design

Let's make a $2^{5-1}$ fractional factorial design (A, B, C, D, \& E).

* What is the best generator for this design?
\pause
\[ \vE = \vA\vB\vC\vD \]

* Use this generator to construct the defining relation.
\pause
\begin{align*}
  \vE\vE &= \vA\vB\vC\vD\vE \\
  \vI &= \vA\vB\vC\vD\vE
\end{align*}

* What is the interaction AB confounded with in our design?
\pause
\begin{align*}
  \vA\vB(\vI) &= \vA\vB(\vA\vB\vC\vD\vE) \\
  \vA\vB &= \vA^2\vB^2\vC\vD\vE \\
  \vA\vB &= \vC\vD\vE
\end{align*}

## Next time: Lower fractional factorial designs

A $2^{k-1}$ fractional factorial design has half the runs of a factorial design.

\medskip
We can also construct $2^{k-2}$ designs (1/4 of the runs), $2^{k-3}$ designs (1/8 of the runs), etc.

\medskip
These lower fractional designs trade fewer runs for greater confounding. We will develop a metric to characterize the level of confounding.
