Site icon R-bloggers

A Brief Tip on Generating Fractional Factorial Designs in R

[This article was first published on Engaging Market Research, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

A number of marketing researchers use the orthoplan procedure in SPSS to generate fractional factorial designs.  It is not surprising, then, that I received a number of questions concerning the recent article in the Journal of Statistical Software by Hideo Aizaki on “Basic Functions for Supporting an Implementation of Choice Experiments in R.”  To summarize their issues, why doesn’t it work like orthoplan in SPSS, and can you answer in 300 words or less?  Actually, I added the 300 words or less comment since “moaning when I started to go into detail” sounds worst.< o:p>
For example, say that you wanted to generate a fractional design for five factors with the following levels: 4x4x3x3x2.  The simplest syntax for orthoplan might be “orthoplan factors = a(1,2,3,4), b(1,2,3,4), c(1,2,3), d(1,2,3), e(1,2).”  And, SPSS would generate 16 different combinations of the orthogonal main-effects design (aka fractional factorial).< o:p>

So, you go to the above article, copy the example, and change the code to conform to your example.< o:p>

# Package< o:p>
library(“support.CEs”)< o:p>

# Example 1: Unlabeled Design< o:p>
rotation.design(attribute.names = list(< o:p>
  A = 1:4, < o:p>
  B = 1:4, < o:p>
  C = 1:3,< o:p>
  D = 1:3,< o:p>
  E = 1:2), < o:p>
nalternatives = 2, nblocks = 1, row.renames = FALSE, < o:p>
randomize = TRUE, seed = 987)< o:p>
des1< o:p>


We seem to need more code, but not that bad.  However, this code will generate the full factorial design with 288 combinations.  What happened to the fractional design with 16 combinations?< o:p>

It’s a long story about how orthoplan works, but I will get to the bottom line.  You should change the two 3-level factors to 4-level factors and rerun the code with the following two changes:  C = 1:4 and D = 1:4.  You will get your 16 combinations.  Now simply recode all the 4’s to 3’s for C and D, and you have your orthoplan-like design in less than 300 words.  The designs before and after the coding look like this:< o:p>

before recoding< o:p>
after recoding< o:p>
A< o:p>
B< o:p>
C< o:p>
D< o:p>
E< o:p>
A< o:p>
B< o:p>
C< o:p>
D< o:p>
E< o:p>
1< o:p>
4< o:p>
3< o:p>
2< o:p>
1< o:p>
1< o:p>
4< o:p>
3< o:p>
2< o:p>
1< o:p>
1< o:p>
2< o:p>
3< o:p>
2< o:p>
4< o:p>
1< o:p>
2< o:p>
3< o:p>
2< o:p>
3< o:p>
1< o:p>
2< o:p>
3< o:p>
1< o:p>
3< o:p>
4< o:p>
2< o:p>
2< o:p>
1< o:p>
3< o:p>
3< o:p>
2< o:p>
2< o:p>
4< o:p>
4< o:p>
1< o:p>
3< o:p>
2< o:p>
2< o:p>
4< o:p>
1< o:p>
3< o:p>
2< o:p>
2< o:p>
5< o:p>
2< o:p>
4< o:p>
3< o:p>
1< o:p>
2< o:p>
2< o:p>
4< o:p>
3< o:p>
1< o:p>
2< o:p>
6< o:p>
3< o:p>
3< o:p>
3< o:p>
3< o:p>
1< o:p>
3< o:p>
3< o:p>
3< o:p>
3< o:p>
1< o:p>
7< o:p>
1< o:p>
2< o:p>
3< o:p>
4< o:p>
1< o:p>
1< o:p>
2< o:p>
3< o:p>
3< o:p>
1< o:p>
8< o:p>
4< o:p>
4< o:p>
4< o:p>
4< o:p>
1< o:p>
4< o:p>
4< o:p>
3< o:p>
3< o:p>
1< o:p>
9< o:p>
3< o:p>
4< o:p>
1< o:p>
2< o:p>
1< o:p>
3< o:p>
4< o:p>
1< o:p>
2< o:p>
1< o:p>
10< o:p>
4< o:p>
2< o:p>
1< o:p>
3< o:p>
2< o:p>
4< o:p>
2< o:p>
1< o:p>
3< o:p>
2< o:p>
11< o:p>
2< o:p>
2< o:p>
2< o:p>
2< o:p>
1< o:p>
2< o:p>
2< o:p>
2< o:p>
2< o:p>
1< o:p>
12< o:p>
2< o:p>
1< o:p>
4< o:p>
3< o:p>
1< o:p>
2< o:p>
1< o:p>
3< o:p>
3< o:p>
1< o:p>
13< o:p>
1< o:p>
1< o:p>
1< o:p>
1< o:p>
1< o:p>
1< o:p>
1< o:p>
1< o:p>
1< o:p>
1< o:p>
14< o:p>
2< o:p>
3< o:p>
1< o:p>
4< o:p>
2< o:p>
2< o:p>
3< o:p>
1< o:p>
3< o:p>
2< o:p>
15< o:p>
3< o:p>
1< o:p>
2< o:p>
4< o:p>
2< o:p>
3< o:p>
1< o:p>
2< o:p>
3< o:p>
2< o:p>
16< o:p>
1< o:p>
4< o:p>
2< o:p>
3< o:p>
2< o:p>
1< o:p>
4< o:p>
2< o:p>
3< o:p>
2< o:p>

< o:p> Why?  Read the IBMSPSS algorithm to see how orthoplan works.  I prefer this pdf because it is easier to read.  Plot spoiler:  the above recode is how SPSS does it.

To leave a comment for the author, please follow the link and comment on their blog: Engaging Market Research.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.