Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a fractional factorial design in R?

Tags:

r

statistics

I'm struggling to create a rather elaborate fractional factorial design using R.

(see http://en.wikipedia.org/wiki/Fractional_factorial_design)

I've searched the Google and the R-lists and have checked out several promising packages (AlgDesign, DoE.base, acepack)

But I have not found anything thing that can handle a fractional design (only interested in main effects) with 8 factors that have either 3, 4, 6, or 11 levels each!

Can anyone point me in the right direction?

Thanks!

like image 736
Bob Colner Avatar asked Feb 18 '11 18:02

Bob Colner


2 Answers

I have used the package AlgDesign to generate fractional factorial designs:

  1. Generate the full factorial design using the function gen.factorial().
  2. Pass the results to optFederov() - this will try to find an optimum fractional design, using the Federov algorithm.

The following code takes about 3 minutes to run on my Windows laptop. The example finds an approximate optimum fractional factorial design with 8 factors with 3, 4, 6 or 11 levels each, as you specified.

Note that I use optFederov(..., approximate=TRUE) - this finds an approximate solution. On my machine, when I set approximate=FALSE the code takes too long to run and Windows throws a strop. You may wish to experiment with different settings.

library(AlgDesign)

levels.design = c(3,4,6,11,3,4,6,11)
f.design <- gen.factorial(levels.design)

fract.design <- optFederov(
        data=f.design,
        nTrials=sum(levels.design),
        approximate=TRUE)

And the output:

head(f.design)

  X1 X2 X3 X4 X5 X6 X7 X8
1 -1 -3 -5 -5 -1 -3 -5 -5
2  0 -3 -5 -5 -1 -3 -5 -5
3  1 -3 -5 -5 -1 -3 -5 -5
4 -1 -1 -5 -5 -1 -3 -5 -5
5  0 -1 -5 -5 -1 -3 -5 -5
6  1 -1 -5 -5 -1 -3 -5 -5


fract.design
$D
[1] 6.813321

$A
[1] 0.375804

$Ge
[1] 0.998

$Dea
[1] 0.998

$design
       Rep.. X1 X2 X3 X4 X5 X6 X7 X8
1          1 -1 -3 -5 -5 -1 -3 -5 -5
10         1 -1  3 -5 -5 -1 -3 -5 -5
...
626475     1  1 -3 -5 -5  1  3  5  5
627253     1 -1 -3  5  5  1  3  5  5

$rows
 [1]      1     10     61    723    790   1596   2307   2314   2365   2374
[11]   2376   7129   7140   7198   7849   7911   7918   7920   8713   8724
[21]   9433   9504  48252  48301  48303  49105  49107  49114  49174  54660
[31]  54711  56233  56304 570241 570963 571834 571836 572556 578151 579015
[41] 617821 617823 619414 620127 620134 625618 626475 627253
like image 66
Andrie Avatar answered Oct 07 '22 13:10

Andrie


Just to add to Andrie's answer. This is how we interpret strength of optimual design.

Design efficiency is judged by Ge. It should be 1 or close to 1. Below links have some explanation and i referred the book "Design and Analysis of Experiments with R". Thought this might be useful for those who are looking for answer. Below are the source from which i got this information.

https://stat.ethz.ch/pipermail/r-help/2007-October/143217.html

Error in Hierarchical Bayesn in R : Bayesn Package

like image 45
StatguyUser Avatar answered Oct 07 '22 13:10

StatguyUser