如何在 R 中创建部分因子设计? [英] How to create a fractional factorial design in R?
问题描述
我正在努力使用 R 创建一个相当复杂的部分因子设计.
(参见 http://en.wikipedia.org/wiki/Fractional_factorial_design)>
我搜索了 Google 和 R-lists 并检查了几个有前途的软件包(AlgDesign、DoE.base、acepack)
但我没有发现任何东西可以处理具有 8 个因子的部分设计(仅对主效应感兴趣),每个因子具有 3、4、6 或 11 个水平!
谁能指出我正确的方向?
谢谢!
我使用包 AlgDesign
来生成分数因子设计:
- 使用函数
gen.factorial()
生成全因子设计. - 将结果传递给
optFederov()
- 这将尝试使用 Federov 算法找到最佳分数设计.
以下代码在我的 Windows 笔记本电脑上运行大约需要 3 分钟.该示例找到了一个近似最优部分因子设计,其中包含 8 个因子,每个因子具有 3、4、6 或 11 个水平,如您所指定.
请注意,我使用 optFederov(...,roach=TRUE)
- 这会找到一个近似解.在我的机器上,当我设置 approximate=FALSE
时,代码运行时间太长,Windows 会抛出一个 strop.您可能希望尝试不同的设置.
库(AlgDesign)水平.设计 = c(3,4,6,11,3,4,6,11)f.design <- gen.factorial(levels.design)fract.design <- optFederov(数据= f.设计,nTrials=sum(levels.design),近似=真)
和输出:
head(f.design)X1 X2 X3 X4 X5 X6 X7 X81 -1 -3 -5 -5 -1 -3 -5 -52 0 -3 -5 -5 -1 -3 -5 -53 1 -3 -5 -5 -1 -3 -5 -54 -1 -1 -5 -5 -1 -3 -5 -55 0 -1 -5 -5 -1 -3 -5 -56 1 -1 -5 -5 -1 -3 -5 -5分形设计$D[1] 6.813321$A[1] 0.375804$Ge[1] 0.998$Dea[1] 0.998$设计代表.. X1 X2 X3 X4 X5 X6 X7 X81 1 -1 -3 -5 -5 -1 -3 -5 -510 1 -1 3 -5 -5 -1 -3 -5 -5...626475 1 1 -3 -5 -5 1 3 5 5627253 1 -1 -3 5 5 1 3 5 5$行[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
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!
I have used the package AlgDesign
to generate fractional factorial designs:
- Generate the full factorial design using the function
gen.factorial()
. - 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
这篇关于如何在 R 中创建部分因子设计?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!